freetds-0.91/m4/ac_caolan_func_which_gethostbyname_r.m4100664 001750 000144 00000005167 10412532304 0016733dnl $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-0.91/m4/ac_have_inaddr_none.m4100664 001750 000144 00000001463 10412532305 0013306dnl $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-0.91/m4/ac_have_malloc_options.m4100664 001750 000144 00000001073 10412532305 0014045dnl $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-0.91/m4/ac_nullzero.m4100664 001750 000144 00000002653 10627536763 0011723# 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-0.91/m4/ac_raf_func_which_getservbyname_r.m4100664 001750 000144 00000004012 10412532305 0016235dnl $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-0.91/m4/ac_tds_func_which_gethostbyaddr_r.m4100664 001750 000144 00000004001 10412532305 0016245dnl $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-0.91/m4/ac_tds_func_which_getpwuid_r.m4100664 001750 000144 00000004647 10473062614 0015262dnl $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-0.91/m4/ac_tds_func_which_localtime_r.m4100664 001750 000144 00000001262 10412532305 0015361dnl $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-0.91/m4/acx_pthread.m4100664 001750 000144 00000022665 11430201131 0011640dnl @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-0.91/m4/ax_cflags_gcc_option.m4100664 001750 000144 00000015351 10412532305 0013514dnl $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-0.91/m4/check_openssl.m4100664 001750 000144 00000001726 10411711316 0012202dnl $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)]) ,[ AC_MSG_RESULT(yes) 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 found_ssl="yes" CFLAGS="$CFLAGS -I$ssldir/include" break fi done if test x$found_ssl != xyes; then AC_MSG_ERROR(Cannot find OpenSSL libraries) else echo "OpenSSL found in $ssldir" NETWORK_LIBS="$NETWORK_LIBS -lssl -lcrypto" LDFLAGS="$LDFLAGS -L$ssldir/lib" HAVE_OPENSSL=yes AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have the OpenSSL.]) fi AC_SUBST(HAVE_OPENSSL) ],[ AC_MSG_RESULT(no) ]) ]) freetds-0.91/m4/gettimemilli.m4100664 001750 000144 00000004177 10467075300 0012061dnl $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-0.91/m4/iconv.m4100664 001750 000144 00000006746 10412076726 0010521dnl $Id: iconv.m4,v 1.1 2006/03/28 00:05:42 jklowden Exp $ # iconv.m4 serial AM4 (gettext-0.11.3) dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. 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). 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_TRY_LINK will then fail, the second AC_TRY_LINK 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_TRY_LINK([#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_TRY_LINK([#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_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) 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) ]) 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_TRY_COMPILE([ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || 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([$]{ac_t:- }[$]am_cv_proto_iconv) AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, [Define as const if the declaration of iconv() needs const.]) fi ]) freetds-0.91/m4/lib-ld.m4100664 001750 000144 00000007054 10412076726 0010537dnl $Id: lib-ld.m4,v 1.1 2006/03/28 00:05:42 jklowden Exp $ # lib-ld.m4 serial 3 (gettext-0.12.2) dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. dnl Subroutines of libtool.m4, dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision dnl with libtool.m4. dnl From libtool-1.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 ld's only accept -v. case `$LD -v 2>&1 conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh 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 GCC]) 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. [[\\/]* | [A-Za-z]:[\\/]*)] [re_direlt='/[^/][^/]*/\.\./'] # Canonicalize the path 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 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do 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 GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$acl_cv_path_LD" if test -n "$LD"; then AC_MSG_RESULT($LD) else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) AC_LIB_PROG_LD_GNU ]) freetds-0.91/m4/lib-link.m4100664 001750 000144 00000055465 10412532305 0011074dnl $Id: lib-link.m4,v 1.2 2006/03/29 16:24:37 freddy77 Exp $ # lib-link.m4 serial 4 (gettext-0.12) dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. dnl From Bruno Haible. dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and dnl augments the CPPFLAGS variable. AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" ac_cv_lib[]Name[]_cppflags="$INC[]NAME" ]) LIB[]NAME="$ac_cv_lib[]Name[]_libs" LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" INC[]NAME="$ac_cv_lib[]Name[]_cppflags" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the dnl results of this search when this library appears as a dependency. HAVE_LIB[]NAME=yes undefine([Name]) undefine([NAME]) ]) dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) dnl searches for libname and the libraries corresponding to explicit and dnl implicit dependencies, together with the specified include files and dnl the ability to compile and link the specified testcode. If found, it dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. AC_LIB_LINKFLAGS_BODY([$1], [$2]) dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, dnl because if the user has installed lib[]Name and not disabled its use dnl via --without-lib[]Name-prefix, he wants to use it. ac_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" LIBS="$LIBS $LIB[]NAME" AC_LINK_IFELSE(AC_LANG_PROGRAM([$3], [$4]), [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) LIBS="$ac_save_LIBS" ]) if test "$ac_cv_lib[]Name" = yes; then HAVE_LIB[]NAME=yes AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) AC_MSG_CHECKING([how to link with lib[]$1]) AC_MSG_RESULT([$LIB[]NAME]) else HAVE_LIB[]NAME=no dnl If $LIB[]NAME didn't lead to a usable library, we don't need dnl $INC[]NAME either. CPPFLAGS="$ac_save_CPPFLAGS" LIB[]NAME= LTLIB[]NAME= fi AC_SUBST([HAVE_LIB]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) undefine([Name]) undefine([NAME]) ]) dnl Determine the platform dependent parameters needed to use rpath: dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, dnl hardcode_direct, hardcode_minus_L. AC_DEFUN([AC_LIB_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" libext="$acl_cv_libext" shlibext="$acl_cv_shlibext" hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" hardcode_direct="$acl_cv_hardcode_direct" 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_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. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 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$1-prefix], [ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib --without-lib$1-prefix don't search for lib$1 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/lib" 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= 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= if test $use_additional = yes; then if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then found_dir="$additional_libdir" found_so="$additional_libdir/lib$name.$shlibext" if test -f "$additional_libdir/lib$name.la"; then found_la="$additional_libdir/lib$name.la" fi else if test -f "$additional_libdir/lib$name.$libext"; then found_dir="$additional_libdir" found_a="$additional_libdir/lib$name.$libext" if test -f "$additional_libdir/lib$name.la"; then found_la="$additional_libdir/lib$name.la" fi 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//'` if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then found_dir="$dir" found_so="$dir/lib$name.$shlibext" if test -f "$dir/lib$name.la"; then found_la="$dir/lib$name.la" fi else if test -f "$dir/lib$name.$libext"; then found_dir="$dir" found_a="$dir/lib$name.$libext" if test -f "$dir/lib$name.la"; then found_la="$dir/lib$name.la" fi 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/lib"; 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 "$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 "$hardcode_libdir_flag_spec" && test "$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 "$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 $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 */lib | */lib/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` 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*) 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/lib"; then haveit= if test "X$additional_libdir" = "X/usr/local/lib"; then if test -n "$GCC"; then case $host_os in linux*) 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 "$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:+$hardcode_libdir_separator}$found_dir" done dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$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=\"$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 ]) 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 ]) freetds-0.91/m4/lib-prefix.m4100664 001750 000144 00000012611 10412076726 0011430dnl $Id: lib-prefix.m4,v 1.1 2006/03/28 00:05:42 jklowden Exp $ # lib-prefix.m4 serial 3 (gettext-0.12.2) dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. 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([AS_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_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/lib" 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*) 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/lib"; 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/lib"; 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" ]) freetds-0.91/m4/libtool.m4100444 001750 000144 00000773176 11561614465 0011057# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 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) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 56 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.58])dnl We use AC_INCLUDES_DEFAULT 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 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_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` ]) # _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 _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_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which 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 _LT_PROG_ECHO_BACKSLASH 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 "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # 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. 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' # 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_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 "X$][$1" | $Xsed -e "$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 "X$" | $Xsed -e "$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' # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) 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 "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Fix-up fallback echo if it was mangled by the above quoting rules. case \$lt_ECHO in *'\\\[$]0 --fallback-echo"')dnl " lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` ;; esac _LT_OUTPUT_LIBTOOL_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]) cat >"$CONFIG_LT" <<_LTEOF #! $SHELL # Generated by $as_me. # Run this file to recreate a libtool stub with the current configuration. lt_cl_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 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) 2008 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. if test "$no_create" != yes; then lt_cl_success=: test "$silent" = yes && 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) fi ])# 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 which 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 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $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. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _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 "X${COLLECT_NAMES+set}" != Xset; 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 '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_XSI_SHELLFNS sed -n '/^# Generated shell functions inserted here/,$p' "$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' TIMESTAMP='$TIMESTAMP' 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)], [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 # _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([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)]) 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], []) # _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 test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; 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" ]) 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 "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; 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" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES # -------------------------- # 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 _LT_TAGVAR(whole_archive_flag_spec, $1)='' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=echo _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 "$lt_cv_apple_cc_single_mod" != "yes"; 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 # ----------------------- # 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. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl AC_LINK_IFELSE(AC_LANG_PROGRAM,[ lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' 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 "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], [AC_DIVERT_PUSH(NOTICE)]) $1 AC_DIVERT_POP ])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Add some code to the start of the generated configure script which # will find an echo command which doesn't interpret backslashes. m4_defun([_LT_PROG_ECHO_BACKSLASH], [_LT_SHELL_INIT([ # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$lt_ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` ;; esac ECHO=${lt_ECHO-echo} if test "X[$]1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X[$]1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then # Yippee, $ECHO works! : else # Restart under the correct shell. exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} fi if test "X[$]1" = X--fallback-echo; then # used as fallback echo shift cat <<_LT_EOF [$]* _LT_EOF exit 0 fi # 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 if test -z "$lt_ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if { echo_test_string=`eval $cmd`; } 2>/dev/null && { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null then break fi done fi if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$ECHO" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. ECHO='print -r' elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} else # Try using printf. ECHO='printf %s\n' if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL ECHO="$CONFIG_SHELL [$]0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$CONFIG_SHELL [$]0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "[$]0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} else # Oops. We lost completely, so just stick with echo. ECHO=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. lt_ECHO=$ECHO if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" fi AC_SUBST(lt_ECHO) ]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that does not interpret backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _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 "x$enable_libtool_lock" != xno && 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 which ABI we are using. 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 which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; 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* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. 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*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|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" ;; ppc*-*linux*|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 x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. 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*) LD="${LD-ld} -m elf64_sparc" ;; *) 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_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [AC_CHECK_TOOL(AR, ar, false) test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1]) 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 openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi _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_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" # 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:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $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 "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/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 x"[$]$2" = xyes; 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 "X$_lt_linker_boilerplate" | $Xsed -e '/^$/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 x"[$]$2" = xyes; 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; ;; 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; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # 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 ;; 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"; 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"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 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 "$cross_compiling" = yes; 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 __oline__ "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 void fnord() { int i=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; /* 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 "x$enable_dlopen" != xyes; 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 ]) ;; *) 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 "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && 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 "x$lt_cv_dlopen_self" = xyes; 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:__oline__: $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:__oline__: \$? = $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 "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/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 "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; 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 "$hard_links" = no; 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 in which 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 "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # 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 "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; 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 "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; 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_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 AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # 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 -e 's/;/ /g'` else lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # 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` 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" else 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; } }'` sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` 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 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 need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; 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 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # 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}' else # 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' fi 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=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $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 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,$host_os in yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) 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="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. 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 ;; 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 ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # 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 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 ;; freebsd1*) dynamic_linker=no ;; 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[[123]]*) 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} $libname${shared_ext}' 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 ;; gnu*) version_type=linux 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 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 "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; 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' ;; interix[[3-9]]*) version_type=linux 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 "$lt_cv_prog_gnu_ld" = yes; then version_type=linux 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 ;; # This must be Linux ELF. linux* | k*bsd*-gnu) version_type=linux 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 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], [shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir # 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 # Append ld.so.conf contents 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;/^$/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 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*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac 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 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; 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 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 "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux 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 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=freebsd-elf 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 "$with_gnu_ld" = yes; 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 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 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 "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _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([], [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], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which 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 which 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 AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl 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(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 /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 lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' 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 ;; gnu*) 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]) 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 Linux ELF. linux* | k*bsd*-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*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; 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 ;; esac ]) 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_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 case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) 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 "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) 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:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:__oline__: $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:__oline__: 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_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cygwin* | *-*-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 "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' _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([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 "$host_cpu" = ia64; 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 # 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 -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$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 -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/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 # and D for any global 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};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print 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 # 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 #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. */ const struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$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_save_LIBS="$LIBS" lt_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_save_LIBS" CFLAGS="$lt_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 "$pipe_works" = yes; 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 _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_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_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)= AC_MSG_CHECKING([for $compiler option to produce PIC]) m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; 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 "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; 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']) ;; 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)= ;; 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 "$host_cpu" = ia64; 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 ;; 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 "$host_cpu" != ia64; 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) 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*) # IBM XL 8.0 on PPC _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*) # 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 "$GCC" = yes; 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 "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; 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']) ;; 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' ;; 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 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 "$host_cpu" = ia64; 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 ;; 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']) ;; 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) 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' ;; pgcc* | pgf77* | pgf90* | pgf95*) # 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*) # IBM XL C 8.0/Fortran 10.1 on PPC _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)='-Wl,' ;; *Sun\ F*) # 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)='' ;; 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*) _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 which 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_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # 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]) # # 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_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' 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 AIX nm, but means don't demangle with GNU 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")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] ], [ 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_flag_spec_ld, $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 "$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 _LT_TAGVAR(ld_shlibs, $1)=yes if test "$with_gnu_ld" = yes; 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 2>&1` in *\ [[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 "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.9.1, 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 modify your PATH *** so that a non-GNU linker is found, and then restart. _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(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/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' 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 (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; 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 ;; 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) tmp_diet=no if test "$host_os" = linux-dietlibc; 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 "$tmp_diet" = no then tmp_addflag= 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; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # 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; $ECHO \"$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' ;; xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; 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; $ECHO \"$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 "x$supports_anon_versioning" = xyes; 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 xlf*) # 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)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; 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 $compiler_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 $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' 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 $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 ;; 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 can not *** 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 $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 if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; 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 "$GCC" = yes && 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 "$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 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 AIX nm, but means don't demangle with GNU 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")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | 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 # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) 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 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,' if test "$GCC" = yes; 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 "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; 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 "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi 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_use_runtimelinking" = yes; 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 _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 "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; 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 _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' # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' 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. _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 `$ECHO "X$deplibs" | $Xsed -e '\''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(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; 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 ;; freebsd1*) _LT_TAGVAR(ld_shlibs, $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 -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 "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $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 $output_objdir/$soname = $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 "$GCC" = yes -a "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${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 "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $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 "$GCC" = yes -a "$with_gnu_ld" = no; 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 -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${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' ;; *) _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 "$with_gnu_ld" = no; 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 "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${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. save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE(int foo(void) {}, _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' ) LDFLAGS="$save_LDFLAGS" else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -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" && $ECHO "X-set_version $verstring" | $Xsed` -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 ;; 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*) 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__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; 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 case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _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' ;; esac 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 _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; 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" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${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" && $ECHO "X-set_version $verstring" | $Xsed` -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 "$GCC" = yes; 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}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${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" && $ECHO "X-set_version $verstring" | $Xsed` -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 "X-set_version $verstring" | $Xsed` -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 "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${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 ${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 "$GCC" = yes; 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 "x$host_vendor" = xsequent; 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 "$GCC" = yes; 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 can NOT 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 "$GCC" = yes; 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 x$host_vendor = xsni; 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 "$_LT_TAGVAR(ld_shlibs, $1)" = no && 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 "$enable_shared" = yes && test "$GCC" = yes; 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_MSG_CHECKING([whether -lc should be explicitly linked in]) $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_TAGVAR(archive_cmds_need_lc, $1)=no else _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* AC_MSG_RESULT([$_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_flag_spec_ld], [1], [[If ld is used when linking, 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([], [fix_srcfile_path], [1], [Fix the shell variable $srcfile for the compiler]) _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([], [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 which 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 "$can_build_shared" = "no" && 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 "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no 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 "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_PROG_CXX # ------------ # Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ # compiler, we have our own version here. m4_defun([_LT_PROG_CXX], [ pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) AC_PROG_CXX if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_CXX dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_CXX], []) # _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], [AC_REQUIRE([_LT_PROG_CXX])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl 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_flag_spec_ld, $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(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 "$_lt_caught_CXX_error" != yes; 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_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++"} 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 "$GXX" = yes; 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 "$GXX" = yes; 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 "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -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 "\-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 "$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 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 # need to do runtime linking. 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 ;; 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,' if test "$GXX" = yes; 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 "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; 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 "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi 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_use_runtimelinking" = yes; 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 _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 "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; 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 _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' # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' 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*) # _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(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 (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; 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 ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; 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 ;; freebsd[[12]]*) # 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 ;; gnu*) ;; 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 $output_objdir/$soname = $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; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $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 $with_gnu_ld = no; 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; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; 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 -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${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" && $ECHO "X-set_version $verstring" | $Xsed` -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 "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -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) 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; $ECHO "X$list" | $Xsed' _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 | $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 | $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 | $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 | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 will 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; $ECHO \"$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=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; xl*) # 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 "x$supports_anon_versioning" = xyes; 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; $ECHO \"$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='echo' # 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 ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) 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__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; 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=echo 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" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -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" && $ECHO "X-set_version $verstring" | $Xsed` -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 "X-set_version $verstring" | $Xsed` -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=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; 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" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${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 "\-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*) # 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='echo' # 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 "$GXX" = yes && test "$with_gnu_ld" = no; 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 -nostdlib $LDFLAGS $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 -nostdlib ${wl}-M $wl$lib.exp -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 "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $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 -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 "\-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 can NOT 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(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 "$_LT_TAGVAR(ld_shlibs, $1)" = no && 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 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 "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _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 # 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 ]) 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 $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue else prev= fi if test "$pre_test_object_deps_done" = no; then case $p 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 ;; *.$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 "$pre_test_object_deps_done" = no; 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 # 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)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; 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_PROG_F77 # ------------ # Since AC_PROG_F77 is broken, in that it returns the empty string # if there is no fortran compiler, we have our own version here. m4_defun([_LT_PROG_F77], [ pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) AC_PROG_F77 if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_F77 dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_F77], []) # _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_REQUIRE([_LT_PROG_F77])dnl AC_LANG_PUSH(Fortran 77) _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_flag_spec_ld, $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(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 "$_lt_disable_F77" != yes; 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 CC=${F77-"f77"} 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 "$can_build_shared" = "no" && 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 "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no 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 "$enable_shared" = yes || 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" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_PROG_FC # ----------- # Since AC_PROG_FC is broken, in that it returns the empty string # if there is no fortran compiler, we have our own version here. m4_defun([_LT_PROG_FC], [ pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) AC_PROG_FC if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_FC dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_FC], []) # _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_REQUIRE([_LT_PROG_FC])dnl AC_LANG_PUSH(Fortran) _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_flag_spec_ld, $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(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 "$_lt_disable_FC" != yes; 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 CC=${FC-"f95"} 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 "$can_build_shared" = "no" && 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 "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no 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 "$enable_shared" = yes || 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" fi # test "$_lt_disable_FC" != yes 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_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} 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 ## 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" ])# _LT_LANG_GCJ_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_GCC=$GCC GCC= CC=${RC-"windres"} 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" ])# _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 "x${GCJFLAGS+set}" = xset || 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_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_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 $lt_ac_count -gt 10 && 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], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) 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_PROG_XSI_SHELLFNS # --------------------- # Bourne and XSI compatible variants of some useful shell functions. m4_defun([_LT_PROG_XSI_SHELLFNS], [case $xsi_shell in yes) cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac } # func_basename file func_basename () { func_basename_result="${1##*/}" } # 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" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}" } # func_stripname 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). func_stripname () { # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"} } # func_opt_split func_opt_split () { func_opt_split_opt=${1%%=*} func_opt_split_arg=${1#*=} } # func_lo2o object func_lo2o () { case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac } # func_xform libobj-or-source func_xform () { func_xform_result=${1%.*}.lo } # func_arith arithmetic-term... func_arith () { func_arith_result=$(( $[*] )) } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=${#1} } _LT_EOF ;; *) # Bourne compatible functions. cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_basename file func_basename () { func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } dnl func_dirname_and_basename dnl A portable version of this function is already defined in general.m4sh dnl so there is no need for it here. # func_stripname 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). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; esac } # sed scripts: my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' my_sed_long_arg='1s/^-[[^=]]*=//' # func_opt_split func_opt_split () { func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` } # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` } # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` } # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "$[@]"` } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` } _LT_EOF esac case $lt_shell_append in yes) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$[1]+=\$[2]" } _LT_EOF ;; *) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$[1]=\$$[1]\$[2]" } _LT_EOF ;; esac ]) freetds-0.91/m4/ltoptions.m4100444 001750 000144 00000027242 11561614465 0011430# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008 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 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_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], [0], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [0], [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_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], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [pic_mode="$withval"], [pic_mode=default]) test -z "$pic_mode" && 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-0.91/m4/ltsugar.m4100444 001750 000144 00000010424 11561614465 0011050# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 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-0.91/m4/ltversion.m4100444 001750 000144 00000001277 11561614465 0011422# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 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. # Generated from ltversion.in. # serial 3017 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.2.6b]) m4_define([LT_PACKAGE_REVISION], [1.3017]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.2.6b' macro_revision='1.3017' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) freetds-0.91/m4/lt~obsolete.m4100444 001750 000144 00000013113 11561614466 0011740# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007 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 4 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_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) 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])]) freetds-0.91/m4/sprintf_i64_format.m4100664 001750 000144 00000003436 11506373026 0013111dnl $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="I64d"]) # long is 64 bit if test "x$ac_cv_sizeof_long" = "x8"; then tds_i64_format=ld 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="lld"]) 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}d"; break]) done fi if test "x$tds_i64_format" != "x"; then AC_DEFINE_UNQUOTED(TDS_I64_FORMAT, ["$tds_i64_format"], [define to format string used for 64bit integers]) fi ]) freetds-0.91/m4/type_socklen_t.m4100664 001750 000144 00000002564 10412532305 0012405dnl $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 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 #include ]) ]) freetds-0.91/README100664 001750 000144 00000006072 11623073277 0007474README for FreeTDS 0.91 Wednesday 17 August 2011 * to build FreeTDS read the file INSTALL or the FreeTDS Users Guide (doc/userguide.tgz) 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 ChangeLog Detailed list of changes 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 ChangeLog. 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: README,v 1.12 2008/01/11 08:30:10 freddy77 Exp $ freetds-0.91/configure.ac100644 001750 000144 00000064023 11623070412 0011064dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ dnl $Id: configure.ac,v 1.60.2.5 2011/08/12 11:50:17 freddy77 Exp $ 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, 0.91) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) AC_REVISION($Revision: 1.60.2.5 $) AM_INIT_AUTOMAKE([dist-bzip2]) AC_CONFIG_HEADERS(include/config.h) dnl configuration directory will be /usr/local/etc AC_PREFIX_DEFAULT(/usr/local) MAJOR=$(echo $VERSION | sed 's,\..*,,g') MINOR=[$(echo $VERSION | sed 's,^[0-9]*\.\([0-9]*\).*,\1,g')] SUBVERSION=[$(echo $VERSION.0 | sed 's,^\([0-9]*\.[0-9]*\)\(rc\|RC\),\1.dev.,g; s,^[0-9]*\.[^.]*\.\([^.]*\).*,\1,g')] BUILD_NUMBER=$(date +"%y%j" | sed 's,^0*,,g') if test "X$SUBVERSION" = "Xdev"; then MINOR=$(expr $MINOR - 1) SUBVERSION=9999 fi AC_SUBST(MAJOR) AC_SUBST(MINOR) AC_SUBST(SUBVERSION) AC_SUBST(BUILD_NUMBER) # ------------------------------------------------------------ # 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 # ------------------------------------------------------------ # Flag to include library-private definitions # ------------------------------------------------------------ CPPFLAGS="$CPPFLAGS -D_FREETDS_LIBRARY_SOURCE" # ------------------------------------------------------------ # 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 AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL 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) AC_CHECK_PROG(PKG_CONFIG,pkg-config,pkg-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 OLDLIBS="$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= 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 NETWORK_LIBS="$LIBS" LIBS="$OLDLIBS" 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. OLDLIBS="$LIBS" # Readline is linked with curses, and on some systems termcap must be # linked in. Others (inc debian) have termcap built into ncurses. 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" LIBS="$OLDLIBS" AC_SUBST(READLINE_LIBS) ACX_PTHREAD AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS" AC_SUBST(AM_CFLAGS) LIBS="$PTHREAD_LIBS $LIBS" fi # check for SSPI AC_ARG_ENABLE(sspi, AS_HELP_STRING([--enable-sspi], [enable SSPI support])) # disable by default enable_sspi=${enable_sspi-no} # 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 --enable-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 \ getopt.h \ libgen.h \ limits.h \ locale.h \ poll.h \ readpassphrase.h \ signal.h \ stddef.h \ sys/param.h \ sys/select.h \ sys/stat.h \ sys/time.h \ sys/types.h \ sys/resource.h \ sys/wait.h \ unistd.h \ wchar.h \ inttypes.h]) AC_CHECK_HEADERS([windows.h sql.h odbcss.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 \ 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;; esac if test "$tds_sysdep_int64_type"; then AC_DEFINE(HAVE_INT64, 1, [Define to 1 if you have a 64-bit integral type.]) SPRINTF_I64_FORMAT else tds_sysdep_int64_type=long AC_MSG_WARN([SQL Server 2000 "bigint" 8-byte integer will not work]) 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;; *) 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], [extern int optreset; 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_SOURCE(,[return 1]), 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 gettimeofday \ nl_langinfo locale_charset setenv putenv \ getuid getpwuid getpwuid_r fstat alarm fork \ gethrtime localtime_r setitimer _lseeki64 _telli64 \ _fseeki64 _ftelli64 setrlimit]) OLD_LIBS="$LIBS" LIBS="$LIBS $NETWORK_LIBS" AC_CHECK_FUNCS([inet_ntoa_r getipnodebyaddr getipnodebyname \ getaddrinfo getnameinfo inet_ntop gethostname poll]) LIBS="$OLD_LIBS" AC_REPLACE_FUNCS([asprintf vasprintf atoll strtok_r readpassphrase \ strlcpy strlcat basename getopt]) AC_FUNC_FSEEKO TDS_GETTIMEMILLI # ------------------------------------------------------------ # 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) [5.0]])) if test "$with_tdsver" = "4.2"; then AC_DEFINE(TDS42, 1, [Define to use TDS 4.2 by default]) elif test "$with_tdsver" = "4.6"; then AC_DEFINE(TDS46, 1, [Define to use TDS 4.6 by default]) elif test "$with_tdsver" = "7.0"; then AC_DEFINE(TDS70, 1, [Define to use TDS 7.0 by default]) elif test "$with_tdsver" = "7.1"; then AC_DEFINE(TDS71, 1, [Define to use TDS 7.1 by default]) else AC_DEFINE(TDS50, 1, [Define to use TDS 5.0 by default]) fi 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*) FREETDS_ODBC_MODULE="-module" ;; 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_ARG_WITH(gnutls, AS_HELP_STRING([--with-gnutls], [build with TLS support])) if test "$with_gnutls" = "yes"; then AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if you have GNU tls.]) if test "$PKG_CONFIG" != "" && "$PKG_CONFIG" --libs gnutls > /dev/null 2>&1; then CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags gnutls`" NETWORK_LIBS="$NETWORK_LIBS `$PKG_CONFIG --libs gnutls`" else CPPFLAGS="$CPPFLAGS `libgnutls-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgnutls-config --libs`" fi OLDLIBS="$LIBS" LIBS="$LIBS $NETWORK_LIBS" AC_CHECK_FUNCS([gnutls_record_disable_padding]) LIBS="$OLDLIBS" 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") # 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 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;], [pthread_mutex_lock(&mutex); pthread_mutex_unlock(&mutex)], AC_DEFINE(TDS_HAVE_PTHREAD_MUTEX, 1, [Define if you have pthread with mutex support])) 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 AC_ARG_ENABLE(odbc-wide, AS_HELP_STRING([--enable-odbc-wide], [enable wide string support in odbc [experimental]])) if test "$enable_odbc_wide" = "yes" ; then AC_DEFINE_UNQUOTED(ENABLE_ODBC_WIDE, 1, [Define to enable ODBC wide string support]) 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" fi AX_CFLAGS_GCC_OPTION([-Wdeclaration-after-statement]) AC_MSG_RESULT(done) # ------------------------------------------------------------ # Final output # ------------------------------------------------------------ AC_CONFIG_FILES(include/tdsver.h \ include/tds_sysdep_public.h \ Makefile \ include/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/server/Makefile \ src/pool/Makefile \ src/odbc/Makefile \ src/odbc/unittests/Makefile \ src/apps/Makefile \ src/apps/fisql/Makefile \ freetds.spec \ win32/Makefile win32/msvc6/Makefile \ win32/version.rc win32/freetds.nsh \ vms/Makefile ) AC_OUTPUT freetds-0.91/aclocal.m4100664 001750 000144 00000173507 11623070614 0010454# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 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_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, [m4_warning([this file was generated for autoconf 2.65. 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'.])]) # ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*- # # Copyright (C) 1999-2006, 2007, 2008 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 17 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 x"${lt_lib_ltdl-no}" = xyes; then if test x"$enable_ltdl_install" != xyes; 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 x"$enable_ltdl_install" = xno; 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 "x$with_included_ltdl" != xyes; 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([gl_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])]) AC_DEFINE_UNQUOTED([LT_LIBEXT],["$libext"],[The archive extension]) name=ltdl LTDLOPEN=`eval "\\$ECHO \"$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 x"${enable_ltdl_install-no}" != xno) AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)]) ])# _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 ;; 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) # 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 "$lt_cv_sys_dlopen_deplibs" != yes; 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([which extension is used for runtime loadable modules], [libltdl_cv_shlibext], [ module=yes eval libltdl_cv_shlibext=$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 ])# 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([which 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 x"$libltdl_cv_preloaded_symbols" = xyes; 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]) 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 x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes 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* | os2* | 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]) 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_SYS_SYMBOL_USCORE])dnl if test x"$lt_cv_sys_symbol_underscore" = xyes; then if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then AC_CACHE_CHECK([whether we have to add an underscore for dlsym], [libltdl_cv_need_uscore], [libltdl_cv_need_uscore=unknown save_LIBS="$LIBS" LIBS="$LIBS $LIBADD_DLOPEN" _LT_TRY_DLOPEN_SELF( [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes], [], [libltdl_cv_need_uscore=cross]) LIBS="$save_LIBS" ]) fi fi if test x"$libltdl_cv_need_uscore" = xyes; 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, 2003, 2005, 2006, 2007, 2008 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.11' 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.11.1], [], [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.11.1])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, 2003, 2005 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], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # 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. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$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, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 # 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. # serial 10 # 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", "GCJ", or "OBJC". # 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 ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" 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'. 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 8's {/usr,}/bin/sh. touch 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 ;; 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, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # 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. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 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"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //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' -e 's/\$U/'"$U"'/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, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 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. # serial 16 # 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. # 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.62])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], [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], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [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([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. 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)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl 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 ]) 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, 2003, 2005, 2008 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}" != 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, 2005 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. # serial 2 # 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, 2002, 2003, 2005, 2009 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. # serial 4 # 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 ]) # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 # 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. # serial 6 # AM_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != 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 dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # 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. # serial 6 # 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 supports --run. # If it does, 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 --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 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_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 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. # serial 4 # _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])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # 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. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # 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 ( 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 rm -f conftest.file 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 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)]) # Copyright (C) 2001, 2003, 2005 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, 2008 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. # serial 2 # _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, 2005 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. # serial 2 # _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. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. 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/iconv.m4]) m4_include([m4/lib-ld.m4]) m4_include([m4/lib-link.m4]) m4_include([m4/lib-prefix.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/sprintf_i64_format.m4]) m4_include([m4/type_socklen_t.m4]) freetds-0.91/Makefile.am100664 001750 000144 00000003773 11411564161 0010645# version $Id: Makefile.am,v 1.49 2010/06/27 05:58:09 freddy77 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 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 Nmakefile FreeTDS.sln ETC = $(DESTDIR)$(sysconfdir) DOCDIR = doc/doc/freetds-$(VERSION) install-data-local: $(mkinstalldirs) $(ETC) if test ! -f $(ETC)/freetds.conf; then \ $(INSTALL_DATA) $(srcdir)/freetds.conf $(ETC)/freetds.conf; \ fi if test ! -f $(ETC)/locales.conf; then \ $(INSTALL_DATA) $(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 CVS 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 $(mkinstalldirs) $(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-0.91/Makefile.in100664 001750 000144 00000063244 11623070620 0010652# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.49 2010/06/27 05:58:09 freddy77 Exp $ VPATH = @srcdir@ 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 = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/freetds.spec.in \ $(top_srcdir)/configure AUTHORS COPYING COPYING.LIB ChangeLog \ INSTALL NEWS TODO compile config.guess config.rpath config.sub \ depcomp install-sh ltmain.sh missing mkinstalldirs 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-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 uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(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 distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 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 Nmakefile FreeTDS.sln ETC = $(DESTDIR)$(sysconfdir) DOCDIR = doc/doc/freetds-$(VERSION) # enable some cheat so make distcheck work (see below) DISTCHECK_CONFIGURE_FLAGS = \ --enable-distcheck-build --enable-extra-checks all: all-recursive .SUFFIXES: am--refresh: @: $(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 .PRECIOUS: 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. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; 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" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) 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; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 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 \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ 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__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__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.lzma*) \ lzma -dc $(distdir).tar.lzma | $(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 a+w $(distdir) mkdir $(distdir)/_build mkdir $(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 \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(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__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: @$(am__cd) '$(distuninstallcheck_dir)' \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-libtool clean-local ctags ctags-recursive dist dist-all \ dist-bzip2 dist-gzip dist-lzma 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-recursive \ uninstall uninstall-am uninstall-local install-data-local: $(mkinstalldirs) $(ETC) if test ! -f $(ETC)/freetds.conf; then \ $(INSTALL_DATA) $(srcdir)/freetds.conf $(ETC)/freetds.conf; \ fi if test ! -f $(ETC)/locales.conf; then \ $(INSTALL_DATA) $(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 CVS 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@ $(mkinstalldirs) $(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-0.91/freetds.spec.in100664 001750 000144 00000010417 11326316450 0011520%define name @PACKAGE@ %define version @VERSION@ # compute some additional dependency from vendor name # # RedHat %define tds_builddep_redhat unixODBC-devel >= 2.0.0 %define tds_dep_suse glibc-locale # SUSE %define tds_builddep_suse unixODBC-devel >= 2.0.0 %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 %{?tds_builddep:BuildRequires: %{tds_builddep}} %{?tds_dep:Requires: %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=4.2 --with-unixodbc="$ODBCDIR" 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-%{version}" %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/doc/freetds-%{version}/userguide doc/images doc/doc/freetds-%{version}/reference %changelog * 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 * Sun 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 * Wed 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-0.91/configure100775 001750 000144 00002215734 11623070616 0010526#! /bin/sh # From configure.ac Revision: 1.60.2.5 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65 for FreeTDS 0.91. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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. 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 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" 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" 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 : # 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. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} 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_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 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=$?; test $as_status -eq 0 && as_status=1 if test "$3"; then as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 fi $as_echo "$as_me: error: $1" >&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; } # 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 -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' 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 if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # 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'" # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$lt_ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` ;; esac ECHO=${lt_ECHO-echo} if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then # Yippee, $ECHO works! : else # Restart under the correct shell. exec $SHELL "$0" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <<_LT_EOF $* _LT_EOF exit 0 fi # 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 if test -z "$lt_ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if { echo_test_string=`eval $cmd`; } 2>/dev/null && { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null then break fi done fi if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$ECHO" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. ECHO='print -r' elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} else # Try using printf. ECHO='printf %s\n' if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL ECHO="$CONFIG_SHELL $0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$CONFIG_SHELL $0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "$0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} else # Oops. We lost completely, so just stick with echo. ECHO=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. lt_ECHO=$ECHO if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" fi test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, 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='0.91' PACKAGE_STRING='FreeTDS 0.91' 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 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 ODBCNODMLIBAPP ODBCNODMLIB ODBCINSTLIB ODBCLIB ODBC_INC ODBC UNIXODBC_FALSE UNIXODBC_TRUE ODBC_FALSE ODBC_TRUE FREETDS_ODBC_MODULE INCODBC_FALSE INCODBC_TRUE 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 PKG_CONFIG 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 OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL lt_ECHO RANLIB AR LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP SED LIBTOOL OBJDUMP DLLTOOL AS EGREP GREP CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE 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 BUILD_NUMBER SUBVERSION MINOR MAJOR 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_dependency_tracking enable_largefile enable_shared enable_static with_pic enable_fast_install with_gnu_ld 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_odbc_wide enable_distcheck_build ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # 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=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 $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 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 0.91 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 0.91:";; 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] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --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 --enable-sspi enable 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-odbc-wide enable wide string support in odbc [experimental] --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 try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --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) [5.0] --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 TLS support --with-openssl --with-openssl=DIR build with OpenSSL (license NOT compatible cf. User Guide) Some influential environment variables: 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 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 0.91 generated by GNU Autoconf 2.65 Copyright (C) 2009 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; test "x$as_lineno_stack" = x && { as_lineno=; 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; } >/dev/null && { 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; test "x$as_lineno_stack" = x && { as_lineno=; 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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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.$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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; 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; test "x$as_lineno_stack" = x && { as_lineno=; 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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; 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 || $as_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; test "x$as_lineno_stack" = x && { as_lineno=; 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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func # ac_fn_c_check_decl LINENO SYMBOL VAR # ------------------------------------ # Tests whether SYMBOL is declared, 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_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 $as_echo_n "checking whether $2 is declared... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $2 (void) $2; #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; test "x$as_lineno_stack" = x && { as_lineno=; 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 { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; 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 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 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 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 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 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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; 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 0.91, which was generated by GNU Autoconf 2.65. 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 cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX 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 cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX 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 cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX 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 cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX 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 ac_site_file1=$CONFIG_SITE 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" 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.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do for ac_t in install-sh install.sh shtool; do if test -f "$ac_dir/$ac_t"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/$ac_t -c" break 2 fi done 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 test "${ac_cv_path_install+set}" = set; 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 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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; } # Just in case sleep 1 echo timestamp > conftest.file # 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 ( 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 rm -f conftest.file 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 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; } 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 --run true"; then am_missing_run="$MISSING --run " 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}" != 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 test "${ac_cv_prog_STRIP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_STRIP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_path_mkdir+set}" = set; 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 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac 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 test "${ac_cv_prog_AWK+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; 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 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='0.91' 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"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_headers="$ac_config_headers include/config.h" MAJOR=$(echo $VERSION | sed 's,\..*,,g') MINOR=$(echo $VERSION | sed 's,^[0-9]*\.\([0-9]*\).*,\1,g') SUBVERSION=$(echo $VERSION.0 | sed 's,^\([0-9]*\.[0-9]*\)\(rc\|RC\),\1.dev.,g; s,^[0-9]*\.[^.]*\.\([^.]*\).*,\1,g') BUILD_NUMBER=$(date +"%y%j" | sed 's,^0*,,g') if test "X$SUBVERSION" = "Xdev"; then MINOR=$(expr $MINOR - 1) SUBVERSION=9999 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 test "${ac_cv_build+set}" = set; 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 test "${ac_cv_host+set}" = set; 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='\' 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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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_set_status 77 as_fn_error "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 test "${ac_cv_objext+set}" = set; 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 test "${ac_cv_c_compiler_gnu+set}" = set; 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 test "${ac_cv_prog_cc_g+set}" = set; 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 test "${ac_cv_prog_cc_c89+set}" = set; 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 #include #include /* 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 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 test "${am_cv_CC_dependencies_compiler_type+set}" = set; 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'. 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 8's {/usr,}/bin/sh. touch 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 ;; 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 test "${ac_cv_prog_CPP+set}" = set; 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.$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.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f 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.$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.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f 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 grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; 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" { test -f "$ac_path_GREP" && $as_test_x "$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 for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; 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" { test -f "$ac_path_EGREP" && $as_test_x "$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 test "${ac_cv_header_stdc+set}" = set; 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 " eval as_val=\$$as_ac_Header if test "x$as_val" = 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" = x""yes; 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 test "${ac_cv_safe_to_define___extensions__+set}" = set; 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 test "${ac_cv_sys_largefile_CC+set}" = set; 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 test "${ac_cv_sys_file_offset_bits+set}" = set; 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 test "${ac_cv_sys_large_files+set}" = set; 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 # ------------------------------------------------------------ # Flag to include library-private definitions # ------------------------------------------------------------ CPPFLAGS="$CPPFLAGS -D_FREETDS_LIBRARY_SOURCE" # ------------------------------------------------------------ # 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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_c_compiler_gnu+set}" = set; 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 test "${ac_cv_prog_cc_g+set}" = set; 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 test "${ac_cv_prog_cc_c89+set}" = set; 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 #include #include /* 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 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 test "${am_cv_CC_dependencies_compiler_type+set}" = set; 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'. 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 8's {/usr,}/bin/sh. touch 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 ;; 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 test "${ac_cv_prog_CPP+set}" = set; 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.$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.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f 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.$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.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f 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 if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $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; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; 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. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { 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; } && test -f conftest2.$ac_objext && { { 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 eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&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_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { 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; } && test -f conftest2.$ac_objext && { { 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 # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; 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; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if test "${ac_cv_c_inline+set}" = set; 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 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 test "${ac_cv_prog_AS+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_AS+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_DLLTOOL+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_DLLTOOL+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_OBJDUMP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 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.2.6b' macro_revision='1.3017' ltmain="$ac_aux_dir/ltmain.sh" { $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 test "${ac_cv_path_SED+set}" = set; 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" { test -f "$ac_path_SED" && $as_test_x "$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 test "${ac_cv_path_FGREP+set}" = set; 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" { test -f "$ac_path_FGREP" && $as_test_x "$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 "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no 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 test "${lt_cv_path_LD+set}" = set; 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 test "${lt_cv_prog_gnu_ld+set}" = set; 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 test "${lt_cv_path_NM+set}" = set; 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 case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) 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 "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$ac_tool_prefix"; then for ac_prog in "dumpbin -symbols" "link -dump -symbols" 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 test "${ac_cv_prog_DUMPBIN+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 -symbols" "link -dump -symbols" 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 test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 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 test "${lt_cv_nm_interface+set}" = set; 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:6793: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:6796: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:6799: 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; } { $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 # 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 test "${lt_cv_sys_max_cmd_len+set}" = set; 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; ;; 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; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # 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 ;; 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"; 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"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 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"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } 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 for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if test "${lt_cv_ld_reload_flag+set}" = set; 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 darwin*) if test "$GCC" = yes; 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 test "${ac_cv_prog_OBJDUMP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${lt_cv_deplibs_check_method+set}" = set; 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 # which 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 lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' 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 ;; gnu*) 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]) 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 Linux ELF. linux* | k*bsd*-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*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; 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 ;; 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_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}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_AR+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="${ac_tool_prefix}ar" $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 fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_AR+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="ar" $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 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 else AR="$ac_cv_prog_AR" fi test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru 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 test "${ac_cv_prog_STRIP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_STRIP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_RANLIB+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi # 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 test "${lt_cv_sys_global_symbol_pipe+set}" = set; 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 "$host_cpu" = ia64; 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 # 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 -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$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 -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/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 # and D for any global 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};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print 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 # 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 #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. */ const struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$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_save_LIBS="$LIBS" lt_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_save_LIBS" CFLAGS="$lt_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 "$pipe_works" = yes; 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 # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && 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 which ABI we are using. 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 which ABI we are using. echo '#line 8001 "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 "$lt_cv_prog_gnu_ld" = yes; 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* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. 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*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|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" ;; ppc*-*linux*|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 test "${lt_cv_cc_needs_belf+set}" = set; 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 x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. 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*) LD="${LD-ld} -m elf64_sparc" ;; *) 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" 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 test "${ac_cv_prog_DSYMUTIL+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_NMEDIT+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_LIPO+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_LIPO+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_OTOOL+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_OTOOL64+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${lt_cv_apple_cc_single_mod+set}" = set; 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 test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; 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 test "${lt_cv_ld_exported_symbols_list+set}" = set; 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; } 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 "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; 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" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; 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" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options 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; pic_mode="$withval" else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # 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 # 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 test "${lt_cv_objdir+set}" = set; 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 "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # 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. 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' # 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 for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` # 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 test "${lt_cv_path_MAGIC_CMD+set}" = set; 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 test "${lt_cv_path_MAGIC_CMD+set}" = set; 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 "$GCC" = yes; then lt_prog_compiler_no_builtin_flag=' -fno-builtin' { $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 test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; 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" # 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:9261: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:9265: \$? = $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 "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/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 x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; 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= { $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 test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; 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' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; 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 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 "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; 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' ;; 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) 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' ;; pgcc* | pgf77* | pgf90* | pgf95*) # 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*) # IBM XL C 8.0/Fortran 10.1 on PPC lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Sun\ F*) # 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='' ;; 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*) 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 which 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}: result: $lt_prog_compiler_pic" >&5 $as_echo "$lt_prog_compiler_pic" >&6; } # # 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 test "${lt_cv_prog_compiler_pic_works+set}" = set; 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" # 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:9600: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:9604: \$? = $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 "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/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 x"$lt_cv_prog_compiler_pic_works" = xyes; 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 test "${lt_cv_prog_compiler_static_works+set}" = set; 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 "X$_lt_linker_boilerplate" | $Xsed -e '/^$/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 x"$lt_cv_prog_compiler_static_works" = xyes; 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 test "${lt_cv_prog_compiler_c_o+set}" = set; 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:9705: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:9709: \$? = $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 "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/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 test "${lt_cv_prog_compiler_c_o+set}" = set; 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:9760: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:9764: \$? = $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 "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/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 "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; 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 "$hard_links" = no; 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_flag_spec_ld= 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 "$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 # 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 2>&1` in *\ [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 "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.9.1, 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 modify your PATH *** so that a non-GNU linker is found, and then restart. _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' 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/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' 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 (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; 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 ;; 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) tmp_diet=no if test "$host_os" = linux-dietlibc; 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 "$tmp_diet" = no then tmp_addflag= 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; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # 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; $ECHO \"$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' ;; xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; 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; $ECHO \"$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 "x$supports_anon_versioning" = xyes; 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 xlf*) # 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= hardcode_libdir_flag_spec_ld='-rpath $libdir' archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; 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 $compiler_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 $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' 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 $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 ;; 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 can not *** 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 $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 if test "$ld_shlibs" = no; 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 "$GCC" = yes && 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 "$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 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 AIX nm, but means don't demangle with GNU 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")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | 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 # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) 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 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,' if test "$GCC" = yes; 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 "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; 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 "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi 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_use_runtimelinking" = yes; 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. 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 } }' 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 "$aix_libpath"; then 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 "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; 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 "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; 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. 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 } }' 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 "$aix_libpath"; then 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 "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; 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' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' 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. 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 `$ECHO "X$deplibs" | $Xsed -e '\''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' fix_srcfile_path='`cygpath -w "$srcfile"`' enable_shared_with_static_runtimes=yes ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported whole_archive_flag_spec='' link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=echo 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 ;; freebsd1*) ld_shlibs=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 -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $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 $output_objdir/$soname = $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 "$GCC" = yes -a "$with_gnu_ld" = no; then archive_cmds='$CC -shared -fPIC ${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 "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_flag_spec_ld='+b $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 "$GCC" = yes -a "$with_gnu_ld" = no; 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 -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared -fPIC ${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' ;; *) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi 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_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 "$GCC" = yes; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${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. 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) {} _ACEOF if ac_fn_c_try_link "$LINENO"; then : archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -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 ;; 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*) 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__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; 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 case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' 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 allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; 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" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${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" && $ECHO "X-set_version $verstring" | $Xsed` -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 "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${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" && $ECHO "X-set_version $verstring" | $Xsed` -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 "X-set_version $verstring" | $Xsed` -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 "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared ${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 ${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 "$GCC" = yes; 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 "x$host_vendor" = xsequent; 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 "$GCC" = yes; 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 can NOT 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 "$GCC" = yes; 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 x$host_vendor = xsni; 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 "$ld_shlibs" = no && 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 "$enable_shared" = yes && test "$GCC" = yes; 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; } $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 archive_cmds_need_lc=no else archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5 $as_echo "$archive_cmds_need_lc" >&6; } ;; 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 "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # 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 -e 's/;/ /g'` else lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # 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` 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" else 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; } }'` sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` 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 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 need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; 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 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # 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}' else # 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' fi 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=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $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 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,$host_os in yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) 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="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. 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 ;; 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 ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # 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 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 ;; freebsd1*) dynamic_linker=no ;; 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[123]*) 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} $libname${shared_ext}' 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 ;; gnu*) version_type=linux 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 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 "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; 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' ;; interix[3-9]*) version_type=linux 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 "$lt_cv_prog_gnu_ld" = yes; then version_type=linux 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 ;; # This must be Linux ELF. linux* | k*bsd*-gnu) version_type=linux 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 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 : 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 # 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 # Append ld.so.conf contents 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;/^$/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 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*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac 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 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; 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 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 "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux 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 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=freebsd-elf 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 "$with_gnu_ld" = yes; 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 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 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 "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $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 "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # 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 "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; 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 "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; 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 test "${ac_cv_lib_dl_dlopen+set}" = set; 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" = x""yes; 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 ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = x""yes; 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 test "${ac_cv_lib_dld_shl_load+set}" = set; 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" = x""yes; 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" = x""yes; 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 test "${ac_cv_lib_dl_dlopen+set}" = set; 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" = x""yes; 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 test "${ac_cv_lib_svld_dlopen+set}" = set; 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" = x""yes; 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 test "${ac_cv_lib_dld_dld_link+set}" = set; 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" = x""yes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && 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 test "${lt_cv_dlopen_self+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; 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 12127 "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 void fnord() { int i=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; /* 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 "x$lt_cv_dlopen_self" = xyes; 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 test "${lt_cv_dlopen_self_static+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; 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 12223 "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 void fnord() { int i=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; /* 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 which 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 "$can_build_shared" = "no" && 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 "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no 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 "$enable_shared" = yes || 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 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 test "${ac_cv_search_dlopen+set}" = set; 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 test "${ac_cv_search_dlopen+set}" = set; then : break fi done if test "${ac_cv_search_dlopen+set}" = set; 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 test "${ac_cv_lib_svld_dlopen+set}" = set; 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" = x""yes; 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 x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes 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" = x""yes; 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" = x""yes; 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 test "${ac_cv_lib_dld_shl_load+set}" = set; 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" = x""yes; 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" = x""yes; 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* | os2* | 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" = x""yes; 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 test "${ac_cv_lib_dld_dld_link+set}" = set; 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" = x""yes; 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" 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 test "${ac_cv_prog_RC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_RC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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_GCC=$GCC GCC= CC=${RC-"windres"} compiler=$CC compiler_RC=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` 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" # 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 echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh 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 GCC" >&5 $as_echo_n "checking for ld used by GCC... " >&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. [\\/]* | [A-Za-z]:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the path 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 test "${acl_cv_path_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do 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 GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi fi LD="$acl_cv_path_LD" if test -n "$LD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&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 test "${acl_cv_prog_gnu_ld+set}" = set; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU ld's 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 test "${acl_cv_rpath+set}" = set; 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" libext="$acl_cv_libext" shlibext="$acl_cv_shlibext" hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" hardcode_direct="$acl_cv_hardcode_direct" 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 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/lib" fi fi fi LIBICONV= LTLIBICONV= INCICONV= 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= if test $use_additional = yes; then if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then found_dir="$additional_libdir" found_so="$additional_libdir/lib$name.$shlibext" if test -f "$additional_libdir/lib$name.la"; then found_la="$additional_libdir/lib$name.la" fi else if test -f "$additional_libdir/lib$name.$libext"; then found_dir="$additional_libdir" found_a="$additional_libdir/lib$name.$libext" if test -f "$additional_libdir/lib$name.la"; then found_la="$additional_libdir/lib$name.la" fi 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 "$shlibext" && test -f "$dir/lib$name.$shlibext"; then found_dir="$dir" found_so="$dir/lib$name.$shlibext" if test -f "$dir/lib$name.la"; then found_la="$dir/lib$name.la" fi else if test -f "$dir/lib$name.$libext"; then found_dir="$dir" found_a="$dir/lib$name.$libext" if test -f "$dir/lib$name.la"; then found_la="$dir/lib$name.la" fi 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/lib"; 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 "$hardcode_direct" = yes; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else if test -n "$hardcode_libdir_flag_spec" && test "$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 "$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 */lib | */lib/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` 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*) 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/lib"; then haveit= if test "X$additional_libdir" = "X/usr/local/lib"; then if test -n "$GCC"; then case $host_os in linux*) 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 "$hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$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=\"$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 test "${am_cv_func_iconv+set}" = set; 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 "#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 test "${am_cv_proto_iconv+set}" = set; 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(__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: ${ac_t:- }$am_cv_proto_iconv" >&5 $as_echo "${ac_t:- }$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 test "${ac_cv_prog_DOXYGEN+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ODBC_CONFIG+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 # 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 test "${ac_cv_prog_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PKG_CONFIG"; then ac_cv_prog_PKG_CONFIG="$PKG_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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PKG_CONFIG="pkg-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 PKG_CONFIG=$ac_cv_prog_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 # ------------------------------------------------------------ # 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 OLDLIBS="$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 test "${ac_cv_search_gethostbyname+set}" = set; 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 test "${ac_cv_search_gethostbyname+set}" = set; then : break fi done if test "${ac_cv_search_gethostbyname+set}" = set; 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" eval as_val=\$$as_ac_var if test "x$as_val" = 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 test "${ac_cv_search_socket+set}" = set; 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 test "${ac_cv_search_socket+set}" = set; then : break fi done if test "${ac_cv_search_socket+set}" = set; 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 test "${ac_cv_search_gethostbyname+set}" = set; 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 test "${ac_cv_search_gethostbyname+set}" = set; then : break fi done if test "${ac_cv_search_gethostbyname+set}" = set; 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 test "${ac_cv_search_gss_init_sec_context+set}" = set; 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 test "${ac_cv_search_gss_init_sec_context+set}" = set; then : break fi done if test "${ac_cv_search_gss_init_sec_context+set}" = set; 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 NETWORK_LIBS="$LIBS" LIBS="$OLDLIBS" if test $tds_mingw = no; then # readline test # Readline is needed by the tty session. Set up a special READLINE_LIBS # substitution for it. OLDLIBS="$LIBS" # Readline is linked with curses, and on some systems termcap must be # linked in. Others (inc debian) have termcap built into ncurses. LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5 $as_echo_n "checking for library containing tgetent... " >&6; } if test "${ac_cv_search_tgetent+set}" = set; 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 test "${ac_cv_search_tgetent+set}" = set; then : break fi done if test "${ac_cv_search_tgetent+set}" = set; 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 test "${ac_cv_lib_readline_readline+set}" = set; 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" = x""yes; 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" eval as_val=\$$as_ac_var if test "x$as_val" = 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="$OLDLIBS" 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 test "${ac_cv_prog_acx_pthread_config+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_PTHREAD_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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" 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-no} # 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 test "${ac_cv_header_stdc+set}" = set; 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 test "${ac_cv_header_time+set}" = set; 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 test "${ac_cv_struct_tm+set}" = set; 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" = x""yes; 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" = x""yes; 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 test "${ac_cv_var_tzname+set}" = set; 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" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM___TM_ZONE 1 _ACEOF fi for ac_header in errno.h \ getopt.h \ libgen.h \ limits.h \ locale.h \ poll.h \ readpassphrase.h \ signal.h \ stddef.h \ sys/param.h \ sys/select.h \ sys/stat.h \ sys/time.h \ sys/types.h \ sys/resource.h \ sys/wait.h \ unistd.h \ wchar.h \ inttypes.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" eval as_val=\$$as_ac_Header if test "x$as_val" = 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 odbcss.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 " eval as_val=\$$as_ac_Header if test "x$as_val" = 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 \ 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" eval as_val=\$$as_ac_Header if test "x$as_val" = 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 test "${ac_cv_have_inaddr_none+set}" = set; 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 test "${ac_cv_sizeof_char+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_short+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_long+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_int+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_float+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_double+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_long_double+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_long_long+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof___int64+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_void_p+set}" = set; 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_set_status 77 as_fn_error "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 test "${ac_cv_sizeof_wchar_t+set}" = set; 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_set_status 77 as_fn_error "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;; esac if test "$tds_sysdep_int64_type"; then $as_echo "#define HAVE_INT64 1" >>confdefs.h 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="I64d" 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=ld 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="lld" 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}d"; 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_FORMAT "$tds_i64_format" _ACEOF fi else tds_sysdep_int64_type=long { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: SQL Server 2000 \"bigint\" 8-byte integer will not work" >&5 $as_echo "$as_me: WARNING: SQL Server 2000 \"bigint\" 8-byte integer will not work" >&2;} 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 #include " if test "x$ac_cv_type_socklen_t" = x""yes; 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 test "${xml_cv_socklen_t_equiv+set}" = set; 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 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 () { extern int optreset; 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 test "${ac_cv_c_bigendian+set}" = set; 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 test "${ac_cv_c_const+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* 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. */ char *t; 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 saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; 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" 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 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 test "${tds_cv_null_is_zero+set}" = set; 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 gettimeofday \ nl_langinfo locale_charset setenv putenv \ getuid getpwuid getpwuid_r fstat alarm fork \ gethrtime localtime_r setitimer _lseeki64 _telli64 \ _fseeki64 _ftelli64 setrlimit 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" eval as_val=\$$as_ac_var if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done OLD_LIBS="$LIBS" LIBS="$LIBS $NETWORK_LIBS" for ac_func in inet_ntoa_r getipnodebyaddr getipnodebyname \ getaddrinfo getnameinfo inet_ntop gethostname poll 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" eval as_val=\$$as_ac_var if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done LIBS="$OLD_LIBS" for ac_func in asprintf vasprintf atoll strtok_r readpassphrase \ strlcpy strlcat basename getopt 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" eval as_val=\$$as_ac_var if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF else case " $LIBOBJS " in *" $ac_func.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" ;; esac fi done { $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 test "${ac_cv_sys_largefile_source+set}" = set; 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 test "${ac_cv_search_clock_gettime+set}" = set; 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 test "${ac_cv_search_clock_gettime+set}" = set; then : break fi done if test "${ac_cv_search_clock_gettime+set}" = set; 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 # ------------------------------------------------------------ # 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 test "${ac_cv_have_malloc_options+set}" = set; 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 if test "$with_tdsver" = "4.2"; then $as_echo "#define TDS42 1" >>confdefs.h elif test "$with_tdsver" = "4.6"; then $as_echo "#define TDS46 1" >>confdefs.h elif test "$with_tdsver" = "7.0"; then $as_echo "#define TDS70 1" >>confdefs.h elif test "$with_tdsver" = "7.1"; then $as_echo "#define TDS71 1" >>confdefs.h else $as_echo "#define TDS50 1" >>confdefs.h fi # 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*) FREETDS_ODBC_MODULE="-module" ;; 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 test "${ac_cv_lib_iodbc_SQLConnect+set}" = set; 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" = x""yes; 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" = x""yes; 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 test "${ac_cv_lib_odbc_SQLConnect+set}" = set; 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" = x""yes; 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" = x""yes; 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 test "${ac_cv_lib_odbcinst_SQLGetPrivateProfileString+set}" = set; 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" = x""yes; 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 test "${ac_cv_lib_iodbcinst_SQLGetPrivateProfileString+set}" = set; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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 test "${ac_cv_sizeof_SQLWCHAR+set}" = set; 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_set_status 77 as_fn_error "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 if test "$PKG_CONFIG" != "" && "$PKG_CONFIG" --libs gnutls > /dev/null 2>&1; then CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags gnutls`" NETWORK_LIBS="$NETWORK_LIBS `$PKG_CONFIG --libs gnutls`" else CPPFLAGS="$CPPFLAGS `libgnutls-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgnutls-config --libs`" fi OLDLIBS="$LIBS" LIBS="$LIBS $NETWORK_LIBS" for ac_func in gnutls_record_disable_padding do : ac_fn_c_check_func "$LINENO" "gnutls_record_disable_padding" "ac_cv_func_gnutls_record_disable_padding" if test "x$ac_cv_func_gnutls_record_disable_padding" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GNUTLS_RECORD_DISABLE_PADDING 1 _ACEOF fi done LIBS="$OLDLIBS" 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; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } 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 found_ssl="yes" CFLAGS="$CFLAGS -I$ssldir/include" break fi done if test x$found_ssl != xyes; then as_fn_error "Cannot find OpenSSL libraries" "$LINENO" 5 else echo "OpenSSL found in $ssldir" NETWORK_LIBS="$NETWORK_LIBS -lssl -lcrypto" LDFLAGS="$LDFLAGS -L$ssldir/lib" HAVE_OPENSSL=yes $as_echo "#define HAVE_OPENSSL 1" >>confdefs.h 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 # 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 test "${ac_cv_func_which_gethostname_r+set}" = set; 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 test "${ac_cv_func_which_getservbyname_r+set}" = set; 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 test "${ac_cv_func_which_gethostbyaddr_r+set}" = set; 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 test "${ac_cv_func_which_getpwuid_r+set}" = set; 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 test "${ac_cv_func_which_localtime_r+set}" = set; 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 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 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 # 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 # 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" = "yes" ; then cat >>confdefs.h <<_ACEOF #define ENABLE_ODBC_WIDE 1 _ACEOF 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" 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 test "${ac_cv_cflags_gcc_option__Wdeclaration_after_statement+set}" = set; 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/tdsver.h include/tds_sysdep_public.h Makefile include/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/server/Makefile src/pool/Makefile src/odbc/Makefile src/odbc/unittests/Makefile src/apps/Makefile src/apps/fisql/Makefile freetds.spec win32/Makefile win32/msvc6/Makefile win32/version.rc win32/freetds.nsh vms/Makefile" 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 test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file 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= 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 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 "${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. 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 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=$?; test $as_status -eq 0 && as_status=1 if test "$3"; then as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 fi $as_echo "$as_me: error: $1" >&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 -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' 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 if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # 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 0.91, which was generated by GNU Autoconf 2.65. 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 0.91 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" Copyright (C) 2009 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=$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"` ;; 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' AS='`$ECHO "X$AS" | $Xsed -e "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "X$DLLTOOL" | $Xsed -e "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' LD_RC='`$ECHO "X$LD_RC" | $Xsed -e "$delay_single_quote_subst"`' old_archive_cmds_RC='`$ECHO "X$old_archive_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' compiler_RC='`$ECHO "X$compiler_RC" | $Xsed -e "$delay_single_quote_subst"`' GCC_RC='`$ECHO "X$GCC_RC" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_RC='`$ECHO "X$lt_prog_compiler_no_builtin_flag_RC" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_wl_RC='`$ECHO "X$lt_prog_compiler_wl_RC" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_pic_RC='`$ECHO "X$lt_prog_compiler_pic_RC" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_static_RC='`$ECHO "X$lt_prog_compiler_static_RC" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_RC='`$ECHO "X$lt_cv_prog_compiler_c_o_RC" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_need_lc_RC='`$ECHO "X$archive_cmds_need_lc_RC" | $Xsed -e "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_RC='`$ECHO "X$enable_shared_with_static_runtimes_RC" | $Xsed -e "$delay_single_quote_subst"`' export_dynamic_flag_spec_RC='`$ECHO "X$export_dynamic_flag_spec_RC" | $Xsed -e "$delay_single_quote_subst"`' whole_archive_flag_spec_RC='`$ECHO "X$whole_archive_flag_spec_RC" | $Xsed -e "$delay_single_quote_subst"`' compiler_needs_object_RC='`$ECHO "X$compiler_needs_object_RC" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_new_cmds_RC='`$ECHO "X$old_archive_from_new_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_RC='`$ECHO "X$old_archive_from_expsyms_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_RC='`$ECHO "X$archive_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' archive_expsym_cmds_RC='`$ECHO "X$archive_expsym_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' module_cmds_RC='`$ECHO "X$module_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' module_expsym_cmds_RC='`$ECHO "X$module_expsym_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' with_gnu_ld_RC='`$ECHO "X$with_gnu_ld_RC" | $Xsed -e "$delay_single_quote_subst"`' allow_undefined_flag_RC='`$ECHO "X$allow_undefined_flag_RC" | $Xsed -e "$delay_single_quote_subst"`' no_undefined_flag_RC='`$ECHO "X$no_undefined_flag_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_RC='`$ECHO "X$hardcode_libdir_flag_spec_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld_RC='`$ECHO "X$hardcode_libdir_flag_spec_ld_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_separator_RC='`$ECHO "X$hardcode_libdir_separator_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_RC='`$ECHO "X$hardcode_direct_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_absolute_RC='`$ECHO "X$hardcode_direct_absolute_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_minus_L_RC='`$ECHO "X$hardcode_minus_L_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_shlibpath_var_RC='`$ECHO "X$hardcode_shlibpath_var_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_automatic_RC='`$ECHO "X$hardcode_automatic_RC" | $Xsed -e "$delay_single_quote_subst"`' inherit_rpath_RC='`$ECHO "X$inherit_rpath_RC" | $Xsed -e "$delay_single_quote_subst"`' link_all_deplibs_RC='`$ECHO "X$link_all_deplibs_RC" | $Xsed -e "$delay_single_quote_subst"`' fix_srcfile_path_RC='`$ECHO "X$fix_srcfile_path_RC" | $Xsed -e "$delay_single_quote_subst"`' always_export_symbols_RC='`$ECHO "X$always_export_symbols_RC" | $Xsed -e "$delay_single_quote_subst"`' export_symbols_cmds_RC='`$ECHO "X$export_symbols_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' exclude_expsyms_RC='`$ECHO "X$exclude_expsyms_RC" | $Xsed -e "$delay_single_quote_subst"`' include_expsyms_RC='`$ECHO "X$include_expsyms_RC" | $Xsed -e "$delay_single_quote_subst"`' prelink_cmds_RC='`$ECHO "X$prelink_cmds_RC" | $Xsed -e "$delay_single_quote_subst"`' file_list_spec_RC='`$ECHO "X$file_list_spec_RC" | $Xsed -e "$delay_single_quote_subst"`' hardcode_action_RC='`$ECHO "X$hardcode_action_RC" | $Xsed -e "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # Quote evaled strings. for var in SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ deplibs_check_method \ file_magic_cmd \ AR \ AR_FLAGS \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ SHELL \ ECHO \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_wl \ lt_prog_compiler_pic \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ 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_flag_spec_ld \ hardcode_libdir_separator \ fix_srcfile_path \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ finish_eval \ old_striplib \ striplib \ LD_RC \ compiler_RC \ lt_prog_compiler_no_builtin_flag_RC \ lt_prog_compiler_wl_RC \ lt_prog_compiler_pic_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_flag_spec_ld_RC \ hardcode_libdir_separator_RC \ fix_srcfile_path_RC \ exclude_expsyms_RC \ include_expsyms_RC \ file_list_spec_RC; do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) 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 \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec \ 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; do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Fix-up fallback echo if it was mangled by the above quoting rules. case \$lt_ECHO in *'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` ;; esac ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which 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' TIMESTAMP='$TIMESTAMP' 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/tdsver.h") CONFIG_FILES="$CONFIG_FILES include/tdsver.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" ;; "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/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/msvc6/Makefile") CONFIG_FILES="$CONFIG_FILES win32/msvc6/Makefile" ;; "win32/version.rc") CONFIG_FILES="$CONFIG_FILES win32/version.rc" ;; "win32/freetds.nsh") CONFIG_FILES="$CONFIG_FILES win32/freetds.nsh" ;; "vms/Makefile") CONFIG_FILES="$CONFIG_FILES vms/Makefile" ;; *) 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= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$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 -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 # 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 {' >"$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 >>"\$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 >>"\$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 < "$tmp/subs1.awk" > "$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 $(srcdir), # ${srcdir} and @srcdir@ 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[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// 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 >"$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_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; 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="$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 "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 >"$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 "$tmp/subs.awk" >$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' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$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 "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$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 "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || as_fn_error "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$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 "$tmp/config.h" "$ac_file" \ || as_fn_error "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$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"" || { # Autoconf 2.62 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"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //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' -e 's/\$U/'"$U"'/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 which 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 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $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. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="RC " # ### BEGIN LIBTOOL CONFIG # Assembler program. AS=$AS # DLL creation program. DLLTOOL=$DLLTOOL # Object dumper program. OBJDUMP=$OBJDUMP # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # 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 # 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 # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # 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 # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # 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 # 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 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 of the directory that contains temporary libtool files. objdir=$objdir # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that does not interpret backslashes. ECHO=$lt_ECHO # 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 # 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 # 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 # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # 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 # 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 # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # 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 # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld # 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 # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path=$lt_fix_srcfile_path # 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 # 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 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 "X${COLLECT_NAMES+set}" != Xset; 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 '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) case $xsi_shell in yes) cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac } # func_basename file func_basename () { func_basename_result="${1##*/}" } # 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" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}" } # func_stripname 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). func_stripname () { # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"} } # func_opt_split func_opt_split () { func_opt_split_opt=${1%%=*} func_opt_split_arg=${1#*=} } # func_lo2o object func_lo2o () { case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac } # func_xform libobj-or-source func_xform () { func_xform_result=${1%.*}.lo } # func_arith arithmetic-term... func_arith () { func_arith_result=$(( $* )) } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=${#1} } _LT_EOF ;; *) # Bourne compatible functions. cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_basename file func_basename () { func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } # func_stripname 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). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; esac } # sed scripts: my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^-[^=]*=//' # func_opt_split func_opt_split () { func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` } # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` } # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` } # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "$@"` } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } _LT_EOF esac case $lt_shell_append in yes) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$1+=\$2" } _LT_EOF ;; *) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$1=\$$1\$2" } _LT_EOF ;; esac sed -n '/^# Generated shell functions inserted here/,$p' "$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 # 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 # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_RC # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_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 # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_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 # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path=$lt_fix_srcfile_path_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 # 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 $? 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-0.91/AUTHORS100664 001750 000144 00000005032 11040514164 0007643Brian Bruns Started this crazy thing James K. Lowden Documentation, maintainer since 2003. 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. 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-0.91/COPYING100664 001750 000144 00000043105 07361676250 0007651 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Library 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) 19yy 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 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) 19yy 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 Library General Public License instead of this License. freetds-0.91/COPYING.LIB100664 001750 000144 00000061261 07361676251 0010262 GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, 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 Appendix: 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., 675 Mass Ave, Cambridge, MA 02139, 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-0.91/ChangeLog100644 001750 000144 00000423573 11623073422 0010365Wed Aug 17 22:20:36 EDT 2011 JK Lowden * README configure.ac - 0.91 release Fri Aug 12 18:29:44 CEST 2011 Frediano Ziglio * include/tds.h src/tds/config.c src/tds/gssapi.c src/tds/mem.c: - add Kerberos realm parameter to connection Fri Aug 12 13:50:27 CEST 2011 Frediano Ziglio * configure.ac src/tds/net.c: - check for gnutls_record_disable_padding function Thu Aug 4 06:38:32 CEST 2011 Frediano Ziglio * win32/tds_sysdep_public.h: - change header inclusion order to avoid wrong redeclarations Thu Jul 14 14:17:48 CEST 2011 Frediano Ziglio * include/sqlfront.h: more fix for php Mon Jul 11 11:11:54 CEST 2011 Frediano Ziglio * include/sqlfront.h: make php compile again Mon Jul 11 11:10:20 CEST 2011 Frediano Ziglio * include/sqlfront.h: do not typedef LPCBYTE twice Thu Jul 7 09:27:20 CEST 2011 Frediano Ziglio * Nmakefile include/replacements.h: - fix Nmakefile (from Ramiro Morales) Wed Jun 29 15:10:25 CEST 2011 Frediano Ziglio * Nmakefile: updated to reflect file rename Wed Jun 29 10:13:31 CEST 2011 Frediano Ziglio * src/tds/net.c: disable ssl padding for compatibility Thu Jun 9 15:02:51 CEST 2011 Frediano Ziglio * src/dblib/dbutil.c: compile fix (wrong backport) Tue Jun 7 10:52:31 CEST 2011 Frediano Ziglio * src/dblib/bcp.c src/dblib/dblib.c src/dblib/dbutil.c: - fix some dblib result Mon Jun 6 14:39:24 CEST 2011 Frediano Ziglio * src/dblib/unittests/t0016.in src/dblib/unittests/t0016.sql: * src/tds/query.c: - fix quoting identifier if reserved words used Mon Jun 6 14:31:44 CEST 2011 Frediano Ziglio * include/sybdb.h src/dblib/dblib.c: - backported patch to support bigint on dblib Thu Jun 2 22:35:20 CEST 2011 Frediano Ziglio * src/dblib/bcp.c: fix previous bcp patch Thu Jun 2 21:21:09 CEST 2011 Frediano Ziglio * src/dblib/bcp.c: fix bcp conversion Thu Jun 2 21:19:33 CEST 2011 Frediano Ziglio * include/tds.h src/dblib/bcp.c src/tds/bulk.c: - fix bcp for queryout Sun May 22 08:34:41 EDT 2011 JK Lowden * src/dblib/bcp.c reverted part of hasty fix Sat May 21 14:10:30 EDT 2011 JK Lowden * doc/userguide.sgml corrected typos * src/dblib/bcp.c relaxed per ML from Bill Thompson today. Sat May 14 09:03:48 EDT 2011 JK Lowden * src/dblib/dbutil.c pass DBNOERR to error handler Tue May 10 23:09:47 EDT 2011 JK Lowden * src/apps/osql correct servername feedback Tue May 10 15:21:09 CEST 2011 Frediano Ziglio * src/tds/gssapi.c src/tds/token.c: - fix Kerberos login using tds 7.2 Sun May 8 18:42:10 EDT 2011 JK Lowden * src/tds/query.c use varchar(4000) per ML patch from Ed Avis Sat May 7 21:03:57 CEST 2011 Frediano Ziglio * configure.ac: detect correctly odbcss.h Mon May 2 20:52:25 EDT 2011 JK Lowden * NEWS slightly edited for clarity Fri Apr 29 09:04:15 CEST 2011 Frediano Ziglio * include/tds.h src/tds/token.c: - correct fix to detect tds 7.1 revision 1 Thu Apr 28 16:50:15 CEST 2011 Frediano Ziglio * src/odbc/odbc.c: rollback patch for SQLTables Thu Apr 28 09:47:00 CEST 2011 Frediano Ziglio * src/tds/token.c: fix for tds 7.1 revision 1 (mssql2k without SPs) Sun Apr 24 20:25:54 CEST 2011 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/prepare_results.c: - fix problem preparing before binding parameters Fri Apr 22 16:14:09 CEST 2011 Frediano Ziglio * src/tds/.cvsignore src/tds/Makefile.am src/tds/data.c: - avoid header name clash Fri Apr 15 09:58:04 CEST 2011 Frediano Ziglio * configure.ac: avoid version clash Fri Apr 15 09:01:57 CEST 2011 Frediano Ziglio * NEWS: fix typo Fri Apr 15 08:59:04 CEST 2011 Frediano Ziglio * src/tds/config.c: fix overriding port or instance Thu Apr 14 20:20:22 EDT 2011 JK Lowden * NEWS add release notes * src/dblib/bcp.c - bcp_send row returns FAIL if dbconvert fails to - convert the bound buffer to the column datatype Mon Apr 11 17:33:55 EDT 2011 JK Lowden * include/tds.h include netinet/in.h Mon Apr 11 15:40:25 CEST 2011 Frediano Ziglio * src/tds/challenge.c: fix OpenSSL compile problem Mon Apr 11 15:33:27 CEST 2011 Frediano Ziglio * src/dblib/dblib.c src/tds/config.c src/tds/login.c: - support DBSETLDBNAME (really, this time) Mon Apr 11 11:58:50 CEST 2011 Frediano Ziglio * src/apps/defncopy.c: - include sybfront.h instead of sqlfront.h (from patches #3172166) Sat Apr 9 09:57:12 EDT 2011 JK Lowden * doc/Makefile.am make dist works Fri Apr 1 13:47:00 CEST 2011 Frediano Ziglio * src/dblib/dblib.c: avoid string format problem Thu Mar 31 10:20:43 CEST 2011 Frediano Ziglio * configure.ac: forgot rc versions Wed Mar 30 14:55:28 CEST 2011 Frediano Ziglio * configure.ac: release version Wed Mar 30 13:29:15 CEST 2011 Frediano Ziglio * include/tds.h src/odbc/odbc.c src/tds/query.c: - avoid unnecessary prepare and unprepare Sun Mar 27 12:34:23 EDT 2011 JK Lowden * include/sybdb.h include/tds.h - src/dblib/dblib.c src/tds/config.c src/tds/login.c - Support DBSETLDBNAME Tue Mar 22 13:51:32 EDT 2011 JK Lowden * autogen.sh neater output * src/apps/tsql.c spell Kerberos correctly * src/dblib/bcp.c initialize bcp_terminator Mon Mar 21 20:21:51 EDT 2011 JK Lowden * doc/userguide.sgml updated for upcoming release Sun Mar 13 14:40:55 EDT 2011 JK Lowden * doc/bsqldb.txt doc/freebcp.txt doc/tsql.txt - doc/userguide.sgml - updated for upcoming release * src/apps/bsqldb.c support numeric/decimal * src/apps/freebcp.c allow no username for trusted logins Sat Mar 12 07:52:15 EST 2011 JK Lowden * doc/userguide.sgml fine tune linker appendix Thu Feb 17 16:40:58 EST 2011 JK Lowden * Nmakefile more help for building under Windows Thu Feb 17 10:51:40 EST 2011 JK Lowden * Nmakefile default to Win32-Debug * src/apps/bsqldb.c use sybfront.h, not sqlfront.h * include/sybdb.h include/tds.h src/dblib/dblib.c - src/tds/login.c - indicate if TDS version automatically downgraded Sat Feb 12 20:53:19 EST 2011 JK Lowden * doc/userguide.sgml Add linker appendix Fri Feb 11 14:54:17 CET 2011 Frediano Ziglio * src/replacements/iconv.c: - improve iconv replacement unsigned/signed declaration Tue Jan 25 00:52:04 EST 2011 JK Lowden * doc/userguide.sgml include/sybdb.h - remove use and reference to sqlfront.h. Sat Jan 22 15:04:21 EST 2011 JK Lowden * src/tds/iconv.c tds_canonical_charset_name cannot return NULL Mon Jan 17 23:27:25 CET 2011 Frediano Ziglio * include/tds.h src/tds/data.c src/tds/token.c: - unify metadata read from server Fri Jan 14 15:15:21 CET 2011 Frediano Ziglio * src/dblib/bcp.c src/dblib/dblib.c: minor dblib results changes Wed Jan 12 10:21:03 CET 2011 Frediano Ziglio * src/tds/query.c: support SQL_VARIANT passing parameters Sun Jan 9 23:34:50 CET 2011 Frediano Ziglio * misc/test-other.sh: add --help option Sat Jan 8 02:36:23 CET 2011 Frediano Ziglio * src/tds/net.c: small optimization for darwin os Sat Jan 8 02:19:38 CET 2011 Frediano Ziglio * src/odbc/unittests/data.c src/tds/token.c: - fix unique inside variant Mon Jan 3 15:25:36 EST 2011 JK Lowden * src/dblib/dblib.c - TDSPORT and TDSVER override even if no configuration file found Fri Dec 31 11:33:05 EST 2010 JK Lowden * doc/api_status.txt doc/htdoc/faq.html - updated per Frediano and corrected validation errors Thu Dec 30 23:06:08 EST 2010 JK Lowden * doc/tsql.txt doc/userguide.sgml doc/htdoc/faq.html - updated to reflect current status Thu Dec 30 20:50:14 CET 2010 Frediano Ziglio * src/odbc/unittests/data.c: add some numeric cases Thu Dec 30 19:53:59 CET 2010 Frediano Ziglio * include/tds.h src/dblib/dblib.c src/dblib/unittests/t0007.c: * src/dblib/unittests/t0007.sql: - fix VARYBINBIND in dblib Thu Dec 30 19:28:16 CET 2010 Frediano Ziglio * include/tds.h src/odbc/sql2tds.c src/tds/threadsafe.c: - fix time shift problem Thu Dec 30 19:18:05 CET 2010 Frediano Ziglio * src/odbc/unittests/Makefile.am src/odbc/unittests/test64.c: - add small test for 64bit problems Thu Dec 30 19:10:58 CET 2010 Frediano Ziglio * src/dblib/unittests/common.c src/dblib/unittests/t0013.c: * src/dblib/unittests/t0014.c: - improve dbmoretext tests Thu Dec 30 15:53:06 CET 2010 Frediano Ziglio * include/sybdb.h src/dblib/unittests/t0007.c: - correct t0007 test (still broken), fix DBVARYCHAR declaration Thu Dec 30 14:06:25 CET 2010 Frediano Ziglio * src/odbc/unittests/typeinfo.c: - check WVARCHAR result and no pending data Thu Dec 30 13:41:44 CET 2010 Frediano Ziglio * src/odbc/unittests/data.c: test Sybase DATE and TIME Thu Dec 30 13:04:41 CET 2010 Frediano Ziglio * src/tds/unittests/Makefile.am src/tds/unittests/common.h: * src/tds/unittests/utf8_1.c src/tds/unittests/utf8_3.c: * src/tds/unittests/utf8.c(added): - move to_utf8 function to new utf8.c file Tue Dec 28 15:36:41 CET 2010 Frediano Ziglio * configure.ac include/tds_sysdep_private.h: * m4/sprintf_i64_format.m4 src/odbc/odbc.c src/tds/convert.c: * src/tds/numeric.c src/tds/token.c: - use C99 constant for printf format string Thu Dec 23 10:32:02 CET 2010 Frediano Ziglio * src/dblib/buffering.h src/dblib/dblib.c: dblib indicator is DBINT Tue Dec 21 11:53:40 EST 2010 JK Lowden * src/apps/bsqldb.c src/apps/tsql.c src/dblib/dblib.c - allow Kerberos/sspi connections without username Thu Dec 16 20:24:00 CST 2010 Craig A. Berry * vms/getpass.c Base VMS getpass/readline on stdin, not SYS$COMMAND. Thu Dec 16 20:18:00 CST 2010 Craig A. Berry * src/apps/freebcp.c Fix typo in -i option. Fri Dec 10 15:42:12 EST 2010 JK Lowden * include/sqlfront.h include/sybdb.h Better Win32 compatibility * src/apps/tsql.c report Kerberos compiled-in status Mon Dec 6 16:23:53 CET 2010 Frediano Ziglio * src/odbc/unittests/data.c src/tds/token.c: - fix protocol problem with TDS7.2 and XML with schema Fri Dec 3 17:01:00 CET 2010 Frediano Ziglio * m4/sprintf_i64_format.m4: - fix problem for cross compiled Darwin system Fri Dec 3 16:01:20 CET 2010 Frediano Ziglio * src/tds/token.c: small comment updates Tue Nov 30 11:55:20 CET 2010 Frediano Ziglio * src/tds/login.c: - fix problem with ct_connect if server not set (reported by Peter C. Norton) Sun Nov 28 15:15:25 CET 2010 Frediano Ziglio * src/tds/ptw32_MCS_lock.c: remove a warning Fri Nov 26 20:46:45 CET 2010 Frediano Ziglio * include/tds.h src/tds/encodings.pl src/tds/iconv.c: - use numeric constant for canonic charsets Fri Nov 26 20:17:27 CET 2010 Frediano Ziglio * src/tds/challenge.c: improve random in challenge code Fri Nov 26 20:05:17 CET 2010 Frediano Ziglio * src/odbc/error.c src/odbc/odbc.c src/odbc/sqlwparams.h: - add PCHARIN/PCHAROUT macros to declare char parameters Fri Nov 26 09:40:25 CET 2010 Frediano Ziglio * include/tds.h src/server/server.c src/tds/bulk.c src/tds/data.c: * src/tds/login.c src/tds/query.c src/tds/token.c: - add and use IS_TDS72_PLUS Thu Nov 25 20:31:38 CET 2010 Frediano Ziglio * src/odbc/odbc.c: - remove additional space from statistic procedure names Sun Nov 21 22:24:02 CET 2010 Frediano Ziglio * src/tds/iconv.c: - fix encoding problem with SQL_AltDiction2_CP1253_CS_AS Fri Nov 19 18:30:55 CET 2010 Frediano Ziglio * src/apps/fisql/fisql.c: spaces -> tabs Thu Nov 18 22:19:03 EST 2010 JK Lowden * doc/fisql.txt src/apps/fisql/fisql.c - applied patch for -D database cf. ML Merle Reinhart 12 Nov 2010 Tue Nov 16 14:25:04 CET 2010 Frediano Ziglio * configure.ac src/tds/challenge.c: fix NTLMv2 on 64-bit machine Tue Nov 16 11:29:37 CET 2010 Frediano Ziglio * src/tds/threadsafe.c: - fix possible core (patch from Peter C. Norton) Tue Nov 9 16:46:15 CET 2010 Frediano Ziglio * include/tds.h include/tdsodbc.h src/odbc/connectparams.c: * src/tds/challenge.c src/tds/config.c: - add "use ntlmv2" option Tue Nov 9 16:41:37 CET 2010 Frediano Ziglio * src/tds/sspi.c: fix possible problem with sspi.h header Tue Nov 9 13:48:22 CET 2010 Frediano Ziglio * src/tds/challenge.c: - send OSversion in NTLM type 1, fix flags using NTLMv2 Tue Nov 9 13:34:50 CET 2010 Frediano Ziglio * src/tds/challenge.c: disable LANMAN authentication (too unsecure) Thu Nov 4 20:38:16 CET 2010 Frediano Ziglio * configure.ac: allow to specify library options with --enable-krb5 Fri Oct 29 16:52:15 CEST 2010 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am: - src/odbc/unittests/peter.c - Sybase does not need to prepare again changing parameters Fri Oct 29 10:49:12 CEST 2010 Frediano Ziglio * misc/types.txt src/odbc/unittests/genparams.c src/tds/data.c: * src/tds/types.pl: - fix SYB5INT8 type Tue Oct 26 10:12:21 CEST 2010 Frediano Ziglio * configure.ac misc/prepare_win32.sh src/ctlib/unittests/cancel.c: * src/dblib/unittests/null.c src/dblib/unittests/null2.c: - some fixes for win64 and MingW Fri Oct 22 22:14:48 CEST 2010 Frediano Ziglio * win32/config.h: add missing define for msvc6 Wed Oct 13 13:47:03 EDT 2010 JK Lowden * Nmakefile - remove FROM_TARBALL, test for CVS instead, and check if - compiler is in the PATH Tue Oct 12 11:29:23 EDT 2010 JK Lowden * Nmakefile src/replacements/Makefile.am - works with tarball if FROM_TARBALL defined Tue Oct 12 13:48:14 CEST 2010 Frediano Ziglio * src/tds/net.c: change OpenSSL ciphers Mon Oct 11 14:57:13 CEST 2010 Frediano Ziglio * src/tds/net.c: fix for OpenSSL Wed Oct 6 10:02:53 CEST 2010 Frediano Ziglio * src/tds/net.c: fix typo Tue Oct 5 10:36:23 CEST 2010 Frediano Ziglio * include/ctlib.h src/ctlib/cs.c src/ctlib/ct.c: * src/ctlib/unittests/t0006.c: - fix CS_VARCHAR_TYPE/CS_VARBINARY_TYPE on ctlib Sat Oct 2 09:07:11 CEST 2010 Frediano Ziglio * src/tds/login.c: - avoid udp 1434 probe if port specified (patch from SF case #3024141) Fri Oct 1 10:28:46 CEST 2010 Frediano Ziglio * src/ctlib/ct.c: cleanup Tue Sep 28 17:09:28 CEST 2010 Frediano Ziglio * src/tds/challenge.c: removed a warning compiling for big endian Tue Sep 28 11:55:05 CEST 2010 Frediano Ziglio * src/tds/token.c: remove warning Tue Sep 28 11:00:33 CEST 2010 Frediano Ziglio * win32/FreeTDS_w.def: add missing exports Tue Sep 28 10:19:51 CEST 2010 Frediano Ziglio * src/tds/mem.c: fix memory leak Tue Sep 28 10:13:57 CEST 2010 Frediano Ziglio * src/tds/token.c: fix problem for UNI(VAR)CHAR encoding Mon Sep 27 17:53:10 EDT 2010 JK Lowden * Nmakefile src/tds/config.c src/tds/mem.c - fix Win32 problems Mon Sep 27 09:25:08 CEST 2010 Frediano Ziglio * src/replacements/iconv.c: add utf16 support to iconv replacement Wed Sep 22 09:03:37 CEST 2010 Frediano Ziglio * src/ctlib/unittests/cancel.c src/dblib/unittests/done_handling.c: * src/odbc/unittests/array_out.c: - fix some portability issues with Solaris/SPARC (thanks to Peter C. Norton) Thu Sep 16 16:32:02 EDT 2010 JK Lowden * doc/bsqldb.txt src/apps/bsqldb.c - add -H hostname to override hostname sent to server Thu Sep 16 14:30:15 CEST 2010 Frediano Ziglio * src/dblib/dblib.c: - update inline documentation for dbiscount (patch from LacaK) Thu Sep 16 13:11:46 CEST 2010 Frediano Ziglio * include/tdsthread.h: init mutex fixes Thu Sep 16 13:09:29 CEST 2010 Frediano Ziglio * win32/Makefile.am win32/dblib.def win32/msvc6/FreeTDS.dsw: * win32/msvc6/Makefile.am win32/msvc6/dblib_dll.dsp: - add project and definition file for dblib dll (patch from LacaK) Thu Sep 16 09:44:12 CEST 2010 Frediano Ziglio * doc/userguide.sgml: - add documentation for "enable gssapi delegation" option Thu Sep 16 09:36:57 CEST 2010 Frediano Ziglio * include/tds.h src/tds/config.c src/tds/gssapi.c: - add delegate option for Kerberos (patch from Peter C. Norton) Wed Sep 15 11:27:16 CEST 2010 Frediano Ziglio * TODO: small note Tue Sep 14 23:49:49 EDT 2010 JK Lowden * src/dblib/dblib.c * src/dblib/unittests/t0007.c src/dblib/unittests/t0007.sql - add VARYBINBIND and BINARYBIND testing (seem broken) Tue Sep 14 10:39:31 EDT 2010 JK Lowden * doc/api_status.txt marked dbiscount OK Mon Sep 13 22:09:46 EDT 2010 JK Lowden * configure.ac use printf, not echo -n * include/sybdb.h src/dblib/dblib.c mark dbpoll as unimplemented Mon Sep 13 20:53:12 EDT 2010 JK Lowden * src/dblib/dblib.c fix error-handler recursion * src/apps/tsql.c format errors better Mon Sep 13 18:32:55 CEST 2010 Frediano Ziglio * include/sybdb.h src/dblib/dblib.c: - patch from LacaK 1. in dbsetlversion() fixes DBVER60 case and adds support for DBVERSION_71 and DBVERSION_72 2. adds dbiscount() which is Microsoft specific DB-Library function 3. in dbcolinfo() adds support Updatabe and Identity fields in DBCOL structure Thu Sep 2 12:35:00 CDT 2010 Craig A. Berry * Find the system poll and poll.h on VMS. * vms/config_h.vms Wed Sep 1 10:39:43 CEST 2010 Frediano Ziglio * include/tds_sysdep_public.h.in src/odbc/unittests/common.h: * src/odbc/unittests/freeclose.c win32/winlogin.c win32/winsetup.c: - Remove warnings for MingW64 Wed Aug 18 13:37:35 CEST 2010 Frediano Ziglio * misc/prepare_win32.sh: search correct host Wed Aug 18 13:27:30 CEST 2010 Frediano Ziglio * include/replacements.h: add missing declaration Tue Aug 17 15:15:57 CEST 2010 Frediano Ziglio * include/tdsodbc.h win32/FreeTDS_w.def win32/Makefile.am: * win32/msvc6/FreeTDS.dsp win32/msvc6/libTDS.dsp: - fix compile problem with msvc6 Tue Aug 10 09:40:00 CEST 2010 Frediano Ziglio * configure.ac m4/acx_pthread.m4: fix compile with HP-UX compiler Thu Aug 5 11:24:51 CEST 2010 Frediano Ziglio * src/tds/net.c: use fakepoll Thu Aug 5 10:58:27 CEST 2010 Frediano Ziglio * include/replacements.h src/replacements/fakepoll.c: fix fakepoll Wed Aug 4 13:01:18 CEST 2010 Frediano Ziglio * src/odbc/odbc.c src/odbc/odbc_util.c: simplify odbc_populate_ird Wed Aug 4 10:04:33 CEST 2010 Frediano Ziglio * src/odbc/odbc_util.c src/odbc/unittests/describecol.in: - fix macro for odbc_set_sql_type_info Wed Aug 4 09:08:51 CEST 2010 Frediano Ziglio * src/ctlib/cs.c src/ctlib/ctutil.c: - remove assumption CS_FAIL == TDS_FAIL and CS_SUCCEED == TDS_SUCCEED Wed Aug 4 08:55:25 CEST 2010 Frediano Ziglio * src/odbc/odbc.c src/odbc/odbc_util.c: * src/odbc/unittests/describecol.c: * src/odbc/unittests/describecol.in: - fix problem for pyodbc and money Sat Jul 31 13:31:08 CEST 2010 Frediano Ziglio * src/dblib/bcp.c: fix bcp_bind with vartype == 0 Sat Jul 31 13:20:26 CEST 2010 Frediano Ziglio * include/tdsthread.h: allow mutex declaration inside structures Sat Jul 31 10:05:48 CEST 2010 Frediano Ziglio * src/ctlib/unittests/Makefile.am src/dblib/unittests/Makefile.am: * src/tds/unittests/Makefile.am: - fix link for iconv in unittests Fri Jul 30 11:08:37 CEST 2010 Frediano Ziglio * configure.ac include/tdsodbc.h src/odbc/Makefile.am: * src/odbc/odbc.c src/odbc/sqlwparams.h win32/FreeTDS.def: * win32/Makefile.am: - find a better way to export automatically without DEF changes Fri Jul 30 09:33:51 CEST 2010 Frediano Ziglio * src/tds/read.c: simplify tds_get_byte Fri Jul 30 09:29:34 CEST 2010 Frediano Ziglio * include/tds.h src/tds/login.c src/tds/net.c: - remove oserr from tds_socket Fri Jul 30 09:17:15 CEST 2010 Frediano Ziglio * configure.ac src/odbc/Makefile.am win32/FreeTDS.def: - win32/FreeTDSW.def * win32/Makefile.am: fix MingW compile if wide odbc disabled Tue Jul 27 10:52:58 CEST 2010 Frediano Ziglio * include/tds.h src/dblib/dblib.c src/tds/login.c src/tds/mem.c: - moved option_flag2 from tds_socket to tds_connection Tue Jul 27 09:18:53 CEST 2010 Frediano Ziglio * misc/sybase_tests: fix dblib build with Sybase libraries Sun Jul 25 12:46:17 CEST 2010 Frediano Ziglio * misc/test-other.sh: update year Sun Jul 25 12:02:49 CEST 2010 Frediano Ziglio * phptests/types.php: add php test Sun Jul 25 10:40:08 CEST 2010 Frediano Ziglio * include/tds.h include/tds_sysdep_private.h include/tdsiconv.h: * src/tds/mem.c src/tds/net.c src/tds/token.c src/tds/util.c: - normalize some names Sun Jul 25 09:48:50 CEST 2010 Frediano Ziglio * include/tds.h src/ctlib/ct.c src/tds/mem.c: - cleanup unused declarations Sat Jul 24 14:40:44 CEST 2010 Frediano Ziglio * src/tds/iconv.c: avoid overflow skipping wrong characters Sat Jul 24 10:25:53 CEST 2010 Frediano Ziglio * src/odbc/odbc_util.c: remove warning Sat Jul 24 10:08:00 CEST 2010 Frediano Ziglio * src/dblib/unittests/common.c src/dblib/unittests/rpc.sql: - fix rpc test for Sybase Fri Jul 23 15:07:21 CEST 2010 Frediano Ziglio * TODO TODO.freddy: updated Fri Jul 23 09:42:11 CEST 2010 Frediano Ziglio * src/odbc/unittests/prepare_results.c: use ird to get column count Thu Jul 22 16:23:52 CEST 2010 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/cursor2.c: fix cursor2 issue Thu Jul 22 16:11:23 CEST 2010 Frediano Ziglio * src/odbc/odbc_util.c: - fix truncation problem setting an ascii string attribute (like catalog) Thu Jul 22 11:55:12 CEST 2010 Frediano Ziglio * src/apps/bsqldb.c src/apps/bsqlodbc.c src/apps/datacopy.c: * src/apps/defncopy.c src/apps/fisql/fisql.c src/apps/freebcp.c: - make applications compile including missing header Wed Jul 21 22:12:05 CEST 2010 Frediano Ziglio * src/apps/bsqldb.c src/apps/bsqlodbc.c src/apps/datacopy.c: * src/apps/defncopy.c src/apps/fisql/fisql.c src/apps/freebcp.c: * src/apps/tsql.c src/tds/locale.c src/tds/mem.c: - move setlocale call to applications to avoid global side effects Wed Jul 21 07:56:18 CEST 2010 Frediano Ziglio * src/odbc/convert_tds2sql.c src/tds/mem.c: - avoid core if locale not detected Tue Jul 20 09:56:36 CEST 2010 Frediano Ziglio * src/odbc/error.c: fix compile using no-gnu compiler Mon Jul 19 13:51:50 CEST 2010 Frediano Ziglio * src/odbc/unittests/Makefile.am src/odbc/unittests/connect.c: - fix connect test for windows Mon Jul 19 12:05:46 CEST 2010 Frediano Ziglio * src/ctlib/blk.c: - applied patch from Shatam Bhattacharya for blk_rowxfer Sun Jul 18 09:26:18 CEST 2010 Frediano Ziglio * src/odbc/odbc_util.c: add some checks Sun Jul 18 08:45:14 CEST 2010 Frediano Ziglio * src/odbc/odbc.c: update driver version Sun Jul 18 08:44:51 CEST 2010 Frediano Ziglio * src/odbc/odbc_util.c: - wrong logic converting octect <-> character count Sat Jul 17 22:05:47 CEST 2010 Frediano Ziglio * include/tdsbytes.h src/tds/challenge.c: small optimization Sat Jul 17 21:58:08 CEST 2010 Frediano Ziglio * include/tdsodbc.h src/odbc/error.c src/odbc/odbc.c: * src/odbc/odbc_util.c: - fix nasty problem with wide encoding (octect/character counts) Sat Jul 17 20:05:19 CEST 2010 Frediano Ziglio * src/odbc/error.c: small optimization Sat Jul 17 19:45:43 CEST 2010 Frediano Ziglio * win32/FreeTDS.def: adding missing wide exports Sat Jul 17 16:49:46 CEST 2010 Frediano Ziglio * src/odbc/odbc.c: do not core if no connection, typos Sat Jul 17 16:42:27 CEST 2010 Frediano Ziglio * src/odbc/odbc.c: add some missing functions for wide support Sat Jul 17 16:25:40 CEST 2010 Frediano Ziglio * win32/config.h: added missing declaration Fri Jul 9 17:17:56 CEST 2010 Frediano Ziglio * win32/config.h win32/msvc6/FreeTDS.dsp win32/msvc6/libTDS.dsp: - update Windows project files Thu Jul 8 11:39:24 CEST 2010 Frediano Ziglio * src/odbc/connectparams.c: - support comma syntax with SERVER parameter Wed Jul 7 16:56:08 CEST 2010 Frediano Ziglio * misc/freetds_autobuild: update automatic test Wed Jul 7 15:56:44 CEST 2010 Frediano Ziglio * misc/sybase_tests src/ctlib/unittests/datafmt.c: - update script to build tests even for ctlib Wed Jul 7 15:39:20 CEST 2010 Frediano Ziglio * misc/check_symbols.txt: add missing symbols Tue Jul 6 11:23:28 CEST 2010 Frediano Ziglio * src/odbc/checkexport.sh vms/odbc_driver_axp.opt: * win32/FreeTDS.def: - update export symbols Mon Jul 5 22:49:34 CEST 2010 Frediano Ziglio * src/odbc/odbc_util.c: improve conversion if wide enabled Mon Jul 5 16:22:33 CEST 2010 Frediano Ziglio * src/odbc/odbc.c: fix for SQLTables and sybase Mon Jul 5 16:22:06 CEST 2010 Frediano Ziglio * src/odbc/unittests/blob1.c: support SQL_NO_TOTAL from SQLGetData Mon Jul 5 11:19:56 CEST 2010 Frediano Ziglio * src/odbc/unittests/array.c src/odbc/unittests/array_out.c: * src/odbc/unittests/attributes.c src/odbc/unittests/base.c: * src/odbc/unittests/binary_test.c src/odbc/unittests/blob1.c: * src/odbc/unittests/cancel.c src/odbc/unittests/common.c: * src/odbc/unittests/common.h src/odbc/unittests/compute.c: * src/odbc/unittests/connect.c src/odbc/unittests/connect2.c: * src/odbc/unittests/const_params.c: * src/odbc/unittests/convert_error.c src/odbc/unittests/copydesc.c: * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor2.c: * src/odbc/unittests/cursor3.c src/odbc/unittests/cursor4.c: * src/odbc/unittests/cursor5.c src/odbc/unittests/cursor6.c: * src/odbc/unittests/cursor7.c src/odbc/unittests/data.c: * src/odbc/unittests/date.c src/odbc/unittests/descrec.c: * src/odbc/unittests/describecol.c src/odbc/unittests/earlybind.c: * src/odbc/unittests/error.c src/odbc/unittests/freeclose.c: * src/odbc/unittests/funccall.c src/odbc/unittests/genparams.c: * src/odbc/unittests/getdata.c src/odbc/unittests/hidden.c: * src/odbc/unittests/insert_speed.c: * src/odbc/unittests/lang_error.c: * src/odbc/unittests/moreandcount.c src/odbc/unittests/norowset.c: * src/odbc/unittests/paramcore.c src/odbc/unittests/params.c: * src/odbc/unittests/prepare_results.c: * src/odbc/unittests/prepclose.c src/odbc/unittests/preperror.c: * src/odbc/unittests/print.c src/odbc/unittests/putdata.c: * src/odbc/unittests/raiserror.c src/odbc/unittests/rebindpar.c: * src/odbc/unittests/rownumber.c src/odbc/unittests/rowset.c: * src/odbc/unittests/rpc.c src/odbc/unittests/scroll.c: * src/odbc/unittests/stats.c src/odbc/unittests/t0001.c: * src/odbc/unittests/t0002.c src/odbc/unittests/t0003.c: * src/odbc/unittests/t0004.c src/odbc/unittests/tables.c: * src/odbc/unittests/test64.c src/odbc/unittests/testodbc.c: * src/odbc/unittests/timeout.c src/odbc/unittests/timeout2.c: * src/odbc/unittests/timeout3.c src/odbc/unittests/timeout4.c: * src/odbc/unittests/transaction.c: * src/odbc/unittests/transaction2.c src/odbc/unittests/type.c: * src/odbc/unittests/typeinfo.c src/odbc/unittests/utf8.c: * src/odbc/unittests/utf8_2.c src/odbc/unittests/warning.c: * src/odbc/unittests/wchar.c: - normalize unittest function names Mon Jul 5 09:20:20 CEST 2010 Frediano Ziglio * src/odbc/unittests/blob1.c src/odbc/unittests/common.c: * src/odbc/unittests/common.h: - move to/from sqlwchar to common code Mon Jul 5 08:58:59 CEST 2010 Frediano Ziglio * src/odbc/odbc.c: fix possible problem using utf8 on Sybase Sat Jul 3 11:49:05 CEST 2010 Frediano Ziglio * configure.ac src/odbc/odbc.c: minor issues Sat Jul 3 11:14:29 CEST 2010 Frediano Ziglio * configure.ac include/tdsodbc.h src/odbc/convert_tds2sql.c: * src/odbc/odbc.c src/odbc/odbc_util.c src/odbc/sql2tds.c: * src/odbc/sqlwparams.h: - add ODBC wide support (disabled by default and still experimental) Sat Jul 3 10:53:03 CEST 2010 Frediano Ziglio * src/replacements/iconv.c: fix return codes from replacement iconv Sat Jul 3 08:57:50 CEST 2010 Frediano Ziglio * configure.ac src/replacements/iconv.c: - rewrote iconv replacement adding support for ucs4 Sat Jul 3 08:56:51 CEST 2010 Frediano Ziglio * src/odbc/error.c src/odbc/odbc.c src/odbc/sqlwparams.h: - other wide encoding merges Sat Jul 3 01:55:38 CEST 2010 Frediano Ziglio * include/tdsiconv.h src/replacements/iconv.c: - cleanup iconv replacement Fri Jul 2 20:57:16 CEST 2010 Frediano Ziglio * include/tds.h src/tds/token.c src/tds/util.c: cleanup Fri Jul 2 16:07:45 CEST 2010 Frediano Ziglio * src/odbc/Makefile.am src/odbc/error.c src/odbc/odbc.c: - src/odbc/sqlwparams.h - use macros to prepare code for wide encoding Fri Jul 2 15:38:06 CEST 2010 Frediano Ziglio * include/tdsodbc.h src/odbc/error.c src/odbc/odbc.c: * src/odbc/odbc_util.c: - put odbc_set_string_i and odbc_set_string together, prepare for wide encoding Fri Jul 2 11:30:40 CEST 2010 Frediano Ziglio * include/tdsodbc.h src/odbc/descriptor.c src/odbc/error.c: - add desc_get_dbc and reuse it Fri Jul 2 11:01:08 CEST 2010 Frediano Ziglio * src/odbc/unittests/stats.c: - correct wrong assumption about statistics functions Tue Jun 29 14:07:32 CEST 2010 Frediano Ziglio * src/tds/mem.c: do not use strtok which is not reentrant Tue Jun 29 14:00:51 CEST 2010 Frediano Ziglio * src/tds/mem.c: use ISO-8859-1 if ASCII is detected Mon Jun 28 22:24:37 CEST 2010 Frediano Ziglio * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: - add odbc_dstr_copy and reuse it Mon Jun 28 21:51:02 CEST 2010 Frediano Ziglio * src/odbc/odbc.c: fix small and quite impossible leak Sun Jun 27 18:51:00 CDT 2010 Craig A. Berry * src/apps/bsqldb.c src/apps/bsqlodbc.c src/apps/defncopy.c * src/apps/fisql/fisql.c src/apps/freebcp.c src/apps/tsql.c - Zero local password memory after setting internal structures. - idea from Christos Zoulas Sun Jun 27 12:40:00 CDT 2010 Craig A. Berry * include/tds.h src/apps/tsql.c src/tds/iconv.c src/tds/locale.c * src/tds/mem.c: - consolidated locale/client charset update Sun Jun 27 07:58:00 CEST 2010 Frediano Ziglio * Makefile.am configure.ac: - honour vms/Makefile.am removing duplications Sat Jun 26 19:50:00 CDT 2010 Craig A. Berry * Makefile.am, src/apps/defncopy.c, src/apps/fisql/fisql.c, * src/apps/freebcp.c, vms/Makefile.am, vms/config_h.vms, * vms/descrip_mms.template, vms/vargdefs.h, vms/vmsarg_command_bcp.cld, * vms/vmsarg_command_defncopy.cld, vms/vmsarg_command_isql.cld, * vms/vmsarg_mapping_bcp.c, ms/vmsarg_mapping_defncopy.c, * vms/vmsarg_mapping_isql.c, vms/vmsarg_parse.c - VMS-style native command syntax for fisql, freebcp, and defncopy Sat Jun 26 11:14:37 CEST 2010 Frediano Ziglio * src/tds/token.c: fix a leak if cursor returns multiple resultsets Sat Jun 26 10:03:51 CEST 2010 Frediano Ziglio * src/odbc/unittests/cursor2.c: remove warning Sat Jun 26 09:23:34 CEST 2010 Frediano Ziglio * src/odbc/unittests/cursor2.c: add test for cursors on rpc Sat Jun 26 09:19:45 CEST 2010 Frediano Ziglio * src/odbc/unittests/cursor2.c: reuse CheckCursor Sun Jun 20 14:19:31 CEST 2010 Frediano Ziglio * misc/test-dist.sh: fix test script due to 2 distribution files Sun Jun 20 10:38:35 CEST 2010 Frediano Ziglio * INSTALL.CVS: add Perl to tools required for CVS build Sat Jun 19 11:51:23 CEST 2010 Frediano Ziglio * include/tds.h src/odbc/odbc.c src/tds/query.c src/tds/token.c: - enable defer by default, tests work correctly, use prepexec for performance Sat Jun 19 09:53:14 CEST 2010 Frediano Ziglio * src/pool/member.c src/tds/unittests/common.c: fix possible core Sat Jun 19 09:47:38 CEST 2010 Frediano Ziglio * README.Windows: add initial README file for windows Fri Jun 18 21:48:50 CEST 2010 Frediano Ziglio * src/odbc/odbc.c: defer prepare Fri Jun 18 21:33:02 CEST 2010 Frediano Ziglio * src/odbc/odbc.c src/odbc/odbc_util.c: - Move prepare code to odbc_prepare Fri May 21 17:18:05 CEST 2010 Frediano Ziglio * src/apps/bsqldb.c src/apps/fisql/fisql.c src/dblib/dblib.c: - handle column size for SYBDATETIMN data type (Craig A. Berry) Fri May 21 16:10:04 CEST 2010 Frediano Ziglio * src/apps/freebcp.c src/apps/freebcp.h: - add -i and -o options to freebcp (patch from Craig A. Berry) Fri May 21 16:01:47 CEST 2010 Frediano Ziglio * vms/Makefile.am vms/descrip_mms.template vms/edit.c: * vms/getpass.c: - update VMS build files (patch from Craig A. Berry). Fri May 21 15:53:53 CEST 2010 Frediano Ziglio * src/apps/freebcp.c: - freebcp's direction doesn't need to be case sensitive (from Craig A. Berry). Fri May 14 00:06:28 CEST 2010 Frediano Ziglio * configure.ac win32/Makefile.am win32/freetds.nsi: - remove Dev-C++ project files (obsolete) Wed May 12 13:18:25 CEST 2010 Frediano Ziglio * src/replacements/fakepoll.c: small compile fix for Visual Studio Wed May 12 10:15:04 CEST 2010 Frediano Ziglio * include/fakepoll.h src/replacements/fakepoll.c: - fix and improve fakepoll for Windows Wed May 12 10:13:17 CEST 2010 Frediano Ziglio * include/tds_sysdep_private.h: fix minor issue with MingW Wed May 12 09:59:17 CEST 2010 Frediano Ziglio * src/tds/net.c: workaround for header incompatibility Mon May 10 17:10:10 CEST 2010 Frediano Ziglio * include/tds_sysdep_private.h src/dblib/dbopen.c: - improve Visual Studio compile Fri May 7 17:09:50 EDT 2010 JK Lowden * src/tds/token.c Applied today's ML patch from Craig A. Berry Fri May 7 13:55:20 EDT 2010 JK Lowden * configure.ac produce gzip tarball, too. Thu May 6 21:08:58 EDT 2010 JK Lowden * src/dblib/unittests/rpc.c src/dblib/unittests/rpc.sql - tidied up and added explicit test for null varchar input Sun May 2 13:52:05 CEST 2010 Frediano Ziglio * src/tds/mem.c: - fix unmatched parenthesis (patch from Mark Brand) and minor memory leaks Fri Apr 30 17:57:22 EDT 2010 JK Lowden * src/tds/mem.c initilize client charset per setlocale(3) and friends Mon Apr 26 11:09:11 CEST 2010 Frediano Ziglio * src/ctlib/ct.c src/ctlib/unittests/t0007.c: - fix maxlength returned by ct_describe for numeric types Tue Apr 13 15:23:12 CEST 2010 Frediano Ziglio * src/ctlib/ct.c: - improve datafmt->status computation (patch from David Dick) Tue Apr 13 15:18:41 CEST 2010 Frediano Ziglio * src/ctlib/cs.c src/ctlib/unittests/common.c: * src/ctlib/unittests/t0006.c: - improve CTLib cs_convert (partial patch from David Dick with additional tests) Sat Apr 10 16:29:29 CEST 2010 Frediano Ziglio * include/tds.h src/tds/log.c: - add TDS_LIKELY/TDS_UNLIKELY macro and use them for logging Sat Apr 10 16:21:49 CEST 2010 Frediano Ziglio * include/tds.h src/tds/log.c: - make execution faster if log disabled (patch from Steve Brown) Thu Apr 8 11:02:24 CEST 2010 Frediano Ziglio * src/apps/bsqldb.c: remove some conversion warnings Thu Apr 8 10:23:34 CEST 2010 Frediano Ziglio * src/dblib/unittests/t0004.c: remove undeclared warning Thu Apr 8 10:17:24 CEST 2010 Frediano Ziglio * include/tds.h src/apps/tsql.c src/tds/token.c: - fix tsql and variant type Thu Apr 8 09:36:21 CEST 2010 Frediano Ziglio * src/tds/token.c: Avoid hang on variant type if conversion enabled Mon Apr 5 14:45:37 EDT 2010 JK Lowden * include/tds.h src/tds/token.c log table metadata succintly * src/dblib/unittests/t0004.c test dbgetchar() Mon Apr 5 14:44:11 EDT 2010 JK Lowden * src/apps/bsqldb.c Support TEXT datatype with any field terminator Sat Apr 3 06:57:18 EDT 2010 JK Lowden * src/apps/bsqldb.c Support TEXT datatype Mon Mar 22 15:41:47 CET 2010 Frediano Ziglio * src/odbc/odbc.c: fix descrec test Wed Mar 3 09:08:14 CET 2010 Frediano Ziglio * src/tds/write.c: compute length supporting all character sets Tue Mar 2 16:40:46 CET 2010 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am src/odbc/unittests/common.h: * src/odbc/unittests/descrec.c: - add a test for SQLGetDescRec/SQLSetDescRec and fix a small issue in SQLGetDescRec Tue Mar 2 16:06:34 CET 2010 Frediano Ziglio * src/odbc/unittests/common.c src/odbc/unittests/common.h: * src/odbc/unittests/error.c src/odbc/unittests/getdata.c: * src/odbc/unittests/paramcore.c src/odbc/unittests/print.c: * src/odbc/unittests/rowset.c src/odbc/unittests/transaction2.c: - add ReadError and reuse it Tue Mar 2 09:32:02 CET 2010 Frediano Ziglio * src/tds/util.c: - remove last exit calls (original patch from David Dick) Mon Mar 1 15:52:14 CET 2010 Frediano Ziglio * src/odbc/unittests/freeclose.c: fix FreeTDS detection Mon Mar 1 15:50:06 CET 2010 Frediano Ziglio * src/odbc/unittests/prepclose.c src/odbc/unittests/timeout3.c: * src/odbc/unittests/timeout4.c: - update for future implementations Mon Mar 1 15:32:43 CET 2010 Frediano Ziglio * src/odbc/unittests/freeclose.c: ported freeclose test to Windows Mon Mar 1 13:37:28 CET 2010 Frediano Ziglio * src/tds/login.c src/tds/net.c src/tds/token.c: - remove some exit calls (original patch from David Dick) Fri Feb 12 11:15:46 CET 2010 Frediano Ziglio * include/tdsthread.h src/dblib/bcp.c src/tds/sspi.c: * src/tds/win_mutex.c: - remove some warnings compiling for windows Fri Feb 12 10:04:15 CET 2010 Frediano Ziglio * src/odbc/unittests/describecol.c: - additional check for SQLDescribeCol length Fri Feb 12 09:56:42 CET 2010 Frediano Ziglio * src/odbc/unittests/describecol.in: - restrict some describecol checks to mssql only Tue Feb 9 09:39:15 CET 2010 Frediano Ziglio * include/tds_sysdep_private.h: - add _snprintf define for windows (patch from David Dick) Mon Feb 8 17:09:49 CET 2010 Frediano Ziglio * win32/msvc6/FreeTDS.dsw win32/msvc6/Makefile.am: * win32/msvc6/libct.dsp: - added Visual C++ project for CTLib (patch from David Dick) Mon Feb 8 13:15:46 CET 2010 Frediano Ziglio * src/tds/iconv.c: remove wrong assert Mon Feb 8 10:46:55 CET 2010 Frediano Ziglio * src/tds/config.c: fix some memory problems Sun Feb 7 16:50:58 EST 2010 JK Lowden * doc/userguide.sgml preparing for release * src/apps/bsqlodbc.c use hdesc to detmine octet count * include/sybdb.h src/dblib/dblib.c src/tds/config.c * src/tds/iconv.c src/tds/login.c src/tds/util.c - Default bad client charset name to ISO 8859-1, - and avoid TDSEPORTINSTANCE when one of port/instance - came from the [default] section. Sun Feb 7 01:33:47 CET 2010 Frediano Ziglio * src/replacements/getopt.c: reverted getopt LGPL patch Fri Feb 5 17:06:14 EST 2010 JK Lowden * src/apps/bsqlodbc.c use SQLGetDescField for nchar buffer size. Tue Feb 2 10:47:26 CET 2010 Frediano Ziglio * src/replacements/getopt.c: replaced getopt with LGPL version Tue Feb 2 10:35:20 CET 2010 Frediano Ziglio * doc/userguide.sgml: add some ODBC considerations Mon Feb 1 15:55:30 CET 2010 Frediano Ziglio * src/dblib/unittests/null2.c: make null2 test work using TDS 4.2 Mon Feb 1 11:15:12 CET 2010 Frediano Ziglio * src/odbc/connectparams.c src/odbc/odbc.c: - update for trusted connections, support Trusted_Connection attribute in odbc.ini Mon Feb 1 11:09:51 CET 2010 Frediano Ziglio * configure.ac doc/userguide.sgml: update documentation Fri Jan 29 19:56:51 CET 2010 Frediano Ziglio * include/tds.h include/tdsodbc.h src/odbc/connectparams.c: * src/odbc/odbc.c src/tds/config.c win32/winsetup.c: - complete connection string if possible Fri Jan 29 15:08:07 CET 2010 Frediano Ziglio * win32/setup.rc: make popup window always visible Fri Jan 29 15:04:27 CET 2010 Frediano Ziglio * include/tds.h: peephole optimization Thu Jan 28 14:30:21 CET 2010 Frediano Ziglio * include/tdsthread.h src/tds/log.c: - improve (a lot!) log performance under windows using append mode Thu Jan 28 14:14:04 CET 2010 Frediano Ziglio * src/tds/net.c: does not overwrite error with other calls Thu Jan 28 11:06:05 CET 2010 Frediano Ziglio * src/tds/sspi.c: remove wrong TODO comment Thu Jan 28 09:53:35 CET 2010 Frediano Ziglio * src/odbc/connectparams.c: reuse string constants Thu Jan 28 00:31:25 EST 2010 JK Lowden * src/dblib/dblib.c more checks for NULL DBPROCESS/LOGINREC Thu Jan 28 00:15:31 CET 2010 Frediano Ziglio * src/dblib/bcp.c: remove small warning Wed Jan 27 16:37:25 CET 2010 Frediano Ziglio * src/dblib/dblib.c: fix format error which could cause core Wed Jan 27 16:34:28 CET 2010 Frediano Ziglio * src/tds/sspi.c: fix thread issue with SSPI Wed Jan 27 16:29:44 CET 2010 Frediano Ziglio * include/tdsthread.h src/tds/Makefile.am src/tds/ptw32_MCS_lock.c: * src/tds/win_mutex.c: - implement pthread compatible mutex for windows (partial code from pthread-win32, LGPL 2 too) Wed Jan 27 13:20:42 CET 2010 Frediano Ziglio * src/tds/sspi.c: - use Negotiate and provide SPN in order to enable Kerberos support using SSPI Wed Jan 27 13:14:46 CET 2010 Frediano Ziglio * include/tds.h src/odbc/connectparams.c src/tds/config.c: - set correctly server_host_name from odbc Wed Jan 27 09:29:57 CET 2010 Frediano Ziglio * src/odbc/odbc.c src/tds/sspi.c: - add support for user/password using SSPI Wed Jan 27 09:07:13 CET 2010 Frediano Ziglio * src/tds/sspi.c: remove useless "A" suffix Tue Jan 26 22:18:16 EST 2010 JK Lowden * src/apps/Makefile.am src/dblib/dblib.c * src/pool/Makefile.am src/server/Makefile.am - link libiconv cf ML 26 Jan 2010 Tue Jan 26 21:25:59 CET 2010 Frediano Ziglio * win32/winsetup.c: small comments Tue Jan 26 13:11:37 EST 2010 JK Lowden * Nmakefile src/tds/sspi.c win32/config.h - build with sspi on Win32, not really working yet Tue Jan 26 11:25:49 EST 2010 JK Lowden * Nmakefile generate header files for CVS checkout Tue Jan 26 14:41:18 CET 2010 Frediano Ziglio * win32/winsetup.c: avoid silly buffer overflow Tue Jan 26 12:20:56 CET 2010 Frediano Ziglio * configure.ac include/tds.h src/tds/Makefile.am src/tds/login.c: * src/tds/sspi.c: - add experimental support for SSPI (not enabled by default) Tue Jan 26 12:09:58 CET 2010 Frediano Ziglio * win32/FreeTDS.def win32/winsetup.c: - allow driver registration like ole controls Tue Jan 26 00:06:54 CET 2010 Frediano Ziglio * src/odbc/Makefile.am: fix windows build out of directory Tue Jan 26 00:05:46 CET 2010 Frediano Ziglio * include/ctlib.h include/dblib.h include/des.h include/hmac_md5.h: * include/md4.h include/md5.h include/replacements.h: * include/replacements/readpassphrase.h include/tds.h: * include/tdsconvert.h include/tdsiconv.h include/tdsodbc.h: * include/tdsstring.h src/tds/tds_checks.h: - fix visilibility warning using mingw Mon Jan 25 15:23:22 CET 2010 Frediano Ziglio * win32/version.rc.in: update copyright note Sat Jan 23 21:42:18 CET 2010 Frediano Ziglio * src/odbc/odbc_util.c: silly patch for Sybase bigint Sat Jan 23 21:25:35 CET 2010 Frediano Ziglio * src/odbc/odbc.c: - Removed 2009-12-22 patch "Better way to fix data_type for date" which does not work on Sybase Fri Jan 22 17:39:39 EST 2010 JK Lowden * src/dblib/bcp.c error message when hostfile wider than table. Fri Jan 22 13:40:35 CET 2010 Frediano Ziglio * configure.ac freetds.spec.in misc/prepare_win32.sh: * misc/test-dist.sh: - package bzip2 file instead of gz one Fri Jan 22 11:45:04 CET 2010 Frediano Ziglio * src/odbc/unittests/copydesc.c: check _SQLFreeDesc Fri Jan 22 11:43:29 CET 2010 Frediano Ziglio * include/tds.h src/tds/token.c: - do not define tds_swap_datatype if not needed Fri Jan 22 10:37:50 CET 2010 Frediano Ziglio * src/tds/Makefile.am: do not clean VC++ project files Thu Jan 21 14:39:15 CET 2010 Frediano Ziglio * src/tds/config.c: - Really override server settings using extended server syntax Thu Jan 21 09:33:32 CET 2010 Frediano Ziglio * Makefile.am src/dblib/Makefile.am src/replacements/Makefile.am: * src/tds/Makefile.am: - Distribute VC++ projects Thu Jan 21 09:24:26 CET 2010 Frediano Ziglio * src/dblib/db-lib.vcproj src/replacements/replacements.vcproj: * src/tds/TDS.vcproj: - Unify includes in VC++ projects, cleanup Tue Jan 12 10:38:18 EST 2010 JK Lowden * Makefile.am src/apps/tsql.c src/replacements/getopt.c * win32/config.h - Win32 support: Added getopt.c from NetBSD and made tsql - compile without warnings Tue Jan 12 11:20:04 CET 2010 Frediano Ziglio * src/replacements/strtok_r.c: Fix strtok_r function Mon Jan 11 19:14:03 CET 2010 Frediano Ziglio * include/tds.h src/tds/config.c src/tds/login.c src/tds/mem.c: * src/tds/util.c: - do not allow bot port and instance to be specified Mon Jan 11 13:03:29 EST 2010 JK Lowden * include/replacements.h more care with strcasecmp macro Mon Jan 11 19:00:10 CET 2010 Frediano Ziglio * src/tds/log.c: removed wrongly committed patch Mon Jan 11 18:56:17 CET 2010 Frediano Ziglio * src/tds/token.c: unneeded with newer types.h Mon Jan 11 18:52:52 CET 2010 Frediano Ziglio * misc/freetds_autobuild: added help Mon Jan 11 09:00:59 EST 2010 JK Lowden * include/replacements.h strcasecmp macro * src/apps/defncopy.c unrevert to 1.17 again * src/tds/log.c define pthread_self() as zero for win32 Mon Jan 11 08:39:49 EST 2010 JK Lowden * src/apps/defncopy.c revert to previous version Sun Jan 10 15:42:50 CET 2010 Frediano Ziglio * include/fakepoll.h include/replacements.h include/tdsodbc.h: * src/apps/bsqldb.c src/apps/defncopy.c src/dblib/bcp.c: * src/dblib/dblib.c src/dblib/unittests/common.c: * src/odbc/connectparams.c src/odbc/odbc.c: * src/odbc/unittests/common.c src/odbc/unittests/common.h: * src/odbc/unittests/tables.c src/odbc/unittests/timeout2.c: * src/replacements/basename.c src/replacements/fakepoll.c: * src/replacements/gettimeofday.c: * src/replacements/readpassphrase.c src/replacements/vasprintf.c: * src/tds/config.c src/tds/convert.c src/tds/log.c src/tds/login.c: * src/tds/net.c src/tds/threadsafe.c src/tds/util.c: * win32/winlogin.c win32/winsetup.c: - Use _WIN32 and _WIN64 instead of WIN32 and WIN64 Sun Jan 10 14:49:39 CET 2010 Frediano Ziglio * src/dblib/db-lib.vcproj src/replacements/replacements.vcproj: - Be consistent about WIN32/WIN64 defines Sun Jan 10 00:41:36 CET 2010 Frediano Ziglio * include/tds_sysdep_private.h src/tds/net.c: - Fix socket error testing for EAGAIN Sat Jan 9 20:04:51 CET 2010 Frediano Ziglio * src/odbc/unittests/test64.c: More verbose Sat Jan 9 15:31:46 CET 2010 Frediano Ziglio * src/dblib/bcp.c: Ignore terminator pointer if terminator len <= 0 Sat Jan 9 14:10:18 CET 2010 Frediano Ziglio * src/apps/defncopy.c: Cleanup, statify Sat Jan 9 11:55:34 CET 2010 Frediano Ziglio * src/apps/defncopy.c: cleanup defncopy Sat Jan 9 10:50:09 CET 2010 Frediano Ziglio * include/tds_sysdep_private.h src/tds/net.c: - Defined and use a sock_strerror Sat Jan 9 10:33:10 CET 2010 Frediano Ziglio * src/tds/net.c: Avoid double definition Sat Jan 9 10:17:41 CET 2010 Frediano Ziglio * src/replacements/vasprintf.c: - Fix possible wrong error report if malloc does not set errno Fri Jan 8 17:38:50 EST 2010 JK Lowden * include/replacements.h src/apps/bsqldb.c src/tds/mem.c - tsql works in win32, optarg is not const Fri Jan 8 17:05:24 EST 2010 JK Lowden * Nmakefile include/replacements.h win32/config.h * src/apps/bsqldb.c src/apps/defncopy.c src/apps/tsql.c * src/tds/config.c src/tds/hmac_md5.c src/tds/mem.c * src/tds/net.c src/tds/numeric.c src/tds/token.c - Build some utilities under Win32. - Print useful log messages for win32 connection failures. Thu Jan 7 14:56:27 CET 2010 Frediano Ziglio * src/odbc/convert_tds2sql.c: added small comments Mon Dec 28 14:30:21 CET 2009 Frediano Ziglio * include/tds.h src/odbc/convert_tds2sql.c src/odbc/odbc.c: * src/odbc/unittests/getdata.c: - Fix SQLGetData converting fixed to variable with truncation Mon Dec 28 13:42:02 CET 2009 Frediano Ziglio * src/odbc/unittests/getdata.c: - Fix problem with iODBC (where sizeof(SQLWCHAR) == 4) Tue Dec 22 15:56:11 EST 2009 JK Lowden * Nmakefile added, builds db-lib on Win32 with nmake.exe * src/odbc/convert_tds2sql.c remove unneeded cast Tue Dec 22 20:01:16 CET 2009 Frediano Ziglio * src/odbc/odbc.c: Better way to fix data_type for date Tue Dec 22 20:00:18 CET 2009 Frediano Ziglio * src/odbc/unittests/common.c: Don't call SQLAllocEnv for ODBC 3 Thu Dec 17 22:08:50 CET 2009 Frediano Ziglio * src/odbc/odbc.c: Automatic odbc version selection Thu Dec 17 11:33:39 CET 2009 Frediano Ziglio * include/tdsodbc.h src/odbc/odbc.c: - Fix statistics functions for Sybase Wed Dec 16 14:06:17 CET 2009 Frediano Ziglio * include/tdsodbc.h src/odbc/connectparams.c src/odbc/error.c: * src/odbc/odbc.c: - Simplified yesterday path for Windows compile Wed Dec 16 13:54:52 CET 2009 Frediano Ziglio * src/odbc/convert_tds2sql.c: Fix conversion for uni(var)char Wed Dec 16 09:22:41 CET 2009 Frediano Ziglio * src/dblib/dblib.c: Fix uninitilized memory access problem Tue Dec 15 12:45:47 CET 2009 Frediano Ziglio * src/odbc/connectparams.c win32/winsetup.c: - Fix compile under Windows Tue Dec 15 12:23:27 CET 2009 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/Makefile.am: * src/odbc/unittests/common.h src/odbc/unittests/stats.c: - Fix data_type returned from statistics function Tue Dec 15 10:52:43 CET 2009 Frediano Ziglio * include/tdsodbc.h src/odbc/connectparams.c src/odbc/odbc.c: - Avoid wrong configuration problem reporting problems Tue Dec 15 10:13:12 CET 2009 Frediano Ziglio * src/odbc/connectparams.c: - Update Unixodbc configuration settings for TDS version Sun Dec 13 20:01:01 EST 2009 JK Lowden * doc/freetds.conf.5 doc/userguide.sgml - updated documentation in preparation for upcoming release. Sun Dec 13 11:37:31 CET 2009 Frediano Ziglio * src/ctlib/unittests/rpc_ct_setparam.c src/tds/query.c: - Fix posting longbinary on Sybase server Sun Dec 13 11:36:48 CET 2009 Frediano Ziglio * src/ctlib/unittests/t0006.c: Style and comments Sun Dec 13 10:48:42 CET 2009 Frediano Ziglio * src/ctlib/ct.c: - Fix problem with long binary managed as char type (patch from Christian Hoffmann) Mon Dec 7 17:22:05 CET 2009 Frediano Ziglio * src/odbc/unittests/getdata.c src/tds/convert.c: - Ported test for conversion from '' text to SQL_C_BINARY, remove possible core Sat Dec 5 14:43:00 EST 2009 JK Lowden * src/apps/tsql.c applied small optind patch from ML Fri Dec 4 11:34:10 CET 2009 Frediano Ziglio * src/odbc/unittests/getdata.c: - check buffer unchanged if overflow detected Wed Dec 2 17:56:52 EST 2009 JK Lowden * src/dblib/dblib.c src/odbc/prepare_query.c src/tds/login.c - warning & uninitialized variable cleanup Wed Dec 2 17:30:10 EST 2009 JK Lowden * include/sqldb.h add Microsoft db-lib error symbols * src/dblib/dblib.c - dbsqlok returns FAIL if error encountered in any DONEINPROC - packet prior to returning. Should return FAIL for - RAISERROR('msg', 16,1). Sun Nov 29 21:16:19 CET 2009 Frediano Ziglio * src/odbc/unittests/getdata.c: - Check error if conversion truncates data Sun Nov 29 21:06:18 CET 2009 Frediano Ziglio * src/odbc/unittests/data.c: Fix MS ODBC problem during test Sun Nov 29 20:02:37 CET 2009 Frediano Ziglio * src/odbc/unittests/data.c: Test univarchar from server Sun Nov 29 19:56:38 CET 2009 Frediano Ziglio * src/odbc/odbc.c: Fix row number return for cursors Fri Nov 27 19:01:33 CET 2009 Frediano Ziglio * src/odbc/odbc_util.c src/odbc/unittests/describecol.in: - Fix SQL_GUID length Fri Nov 27 17:15:36 CET 2009 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/getdata.c: - Fix SQLGetData from fixed to CHAR not returning always SQL_SUCCESS Thu Nov 26 10:46:01 CET 2009 Frediano Ziglio * include/ctlib.h include/tds.h src/ctlib/ct.c src/tds/config.c: * src/tds/login.c src/tds/mem.c: - Move server_addr into ctlib Thu Nov 26 10:06:51 CET 2009 Frediano Ziglio * include/tds.h src/tds/data.c src/tds/tds_checks.c: * src/tds/tds_checks.h src/tds/token.c: - Fix univarchar in Sybase servers Tue Nov 24 16:48:17 CET 2009 Frediano Ziglio * src/tds/config.c: small optimization Mon Nov 23 12:30:27 CET 2009 Frediano Ziglio * win32/msvc6/libTDS.dsp: Add bulk.c to msvc6 project file Mon Nov 23 09:48:23 CET 2009 Frediano Ziglio * src/ctlib/ct.c src/dblib/bcp.c: - Use strtok_r instead of strtok to be more thread safe Sun Nov 22 16:46:00 EST 2009 JK Lowden * src/tds/config.c src/tds/mem.c - No error if valid DNS name not in freetds.conf. - Better reporting of server name on login failure. Thu Nov 19 09:44:19 CET 2009 Frediano Ziglio * src/odbc/odbc.c: fix SQLColAttributes for ODBC 2 clients Thu Nov 19 09:32:38 CET 2009 Frediano Ziglio * src/tds/config.c: fix typo in config.c Fri Nov 6 08:49:07 CET 2009 Frediano Ziglio * src/tds/config.c: - Fix compatibility problem with "server:port" syntax Fri Oct 23 15:12:16 EDT 2009 JK Lowden * src/apps/tsql.c exit after -L output * src/dblib/dblib.c * src/dblib/dbopen.c - dbdatecrack follows MSDBLIB, not WIN32 * src/tds/config.c - do not parse freetds.conf [servername] for instance/port. Fri Oct 16 09:58:46 CEST 2009 Frediano Ziglio * src/dblib/dblib.c: Fix dbwritetext with text == NULL Mon Oct 12 09:26:46 CEST 2009 Frediano Ziglio * misc/prepare_win32.sh: - add comments to misc/prepare_win32.sh script Sat Oct 3 11:19:20 CEST 2009 Frediano Ziglio * src/odbc/odbc.c: unprepare optimization for emulated dynamics Fri Oct 2 11:23:18 CEST 2009 Frediano Ziglio * src/ctlib/ct.c src/tds/query.c src/tds/tds_checks.c: - Support RPCs using tds 4.2 Thu Oct 1 11:47:53 CEST 2009 Frediano Ziglio * src/odbc/convert_tds2sql.c src/tds/iconv.c: - Avoid core using SQLWCHAR and TDS 4.2 Wed Sep 30 13:51:16 CEST 2009 Frediano Ziglio * src/tds/log.c: Avoid memory problems logging data Tue Sep 29 11:15:56 CEST 2009 Frediano Ziglio * src/tds/convert.c: fix float to money precision during conversion Mon Sep 28 16:06:37 CEST 2009 Frediano Ziglio * src/tds/login.c: Fix SSL connection under mssql2k Mon Sep 14 12:02:10 CEST 2009 Frediano Ziglio * configure.ac src/dblib/unittests/common.c: - limit stack use in dblib tests Fri Sep 4 09:11:38 CEST 2009 Frediano Ziglio * configure.ac vms/README.vms: Fix --with-tdsver option Thu Sep 3 13:53:26 CEST 2009 Frediano Ziglio * TODO src/tds/token.c: - fix NULL becaming empty strings under Sybase Thu Sep 3 11:25:04 CEST 2009 Frediano Ziglio * src/tds/challenge.c: fix NTLM2 check Wed Sep 2 11:26:14 CEST 2009 Frediano Ziglio * src/dblib/unittests/numeric.c: fix dblib numeric test for Sybase Tue Sep 1 10:01:45 CEST 2009 Frediano Ziglio * src/dblib/dblib.c: fix numeric -> numeric conversions Tue Sep 1 07:47:25 CEST 2009 Frediano Ziglio * src/dblib/rpc.c src/dblib/unittests/.cvsignore: * src/dblib/unittests/Makefile.am src/dblib/unittests/common.c: * src/dblib/unittests/common.h src/dblib/unittests/numeric.c: * src/dblib/unittests/numeric.sql: - add and fix test for numeric in dblib Thu Aug 27 15:36:42 CEST 2009 Frediano Ziglio * src/odbc/unittests/cancel.c: - override odbcinst.ini in cancel test to avoid hang using unixODBC Thu Aug 27 14:31:52 CEST 2009 Frediano Ziglio * src/odbc/unittests/genparams.c: update genparams test Wed Aug 26 14:31:33 CEST 2009 Frediano Ziglio * src/odbc/sql2tds.c src/odbc/unittests/genparams.c src/tds/data.c: * src/tds/query.c src/tds/tds_checks.c src/tds/token.c: - more fixes for varchar(max)/varbinary(max) Wed Aug 26 14:18:35 CEST 2009 Frediano Ziglio * src/dblib/unittests/common.c: - make check now works if configure was launched from another directory Wed Aug 26 14:16:00 CEST 2009 Frediano Ziglio * misc/test-dist.sh: test-dist now works with new configure script Tue Aug 25 16:31:41 CEST 2009 Frediano Ziglio * misc/freetds_autobuild: - update DBD::ODBC test, fix for config.rpath required Tue Aug 25 16:23:49 CEST 2009 Frediano Ziglio * doc/freebcp.txt doc/freetds.conf.5 doc/tds_ssl.html: * doc/userguide.sgml include/sybdb.h include/tds.h src/dblib/bcp.c: * src/dblib/dblib.c src/dblib/unittests/t0022.c src/pool/util.c: * src/server/login.c src/server/server.c src/server/unittest.c: * src/tds/bulk.c src/tds/config.c src/tds/login.c src/tds/mem.c: * src/tds/net.c src/tds/query.c src/tds/tds_checks.c: * src/tds/token.c src/tds/util.c win32/winsetup.c: - Use MS protocol version (7.1 for mssql2k and 7.2 for mssql2k5) Fri Aug 21 12:10:57 CEST 2009 Frediano Ziglio * include/tds.h src/tds/data.c src/tds/token.c: - fix variant type for data converted to client encoding Fri Aug 21 12:01:24 CEST 2009 Frediano Ziglio * src/tds/net.c: - make ssl more threadsafe using pthread in libgcrypt if possible Fri Aug 21 11:59:39 CEST 2009 Frediano Ziglio * src/tds/net.c: - fix a problem with Interix (cfr http://debian-interix.net/bugs/libs/) Fri Aug 21 11:57:54 CEST 2009 Frediano Ziglio * src/tds/net.c: small optimization for method constant Thu Aug 20 20:59:22 CEST 2009 Frediano Ziglio * src/odbc/convert_tds2sql.c src/odbc/unittests/data.c: * src/tds/token.c: - fix N(VAR)CHAR inside variant Thu Aug 20 19:52:58 CEST 2009 Frediano Ziglio * include/tds.h src/tds/iconv.c src/tds/token.c: - pass raw collation structure to tds_iconv_from_collate Thu Aug 20 19:51:40 CEST 2009 Frediano Ziglio * include/tds.h: small fix for ms xml type Thu Aug 20 19:51:03 CEST 2009 Frediano Ziglio * src/tds/config.c src/tds/login.c src/tds/query.c src/tds/token.c: - enable tds 7.2 support for odbc Thu Aug 20 19:49:45 CEST 2009 Frediano Ziglio * src/tds/read.c: small tds_get_n improve Thu Aug 20 19:48:56 CEST 2009 Frediano Ziglio * include/tds.h src/tds/data.c src/tds/token.c src/tds/types.pl: - use iconv on variant Thu Aug 20 17:14:29 CEST 2009 Frediano Ziglio * src/odbc/odbc.c: fix describecol test Wed Aug 19 13:48:28 CEST 2009 Frediano Ziglio * src/odbc/unittests/data.c src/tds/token.c: handle variant data Wed Aug 19 11:51:14 CEST 2009 Frediano Ziglio * src/dblib/dblib.c: small improve Tue Aug 18 17:11:07 CEST 2009 Frediano Ziglio * src/tds/tds_checks.c src/tds/token.c misc/types.txt: * src/odbc/odbc_util.c: - improve ms xml support Tue Aug 18 17:07:18 CEST 2009 Frediano Ziglio * src/tds/token.c: fix silly error Tue Aug 18 17:04:42 CEST 2009 Frediano Ziglio * src/ctlib/ct.c: small fix for empty strings Tue Aug 18 14:23:46 CEST 2009 Frediano Ziglio * misc/freetds_autobuild: - remove 0.64 support - reuse a new function Tue Aug 18 13:09:13 CEST 2009 Frediano Ziglio * src/tds/query.c: fix empty string binding for Sybase Tue Aug 18 09:27:03 CEST 2009 Frediano Ziglio * src/tds/tds_checks.c: - remove too strict test (fails for Sybase LONGCHAR) Mon Aug 17 18:52:20 CEST 2009 Frediano Ziglio * src/tds/login.c: applied David Wood patch for Sybase host process Fri Aug 14 15:53:01 CEST 2009 Frediano Ziglio * configure.ac: - use pkg-config instead of libgnutls-config if possible Fri Jul 24 17:06:23 CEST 2009 Frediano Ziglio * src/tds/token.c: fix Sybase LONGCHAR/LONGBINARY Thu Jul 23 20:21:50 CEST 2009 Frediano Ziglio * src/apps/freebcp.c src/apps/freebcp.h: - support setting charset in freebcp Tue Jul 21 08:43:36 CEST 2009 Frediano Ziglio * src/ctlib/unittests/rpc_ct_param.c: add empty column Tue Jul 21 08:39:36 CEST 2009 Frediano Ziglio * src/dblib/unittests/t0022.c: cleanup Mon Jul 20 19:41:20 CEST 2009 Frediano Ziglio * src/tds/token.c: fix log string Mon Jul 20 19:38:01 CEST 2009 Frediano Ziglio * include/tds.h src/tds/login.c src/tds/mem.c: remove some warnings Thu Jul 16 19:33:54 CEST 2009 Frediano Ziglio * src/tds/login.c: better encryption support for mssql Thu Jul 16 10:36:03 EDT 2009 JK Lowden * src/apps/osql work around mawk limitations Tue Jul 14 17:48:04 EDT 2009 JK Lowden * src/apps/osql more messages, perhaps somewhat clearer Fri Jul 10 14:01:28 EDT 2009 JK Lowden * src/dblib/bcp.c pad nullable CHAR written to hostfile. Thu Jun 25 22:51:09 CEST 2009 Frediano Ziglio * src/ctlib/ct.c: Andrew Victor patch for empty strings (modified) Thu Jun 25 22:47:37 CEST 2009 Frediano Ziglio * src/ctlib/ct.c: comment style Thu Jun 25 22:31:53 CEST 2009 Frediano Ziglio * src/ctlib/unittests/lang_ct_param.c: - add test for empty not null strings Tue Jun 23 19:49:52 EDT 2009 JK Lowden * doc/htdoc/news.html added HP/UX news Sat Jun 20 17:57:22 EDT 2009 JK Lowden * CVSROOT/config removed local keyword because not supported Fri Jun 19 09:50:29 EDT 2009 JK Lowden * ChangeLog testing local keyword expansion Fri Jun 19 09:49:26 EDT 2009 JK Lowden * CVSROOT/config added $FreeTDS$ local keyword Wed Jun 17 19:07:24 CEST 2009 Frediano Ziglio * src/tds/iconv.c: reuse some macros for version check Wed Jun 17 18:20:53 CEST 2009 Frediano Ziglio * src/tds/iconv.c: fix iconv portability problem Fri Jun 12 10:53:39 CEST 2009 Frediano Ziglio * include/tds.h src/odbc/convert_tds2sql.c: * src/odbc/unittests/data.c src/tds/convert.c src/tds/tds_checks.c: * src/tds/token.c: - improve variant support if --enable-developing Wed Jun 10 20:54:07 CEST 2009 Frediano Ziglio * src/odbc/convert_tds2sql.c src/odbc/odbc.c src/odbc/odbc_util.c: - move blob check to odbc_tds2sql Wed Jun 10 18:44:48 CEST 2009 Frediano Ziglio * src/ctlib/ct.c: limit indentation Tue Jun 9 10:54:29 CEST 2009 Frediano Ziglio * src/apps/datacopy.c src/ctlib/blk.c src/ctlib/cs.c: * src/ctlib/ct.c src/odbc/connectparams.c src/odbc/descriptor.c: * src/pool/main.c src/pool/member.c src/tds/challenge.c: * src/tds/iconv.c src/tds/token.c: - use calloc instead of malloc and memset Tue Jun 9 08:49:43 CEST 2009 Frediano Ziglio * src/ctlib/cs.c src/ctlib/ct.c src/tds/convert.c src/tds/data.c: - revert Andrew Victor patch Mon Jun 8 21:54:55 CEST 2009 Frediano Ziglio * include/ctlib.h src/ctlib/blk.c src/ctlib/ct.c: - make _ct_get_client_type call shorter Mon Jun 8 21:39:32 CEST 2009 Frediano Ziglio * src/ctlib/ct.c: avoid improper fall through on error Mon Jun 8 20:38:45 CEST 2009 Frediano Ziglio * BUGS: updated Sat Jun 6 18:23:50 CEST 2009 Frediano Ziglio * doc/userguide.sgml: update ClientCharset setting Fri Jun 5 21:36:29 EDT 2009 JK Lowden * src/ctlib/cs.c src/ctlib/ct.c * src/tds/convert.c src/tds/data.c - Applied patch from Andrew Victor ML 24 November 2008 - "CTLib implementation handles NVARCHAR strings as VARCHAR" Thu Jun 4 07:39:49 CEST 2009 Frediano Ziglio * doc/api_status.txt: updated Wed Jun 3 23:41:17 EDT 2009 JK Lowden * doc/api_status.txt doc/userguide.sgml - added ClientCharset connection attribute Thu May 28 18:23:16 CEST 2009 Frediano Ziglio * include/tds.h misc/types.txt src/apps/tsql.c src/ctlib/ct.c: * src/dblib/bcp.c src/dblib/buffering.h src/dblib/dblib.c: * src/dblib/rpc.c src/odbc/odbc.c src/odbc/odbc_util.c: * src/odbc/prepare_query.c src/odbc/sql2tds.c src/tds/mem.c: * src/tds/query.c src/tds/read.c src/tds/tds_checks.c: * src/tds/token.c src/tds/unittests/dataread.c: * src/tds/unittests/utf8_1.c src/tds/unittests/utf8_2.c: - improve support for mssql2005 types (still under development) Thu May 28 18:17:43 CEST 2009 Frediano Ziglio * src/odbc/unittests/data.c: add tests for mssql2005 types Thu May 28 18:15:23 CEST 2009 Frediano Ziglio * src/dblib/unittests/common.h: add SYBDECIMAL Wed May 27 19:57:53 CEST 2009 Frediano Ziglio * src/odbc/unittests/genparams.c: fix for MS ODBC Tue May 26 18:18:50 CEST 2009 Frediano Ziglio * src/tds/query.c: reduce num scope Fri May 22 19:33:28 CEST 2009 Frediano Ziglio * src/odbc/sql2tds.c: fix genparams Thu May 21 23:58:34 CEST 2009 Frediano Ziglio * TODO.freddy src/odbc/unittests/blob1.c: update notes Thu May 21 18:41:21 CEST 2009 Frediano Ziglio * src/odbc/prepare_query.c src/odbc/unittests/blob1.c: - support wchar -> binary conversions Thu May 21 18:39:31 CEST 2009 Frediano Ziglio * include/tdsconvert.h src/odbc/prepare_query.c src/tds/convert.c: - extract and reuse tds_char2hex Thu May 21 18:35:15 CEST 2009 Frediano Ziglio * src/odbc/prepare_query.c: improve continue_parse_prepared_query Thu May 21 18:30:48 CEST 2009 Frediano Ziglio * src/odbc/unittests/blob1.c: add wchar test Wed May 20 18:36:51 CEST 2009 Frediano Ziglio * src/dblib/bcp.c: prevent core and return error Wed May 20 18:34:45 CEST 2009 Frediano Ziglio * src/odbc/sql2tds.c: fix blob1 test Wed May 20 18:27:49 CEST 2009 Frediano Ziglio * src/odbc/unittests/blob1.c: - allow easy extension and add some type check Wed May 20 10:15:08 EDT 2009 JK Lowden * src/apps/osql - check ODBC library instead of isql for default directories. Mon May 11 17:11:52 CEST 2009 Frediano Ziglio * src/odbc/unittests/blob1.c: test wide for output Mon May 11 11:04:52 CEST 2009 Frediano Ziglio * src/tds/read.c: fix reading empty packets Mon May 11 09:52:26 CEST 2009 Frediano Ziglio * src/dblib/buffering.h: fix a test * src/dblib/unittests/t0013.c src/dblib/unittests/t0013.sql: - remove table if exixts Mon May 11 09:24:40 CEST 2009 Frediano Ziglio * src/ctlib/ct.c: remove warnings and duplicate logs Sun May 3 15:26:26 EDT 2009 JK Lowden * src/ctlib/blk.c src/ctlib/cs.c src/ctlib/ct.c * src/ctlib/ctutil.c src/ctlib/unittests/common.c * src/dblib/dbutil.c BUGS - better ct-lib logging Thu Apr 30 08:48:24 CEST 2009 Frediano Ziglio * misc/check_symbols.txt misc/order_coverage.pl: notes and updates Thu Apr 23 15:29:30 CEST 2009 Frediano Ziglio * misc/commit: small fix Thu Apr 23 15:12:24 CEST 2009 Frediano Ziglio * src/dblib/buffering.h src/dblib/dblib.c: - add internal test for buffering - clear row number if deleted - fix buffer_delete_rows - fix dbclrbuf not clearing all rows Thu Apr 23 11:40:43 CEST 2009 Frediano Ziglio * misc/sybase_tests: fix rebuild Thu Apr 23 11:36:05 CEST 2009 Frediano Ziglio * src/dblib/unittests/t0002.c: fix test Wed Apr 22 17:11:00 CEST 2009 Frediano Ziglio * src/dblib/unittests/t0008.c: fix test Tue Apr 21 15:39:35 CEST 2009 Frediano Ziglio * misc/sybase_tests: improve Tue Apr 21 11:43:31 CEST 2009 Frediano Ziglio * misc/prepare_win32.sh: batch for dblib tests Mon Apr 20 10:55:17 CEST 2009 Frediano Ziglio * src/dblib/dblib.c: fix timeout test Sat Apr 18 15:18:39 EDT 2009 JK Lowden * include/sybdb.h include/tds.h * src/apps/bsqldb.c src/apps/tsql.c * src/ctlib/ct.c src/dblib/dblib.c src/odbc/odbc.c * src/tds/config.c src/tds/login.c src/tds/util.c - support TDSEINTF and TDSEUHST to distinguish name-lookup failures. Sat Apr 18 17:21:15 CEST 2009 Frediano Ziglio * src/dblib/unittests/timeout.c: - fix test according to vendors behavior Fri Apr 17 19:16:14 CEST 2009 Frediano Ziglio * misc/sybase_tests: set LD_RUN_PATH to find proper libraries Fri Apr 17 16:28:55 CEST 2009 Frediano Ziglio * misc/sybase_tests: script to compile dblib unittests using Sybase Fri Apr 17 11:54:00 CEST 2009 Frediano Ziglio * src/dblib/unittests/common.c: disable output buffering * src/dblib/unittests/null2.c: fix for MS library Thu Apr 16 09:23:45 CEST 2009 Frediano Ziglio * src/dblib/unittests/common.c: fix extension stripping Wed Apr 15 22:54:49 CEST 2009 Frediano Ziglio * src/dblib/unittests/common.c: fix dirname for win32 Wed Apr 15 09:59:47 CEST 2009 Frediano Ziglio * src/dblib/unittests/common.c: fix core detecting sql input file Wed Apr 8 21:35:02 EDT 2009 JK Lowden * include/fakepoll.h src/dblib/unittests/common.c * vms/config_h.vms vms/descrip_mms.template - apply patch from Craig A. Berry ML 8 April 2009 * doc/userguide.sgml document ASA Servername Fri Mar 27 10:22:22 CET 2009 Frediano Ziglio * src/tds/net.c: remove warning and check Tue Mar 24 11:38:29 CET 2009 Frediano Ziglio * misc/test-auto.sh: style update Mon Mar 23 21:19:02 EDT 2009 JK Lowden * src/dblib/bcp.c src/dblib/dblib.c src/dblib/dbutil.c * src/dblib/rpc.c src/dblib/xact.c - remove hard-coded #include directories * BUGS add freebcp bug from ML Mon Mar 23 14:26:46 CET 2009 Frediano Ziglio * src/dblib/dblib.c: fix uninitialized data Thu Mar 19 17:02:22 CET 2009 Frediano Ziglio * src/tds/query.c: - patch from Craig A. Berry for uninitialized variable Thu Mar 19 16:12:41 CET 2009 Frediano Ziglio * misc/prepare_win32.sh: no pack option Thu Mar 19 16:09:30 CET 2009 Frediano Ziglio * src/dblib/unittests/common.c src/replacements/basename.c: - fix some problems under win32 Thu Mar 19 14:36:34 CET 2009 Frediano Ziglio * misc/prepare_win32.sh: include sql files Thu Mar 19 14:13:12 CET 2009 Frediano Ziglio * misc/commit: support file addition Thu Mar 19 14:11:31 CET 2009 Frediano Ziglio * src/dblib/unittests/common.c src/dblib/unittests/common.h: * src/dblib/unittests/null.c src/dblib/unittests/t0021.c: * misc/prepare_win32.sh: - make dblib tests compile with ms dblib Tue Mar 17 14:34:15 CET 2009 Frediano Ziglio * src/dblib/unittests/Makefile.am: fix distribution Tue Mar 17 10:05:23 CET 2009 Frediano Ziglio * src/odbc/unittests/genparams.c src/odbc/unittests/moreandcount.c: * src/odbc/unittests/typeinfo.c: - relax some tests Mon Mar 16 21:46:05 CET 2009 Frediano Ziglio * win32/tds_sysdep_public.h: - fix redefinition (due to change on Fri Feb 27 11:46:15 CET 2009) Mon Mar 16 13:18:31 CET 2009 Frediano Ziglio * src/odbc/unittests/common.c: disable buffering * src/odbc/unittests/const_params.c: fix for MS ODBC Mon Mar 16 08:49:25 CET 2009 Frediano Ziglio * src/tds/net.c: roll back to avoid possible core in OpenSSL code Wed Mar 11 10:07:02 CET 2009 Frediano Ziglio * src/dblib/bcp.c: avoid memory corruption on out of memory Mon Mar 9 21:53:46 CET 2009 Frediano Ziglio * TODO.freddy src/odbc/unittests/genparams.c: add test for binary Mon Mar 9 21:35:38 CET 2009 Frediano Ziglio * TODO.freddy src/odbc/unittests/genparams.c: - add test for NULL input data Fri Mar 6 21:18:28 CET 2009 Frediano Ziglio * src/tds/query.c: fix really stupid core Fri Mar 6 18:34:12 CET 2009 Frediano Ziglio * src/odbc/sql2tds.c src/odbc/unittests/genparams.c: - add and fix test for text Fri Mar 6 15:30:58 CET 2009 Frediano Ziglio * src/tds/config.c: fix kerberos login with no freetds.conf Fri Mar 6 10:13:41 CET 2009 Frediano Ziglio * src/odbc/unittests/putdata.c: just some comments Fri Mar 6 03:27:07 CET 2009 Frediano Ziglio * src/tds/query.c: fix genparams test for Sybase Fri Mar 6 02:52:12 CET 2009 Frediano Ziglio * src/tds/query.c: fix putdata test for Sybase Wed Mar 4 18:51:16 CET 2009 Frediano Ziglio * src/dblib/dblib.c: remove a warning and change style Wed Mar 4 18:40:56 CET 2009 Frediano Ziglio * src/dblib/dblib.c: make it compile Mon Mar 2 08:58:31 CET 2009 Frediano Ziglio * win32/msvc6/libTDS.dsp: add needed files Mon Mar 2 00:09:58 EST 2009 JK Lowden * src/dblib/bcp.c src/dblib/dblib.c * samples/bcp_test.cpp samples/Makefile.bcp_test - bcp_init sets default values for host file columns - if host_filename is not NULL. Sat Feb 28 12:32:06 EST 2009 JK Lowden * include/sybdb.h DBDATEREC members are 32-bit * BUGS TODO more things to fix * include/tds.h src/tds/login.c src/tds/net.c - login packet debugging options Fri Feb 27 16:50:57 CET 2009 Frediano Ziglio * src/dblib/unittests/bcp.c src/dblib/unittests/common.c: * src/dblib/unittests/common.h src/dblib/unittests/dbmorecmds.c: * src/dblib/unittests/done_handling.c src/dblib/unittests/rpc.c: * src/dblib/unittests/t0001.c src/dblib/unittests/t0002.c: * src/dblib/unittests/t0003.c src/dblib/unittests/t0004.c: * src/dblib/unittests/t0005.c src/dblib/unittests/t0006.c: * src/dblib/unittests/t0007.c src/dblib/unittests/t0009.c: * src/dblib/unittests/t0011.c src/dblib/unittests/t0012.c: * src/dblib/unittests/t0013.c src/dblib/unittests/t0014.c: * src/dblib/unittests/t0015.c src/dblib/unittests/t0016.c: * src/dblib/unittests/t0017.c src/dblib/unittests/t0018.c: * src/dblib/unittests/t0020.c src/dblib/unittests/t0022.c: * src/dblib/unittests/t0023.c src/dblib/unittests/text_buffer.c: * src/dblib/unittests/timeout.c: - remove INPUT param from sql_cmd Fri Feb 27 11:46:15 CET 2009 Frediano Ziglio * include/tds_sysdep_private.h include/tds_sysdep_public.h.in: - cleanup public sysdep header Fri Feb 27 11:37:34 CET 2009 Frediano Ziglio * src/dblib/unittests/common.c: - replace errx and warnx cause not that portable Fri Feb 27 11:11:32 CET 2009 Frediano Ziglio * configure.ac include/tds_sysdep_private.h: * src/odbc/unittests/freeclose.c src/odbc/unittests/timeout3.c: * src/pool/user.c src/server/login.c src/tds/net.c: - fix nasty problem under HP-UX Fri Feb 27 11:07:20 CET 2009 Frediano Ziglio * src/tds/log.c src/tds/query.c: fix possible format problems Thu Feb 26 20:04:00 CET 2009 Frediano Ziglio * configure.ac src/dblib/bcp.c: - fixes for MingW - don't use old winsock library Mon Feb 23 17:07:41 CET 2009 Frediano Ziglio * src/odbc/odbc.c: applied patch by Amir Shamsuddin to fix core Wed Feb 11 15:39:34 CET 2009 Frediano Ziglio * src/ctlib/unittests/Makefile.am src/dblib/unittests/Makefile.am: * src/odbc/unittests/Makefile.am src/tds/unittests/Makefile.am: - use libtool -R option instead of -Wl,--rpath Tue Feb 10 21:39:47 EST 2009 JK Lowden * doc/getting_started.txt doc/policy.txt * doc/userguide.sgml doc/htdoc/contrib.html * doc/htdoc/faq.html - updated brian's address Fri Feb 6 19:22:16 EST 2009 JK Lowden * include/sybdb.h include/tds.h src/dblib/dblib.c * src/tds/convert.c src/tds/mem.c src/tds/net.c - better winsock initialization and dbdatecrack Fri Feb 6 15:25:10 CET 2009 Frediano Ziglio * misc/freetds_autobuild: remove openjade warning * src/tds/unittests/convert.c: make valgrind happy Fri Feb 6 12:11:27 CET 2009 Frediano Ziglio * src/tds/unittests/convert.c: fix convert test Fri Feb 6 11:59:03 CET 2009 Frediano Ziglio * src/dblib/unittests/rpc.sql: fix rpc test Fri Feb 6 11:10:35 CET 2009 Frediano Ziglio * src/dblib/unittests/common.c: remove file leak in unittests Thu Feb 5 09:49:08 CET 2009 Frediano Ziglio * src/dblib/unittests/done_handling.c src/dblib/unittests/rpc.c: * src/dblib/unittests/t0011.c src/dblib/unittests/t0016.c: * src/dblib/unittests/t0023.c: - remove warnings Tue Feb 3 10:10:24 CET 2009 Frediano Ziglio * src/dblib/unittests/t0014.c: fix memory error Sun Feb 1 17:15:49 EST 2009 JK Lowden * src/dblib/unittests/common.h src/dblib/unittests/common.c * src/dblib/unittests/bcp.c src/dblib/unittests/dbmorecmds.c * src/dblib/unittests/done_handling.c src/dblib/unittests/rpc.c * src/dblib/unittests/t0001.c src/dblib/unittests/t0002.c * src/dblib/unittests/t0003.c src/dblib/unittests/t0004.c * src/dblib/unittests/t0005.c src/dblib/unittests/t0006.c * src/dblib/unittests/t0007.c src/dblib/unittests/t0008.c * src/dblib/unittests/t0009.c src/dblib/unittests/t0011.c * src/dblib/unittests/t0012.c src/dblib/unittests/t0013.c * src/dblib/unittests/t0014.c src/dblib/unittests/t0015.c * src/dblib/unittests/t0016.c src/dblib/unittests/t0017.c * src/dblib/unittests/t0018.c src/dblib/unittests/t0020.c * src/dblib/unittests/t0021.c src/dblib/unittests/t0022.c * src/dblib/unittests/t0023.c * src/dblib/unittests/text_buffer.c src/dblib/unittests/timeout.c * src/dblib/unittests/bcp.sql src/dblib/unittests/dbmorecmds.sql * src/dblib/unittests/done_handling.sql src/dblib/unittests/rpc.sql * src/dblib/unittests/t0001.sql src/dblib/unittests/t0002.sql * src/dblib/unittests/t0003.sql src/dblib/unittests/t0004.sql * src/dblib/unittests/t0005.sql src/dblib/unittests/t0006.sql * src/dblib/unittests/t0007.sql src/dblib/unittests/t0009.sql * src/dblib/unittests/t0011.sql src/dblib/unittests/t0012.sql * src/dblib/unittests/t0013.sql src/dblib/unittests/t0014.sql * src/dblib/unittests/t0015.sql src/dblib/unittests/t0016.sql * src/dblib/unittests/t0017.sql src/dblib/unittests/t0018.sql * src/dblib/unittests/t0020.sql src/dblib/unittests/t0022.sql * src/dblib/unittests/t0023.sql * src/dblib/unittests/text_buffer.sql src/dblib/unittests/timeout.sql - read unit test SQL from external file. Sat Jan 31 13:15:26 EST 2009 JK Lowden * doc/api_status.txt * include/sybdb.h * src/dblib/bcp.c src/dblib/dblib.c * src/dblib/rpc.c src/dblib/xact.c - s/char*/const char arg[]/g: constify db-lib functions Fri Jan 23 11:41:15 CET 2009 Frediano Ziglio * src/tds/mem.c: remove warning Fri Jan 23 11:35:21 CET 2009 Frediano Ziglio * src/dblib/dblib.c src/tds/query.c src/tds/write.c: - fix minor unsigned/signed issues Fri Jan 23 10:42:12 CET 2009 Frediano Ziglio * src/tds/login.c: remove buffer overflow reading Wed Jan 21 09:43:32 CET 2009 Frediano Ziglio * src/replacements/fakepoll.c: make it compile Wed Jan 21 09:33:39 CET 2009 Frediano Ziglio * src/replacements/vasprintf.c: fix portability problem * src/tds/challenge.c: check correctly error converting to ucs2 Mon Jan 19 15:36:50 CET 2009 Frediano Ziglio * src/tds/mem.c: dos2unix Fri Jan 16 15:28:57 EST 2009 JK Lowden * FreeTDS.sln * src/ctlib/ct-lib.vcproj src/dblib/db-lib.vcproj * src/odbc/odbc.vcproj src/replacements/replacements.vcproj * src/tds/TDS.vcproj - add Visual Studio project files Fri Jan 16 15:19:20 EST 2009 JK Lowden * include/md4.h include/md5.h * include/replacements.h * include/sqldb.h include/sqlfront.h include/sybdb.h * include/tds.h include/tds_sysdep_private.h * include/tdsstring.h * samples/odbc_rpc.pl * src/dblib/bcp.c src/dblib/dblib.c * src/dblib/dbopen.c src/dblib/dbutil.c * src/dblib/rpc.c src/dblib/xact.c * src/replacements/fakepoll.c src/replacements/readpassphrase.c * src/replacements/vasprintf.c * src/tds/bulk.c src/tds/challenge.c src/tds/config.c * src/tds/convert.c src/tds/getmac.c src/tds/iconv.c * src/tds/log.c src/tds/login.c src/tds/md4.c * src/tds/md5.c src/tds/mem.c src/tds/net.c src/tds/numeric.c * src/tds/query.c src/tds/read.c src/tds/tdsstring.c * src/tds/threadsafe.c src/tds/token.c src/tds/vstrbuild.c * src/tds/write.c * src/tds/unittests/dynamic1.c src/tds/unittests/flags.c * src/tds/unittests/numeric.c - fewer warnings compiling for Win64 Mon Jan 12 09:15:34 CET 2009 Frediano Ziglio * src/apps/bsqldb.c: ask for password if not specified Mon Jan 12 09:08:21 CET 2009 Frediano Ziglio * src/apps/tsql.c: make get_default_instance_port static Thu Jan 8 23:47:33 EST 2009 JK Lowden * src/apps/Makefile.am src/apps/fisql/Makefile.am * src/replacements/fakepoll.h - add LIBICONV to linker flags Tue Jan 6 21:53:56 EST 2009 JK Lowden * include/Makefile.am * include/fakepoll.h src/replacements/fakepoll.h * include/replacements.h src/replacements/Makefile.am - organized fakepoll like the other replacements * src/apps/defncopy.c print numeric sized correctly * src/tds/token.c minor logging Sat Jan 3 10:25:24 EST 2009 JK Lowden * src/tds/convert.c src/tds/tds_willconvert.pl - support SYBUNIQUE and SYBIMAGE Sat Jan 3 15:56:46 CET 2009 Frediano Ziglio * src/replacements/fakepoll.c: check win32 maxfd in a different way Mon Dec 29 18:08:00 CET 2008 Frediano Ziglio * src/replacements/fakepoll.c: fix typo in comment Sat Dec 27 16:47:40 EST 2008 JK Lowden * src/replacements/fakepoll.c src/replacements/fakepoll.h - different approach to Win32 compatibility Fri Dec 26 13:20:39 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: cleanup Mon Dec 22 16:32:17 CET 2008 Frediano Ziglio * src/tds/net.c: use strtok_r instead of strtok Sat Dec 20 20:30:47 CET 2008 Frediano Ziglio * src/tds/net.c: remove warning Sat Dec 20 20:16:20 CET 2008 Frediano Ziglio * src/tds/mem.c: fix quite impossible memory leak Sat Dec 20 20:13:33 CET 2008 Frediano Ziglio * misc/commit: fix small problem with small comments Sat Dec 20 20:11:46 CET 2008 Frediano Ziglio * src/replacements/fakepoll.c: fix win32 portability issue Sat Dec 20 00:52:51 EST 2008 JK Lowden * src/tds/login.c src/tds/mem.c src/tds/net.c - initialize tds_login at allocation, not connection * configure.ac include/Makefile.am - sort header files for readability * doc/userguide.dsl.in HTML 4.0 strict output * doc/userguide.sgml minor updates * src/replacements/Makefile.am * src/replacements/fakepoll.h src/replacements/fakepoll.c - added fakepoll Fri Dec 19 20:22:03 CET 2008 Frediano Ziglio * misc/commit: - fix date language problem - multiple comments support Fri Dec 19 19:43:07 CET 2008 Frediano Ziglio * src/tds/bulk.c: fix possible issue with 64 bit machines Fri Dec 19 17:22:14 CET 2008 Frediano Ziglio * src/tds/net.c: - fix typo, process last empty field from sql browser Fri Dec 19 16:40:53 CET 2008 Frediano Ziglio * include/tds.h src/tds/bulk.c: - notes, reduce variable scope, remove new_record_size Fri Dec 19 11:38:30 CET 2008 Frediano Ziglio * src/dblib/unittests/bcp.c src/dblib/unittests/bcp.h: - make some variable static Fri Dec 19 11:36:53 CET 2008 Frediano Ziglio * src/ctlib/blk.c: fix memory problem * src/ctlib/ct.c: small optimization Wed Dec 17 12:10:29 CET 2008 Frediano Ziglio * src/tds/config.c: optimize Wed Dec 17 12:01:55 CET 2008 Frediano Ziglio * src/ctlib/ct.c src/dblib/dblib.c src/odbc/odbc.c src/pool/member.c: * src/tds/login.c src/tds/unittests/common.c: - check tds_connect_and_login result correctly Tue Dec 16 16:39:35 CET 2008 Frediano Ziglio * include/tds.h src/ctlib/ct.c src/dblib/dblib.c src/tds/bulk.c: - add and reuse tds_writetext_(start|continue|end) Tue Dec 16 10:25:33 CET 2008 Frediano Ziglio * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/tds/bulk.c: - add and reuse tds_bcp_init - small bulk.c improves Tue Dec 16 10:19:26 CET 2008 Frediano Ziglio * src/tds/util.c src/apps/tsql.c: - remove formatting problems Mon Dec 15 16:48:44 CET 2008 Frediano Ziglio * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/tds/bulk.c: - add and reuse tds_bcp_done, tds_bcp_start and tds_bcp_start_copy_in Mon Dec 15 14:18:38 CET 2008 Frediano Ziglio * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/tds/bulk.c: - add and reuse tds_bcp_send_colmetadata - fix some tdsdump_log in bulk.c Mon Dec 15 13:33:10 CET 2008 Frediano Ziglio * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/tds/bulk.c: - add and reuse tds_bcp_send_record Mon Dec 15 00:15:18 EST 2008 JK Lowden * include/tds.h src/apps/tsql.c * src/ctlib/ct.c src/dblib/dblib.c * src/odbc/odbc.c src/pool/member.c * src/server/query.c src/tds/config.c * src/tds/log.c src/tds/login.c * src/tds/net.c src/tds/util.c * src/tds/unittests/common.c - Remove TDSSOCKET::last_packet, added tds_lastpacket(). - Rename tds_connect to tds_connect_and_login. - Change tds_connect_and_login to return TDSERROR. - Remove tdserror calls from tds_open_socket. - Add tds_connect as wrapper to tds_open_socket. - Connecting with TDSVER 0.0 works without producing - spurious messages. Fri Dec 12 20:40:56 EST 2008 JK Lowden * include/tds.h src/apps/tsql.c src/tds/log.c src/tds/net.c - add -L to tsql to list servers using MC-SQLR CLNT_UCAST_EX. - This message type can be used to discover the default - port for Microsoft servers beginning with SQL Server 2000. Fri Dec 12 14:53:03 CET 2008 Frediano Ziglio * include/ctlib.h include/dblib.h include/tds.h src/ctlib/blk.c: * src/dblib/bcp.c src/tds/Makefile.am src/tds/bulk.c(added): - start putting some BCP stuff into libTDS Thu Dec 11 13:36:33 CET 2008 Frediano Ziglio * include/tdsthread.h src/dblib/dblib.c src/tds/log.c: - add TDS_MUTEX_DECLARE Thu Dec 11 13:29:50 CET 2008 Frediano Ziglio * src/apps/Makefile.am src/apps/datacopy.c src/apps/freebcp.c: * src/apps/freebcp.h: - avoid some possible buffer overflows Thu Dec 11 11:11:34 CET 2008 Frediano Ziglio * src/odbc/unittests/cancel.c: add test for thread Wed Dec 10 18:07:31 EST 2008 JK Lowden * doc/userguide.sgml - add osql to unixODBC troubleshooting Wed Dec 10 15:55:30 CET 2008 Frediano Ziglio * include/tds.h src/apps/tsql.c src/ctlib/cs.c: * src/ctlib/unittests/common.c src/dblib/dblib.c src/tds/config.c: * src/tds/unittests/convert.c: - declare tds_g_append_mode and STD_DATETIME_FMT in tds.h Tue Dec 09 10:38:07 CET 2008 Frediano Ziglio * include/hmac_md5.h include/tds.h include/tdsconvert.h: * src/tds/tds_checks.h: - optimize link using gcc4 Fri Dec 05 09:31:29 CET 2008 Frediano Ziglio * src/odbc/unittests/putdata.c: improve Wed Dec 03 13:54:18 CET 2008 Frediano Ziglio * src/odbc/unittests/array_out.c src/odbc/unittests/blob1.c: * src/odbc/unittests/cancel.c src/odbc/unittests/common.c: * src/odbc/unittests/common.h src/odbc/unittests/connect.c: * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor5.c: * src/odbc/unittests/cursor7.c src/odbc/unittests/error.c: * src/odbc/unittests/lang_error.c src/odbc/unittests/prepclose.c: * src/odbc/unittests/print.c src/odbc/unittests/putdata.c: * src/odbc/unittests/raiserror.c src/odbc/unittests/tables.c: * src/odbc/unittests/timeout.c src/odbc/unittests/timeout4.c: * src/odbc/unittests/transaction.c src/odbc/unittests/transaction2.c: * src/odbc/unittests/typeinfo.c src/odbc/unittests/utf8.c: * src/odbc/unittests/warning.c: - remove global RetCode - new Command2 macro, use it Wed Dec 03 09:35:32 CET 2008 Frediano Ziglio * src/ctlib/cs.c src/dblib/dblib.c: avoid possible buffer overflow * src/dblib/dbutil.c: make message const * src/odbc/odbc.c: make odbc_prret thread safe Tue Dec 02 11:53:14 CET 2008 Frediano Ziglio * src/dblib/unittests/t0013.c: avoid leak Mon Dec 01 10:58:04 CET 2008 Frediano Ziglio * src/dblib/unittests/t0013.c: remove warning Mon Nov 17 19:46:34 EST 2008 JK Lowden * src/dblib/dblib.c * src/dblib/bcp.c src/dblib/unittests/bcp.c * src/dblib/unittests/common.c src/dblib/unittests/common.h * src/dblib/unittests/dbmorecmds.c * src/dblib/unittests/hang.c src/dblib/unittests/null.c * src/dblib/unittests/null2.c src/dblib/unittests/rpc.c * src/dblib/unittests/setnull.c * src/dblib/unittests/t0001.c src/dblib/unittests/t0002.c * src/dblib/unittests/t0003.c src/dblib/unittests/t0004.c * src/dblib/unittests/t0005.c src/dblib/unittests/t0006.c * src/dblib/unittests/t0007.c src/dblib/unittests/t0008.c * src/dblib/unittests/t0009.c src/dblib/unittests/t0011.c * src/dblib/unittests/t0012.c src/dblib/unittests/t0013.c * src/dblib/unittests/t0014.c src/dblib/unittests/t0015.c * src/dblib/unittests/t0016.c src/dblib/unittests/t0018.c * src/dblib/unittests/t0020.c src/dblib/unittests/t0021.c * src/dblib/unittests/t0022.c src/dblib/unittests/t0023.c * src/dblib/unittests/text_buffer.c * src/dblib/unittests/thread.c * src/dblib/unittests/timeout.c * win32/tds_sysdep_public.h - begin making unittests work with Microsoft's library Sat Nov 15 10:56:48 CET 2008 Frediano Ziglio * include/tds_sysdep_private.h src/apps/bsqlodbc.c: * src/pool/member.c src/pool/user.c: - remove some windows warnings Fri Nov 14 00:56:39 EST 2008 JK Lowden * src/apps/bsqlodbc.c - better metadata and -V option for ODBC version Wed Nov 12 21:58:17 CET 2008 Frediano Ziglio * Makefile.am config.rpath: fix an issue with some libtool version Wed Nov 12 11:36:32 CET 2008 Frediano Ziglio * src/dblib/unittests/t0013.c: check field data * src/odbc/prepare_query.c src/odbc/sql2tds.c: - fix error result Tue Nov 11 19:42:30 EST 2008 JK Lowden * include/dblib.h src/dblib/dblib.c - dbsqlok did not process entire packet - Cf. ML today from Ted Hayes * src/dblib/unittests/t0005.c cosmetic changes * src/tds/Makefile.am remember to build types.h * src/ctlib/unittests/Makefile.am src/dblib/unittests/Makefile.am * src/odbc/unittests/Makefile.am * src/tds/unittests/Makefile.am - set RPATH to prefer build tree Tue Nov 11 09:39:05 CET 2008 Frediano Ziglio * src/odbc/unittests/error.c: fix test for newer Sybase Tue Nov 11 09:33:55 CET 2008 Frediano Ziglio * src/odbc/unittests/transaction2.c: fix test for Sybase Mon Nov 10 18:20:10 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: check proper return code Fri Nov 07 17:24:12 CET 2008 Frediano Ziglio * include/tds.h: commented unused field Thu Nov 06 16:55:25 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c src/odbc/unittests/common.c: * src/odbc/unittests/common.h src/odbc/unittests/connect.c: * src/odbc/unittests/connect2.c src/odbc/unittests/error.c: * src/odbc/unittests/test64.c src/odbc/unittests/timeout.c: * src/odbc/unittests/timeout3.c src/odbc/unittests/utf8.c: * src/odbc/unittests/utf8_2.c: - remove CHK and CheckReturn - style update Thu Nov 06 15:39:50 CET 2008 Frediano Ziglio * src/tds/challenge.c: make it compile under VC6 Wed Nov 05 20:21:29 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/freeclose.c: - reduce one round-trip with server - improve freeclose test to detect complete rebindings - use always cursor results if cursor used Wed Nov 05 15:54:26 CET 2008 Frediano Ziglio * include/tds.h src/tds/mem.c src/tds/token.c: - remove warning Wed Nov 05 15:26:17 CET 2008 Frediano Ziglio * src/tds/unittests/toodynamic.c(added) include/tds.h: * src/tds/mem.c src/tds/query.c src/tds/unittests/Makefile.am: - fix problem for too dynamics reported by Man Min Yan Tue Nov 04 16:24:24 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/cursor3.c: - fix SQLGetData with cursors Tue Nov 04 15:43:25 CET 2008 Frediano Ziglio * src/odbc/unittests/array.c src/odbc/unittests/array_out.c: * src/odbc/unittests/attributes.c src/odbc/unittests/binary_test.c: * src/odbc/unittests/blob1.c src/odbc/unittests/cancel.c: * src/odbc/unittests/common.c src/odbc/unittests/common.h: * src/odbc/unittests/compute.c src/odbc/unittests/const_params.c: * src/odbc/unittests/convert_error.c src/odbc/unittests/cursor1.c: * src/odbc/unittests/cursor2.c src/odbc/unittests/cursor3.c: * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: * src/odbc/unittests/cursor6.c src/odbc/unittests/cursor7.c: * src/odbc/unittests/data.c src/odbc/unittests/date.c: * src/odbc/unittests/describecol.c src/odbc/unittests/earlybind.c: * src/odbc/unittests/error.c src/odbc/unittests/freeclose.c: * src/odbc/unittests/funccall.c src/odbc/unittests/genparams.c: * src/odbc/unittests/getdata.c src/odbc/unittests/hidden.c: * src/odbc/unittests/insert_speed.c src/odbc/unittests/moreandcount.c: * src/odbc/unittests/norowset.c src/odbc/unittests/paramcore.c: * src/odbc/unittests/params.c src/odbc/unittests/prepare_results.c: * src/odbc/unittests/preperror.c src/odbc/unittests/print.c: * src/odbc/unittests/putdata.c src/odbc/unittests/raiserror.c: * src/odbc/unittests/rebindpar.c src/odbc/unittests/rownumber.c: * src/odbc/unittests/rowset.c src/odbc/unittests/rpc.c: * src/odbc/unittests/scroll.c src/odbc/unittests/t0001.c: * src/odbc/unittests/t0002.c src/odbc/unittests/t0003.c: * src/odbc/unittests/test64.c src/odbc/unittests/testodbc.c: * src/odbc/unittests/timeout.c src/odbc/unittests/timeout2.c: * src/odbc/unittests/transaction.c src/odbc/unittests/transaction2.c: * src/odbc/unittests/typeinfo.c src/odbc/unittests/utf8.c: * src/odbc/unittests/utf8_2.c src/odbc/unittests/warning.c: * src/odbc/unittests/wchar.c: - more restyling Tue Nov 04 11:56:32 CET 2008 Frediano Ziglio * src/odbc/unittests/array_out.c src/odbc/unittests/binary_test.c: * src/odbc/unittests/blob1.c src/odbc/unittests/cancel.c: * src/odbc/unittests/common.c src/odbc/unittests/common.h: * src/odbc/unittests/compute.c src/odbc/unittests/connect.c: * src/odbc/unittests/connect2.c src/odbc/unittests/const_params.c: * src/odbc/unittests/convert_error.c src/odbc/unittests/copydesc.c: * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor2.c: * src/odbc/unittests/cursor3.c src/odbc/unittests/cursor4.c: * src/odbc/unittests/cursor5.c src/odbc/unittests/cursor6.c: * src/odbc/unittests/cursor7.c src/odbc/unittests/data.c: * src/odbc/unittests/date.c src/odbc/unittests/describecol.c: * src/odbc/unittests/error.c src/odbc/unittests/freeclose.c: * src/odbc/unittests/funccall.c src/odbc/unittests/genparams.c: * src/odbc/unittests/getdata.c src/odbc/unittests/hidden.c: * src/odbc/unittests/insert_speed.c src/odbc/unittests/lang_error.c: * src/odbc/unittests/moreandcount.c src/odbc/unittests/norowset.c: * src/odbc/unittests/paramcore.c src/odbc/unittests/params.c: * src/odbc/unittests/prepare_results.c src/odbc/unittests/prepclose.c: * src/odbc/unittests/preperror.c src/odbc/unittests/print.c: * src/odbc/unittests/putdata.c src/odbc/unittests/raiserror.c: * src/odbc/unittests/rebindpar.c src/odbc/unittests/rownumber.c: * src/odbc/unittests/rowset.c src/odbc/unittests/rpc.c: * src/odbc/unittests/scroll.c src/odbc/unittests/t0001.c: * src/odbc/unittests/t0002.c src/odbc/unittests/t0003.c: * src/odbc/unittests/t0004.c src/odbc/unittests/tables.c: * src/odbc/unittests/test64.c src/odbc/unittests/testodbc.c: * src/odbc/unittests/timeout.c src/odbc/unittests/timeout2.c: * src/odbc/unittests/timeout3.c src/odbc/unittests/timeout4.c: * src/odbc/unittests/transaction.c src/odbc/unittests/transaction2.c: * src/odbc/unittests/typeinfo.c src/odbc/unittests/utf8.c: * src/odbc/unittests/utf8_2.c src/odbc/unittests/warning.c: * src/odbc/unittests/wchar.c: - introduced new CHK* macros and use them Fri Oct 31 15:35:00 CET 2008 Frediano Ziglio * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor5.c: * src/odbc/unittests/utf8.c src/odbc/unittests/utf8_2.c: - style updates, reuse macros Fri Oct 31 14:59:36 CET 2008 Frediano Ziglio * src/odbc/unittests/utf8.c src/odbc/unittests/utf8_2.c: - fix test for MSSQL * src/odbc/unittests/common.c src/odbc/unittests/cursor1.c: - reuse code Wed Oct 29 10:54:30 CET 2008 Frediano Ziglio * src/odbc/unittests/putdata.c: improve test for wide charaters Wed Oct 29 10:31:08 CET 2008 Frediano Ziglio * src/odbc/unittests/common.c src/odbc/unittests/common.h: * src/odbc/unittests/cursor1.c src/odbc/unittests/data.c: * src/odbc/unittests/genparams.c src/odbc/unittests/tables.c: * src/odbc/unittests/utf8.c src/odbc/unittests/utf8_2.c: - new function to read and check db version Wed Oct 29 09:41:42 CET 2008 Frediano Ziglio * src/tds/convert.c: fix small memory read overflow Tue Oct 28 13:50:30 CET 2008 Frediano Ziglio * src/tds/tds_checks.c: relax libTDS check Mon Oct 27 15:25:06 CET 2008 Frediano Ziglio * src/odbc/sql2tds.c src/odbc/unittests/genparams.c: - implement conversion from SQL_C_WCHAR to no char Mon Oct 27 15:21:50 CET 2008 Frediano Ziglio * TODO.freddy src/odbc/odbc.c src/odbc/unittests/getdata.c: - improve and fix test for SQLGetData and SQL_C_WCHAR - small fix for odbc_prret Fri Oct 24 10:27:54 CET 2008 Frediano Ziglio * TODO.freddy: update * src/odbc/sql2tds.c: fix SQL_NTS for SQL_C_WCHAR * src/odbc/sqlwchar.c: optimize * src/odbc/unittests/cancel.c: avoid valgrind error * src/odbc/unittests/genparams.c: - add check for SQL_NTS - add check for NUMERIC - add note - rename Test function to TestOutput Thu Oct 23 17:09:26 CET 2008 Frediano Ziglio * src/odbc/sql2tds.c src/odbc/unittests/genparams.c: - improve some conversions from SQL_C_WCHAR Thu Oct 23 17:05:03 CET 2008 Frediano Ziglio * TODO.freddy: updates * include/tdsodbc.h src/odbc/convert_tds2sql.c: - move ODBC_WIDE_NAME computation in include/tdsodbc.c Thu Oct 23 14:38:40 CET 2008 Frediano Ziglio * src/odbc/convert_tds2sql.c: - support conversions from SQL_C_WCHAR to fixed types Thu Oct 23 14:32:15 CET 2008 Frediano Ziglio * src/odbc/convert_tds2sql.c: - reduce some variable scope Thu Oct 23 10:01:23 CET 2008 Frediano Ziglio * src/odbc/unittests/data.c: - improve test Thu Oct 23 08:00:17 CET 2008 Frediano Ziglio * src/odbc/convert_tds2sql.c: - update correctly sqlgetdatapos - add some comments - destlen is always >= 0 (SQLULEN) Wed Oct 22 22:15:20 CET 2008 Frediano Ziglio * src/odbc/convert_tds2sql.c src/odbc/unittests/data.c: - support conversions from wire to SQL_C_WCHAR Wed Oct 22 17:21:18 CET 2008 Frediano Ziglio * src/odbc/odbc_util.c src/odbc/unittests/data.c: - initial SQL_C_WCHAR support Wed Oct 22 16:14:20 CET 2008 Frediano Ziglio * src/odbc/unittests/data.c: improve Fri Oct 17 14:20:00 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c src/odbc/unittests/cancel.c: * src/odbc/unittests/hidden.c: - reuse CHK macro Fri Oct 17 11:36:45 CET 2008 Frediano Ziglio * include/tds.h src/tds/mem.c src/tds/token.c: - make it compile without --enable-developing Fri Oct 17 10:55:56 CET 2008 Frediano Ziglio * src/odbc/convert_tds2sql.c src/odbc/odbc.c: - enable wide characters from server Fri Oct 17 10:37:25 CET 2008 Frediano Ziglio * include/tdsiconv.h src/tds/iconv.c: - add tds_iconv_get to allow multiple client charsets Fri Oct 17 10:26:55 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/convert_tds2sql.c src/odbc/odbc.c: * src/odbc/odbc_util.c: - allow SQL_NO_TOTAL from odbc_tds2sql Fri Oct 17 10:13:19 CET 2008 Frediano Ziglio * src/odbc/odbc.c: rollback SQLGetData changes to 1.481 Fri Oct 17 10:05:00 CET 2008 Frediano Ziglio * src/odbc/unittests/genparams.c: - use #ifdef ENABLE_DEVELOPING for truncation test Thu Oct 16 16:09:45 CET 2008 Frediano Ziglio * src/odbc/prepare_query.c: small optimization Thu Oct 16 16:08:40 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: make it works Thu Oct 16 13:26:27 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/convert_tds2sql.c src/odbc/odbc.c: * src/odbc/odbc_util.c: - move column_text_sqlgetdatapos logic to odbc_tds2sql Wed Oct 15 16:51:05 CET 2008 Frediano Ziglio * src/odbc/unittests/utf8_2.c: error message more verbose Mon Oct 06 15:43:03 CET 2008 Frediano Ziglio * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: * src/tds/iconv.c src/odbc/unittests/utf8_2.c(added): - fixed string truncation with charset with shift state Thu Oct 01 10:06:13 CET 2008 Frediano Ziglio * src/replacements/basename.c src/replacements/gettimeofday.c: - remove wrong comments Thu Sep 25 10:05:40 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: - rollback changes, our version, was correct Fri Sep 19 15:37:40 CET 2008 Frediano Ziglio * src/tds/Makefile.am: fix compile Thu Sep 18 10:50:48 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/convert_tds2sql.c src/odbc/odbc.c: * src/odbc/odbc_util.c: - more error set in odbc_tds2sql Thu Sep 18 10:17:49 CET 2008 Frediano Ziglio * src/tds/token.c: reduce use of #if Wed Sep 17 13:25:51 CET 2008 Frediano Ziglio * src/odbc/odbc.c: typo error Wed Sep 17 14:14:15 CET 2008 Frediano Ziglio * src/tds/.cvsignore src/tds/Makefile.am src/tds/convert.c: * src/tds/data.c src/tds/read.c src/tds/types.pl(added): - autogenerate some functions based on types.txt Sun Sep 14 09:44:55 CET 2008 Frediano Ziglio * include/tds.h src/odbc/odbc.c src/tds/mem.c src/tds/token.c: - renamed TDSSOCKET->no_data_conv to TDSSOCKET->use_iconv Sat Sep 13 09:18:17 CET 2008 Frediano Ziglio * src/tds/token.c: fix compile if no --enable-development Fri Sep 12 17:05:54 CET 2008 Frediano Ziglio * include/tds.h src/tds/config.c src/tds/token.c: - removed is_binary_type macro, not used anymore - removed broken_money setting, not used - added no_data_conv to disable data conversions * src/odbc/odbc.c src/odbc/unittests/data.c: - updated to support no_data_conv Thu Sep 11 17:07:10 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/convert_tds2sql.c src/odbc/odbc.c: * src/odbc/odbc_util.c src/odbc/prepare_query.c src/odbc/sql2tds.c: - renamed sql2tds -> odbc_sql2tds and convert_tds2sql -> odbc_tds2sql Wed Sep 10 13:36:48 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/sql2tds.c: - avoid useless buffer allocations Wed Sep 10 13:19:53 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: * src/odbc/prepare_query.c src/odbc/sql2tds.c: - move odbc_convert_err_set in odbc_util and reuse it - improve sql2tds error handling Tue Sep 09 16:53:54 CET 2008 Frediano Ziglio * src/odbc/sql2tds.c: be coherent about constants Tue Sep 09 16:41:08 CET 2008 Frediano Ziglio * src/ctlib/unittests/common.c src/dblib/unittests/common.c: * src/odbc/unittests/common.c src/tds/unittests/common.c: - allow to override PWD file path using TDSPWDFILE environment Mon Sep 08 21:21:57 CET 2008 Frediano Ziglio * src/odbc/unittests/utf8.c: test with small column sizes * src/tds/query.c: fix column size preparing Mon Sep 8 13:49:19 EDT 2008 JK Lowden * include/cspublic.h fix #define of BLK_VERSION_110 Thu Sep 04 08:42:56 CET 2008 Frediano Ziglio * src/odbc/prepare_query.c src/odbc/sql2tds.c: - fill on_server.column_size * src/odbc/unittests/genparams.c: test for truncation * src/tds/query.c: do not send invalid sizes Mon Sep 01 17:16:05 CET 2008 Frediano Ziglio * src/odbc/unittests/genparams.c: - reproduce bug detected by Sebastien Flaesch on column size computation for NVARCHAR Fri Aug 29 16:18:44 CET 2008 Frediano Ziglio * src/odbc/unittests/genparams.c: update test Wed Aug 27 09:57:20 CET 2008 Frediano Ziglio * src/odbc/unittests/rowset.c: - don't test for cursors if not implemented Wed Aug 27 09:43:45 CET 2008 Frediano Ziglio * src/odbc/unittests/data.c: - don't test nvarchar if Sybase Wed Aug 27 09:27:49 CET 2008 Frediano Ziglio * src/ctlib/unittests/common.c: allow empty password on tests Tue Aug 26 16:11:05 CET 2008 Frediano Ziglio * src/ctlib/cs.c: - applied Andrew Victor patch for unused gmtime result Fri Aug 22 07:25:58 CET 2008 Frediano Ziglio * src/tds/query.c: - applied modified patch from Chris Reeves for fix tds_send_emulated_execute if no parameters Mon Aug 18 15:30:45 CET 2008 Frediano Ziglio * include/tdsbytes.h include/tdsodbc.h src/apps/tsql.c: * src/dblib/dblib.c src/odbc/connectparams.c: * src/odbc/convert_tds2sql.c src/odbc/error.c: * src/odbc/odbc.c src/odbc/odbc_checks.c: * src/odbc/odbc_util.c src/odbc/prepare_query.c: * src/odbc/sql2tds.c src/tds/challenge.c: * src/tds/config.c src/tds/log.c src/tds/login.c: * src/tds/mem.c src/tds/net.c src/tds/numeric.c: * src/tds/query.c src/tds/token.c: - update copyright Mon Aug 18 09:17:26 CET 2008 Frediano Ziglio * misc/freetds_autobuild: update DBD::ODBC Sun Aug 17 22:45:47 CET 2008 Frediano Ziglio * src/odbc/connectparams.c: - skip empty options in SQLDriverConnect to make DBD::ODBC happy Sun Aug 17 09:44:29 CET 2008 Frediano Ziglio * src/ctlib/ctutil.c src/dblib/dbutil.c src/odbc/unittests/utf8.c: - remove some warnings Sun Aug 17 09:26:47 CET 2008 Frediano Ziglio * src/odbc/odbc.c: rollback change to make blob1 test work again Sat Aug 16 20:08:03 CET 2008 Frediano Ziglio * src/tds/query.c: do not loose sync on conversion errors Sat Aug 16 16:47:21 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/odbc_util.c src/odbc/sql2tds.c: - allow SQL_WCHAR/SQL_WVARCHAR * src/odbc/unittests/Makefile.am src/odbc/unittests/utf8.c: - add test for utf-8 encoding on client Fri Aug 15 11:55:05 CET 2008 Frediano Ziglio * src/ctlib/unittests/Makefile.am: - make win64 compile again Fri Aug 15 10:12:34 CET 2008 Frediano Ziglio * doc/userguide.sgml: remove strange characters Fri Aug 15 00:42:28 EDT 2008 JK Lowden * doc/Makefile.am doc/userguide.dsl.in doc/userguide.sgml - Generate UTF-8 output with content-type header Thu Aug 14 11:14:21 CET 2008 Frediano Ziglio * doc/userguide.sgml: make openjade happy Thu Aug 14 10:48:38 CET 2008 Frediano Ziglio * include/tds.h src/tds/config.c: - add "asa database" option to specify ASA database Wed Aug 13 15:06:17 EDT 2008 JK Lowden * doc/userguide.sgml advice about unicode strings * src/dblib/dblib.c tdserror for setting invalid TDS version Wed Aug 13 00:08:28 EDT 2008 JK Lowden * src/tds/iconv.c clarified log messages Thu Aug 07 12:05:03 CET 2008 Frediano Ziglio * src/tds/net.c: small network optimization Thu Aug 07 09:17:58 CET 2008 Frediano Ziglio * src/tds/challenge.c: use NTLMv2 if possible Wed Aug 06 09:32:32 CET 2008 Frediano Ziglio * src/tds/config.c src/tds/login.c src/tds/mem.c src/tds/token.c: - keep packet size to safe values Thu Jul 31 16:53:35 CET 2008 Frediano Ziglio * src/tds/challenge.c: removed important FIXMEs Thu Jul 31 06:12:05 EDT 2008 JK Lowden * doc/tds.html: updated and cleaned up somewhat Wed Jul 30 23:25:26 CET 2008 Frediano Ziglio * src/tds/challenge.c: additional cleanup and notes Wed Jul 30 16:36:52 CET 2008 Frediano Ziglio * src/tds/challenge.c: - merged patch #2031829 about NTLMv2, still some FIXME/TODO Wed Jul 30 10:05:02 CET 2008 Frediano Ziglio * include/Makefile.am: add missing header for hmac Wed Jul 30 10:01:14 CET 2008 Frediano Ziglio * include/hmac_md5.h(added) src/tds/hmac_md5.c(added): * src/tds/Makefile.am: - added needed hmac code for NTLMv2 Tue Jul 29 09:54:23 EDT 2008 JK Lowden * src/ctlib/ct.c: - patch from ML on 29 July 2008 from Andrew Victor - re BLOBs as parameters Mon Jul 28 16:56:36 EDT 2008 JK Lowden * samples/odbc_rpc.pl src/odbc/error.c src/odbc/odbc.c: - tracking down SQLParamData behavior Thu Jul 24 18:02:52 EDT 2008 JK Lowden * samples/odbc_rpc.pl: * src/odbc/odbc.c src/odbc/prepare_query.c src/tds/net.c: - test parameter binding with SQL_LONGVARCHAR Wed Jul 23 16:05:41 EDT 2008 JK Lowden * src/odbc/error.c src/odbc/odbc.c: - record error in log and remove some redundant logging of - entry into static functions Thu Jul 17 13:51:07 CET 2008 Frediano Ziglio * INSTALL INSTALL.CVS Makefile.am TODO vms/config_h.vms: * win32/config.h: - updated due to file rename Thu Jul 17 07:37:28 CET 2008 Frediano Ziglio * TODO: updated Wed Jul 16 09:36:42 CET 2008 Frediano Ziglio * src/odbc/unittests/cursor6.c src/odbc/unittests/cursor7.c: - fixed for Sybase Tue Jul 15 17:20:38 CET 2008 Frediano Ziglio * src/tds/token.c: some code for mssql2005 Tue Jul 15 17:13:42 CET 2008 Frediano Ziglio * src/odbc/unittests/genparams.c: improved for WCHARs Tue Jul 15 11:52:45 CET 2008 Frediano Ziglio * src/ctlib/unittests/datafmt.c src/odbc/sql2tds.c: * src/dblib/unittests/rpc.c: - remove warnings Tue Jul 15 11:51:59 CET 2008 Frediano Ziglio * misc/freetds_autobuild: from version 0.82 do all tests Mon Jul 14 17:09:56 CET 2008 Frediano Ziglio * TODO.freddy src/odbc/odbc.c src/odbc/odbc_util.c: - small improves for SQLWCHAR support Mon Jul 14 09:49:12 EDT 2008 JK Lowden * src/odbc/odbc_util.c added two symbols to a switch Mon Jul 14 15:06:19 CET 2008 Frediano Ziglio * src/odbc/unittests/data.c: improve for nvarchar Mon Jul 14 10:14:29 CET 2008 Frediano Ziglio * src/odbc/prepare_query.c src/odbc/sql2tds.c: - minor SQLWCHAR improves Fri Jul 11 11:25:28 CET 2008 Frediano Ziglio * src/odbc/unittests/data.c src/odbc/unittests/genparams.c: - make some tests run even on mssql2005 - add initial test for NVARCHAR Fri Jul 11 11:25:28 CET 2008 Frediano Ziglio * src/tds/login.c: cleanup Wed Jul 9 05:34:20 EDT 2008 JK Lowden * src/tds/token.c use locally provided server name correctly Tue Jul 8 15:38:37 EDT 2008 JK Lowden * src/dblib/dblib.c: don't dereference a NULL dbproc. Tue Jul 8 13:02:14 EDT 2008 JK Lowden * include/tds.h src/tds/token.c: - use locally provided server name if the error message - packet doesn't include one. Tue Jul 08 10:46:04 CET 2008 Frediano Ziglio * src/pool/stream.c: remove memory leak Tue Jul 08 10:44:57 CET 2008 Frediano Ziglio * include/tds.h: add new constants for mssql2005 Tue Jul 08 10:39:12 CET 2008 Frediano Ziglio * src/ctlib/unittests/Makefile.am: make win32 happy Mon Jul 7 17:42:00 EDT 2008 JK Lowden * src/ctlib/unittests/Makefile.am link statically Mon Jul 7 14:27:28 EDT 2008 JK Lowden * src/apps/tsql.c added -v to print instance information Mon Jul 07 15:16:09 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: make it works with MS ODBC Mon Jul 07 13:23:52 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/Makefile.am src/odbc/sql2tds.c: - start wchar support Mon Jul 07 13:09:20 CET 2008 Frediano Ziglio * src/ctlib/unittests/common.c: make portable to win32 * src/odbc/prepare_query.c: add small comment Sun Jul 6 12:25:38 EDT 2008 JK Lowden * src/ctlib/unittests/Makefile.am src/ctlib/unittests/common.c * src/ctlib/unittests/common.h - unit tests accept command-line options * src/ctlib/unittests/datafmt.c added Sat Jul 5 18:52:45 EDT 2008 JK Lowden * include/cspublic.h src/ctlib/cs.c src/ctlib/ct.c * src/ctlib/unittests/Makefile.am src/ctlib/unittests/common.c * src/ctlib/unittests/datafmt.c - cs_convert sets output resultlen even when dest is too small. * src/odbc/prepare_query.c src/odbc/unittests/blob1.c - make it compile.... Fri Jul 4 16:59:48 EDT 2008 JK Lowden * include/tds.h src/odbc/odbc.c - src/odbc/prepare_query.c src/odbc/unittests/blob1.c - Applied patch from ML Suren A. Chiling 3 July 2008 * src/tds/query.c fixed warning and formatting * TODO added NetBSD note * src/dblib/dblib.c NTBSTRINGBIND attempt Tue Jun 25 13:54:29 CET 2008 Frediano Ziglio * src/odbc/unittests/cursor7.c: cleanup Wed Jun 18 11:05:19 CET 2008 Frediano Ziglio * include/tds.h src/odbc/odbc.c src/odbc/unittests/cursor7.c: * src/tds/query.c: - applied Daniel A. Veiga patch for SQL_ATTR_ROW_NUMBER (sligtly modified) Wed Jun 11 23:26:34 EDT 2008 JK Lowden * src/odbc/unittests/Makefile.am * src/odbc/unittests/cursor7.c (added) - test for fetching overlapping batches Wed Jun 11 23:07:29 EDT 2008 JK Lowden * src/odbc/odbc.c src/odbc/unittests/getdata.c - Applied patch from Suren A. Chilingaryan cf. - ML on 10 June 2008 Sat Jun 7 17:52:24 EDT 2008 JK Lowden * src/dblib/dblib.c src/dblib/rpc.c src/dblib/unittests/rpc.c * src/tds/convert.c - small improvements to style, logging, and error messages Thu Jun 05 18:21:25 CET 2008 Frediano Ziglio * src/odbc/odbc.c: - fix cursor6 test - SQLFetch odbc 2 compliant Thu Jun 05 18:08:29 CET 2008 Frediano Ziglio * src/odbc/unittests/cursor6.c(added): - added new test Fri May 30 17:47:59 EDT 2008 JK Lowden * include/cspublic.h - applied ML patch of 19 May 2008 for BLK_VERSION for sqsh Wed May 28 23:08:23 CET 2008 Frediano Ziglio * src/server/server.c: fix possible NULL access Wed May 28 22:08:36 CET 2008 Frediano Ziglio * src/apps/freebcp.c src/apps/tsql.c: - fix minor memory leaks Wed May 28 09:41:16 EDT 2008 JK Lowden * configure.ac src/apps/tsql.c - reset getopt(3) portably Tue May 27 18:21:46 EDT 2008 JK Lowden * include/tds.h include arpa/inet.h Tue May 27 10:23:00 CET 2008 Frediano Ziglio * src/apps/tsql.c: compile fix * src/tds/numeric.c: add test to avoid future buffer overflows Tue May 27 10:00:44 CET 2008 Frediano Ziglio * include/tds.h: fix possible buffer overflow Mon May 26 15:56:10 CET 2008 Frediano Ziglio (mostly from Coverity reports) * include/tdsbytes.h: remove warning * src/apps/tsql.c src/dblib/bcp.c src/dblib/dblib.c: - remove some leaks * src/tds/mem.c: avoid deference of null pointer Wed May 21 23:51:21 EDT 2008 JK Lowden * src/odbc/unittests/common.c * vms/config_h.vms vms/descrip_mms.template - applied ML patch from Craig A. Berry Wed May 21 21:13:31 EDT 2008 JK Lowden * TODO doc/api_status.txt src/ctlib/ct.c - Blindly applied suggestion from S. Magne on ML - to fix ct_cancel for CS_CANCEL_ALL Thu May 15 11:43:18 EDT 2008 JK Lowden * configure.ac corrected odbc_nodm help string Tue May 13 10:02:37 EDT 2008 JK Lowden * doc/htdoc/faq.html added libtds.so question Sun May 11 19:40:29 EDT 2008 Nick Castellano * src/replacements/readpassphrase.c: - cast to unsigned char when calling ctype macros Fri May 9 14:47:15 EDT 2008 JK Lowden * src/apps/osql handles 'server = ipaddr' in odbc.ini Thu May 8 14:29:50 EDT 2008 JK Lowden * doc/Makefile.am s/nobase_data/noinst/ per jlam on ML Wed May 7 10:41:43 CET 2008 Frediano Ziglio * include/Makefile.am include/odbcss.h(added) src/odbc/error.c: - added new odbcss.h to support some constants Tue May 6 13:41:32 EDT 2008 JK Lowden * doc/userguide.sgml updated links to external docs Mon May 5 20:11:58 EDT 2008 JK Lowden * include/cstypes.h src/ctlib/ct.c - applied CS_BIGINT patch from Stephen Degler Fri May 02 12:03:47 CET 2008 Frediano Ziglio * src/tds/log.c: fixed printf format problem Wed Apr 30 10:07:37 EDT 2008 JK Lowden * src/dblib/dblib.c added missing break to nested switch - in _dbresults Thu Apr 29 16:54:49 CET 2008 Frediano Ziglio * src/odbc/odbc.c: typo error Thu Apr 24 11:57:24 EDT 2008 JK Lowden * doc/htdoc/faq.html small clarifications Wed Apr 23 17:25:58 EDT 2008 JK Lowden * src/apps/bsqldb.c removed spurious 0xA0 from output * src/odbc/odbc.c add error diagnostic to SQLGetData * include/tds.h src/tds/log.c src/tds/login.c * src/tds/token.c - add tdsdump_col() Sun Mar 23 16:55:08 EDT 2008 JK Lowden * doc/userguide.sgml clarified localization Sun Mar 23 13:14:05 EDT 2008 JK Lowden * configure.ac doc/Makefile.am - applied ML patches from Johnny C. Lam for callout locations - and gnutls test Thu Mar 13 14:22:28 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/error.c: - make errs offset constant in all odbc structures to make error.c simpler - support SQL_HANDLE_DESC in SQLGetDiagField * src/odbc/odbc.c: remove TODO comment * src/odbc/odbc_checks.c: typo Wed Mar 12 15:25:11 CET 2008 Frediano Ziglio * src/odbc/error.c: check proper handle type Wed Mar 12 14:53:50 CET 2008 Frediano Ziglio * src/odbc/odbc.c: handle SQL_TIMESTAMP like SQL_TYPE_TIMESTAMP Wed Mar 12 14:34:21 CET 2008 Frediano Ziglio * src/odbc/odbc.c: fix auto-commit set * src/odbc/unittests/common.c src/odbc/unittests/common.h: - make possible to override connection attributes * src/odbc/unittests/transaction2.c: - improve Tue Mar 11 09:42:04 CET 2008 Frediano Ziglio * src/odbc/odbc.c: fix auto-commit off before connection Tue Mar 11 09:36:11 CET 2008 Frediano Ziglio * src/tds/encodings.pl: fix a problem with cvs and branches Fri Mar 07 16:40:16 CET 2008 Frediano Ziglio * src/odbc/unittests/transaction2.c: improved Fri Mar 07 11:57:00 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am: * src/odbc/unittests/transaction2.c(added): - transaction level support Fri Mar 07 09:55:57 CET 2008 Frediano Ziglio * doc/tds.html: updated Wed Mar 05 12:0:43 CET 2008 Frediano Ziglio * win32/build_dsw.pl: change some build options Fri Feb 29 11:50:06 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am src/odbc/unittests/rowset.c(added): - ported tests and SQL_ROWSET_SIZE fix Thu Feb 28 18:24:31 EST 2008 JK Lowden * doc/htdoc/news.html announced 0.82RC2 * vms/configure.com turn off iconv by default Wed Feb 20 09:04:58 CET 2008 Frediano Ziglio * src/tds/convert.c: avoid duplicate case Fri Feb 15 11:25:46 EST 2008 JK Lowden * src/dblib/dblib.c src/tds/convert.c - support SYBUNIQUE printable width Fri Feb 15 12:05:48 CET 2008 Frediano Ziglio * src/odbc/odbc.c: fix SQL_ATTR_CONNECTION_DEAD Fri Feb 15 11:53:41 CET 2008 Frediano Ziglio * configure.ac: fix nasty problem with HP-UX Wed Feb 13 09:50:35 CET 2008 Frediano Ziglio * src/apps/bsqlodbc.c: fix memory error * src/tds/query.c: remove possible buffer underflow * src/odbc/unittests/test64.c: truncate upper part for low Fri Feb 08 10:26:36 CET 2008 Frediano Ziglio * src/odbc/unittests/Makefile.am src/odbc/unittests/describecol.in: * src/odbc/unittests/params.c src/odbc/unittests/putdata.c: * src/odbc/unittests/raiserror.c src/odbc/unittests/rownumber.c: * src/odbc/unittests/t0001.c src/odbc/unittests/t0002.c: * src/odbc/unittests/testodbc.c src/odbc/unittests/timeout3.c: - more reuse and unification Fri Feb 08 09:30:48 CET 2008 Frediano Ziglio * src/odbc/unittests/rpc.c: reuse code and macros Wed Feb 06 09:28:55 CET 2008 Frediano Ziglio * src/odbc/unittests/testodbc.c: simplify Wed Feb 06 09:27:10 CET 2008 Frediano Ziglio * src/odbc/unittests/rpc.c src/odbc/unittests/cursor5.c: * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor3.c: - use printf instead of fprintf(stdout...) Tue Feb 05 15:59:04 CET 2008 Frediano Ziglio * src/tds/unittests/t0007.c: - improve SYBINT8 conversions testing Mon Feb 04 08:49:58 CET 2008 Frediano Ziglio * src/tds/convert.c: fix silly memory leak Thu Jan 21 10:12:42 CET 2008 Frediano Ziglio * src/odbc/unittests/convert_error.c src/odbc/unittests/genparams.c: - more reuse Tue Jan 29 15:28:32 CET 2008 Frediano Ziglio * src/odbc/unittests/array_out.c src/odbc/unittests/common.c: * src/odbc/unittests/common.h src/odbc/unittests/compute.c: * src/odbc/unittests/connect2.c src/odbc/unittests/const_params.c: * src/odbc/unittests/copydesc.c src/odbc/unittests/cursor1.c: * src/odbc/unittests/cursor2.c src/odbc/unittests/cursor3.c: * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: * src/odbc/unittests/data.c src/odbc/unittests/date.c: * src/odbc/unittests/error.c src/odbc/unittests/funccall.c: * src/odbc/unittests/genparams.c src/odbc/unittests/getdata.c: * src/odbc/unittests/hidden.c src/odbc/unittests/lang_error.c: * src/odbc/unittests/moreandcount.c src/odbc/unittests/norowset.c: * src/odbc/unittests/params.c src/odbc/unittests/prepare_results.c: * src/odbc/unittests/print.c src/odbc/unittests/putdata.c: * src/odbc/unittests/raiserror.c src/odbc/unittests/rebindpar.c: * src/odbc/unittests/scroll.c src/odbc/unittests/t0001.c: * src/odbc/unittests/t0002.c src/odbc/unittests/t0003.c: * src/odbc/unittests/t0004.c src/odbc/unittests/tables.c: * src/odbc/unittests/test64.c src/odbc/unittests/timeout.c: * src/odbc/unittests/timeout2.c src/odbc/unittests/timeout4.c: * src/odbc/unittests/transaction.c src/odbc/unittests/typeinfo.c: * src/odbc/unittests/warning.c: - reuse reuse reuse! Tue Jan 29 10:34:41 CET 2008 Frediano Ziglio * src/odbc/convert_tds2sql.c src/odbc/odbc.c src/odbc/odbc_util.c: * src/odbc/unittests/getdata.c: - handle errors from convert_tds2sql Sun Jan 27 18:35:55 CET 2008 Frediano Ziglio * src/odbc/odbc.c: - implemented SQL_ATTR_CONNECTION_DEAD Thu Jan 24 22:14:31 CET 2008 Frediano Ziglio * src/dblib/dblib.c src/tds/vstrbuild.c: - va_list cleanups Thu Jan 24 22:01:41 CET 2008 Frediano Ziglio * src/odbc/unittests/describecol.in: - some additional tests Mon Jan 21 16:33:58 CET 2008 Frediano Ziglio * src/odbc/odbc_util.c: - merge fix for date/time from Dann Corbit Sun Jan 20 17:36:34 CET 2008 Frediano Ziglio * src/odbc/connectparams.c: remove warning Sun Jan 20 15:23:16 CET 2008 Frediano Ziglio * configure.ac include/tds_sysdep_private.h: * include/tds_sysdep_public.h.in src/apps/Makefile.am: * src/ctlib/unittests/cancel.c src/dblib/unittests/timeout.c: * src/odbc/unittests/describecol.c src/replacements/iconv.c: * src/tds/query.c win32/tds_sysdep_public.h win32/winlogin.c: * win32/winsetup.c: - port to win64 Fri Jan 18 14:33:09 CET 2008 Frediano Ziglio * include/tds.h src/odbc/connectparams.c src/tds/config.c: - merge Sebastien Flaesch patch for ODBC parameters - add ClientCharset, DumpFile, DumpFileAppend, DebugFlags, Encryption - rewrote ODBCINSTGetProperties Thu Jan 17 17:44:43 EST 2008 JK Lowden * doc/htdoc/news.html announce 0.82RC1 Thu Jan 17 7:56:02 CET 2008 Frediano Ziglio * src/tds/net.c: do not dump received header Mon Jan 14 20:20:31 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/odbc.c: - handle SQLCancel in signal handlers Sun Jan 13 20:59:55 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/cancel.c src/tds/token.c: - detect cancellation and add proper error - remove errors from cancel test Sat Jan 12 1:13:30 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: small fix for 64bit * src/tds/net.c: fix for heavy loads Fri Jan 11 13:42:06 CET 2008 Frediano Ziglio * configure.ac src/apps/tsql.c: - fix compile problem for MacOSX Fri Jan 11 10:42:58 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: make it work with Sybase * configure.ac: test for poll function Fri Jan 11 9:29:44 CET 2008 Frediano Ziglio * README: merged Thu Jan 10 17:55:41 EST 2008 JK Lowden * include/tds_sysdep_private.h src/tds/net.c - moved some preprocessor logic to the header file * INSTALL.CVS NEWS TODO doc/userguide.sgml - updated documentation Thu Jan 10 22:19:26 CET 2008 Frediano Ziglio * src/odbc/unittests/cancel.c src/odbc/unittests/hidden.c: - memory fixes Thu Jan 10 17:04:15 CET 2008 Frediano Ziglio * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: * src/odbc/unittests/cancel.c(added): - add test for SQLCancel Thu Jan 10 16:28:44 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c src/odbc/unittests/cursor3.c: * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: - use temporary tables Thu Jan 10 16:25:19 CET 2008 Frediano Ziglio * doc/README.releasing misc/freetds_autobuild: updates Thu Jan 10 14:10:28 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am src/odbc/unittests/blob1.c(added): - fix problem with SQLGetData and blobs Thu Jan 10 09:46:41 CET 2008 Frediano Ziglio * TODO src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am: - small fix for hidden fields (ignore them entirely) Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release $FreeTDS$ $Id: ChangeLog,v 1.3205.2.42 2011/08/12 16:29:36 freddy77 Exp $ freetds-0.91/INSTALL100664 001750 000144 00000017305 11037631201 0007630$Id: INSTALL,v 1.6 2008/07/17 11:52:33 freddy77 Exp $ FreeTDS Installation For complete instructions, see the FreeTDS Users Guide. It is included in the distribution as "doc/userguide.tgz"; simply untar 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. ------ These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' is used to create `configure' by a program called `autoconf'. You only need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. Type ./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. For more information, try "./configure --help". Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. freetds-0.91/NEWS100644 001750 000144 00000047624 11557651000 0007311$Id: NEWS,v 1.44.4.3 2011/05/03 00:53:20 jklowden Exp $ 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-0.91/TODO100664 001750 000144 00000015175 11444110611 0007271This 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 $Id: TODO,v 1.176 2010/09/15 09:27:37 freddy77 Exp $ ------------ Bug? ML 2007-05-30 "dbsqlexec() never returns" tds_send_cancel in tds_goodwrite (wrong??) BUG: sending ICONV charset name, not TDS name in 5.0 login packet. 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)" Broken: . Passing invalid character set names to server with tsql? tsql (and so libTDS) can pass invalid charset names to Sybase libTDS assume Sybase can handle this charset but it's false and doesn't convert correctly. Work in progress: . log and call error handler on problems with tds_iconv_init(). . iconv - support string conversions for Sybase . add doc/htdoc/Makefile with "publish" target to commit cvs and update freetds.org . drop txt2man from cvs, skip building man pages without it. . be able to disable iconv for BCP (see Sybase documentation) For future versions (in priority order within library): All: . 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. . create "TDSVER=auto": try 7.2, 7.1, 7.0, 5.0, 4.2 (in that order)? Must support instance names, too, and tsql should report progress in verbose mode. Currently supported using TDSVER=0.0, check for instances, tsql do not say nothing. Also cache detection somewhere . move error message macro/prototype to tds.h.in; use in dblib.c. . Add missing constants needed for python and verify working . Add missing constants needed for Gnome-DB and verify working . conversion from ucs2 to utf8, provide for 2+ bytes/character . Finish off the TDS dissector for ethereal . more solid. handle out of memory conditions (started, we must test all allocation and all function that return allocated data and be able to rollback to a safe state) . optimize numeric conversions (partial, handle numeric->int and similar directly) change precision (multiply/divide by 10^n) and extract number checking overflow/underflow change precision done (numeric.c) numeric done, 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?) . review the way parameters are packed (too complicate, see ctlib bulk, cf "bulk copy and row buffer") . improve cursor support on dblib and ctlib . support for NT named pipe (requested long ago for mssql6.5 server, only for completeness). If the reader knows a library to handle named pipes compatible with LGPL please tell us. . 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 . new mssql2005 protocol . new mssql2008 types 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 . 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) . SQLDescribeParam (Sybase seems to require it) A 100% success for DBD::ODBC require this . change ODBC_RETURN to return errs.lastrc (not to set) and use errs.lastrc to store error, cache some errors (truncated output) optimize ODBC_RETURN (remove useless) . handle no termination on odbc_set_string* . handle async flags ?? . 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? . 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, especially for TDS 5.0/7.0 Done freetds-0.91/compile100555 001750 000144 00000007271 11561614472 0010167#! /bin/sh # Wrapper for compilers which do not understand `-c -o'. scriptversion=2009-10-06.20; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 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 # . 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 $? ;; esac ofile= cfile= eat= 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-0.91/config.guess100555 001750 000144 00000127637 11561614472 0011142#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. timestamp='2009-12-30' # 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 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. # # 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 Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # 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;hb=HEAD 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 (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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 # 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 tupples: *-*-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=`(/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 ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in 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 # 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/[-_].*/\./'` ;; 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}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${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 ;; 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'` exit ;; 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:*:[456]) 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/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` 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:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 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-gnu`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 '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix 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="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${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-gnu else echo ${UNAME_MACHINE}-unknown-linux-gnueabi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu 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-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu 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-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu 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 configury 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 ;; 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 ;; 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 case $UNAME_PROCESSOR in i386) eval $set_cc_for_build 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 UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac 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 ;; 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 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp 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` /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-0.91/config.rpath100775 001750 000144 00000043647 11106641605 0011125#! /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=/' <. Submit a context # diff and a properly formatted GNU ChangeLog entry. # # 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;hb=HEAD # 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 $0 [OPTION] 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 (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) 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*) 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 \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | 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 \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | rx \ | score \ | 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 \ | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-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-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | 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-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | 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-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | 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 ;; 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 ;; 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) 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 ;; 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'm not sure what "Sysv32" means. Should this be sysv3.2? 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 ;; 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 ;; mingw32) basic_machine=i386-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 ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; 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 ;; 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) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) 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 | ppc64-le | powerpc64-little) 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) 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 ;; 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 ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tile*) basic_machine=tile-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 ;; 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* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -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* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -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*) # 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 ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -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 ;; # 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 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; 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 ;; *-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-0.91/depcomp100555 001750 000144 00000044267 11561614472 0010174#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 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 outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac 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" # 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 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 -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## 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). ## - 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 -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## 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. tr ' ' ' ' < "$tmpdepfile" | ## 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. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -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 -eq 0; then : else 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 ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; 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. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 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 -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else 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. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 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 -eq 0; then : else 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,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#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. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # 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.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #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:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. 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" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. 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:: \1 \\:p' >> "$depfile" echo " " >> "$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-0.91/install-sh100775 001750 000144 00000012720 07361676256 0010627#!/bin/sh # # 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. It can only install one file at a time, a restriction # shared with many OS's install programs. # 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. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true 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 $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | 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 $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $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 $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 freetds-0.91/ltmain.sh100555 001750 000144 00000733110 11561614465 0010434# Generated from ltmain.m4sh. # ltmain.sh (GNU libtool) 2.2.6b # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --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 # --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 informational messages (default) # --version print version information # -h, --help print short or 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. # 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) # $progname: (GNU libtool) 2.2.6b # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . PROGRAM=ltmain.sh PACKAGE=libtool VERSION=2.2.6b TIMESTAMP="" package_revision=1.3017 # 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 # NLS nuisances: We save the old values to restore during execute mode. # Only set LANG and LC_ALL to C if already set. # These must not be set unconditionally because not all systems understand # e.g. LANG=C (notably SCO). lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done $lt_unset CDPATH unset CP unset MV unset RM : ${CP="cp -f"} : ${ECHO="echo"} : ${EGREP="/bin/grep -E"} : ${FGREP="/bin/grep -F"} : ${GREP="/bin/grep"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SED="/bin/sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: 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. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # 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" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } # Generated shell functions inserted here. # 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: # In the unlikely event $progname began with a '-', it would play havoc with # func_echo (imagine progname=-n), so we prepend ./ in that case: func_dirname_and_basename "$progpath" progname=$func_basename_result case $progname in -*) progname=./$progname ;; esac # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=: for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to 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 '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname${mode+: }$mode: $*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && 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_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` done my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_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 "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "X$my_tmpdir" | $Xsed } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # 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 () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "X$1" | $Xsed \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_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. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent 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 () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent 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 () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_version # Echo version message to standard output and exit. func_version () { $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $SED -n '/^# Usage:/,/# -h/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" $ECHO $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help # Echo long help message to standard output and exit. func_help () { $SED -n '/^# Usage:/,/# Report bugs to/ { s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ p }' < "$progpath" exit $? } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { func_error "missing argument for $1" exit_cmd=exit } exit_cmd=: # Check that we have a working $ECHO. if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then # Yippee, $ECHO works! : else # Restart under the correct shell, and then maybe $ECHO will work. exec $SHELL "$progpath" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat </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 } # Parse options once, thoroughly. This comes as soon as possible in # the script to make things like `libtool --version' happen quickly. { # 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 # Parse non-mode specific arguments: while test "$#" -gt 0; do opt="$1" shift case $opt in --config) func_config ;; --debug) preserve_args="$preserve_args $opt" func_echo "enabling shell trace mode" opt_debug='set -x' $opt_debug ;; -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break execute_dlfiles="$execute_dlfiles $1" shift ;; --dry-run | -n) opt_dry_run=: ;; --features) func_features ;; --finish) mode="finish" ;; --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break 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 $opt" exit_cmd=exit break ;; esac mode="$1" shift ;; --preserve-dup-deps) opt_duplicate_deps=: ;; --quiet|--silent) preserve_args="$preserve_args $opt" opt_silent=: ;; --verbose| -v) preserve_args="$preserve_args $opt" opt_silent=false ;; --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break preserve_args="$preserve_args $opt $1" func_enable_tag "$1" # tagname is set here shift ;; # Separate optargs to long options: -dlopen=*|--mode=*|--tag=*) func_opt_split "$opt" set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} shift ;; -\?|-h) func_usage ;; --help) opt_help=: ;; --version) func_version ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) nonopt="$opt" break ;; esac done case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_duplicate_deps ;; esac # Having warned about all mis-specified options, bail out if # anything was wrong. $exit_cmd $EXIT_FAILURE } # 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 } ## ----------- ## ## Main. ## ## ----------- ## $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi test -z "$mode" && func_fatal_error "error: you must specify a MODE." # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$execute_dlfiles" && test "$mode" != execute; 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=$mode' for more information." } # 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 \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # 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 "$lalib_p" = yes } # 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 () { func_lalib_p "$1" } # 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_ltwrapper_scriptname_result="" if func_ltwrapper_executable_p "$1"; then func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" fi } # 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 () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" 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 () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$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 () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_quote_for_eval "$arg" CC_quoted="$CC_quoted $func_quote_for_eval_result" done 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 "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; # 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_quote_for_eval "$arg" CC_quoted="$CC_quoted $func_quote_for_eval_result" done case "$@ " in " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) # 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 "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T <?"'"'"' &()|`$[]' \ && 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 "$build_old_libs" = yes; 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 "$pic_mode" = no && test "$deplibs_check_method" != pass_all; 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 "$compiler_c_o" = no; then output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e '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 "$need_locks" = yes; 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 "$need_locks" = warn; 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 removelist="$removelist $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist removelist="$removelist $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; 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 command="$command -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && 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 "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then command="$command -o $obj" fi # Suppress compiler output if we already did a PIC compilation. command="$command$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && 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 "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $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 building PIC objects only -prefer-non-pic try to building 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 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 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 -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 -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 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 \`$mode'" ;; esac $ECHO $ECHO "Try \`$progname --help' for more information about other modes." exit $? } # Now that we've collected a possible --mode arg, show help if necessary $opt_help && func_mode_help # func_mode_execute arg... func_mode_execute () { $opt_debug # 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 $execute_dlfiles; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) # 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 dir="$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 -*) ;; *) # 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_quote_for_eval "$file" args="$args $func_quote_for_eval_result" done if test "X$opt_dry_run" = Xfalse; then 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" else # 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 fi } test "$mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libdirs="$nonopt" admincmds= if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for dir do libdirs="$libdirs $dir" done 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" || admincmds="$admincmds $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS $ECHO "X----------------------------------------------------------------------" | $Xsed $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 "X----------------------------------------------------------------------" | $Xsed exit $EXIT_SUCCESS } test "$mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. $ECHO "X$nonopt" | $GREP shtool >/dev/null; 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" install_prog="$install_prog$func_quote_for_eval_result" # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= for arg do if test -n "$dest"; then files="$files $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) case " $install_prog " in *[\\\ /]cp\ *) ;; *) prev=$arg ;; esac ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" install_prog="$install_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 -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=yes if test "$isdir" = yes; 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. staticlibs="$staticlibs $file" ;; *.la) # 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 "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) future_libdirs="$future_libdirs $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" dir="$dir$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -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 "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "X$relink_command" | $Xsed -e "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_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) 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" && staticlibs="$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 "$build_old_libs" = yes; 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=yes 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 "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { 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 "X$file$stripped_ext" | $Xsed -e "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_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $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 "$mode" = install && 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 () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; 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$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; 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 "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` for progfile in $progfiles; do func_verbose "extracting global C symbols from \`$progfile'" $opt_dry_run || eval "$NM $progfile | $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" $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" } 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 $ECHO >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; " case $host in *cygwin* | *mingw* | *cegcc* ) $ECHO >> "$output_objdir/$my_dlsyms" "\ /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */" lt_dlsym_const= ;; *osf5*) echo >> "$output_objdir/$my_dlsyms" "\ /* This system does not cope well with relocations in const data */" lt_dlsym_const= ;; *) lt_dlsym_const=const ;; esac $ECHO >> "$output_objdir/$my_dlsyms" "\ extern $lt_dlsym_const lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; $lt_dlsym_const lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," 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" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) symtab_cflags="$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"' # 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 "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "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 "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` fi } # 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. func_win32_libid () { $opt_debug 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 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then win32_nmres=`eval $NM -f posix -A $1 | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` 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_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' 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 () { $opt_debug 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` darwin_base_archive=`basename "$darwin_archive"` 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 "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | $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 | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper_part1 [arg=no] # # Emit the first part of a libtool wrapper script on stdout. # For more information, see the description associated with # func_emit_wrapper(), below. func_emit_wrapper_part1 () { func_emit_wrapper_part1_arg1=no if test -n "$1" ; then func_emit_wrapper_part1_arg1=$1 fi $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $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. Xsed='${SED} -e 1s/^X//' 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 ECHO=\"$qecho\" file=\"\$0\" # Make sure echo works. if test \"X\$1\" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then # Yippee, \$ECHO works! : else # Restart under the correct shell, and then maybe \$ECHO will work. exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} fi fi\ " $ECHO "\ # Find the directory that this script lives in. thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e '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 \"X\$file\" | \$Xsed -e '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 \"X\$file\" | \$Xsed -e 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` done " } # end: func_emit_wrapper_part1 # func_emit_wrapper_part2 [arg=no] # # Emit the second part of a libtool wrapper script on stdout. # For more information, see the description associated with # func_emit_wrapper(), below. func_emit_wrapper_part2 () { func_emit_wrapper_part2_arg1=no if test -n "$1" ; then func_emit_wrapper_part2_arg1=$1 fi $ECHO "\ # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_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 \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; 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" # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && 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 \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` export $shlibpath_var " fi # fixup the dll searchpath if we need to. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 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\ " } # end: func_emit_wrapper_part2 # 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 in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=no if test -n "$1" ; then func_emit_wrapper_arg1=$1 fi # split this up so that func_emit_cwrapperexe_src # can call each part independently. func_emit_wrapper_part1 "${func_emit_wrapper_arg1}" func_emit_wrapper_part2 "${func_emit_wrapper_arg1}" } # func_to_host_path arg # # Convert paths to host format when used with build tools. # Intended for use with "native" mingw (where libtool itself # is running under the msys shell), or in the following cross- # build environments: # $build $host # mingw (msys) mingw [e.g. native] # cygwin mingw # *nix + wine mingw # where wine is equipped with the `winepath' executable. # In the native mingw case, the (msys) shell automatically # converts paths for any non-msys applications it launches, # but that facility isn't available from inside the cwrapper. # Similar accommodations are necessary for $host mingw and # $build cygwin. Calling this function does no harm for other # $host/$build combinations not listed above. # # ARG is the path (on $build) that should be converted to # the proper representation for $host. The result is stored # in $func_to_host_path_result. func_to_host_path () { func_to_host_path_result="$1" if test -n "$1" ; then case $host in *mingw* ) lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' case $build in *mingw* ) # actually, msys # awkward: cmd appends spaces to result lt_sed_strip_trailing_spaces="s/[ ]*\$//" func_to_host_path_tmp1=`( cmd //c echo "$1" |\ $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ $SED -e "$lt_sed_naive_backslashify"` ;; *cygwin* ) func_to_host_path_tmp1=`cygpath -w "$1"` func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ $SED -e "$lt_sed_naive_backslashify"` ;; * ) # Unfortunately, winepath does not exit with a non-zero # error code, so we are forced to check the contents of # stdout. On the other hand, if the command is not # found, the shell will set an exit code of 127 and print # *an error message* to stdout. So we must check for both # error code of zero AND non-empty stdout, which explains # the odd construction: func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ $SED -e "$lt_sed_naive_backslashify"` else # Allow warning below. func_to_host_path_result="" fi ;; esac if test -z "$func_to_host_path_result" ; then func_error "Could not determine host path corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_path_result="$1" fi ;; esac fi } # end: func_to_host_path # func_to_host_pathlist arg # # Convert pathlists to host format when used with build tools. # See func_to_host_path(), above. This function supports the # following $build/$host combinations (but does no harm for # combinations not listed here): # $build $host # mingw (msys) mingw [e.g. native] # cygwin mingw # *nix + wine mingw # # 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. # # ARG is a pathlist (on $build) that should be converted to # the proper representation on $host. The result is stored # in $func_to_host_pathlist_result. func_to_host_pathlist () { func_to_host_pathlist_result="$1" if test -n "$1" ; then case $host in *mingw* ) lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # 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_to_host_pathlist_tmp2="$1" # Once set for this call, this variable should not be # reassigned. It is used in tha fallback case. func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\ $SED -e 's|^:*||' -e 's|:*$||'` case $build in *mingw* ) # Actually, msys. # Awkward: cmd appends spaces to result. lt_sed_strip_trailing_spaces="s/[ ]*\$//" func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\ $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ $SED -e "$lt_sed_naive_backslashify"` ;; *cygwin* ) func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"` func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ $SED -e "$lt_sed_naive_backslashify"` ;; * ) # unfortunately, winepath doesn't convert pathlists func_to_host_pathlist_result="" func_to_host_pathlist_oldIFS=$IFS IFS=: for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do IFS=$func_to_host_pathlist_oldIFS if test -n "$func_to_host_pathlist_f" ; then func_to_host_path "$func_to_host_pathlist_f" if test -n "$func_to_host_path_result" ; then if test -z "$func_to_host_pathlist_result" ; then func_to_host_pathlist_result="$func_to_host_path_result" else func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result" fi fi fi IFS=: done IFS=$func_to_host_pathlist_oldIFS ;; esac if test -z "$func_to_host_pathlist_result" ; then func_error "Could not determine the host path(s) corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This may break if $1 contains DOS-style drive # specifications. The fix is not to complicate the expression # below, but for the user to provide a working wine installation # with winepath so that path translation in the cross-to-mingw # case works properly. lt_replace_pathsep_nix_to_dos="s|:|;|g" func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ $SED -e "$lt_replace_pathsep_nix_to_dos"` fi # Now, add the leading and trailing path separators back case "$1" in :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" ;; esac case "$1" in *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;" ;; esac ;; esac fi } # end: func_to_host_pathlist # 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 # define setmode _setmode #else # include # include # ifdef __CYGWIN__ # include # define HAVE_SETENV # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif # endif #endif #include #include #include #include #include #include #include #include #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 #ifdef _MSC_VER # define S_IXUSR _S_IEXEC # define stat _stat # ifndef _INTPTR_T_DEFINED # define intptr_t int # endif #endif #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 */ #ifdef __CYGWIN__ # define FOPEN_WB "wb" #endif #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 ((void *) stale); stale = 0; } \ } while (0) #undef LTWRAPPER_DEBUGPRINTF #if defined DEBUGWRAPPER # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args static void ltwrapper_debugprintf (const char *fmt, ...) { va_list args; va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } #else # define LTWRAPPER_DEBUGPRINTF(args) #endif const char *program_name = NULL; 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_fatal (const char *message, ...); 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_opt_process_env_set (const char *arg); void lt_opt_process_env_prepend (const char *arg); void lt_opt_process_env_append (const char *arg); int lt_split_name_value (const char *arg, char** name, char** value); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); static const char *script_text_part1 = EOF func_emit_wrapper_part1 yes | $SED -e 's/\([\\"]\)/\\\1/g' \ -e 's/^/ "/' -e 's/$/\\n"/' echo ";" cat <"))); for (i = 0; i < newargc; i++) { LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : ""))); } EOF case $host_os in mingw*) cat <<"EOF" /* execv doesn't actually work on mingw as expected on unix */ rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); if (rval == -1) { /* failed to start process */ LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); return 127; } return rval; EOF ;; *) cat <<"EOF" execv (lt_argv_zero, newargz); return rval; /* =127, but avoids unused variable warning */ EOF ;; esac cat <<"EOF" } void * xmalloc (size_t num) { void *p = (void *) malloc (num); if (!p) lt_fatal ("Memory exhausted"); return p; } char * xstrdup (const char *string) { return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL; } const char * base_name (const char *name) { const char *base; #if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* Skip over the disk name in MSDOS pathnames. */ if (isalpha ((unsigned char) name[0]) && name[1] == ':') name += 2; #endif for (base = name; *name; name++) if (IS_DIR_SEPARATOR (*name)) base = name + 1; return base; } int check_executable (const char *path) { struct stat st; LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!")); if ((!path) || (!*path)) return 0; if ((stat (path, &st) >= 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; LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!")); 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]; int tmp_len; char *concat_name; LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); 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 = 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 ("getcwd failed"); 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 ("getcwd failed"); 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) { LTWRAPPER_DEBUGPRINTF (("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 { char *errstr = strerror (errno); lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal ("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 (strcmp (str, pat) == 0) *str = '\0'; } return str; } static void lt_error_core (int exit_status, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s: %s: ", program_name, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, "FATAL", message, ap); va_end (ap); } void lt_setenv (const char *name, const char *value) { LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", (name ? name : ""), (value ? value : ""))); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int 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) { int orig_value_len = strlen (orig_value); int 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; } int lt_split_name_value (const char *arg, char** name, char** value) { const char *p; int len; if (!arg || !*arg) return 1; p = strchr (arg, (int)'='); if (!p) return 1; *value = xstrdup (++p); len = strlen (arg) - strlen (*value); *name = XMALLOC (char, len); strncpy (*name, arg, len-1); (*name)[len - 1] = '\0'; return 0; } void lt_opt_process_env_set (const char *arg) { char *name = NULL; char *value = NULL; if (lt_split_name_value (arg, &name, &value) != 0) { XFREE (name); XFREE (value); lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg); } lt_setenv (name, value); XFREE (name); XFREE (value); } void lt_opt_process_env_prepend (const char *arg) { char *name = NULL; char *value = NULL; char *new_value = NULL; if (lt_split_name_value (arg, &name, &value) != 0) { XFREE (name); XFREE (value); lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg); } new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); XFREE (name); XFREE (value); } void lt_opt_process_env_append (const char *arg) { char *name = NULL; char *value = NULL; char *new_value = NULL; if (lt_split_name_value (arg, &name, &value) != 0) { XFREE (name); XFREE (value); lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg); } new_value = lt_extend_str (getenv (name), value, 1); lt_setenv (name, new_value); XFREE (new_value); XFREE (name); XFREE (value); } void lt_update_exe_path (const char *name, const char *value) { LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", (name ? name : ""), (value ? 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 #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", (name ? name : ""), (value ? 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 } # end: func_emit_cwrapperexe_src # func_mode_link arg... func_mode_link () { $opt_debug 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 # which 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 which 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 dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no 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 "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && 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 dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$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 "*) ;; *) deplibs="$deplibs $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # moreargs="$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 "$pic_object" = none && test "$non_pic_object" = none; 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 "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$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 "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; 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 "$pic_object" = none ; 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 ;; 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 "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) weak_libs="$weak_libs $arg" prev= continue ;; xcclinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$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 ;; -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$arg" = "X-export-symbols"; 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" dir=$func_stripname_result if test -z "$dir"; 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 # 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 "*) ;; *) deplibs="$deplibs -L$dir" lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) dllsearchpath="$dllsearchpath:$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*) # 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$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework deplibs="$deplibs System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi deplibs="$deplibs $arg" 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) compiler_flags="$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) compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) new_inherited_linker_flags="$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 ;; -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_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$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" arg="$arg $wl$func_quote_for_eval_result" compiler_flags="$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" arg="$arg $wl$func_quote_for_eval_result" compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" linker_flags="$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" ;; # -64, -mips[0-9] enable 64-bit mode on the SGI compiler # -r[0-9][0-9]* specifies the processor on the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler # +DA*, +DD* enable 64-bit mode on the HP compiler # -q* pass through compiler args for the IBM compiler # -m*, -t[45]*, -txscale* pass through architecture-specific # compiler args for GCC # -F/path gives path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC # @file GCC response files -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" compiler_flags="$compiler_flags $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. objs="$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 "$pic_object" = none && test "$non_pic_object" = none; 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 "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$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 "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; 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 "$pic_object" = none ; 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. deplibs="$deplibs $arg" old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. if test "$prev" = dlfiles; then # This library was specified with -dlopen. dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. dlprefiles="$dlprefiles $arg" prev= else deplibs="$deplibs $arg" 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 "$export_dynamic" = yes && 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 \"X\${$shlibpath_var}\" \| \$Xsed -e \'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\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" # 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_duplicate_deps ; then case "$libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi libs="$libs $deplib" done if test "$linkmode" = lib; 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 "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; esac pre_post_deps="$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=no 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 "$linkmode,$pass" = "lib,link"; 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 "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= case $lib in *.la) func_source "$lib" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` case " $weak_libs " in *" $deplib_base "*) ;; *) deplibs="$deplibs $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else compiler_flags="$compiler_flags $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; 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 "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # 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 "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; 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=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" dir=$func_stripname_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) lib="$deplib" ;; *.$libext) if test "$pass" = conv; 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=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then $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." else $ECHO $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else newdlfiles="$newdlfiles $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # 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 "X$inherited_linker_flags" | $Xsed -e '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 "*) ;; *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test "$pass" = conv; 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. convenience="$convenience $ladir/$objdir/$old_library" old_convenience="$old_convenience $ladir/$objdir/$old_library" elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= for l in $old_library $library_names; do linklib="$l" done 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 "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; 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. dlprefiles="$dlprefiles $lib $dependency_libs" else newdlfiles="$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 "X$installed" = Xyes; then if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$libdir" absdir="$libdir" fi test "X$hardcode_automatic" = Xyes && 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 notinst_path="$notinst_path $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later notinst_path="$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 "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then newdlprefiles="$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" && \ dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then newdlprefiles="$newdlprefiles $dir/$dlname" else newdlprefiles="$newdlprefiles $dir/$linklib" fi fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; 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 "$linkmode" = prog && test "$pass" != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; 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_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || 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:"*) ;; *) temp_rpath="$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 "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && 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 "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded notinst_deplibs="$notinst_deplibs $lib" need_relink=no ;; *) if test "$installed" = no; then notinst_deplibs="$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 "$shouldnotlink" = yes && test "$pass" = link; then $ECHO if test "$linkmode" = prog; 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 "$linkmode" = lib && test "$hardcode_into_libs" = yes; 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 "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$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*) 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 "$linkmode" = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; 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 can not # 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 "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; 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 "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; 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 [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; 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 "$linkmode" = prog; 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 "$hardcode_direct" != unsupported; 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 "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; 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 can not 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 "$module" = yes; 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 "$build_old_libs" = no; 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 "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; 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 "*) ;; *) xrpath="$xrpath $temp_xrpath";; esac;; *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" if $opt_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do case $deplib in -L*) path="$deplib" ;; *.la) 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 compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" linker_flags="$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 "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # 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 "*) ;; *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_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 "*) ;; *) tmp_libs="$tmp_libs $deplib" ;; esac ;; *) tmp_libs="$tmp_libs $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # 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 tmp_libs="$tmp_libs $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; 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" objs="$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 "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; 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 "$deplibs_check_method" != pass_all; 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!" libobjs="$libobjs $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; 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 # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|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" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; 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 "$loop" -ne 0; 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) 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 "$loop" -ne 0; 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. verstring="$verstring:${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. 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 "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" libobjs="$libobjs $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$mode" != relink; 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 "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi removelist="$removelist $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "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 temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; 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 "*) ;; *) dlfiles="$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 "*) ;; *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework deplibs="$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 "$build_libtool_need_lc" = "yes"; then deplibs="$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` 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 "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then newdeplibs="$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. newdeplibs="$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 "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) newdeplibs="$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 \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then newdeplibs="$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. newdeplibs="$newdeplibs $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` done fi if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | $GREP . >/dev/null; then $ECHO if test "X$deplibs_check_method" = "Xnone"; 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 fi ;; 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 "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; 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 "$build_old_libs" = no; 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 "$allow_undefined" = no; 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 "$build_old_libs" = no; 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 "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO "X $deplibs" | $Xsed -e '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 "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$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 "$build_libtool_libs" = yes; then if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $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"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$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" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$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 "$mode" != relink && 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 linknames="$linknames $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$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" delfiles="$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 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # 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 fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || 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 cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" func_len " $cmd" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then func_show_eval "$cmd" 'exit $?' 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 "X$skipped_export" != "X:"; 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 "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && 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 delfiles="$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 "*) ;; *) tmp_deplibs="$tmp_deplibs $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && 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" generated="$generated $gentop" func_extract_archives $gentop $convenience libobjs="$libobjs $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking if test "$mode" = relink; 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 "$module" = yes && 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 "X$skipped_export" != "X:" && 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 output_la=`$ECHO "X$output" | $Xsed -e "$basename"` # 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 "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" $ECHO 'INPUT (' > $output for obj in $save_libobjs do $ECHO "$obj" >> $output done $ECHO ')' >> $output delfiles="$delfiles $output" elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do $ECHO "$obj" >> $output done delfiles="$delfiles $output" output=$firstobj\"$file_list_spec$output\" 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 "X$objlist" = X || 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 "$k" -eq 1 ; then # The first file doesn't have a previous command to add. eval concat_cmds=\"$reload_cmds $objlist $last_robj\" else # All subsequent reloadable object files will link in # the last one created. eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$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~ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi delfiles="$delfiles $output" else output= fi if ${skipped_export-false}; then 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 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_silent || { 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 "$mode" = relink; 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 if ${skipped_export-false}; then 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 "X$include_expsyms" | $Xsed | $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 delfiles="$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 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 "$module" = yes && 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" generated="$generated $gentop" func_extract_archives $gentop $dlprefiles libobjs="$libobjs $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { 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 "$mode" = relink; 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 "$mode" = relink; 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 "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; 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= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` else gentop="$output_objdir/${obj}x" generated="$generated $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 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 if test "$build_libtool_libs" != yes; then 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 fi if test -n "$pic_flag" || test "$pic_mode" != default; 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" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ 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 "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e '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 "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) compile_command="$compile_command ${wl}-bind_at_load" finalize_command="$finalize_command ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e '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 "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done compile_deplibs="$new_libs" compile_command="$compile_command $compile_deplibs" finalize_command="$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 "*) ;; *) finalize_rpath="$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"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$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;; *) dllsearchpath="$dllsearchpath:$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) dllsearchpath="$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"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) finalize_perm_rpath="$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 "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *cegcc) # Disable wrappers for cegcc, we are cross compiling anyway. wrappers_required=no ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "X$compile_command" | $Xsed -e '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=$?' # 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 fi 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 rpath="$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 rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; 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 "X$link_command" | $Xsed -e '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 $?' exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # 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" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "X$link_command" | $Xsed -e '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 $?' # 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 "X$relink_command" | $Xsed -e "$sed_quote_subst"` fi # Quote $ECHO for shipping. if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then case $progpath in [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; esac qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` else qecho=`$ECHO "X$ECHO" | $Xsed -e "$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 if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then oldobjs="$oldobjs $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $addlibs oldobjs="$oldobjs $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; 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" generated="$generated $gentop" func_extract_archives $gentop $dlprefiles oldobjs="$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" generated="$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" oldobjs="$oldobjs $gentop/$newobj" ;; *) oldobjs="$oldobjs $obj" ;; esac done fi 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 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 "X$oldobjs" = "X" ; 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 "$build_old_libs" = yes && 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 "X$relink_command" | $Xsed -e "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; 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" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" newdependency_libs="$newdependency_libs $libdir/$name" ;; *) newdependency_libs="$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" newdlfiles="$newdlfiles $libdir/$name" ;; *) newdlfiles="$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" newdlprefiles="$newdlprefiles $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 newdlfiles="$newdlfiles $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlprefiles="$newdlprefiles $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $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 can not 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 "$installed" = no && test "$need_relink" = yes; 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 } { test "$mode" = link || test "$mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= 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) RM="$RM $arg"; rmforce=yes ;; -*) RM="$RM $arg" ;; *) files="$files $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= origobjdir="$objdir" for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then objdir="$origobjdir" else objdir="$dir/$origobjdir" fi func_basename "$file" name="$func_basename_result" test "$mode" = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates if test "$mode" = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; 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 test "$rmforce" = yes; 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 rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" case "$mode" in clean) case " $library_names " in # " " in the beginning catches empty $dlname *" $dlname "*) ;; *) rmfiles="$rmfiles $objdir/$dlname" ;; esac test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || 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 "$pic_object" != none; then rmfiles="$rmfiles $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then rmfiles="$rmfiles $dir/$non_pic_object" fi fi ;; *) if test "$mode" = clean ; 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 rmfiles="$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 rmfiles="$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 rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then rmfiles="$rmfiles $objdir/lt-$name" fi if test "X$noexename" != "X$name" ; then rmfiles="$rmfiles $objdir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done objdir="$origobjdir" # 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 } { test "$mode" = uninstall || test "$mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$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 # in which 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: # vi:sw=2 freetds-0.91/missing100775 001750 000144 00000024036 07550354260 0010211#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. # Originally 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, 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. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing 0.4 - GNU automake" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. You can get \`$1Help2man' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then # We have makeinfo, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 fi # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 freetds-0.91/mkinstalldirs100775 001750 000144 00000001335 07361676265 0011431#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.1.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-0.91/interfaces100664 001750 000144 00000004467 07551114173 0010664# # 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-0.91/src/Makefile.am100664 001750 000144 00000000613 10024661716 0011425# $Id: Makefile.am,v 1.8 2004/03/13 19:41:02 jklowden Exp $ if INCAPPS APPS = apps endif if INCPOOL POOL = pool SERVER = server else !INCPOOL if INCSERVER SERVER = server endif endif if ODBC SUBDIRS = replacements tds ctlib dblib odbc $(APPS) $(SERVER) $(POOL) DIST_SUBDIRS = $(SUBDIRS) else SUBDIRS = replacements tds ctlib dblib $(APPS) $(SERVER) $(POOL) DIST_SUBDIRS = odbc $(SUBDIRS) endif freetds-0.91/src/Makefile.in100664 001750 000144 00000045317 11623070617 0011450# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-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 uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags 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@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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.8 2004/03/13 19:41:02 jklowden Exp $ @INCAPPS_TRUE@APPS = apps @INCPOOL_TRUE@POOL = pool @INCPOOL_FALSE@@INCSERVER_TRUE@SERVER = server @INCPOOL_TRUE@SERVER = server @ODBC_FALSE@SUBDIRS = replacements tds ctlib dblib $(APPS) $(SERVER) $(POOL) @ODBC_TRUE@SUBDIRS = replacements tds ctlib dblib odbc $(APPS) $(SERVER) $(POOL) @ODBC_FALSE@DIST_SUBDIRS = odbc $(SUBDIRS) @ODBC_TRUE@DIST_SUBDIRS = $(SUBDIRS) 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 .PRECIOUS: 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. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; 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" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) 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; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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 \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic clean-libtool \ ctags ctags-recursive 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-recursive \ uninstall uninstall-am # 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-0.91/src/replacements/Makefile.am100664 001750 000144 00000000726 11455100170 0014103# $Id: Makefile.am,v 1.17 2010/10/12 15:36:24 jklowden Exp $ AM_CPPFLAGS= -I$(top_srcdir)/include -I$(top_srcdir)/src/replacements noinst_LTLIBRARIES= libreplacements.la libreplacements_la_SOURCES= iconv.c gettimeofday.c fakepoll.c libreplacements_la_LDFLAGS= libreplacements_la_LIBADD= @LTLIBOBJS@ EXTRA_DIST= asprintf.c \ atoll.c \ basename.c \ getopt.c \ readpassphrase.c \ strlcat.c \ strlcpy.c \ strtok_r.c \ vasprintf.c \ replacements.vcproj freetds-0.91/src/replacements/Makefile.in100664 001750 000144 00000042557 11623070620 0014127# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in asprintf.c \ atoll.c basename.c getopt.c readpassphrase.c strlcat.c \ strlcpy.c strtok_r.c vasprintf.c 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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 fakepoll.lo libreplacements_la_OBJECTS = $(am_libreplacements_la_OBJECTS) libreplacements_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libreplacements_la_LDFLAGS) $(LDFLAGS) -o $@ 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libreplacements_la_SOURCES) DIST_SOURCES = $(libreplacements_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 2010/10/12 15:36:24 jklowden Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/replacements noinst_LTLIBRARIES = libreplacements.la libreplacements_la_SOURCES = iconv.c gettimeofday.c fakepoll.c libreplacements_la_LDFLAGS = libreplacements_la_LIBADD = @LTLIBOBJS@ EXTRA_DIST = asprintf.c \ atoll.c \ basename.c \ getopt.c \ readpassphrase.c \ strlcat.c \ strlcpy.c \ strtok_r.c \ vasprintf.c \ replacements.vcproj 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/replacements/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/replacements/Makefile .PRECIOUS: 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)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libreplacements.la: $(libreplacements_la_OBJECTS) $(libreplacements_la_DEPENDENCIES) $(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)/atoll.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/basename.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)/strtok_r.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vasprintf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepoll.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@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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) 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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 \ mostlyclean-am distclean: distclean-am -rm -rf $(DEPDIR) ./$(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) ./$(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 all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags 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 uninstall uninstall-am # 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-0.91/src/replacements/asprintf.c100664 001750 000144 00000001072 10473062614 0014045/* * asprintf(3) * 20020809 entropy@tappedin.com * public domain. no warranty. use at your own risk. have a nice day. */ #if HAVE_CONFIG_H #include #endif #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds_sysdep_private.h" #include "replacements.h" TDS_RCSID(var, "$Id: asprintf.c,v 1.7 2006/08/23 14:26:20 freddy77 Exp $"); int 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-0.91/src/replacements/atoll.c100664 001750 000144 00000002256 10265721562 0013342/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include "tds_sysdep_private.h" #include "replacements.h" TDS_RCSID(var, "$Id: atoll.c,v 1.8 2005/07/15 11:52:18 freddy77 Exp $"); tds_sysdep_int64_type atoll(const char *nptr) { return atol(nptr); } freetds-0.91/src/replacements/basename.c100664 001750 000144 00000003117 11322363577 0014002/* 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. */ #if HAVE_CONFIG_H #include #endif #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds_sysdep_private.h" #include "replacements.h" #if ! HAVE_BASENAME TDS_RCSID(var, "$Id: basename.c,v 1.5 2010/01/10 14:43:11 freddy77 Exp $"); #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-0.91/src/replacements/getopt.c100664 001750 000144 00000011157 11333405162 0013521/* $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 #ifdef _FREETDS_LIBRARY_SOURCE # include "tds_sysdep_private.h" #endif /* _FREETDS_LIBRARY_SOURCE */ #if defined(LIBC_SCCS) && !defined(lint) # if 0 static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; # else __RCSID("$NetBSD: getopt.c,v 1.27 2005/11/29 03:12:00 christos Exp $"); # endif #else TDS_RCSID(var, "$Id: getopt.c,v 1.3 2010/02/07 00:33:54 freddy77 Exp $"); #endif /* LIBC_SCCS and not lint */ #if !defined(_WIN32) # include "namespace.h" #endif #include #include #include #include #include #if !defined(_WIN32) # include #endif #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 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-0.91/src/replacements/readpassphrase.c100664 001750 000144 00000015063 11322363577 0015237/* 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 */ #if HAVE_CONFIG_H #include #endif #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 * 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 * 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-0.91/src/replacements/strlcat.c100664 001750 000144 00000002611 10266774754 0013712/* 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. */ #if HAVE_CONFIG_H #include #endif #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds_sysdep_private.h" #include "replacements.h" /* $Id: strlcat.c,v 1.1 2005/07/18 18:50:20 freddy77 Exp $ */ size_t tds_strlcat(char *dest, const char *src, size_t len) { size_t dest_len = strlen(dest); size_t src_len = strlen(src); --len; if (dest_len + src_len > 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-0.91/src/replacements/strlcpy.c100664 001750 000144 00000002432 10266774754 0013737/* 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. */ #if HAVE_CONFIG_H #include #endif #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds_sysdep_private.h" #include "replacements.h" /* $Id: strlcpy.c,v 1.1 2005/07/18 18:50:20 freddy77 Exp $ */ size_t tds_strlcpy(char *dest, const char *src, size_t len) { size_t l = strlen(src); --len; if (l > len) { memcpy(dest, src, len); dest[len] = 0; } else { memcpy(dest, src, l + 1); } return l; } freetds-0.91/src/replacements/strtok_r.c100664 001750 000144 00000003403 11323046371 0014063/* * strtok_r(3) * 20020927 entropy@tappedin.com * public domain. no warranty. use at your own risk. have a nice day. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds_sysdep_private.h" #include "replacements.h" TDS_RCSID(var, "$Id: strtok_r.c,v 1.7 2010/01/12 10:20:41 freddy77 Exp $"); #undef strtok_r char * 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; } #ifdef TDS_INTERNAL_TEST /* gcc -O2 -Wall strtok_r.c -o strtok -DTDS_INTERNAL_TEST -I../../include -DHAVE_CONFIG_H */ #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 = 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"); } 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; } #endif freetds-0.91/src/replacements/vasprintf.c100664 001750 000144 00000004536 11322363600 0014234/* * vasprintf(3) * 20020809 entropy@tappedin.com * public domain. no warranty. use at your own risk. have a nice day. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tds_sysdep_private.h" #include "replacements.h" TDS_RCSID(var, "$Id: vasprintf.c,v 1.22 2010/01/10 14:43:12 freddy77 Exp $"); #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 vasprintf(char **ret, const char *fmt, va_list ap) { #if 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-0.91/src/replacements/iconv.c100664 001750 000144 00000024116 11525237643 0013346/* 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. */ /* * 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 (UCS-2). * * It supports ISO-8859-1, ASCII, UCS-2, UCS-4 and UTF-8 */ #if HAVE_CONFIG_H #include #endif #if ! HAVE_ICONV #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_ERRNO_H #include #endif #include #include #include "tds.h" #include "tdsbytes.h" #include "tdsiconv.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: iconv.c,v 1.21 2011/02/11 13:54:43 freddy77 Exp $"); /** * \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 }; 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; unsigned mask; 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 -EINVAL; } if (buf_len < o_len) return -E2BIG; buf += o_len; mask = 0xff80; for (;;) { *--buf = 0x80 | (c & 0x3f); c >>= 6; mask >>= 1; if (c < 0x40) { *--buf = mask | c; break; } } 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) { if (len < 1) return -EINVAL; *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 (len < 1) return -EINVAL; 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 (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; if (TDS_UNLIKELY(readed < 0)) { local_errno = -readed; break; } written = put_func(ob, ol, out_c); 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-0.91/src/replacements/gettimeofday.c100664 001750 000144 00000004141 11322363577 0014706/* 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. */ #if HAVE_CONFIG_H #include #endif #if defined(_WIN32) #if HAVE_ERRNO_H #include #endif #include "tds.h" #include "replacements.h" TDS_RCSID(var, "$Id: gettimeofday.c,v 1.5 2010/01/10 14:43:11 freddy77 Exp $"); /* * 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 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-0.91/src/replacements/fakepoll.c100664 001750 000144 00000010744 11426476474 0014036/* * 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 fakepoll.h * are based on fakepoll.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. */ #if HAVE_CONFIG_H #include #endif #ifndef HAVE_POLL static char software_version[] = "$Id: fakepoll.c,v 1.11 2010/08/05 08:58:36 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #include #include #include "replacements.h" #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 TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #include #include int fakepoll(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-0.91/src/replacements/replacements.vcproj100775 001750 000144 00000017430 11326010000 0015746 freetds-0.91/src/tds/tds_willconvert.h100664 001750 000144 00000052400 11623073520 0013553/* ($Id: tds_willconvert.pl,v 1.3 2009/01/03 15:26:09 jklowden Exp $) */ /*** 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. ***/ { SYBVARCHAR, SYBVARCHAR , 1 } , { SYBVARCHAR, SYBCHAR , 1 } , { SYBVARCHAR, SYBTEXT , 1 } , { SYBVARCHAR, SYBBINARY , 1 } , { SYBVARCHAR, SYBVARBINARY , 1 } , { SYBVARCHAR, SYBIMAGE , 1 } , { SYBVARCHAR, SYBINT1 , 1 } , { SYBVARCHAR, SYBINT2 , 1 } , { SYBVARCHAR, SYBINT4 , 1 } , { SYBVARCHAR, SYBINT8 , 1 } , { SYBVARCHAR, SYBFLT8 , 1 } , { SYBVARCHAR, SYBREAL , 1 } , { SYBVARCHAR, SYBNUMERIC , 1 } , { SYBVARCHAR, SYBDECIMAL , 1 } , { SYBVARCHAR, SYBBIT , 1 } , { SYBVARCHAR, SYBMONEY , 1 } , { SYBVARCHAR, SYBMONEY4 , 1 } , { SYBVARCHAR, SYBDATETIME , 1 } , { SYBVARCHAR, SYBDATETIME4 , 1 } , { SYBVARCHAR, SYBBOUNDARY , 1 } , { SYBVARCHAR, SYBUNIQUE , 1 } , { SYBVARCHAR, SYBSENSITIVITY , 0 } , { SYBCHAR, SYBVARCHAR , 1 } , { SYBCHAR, SYBCHAR , 1 } , { SYBCHAR, SYBTEXT , 1 } , { SYBCHAR, SYBBINARY , 1 } , { SYBCHAR, SYBVARBINARY , 1 } , { SYBCHAR, SYBIMAGE , 1 } , { SYBCHAR, SYBINT1 , 1 } , { SYBCHAR, SYBINT2 , 1 } , { SYBCHAR, SYBINT4 , 1 } , { SYBCHAR, SYBINT8 , 1 } , { SYBCHAR, SYBFLT8 , 1 } , { SYBCHAR, SYBREAL , 1 } , { SYBCHAR, SYBNUMERIC , 1 } , { SYBCHAR, SYBDECIMAL , 1 } , { SYBCHAR, SYBBIT , 1 } , { SYBCHAR, SYBMONEY , 1 } , { SYBCHAR, SYBMONEY4 , 1 } , { SYBCHAR, SYBDATETIME , 1 } , { SYBCHAR, SYBDATETIME4 , 1 } , { SYBCHAR, SYBBOUNDARY , 1 } , { SYBCHAR, SYBUNIQUE , 1 } , { SYBCHAR, SYBSENSITIVITY , 0 } , { SYBTEXT, SYBVARCHAR , 1 } , { SYBTEXT, SYBCHAR , 1 } , { SYBTEXT, SYBTEXT , 1 } , { SYBTEXT, SYBBINARY , 1 } , { SYBTEXT, SYBVARBINARY , 1 } , { SYBTEXT, SYBIMAGE , 1 } , { SYBTEXT, SYBINT1 , 1 } , { SYBTEXT, SYBINT2 , 1 } , { SYBTEXT, SYBINT4 , 1 } , { SYBTEXT, SYBINT8 , 1 } , { SYBTEXT, SYBFLT8 , 1 } , { SYBTEXT, SYBREAL , 1 } , { SYBTEXT, SYBNUMERIC , 1 } , { SYBTEXT, SYBDECIMAL , 1 } , { SYBTEXT, SYBBIT , 1 } , { SYBTEXT, SYBMONEY , 1 } , { SYBTEXT, SYBMONEY4 , 1 } , { SYBTEXT, SYBDATETIME , 1 } , { SYBTEXT, SYBDATETIME4 , 1 } , { SYBTEXT, SYBBOUNDARY , 1 } , { SYBTEXT, SYBUNIQUE , 1 } , { SYBTEXT, SYBSENSITIVITY , 0 } , { SYBBINARY, SYBVARCHAR , 1 } , { SYBBINARY, SYBCHAR , 1 } , { SYBBINARY, SYBTEXT , 1 } , { SYBBINARY, SYBBINARY , 1 } , { SYBBINARY, SYBVARBINARY , 1 } , { SYBBINARY, SYBIMAGE , 1 } , { SYBBINARY, SYBINT1 , 1 } , { SYBBINARY, SYBINT2 , 1 } , { SYBBINARY, SYBINT4 , 1 } , { SYBBINARY, SYBINT8 , 1 } , { SYBBINARY, SYBFLT8 , 1 } , { SYBBINARY, SYBREAL , 1 } , { SYBBINARY, SYBNUMERIC , 1 } , { SYBBINARY, SYBDECIMAL , 1 } , { SYBBINARY, SYBBIT , 1 } , { SYBBINARY, SYBMONEY , 1 } , { SYBBINARY, SYBMONEY4 , 1 } , { SYBBINARY, SYBDATETIME , 0 } , { SYBBINARY, SYBDATETIME4 , 0 } , { SYBBINARY, SYBBOUNDARY , 0 } , { SYBBINARY, SYBUNIQUE , 0 } , { SYBBINARY, SYBSENSITIVITY , 0 } , { SYBVARBINARY, SYBVARCHAR , 1 } , { SYBVARBINARY, SYBCHAR , 1 } , { SYBVARBINARY, SYBTEXT , 1 } , { SYBVARBINARY, SYBBINARY , 1 } , { SYBVARBINARY, SYBVARBINARY , 1 } , { SYBVARBINARY, SYBIMAGE , 1 } , { SYBVARBINARY, SYBINT1 , 1 } , { SYBVARBINARY, SYBINT2 , 1 } , { SYBVARBINARY, SYBINT4 , 1 } , { SYBVARBINARY, SYBINT8 , 1 } , { SYBVARBINARY, SYBFLT8 , 1 } , { SYBVARBINARY, SYBREAL , 1 } , { SYBVARBINARY, SYBNUMERIC , 1 } , { SYBVARBINARY, SYBDECIMAL , 1 } , { SYBVARBINARY, SYBBIT , 1 } , { SYBVARBINARY, SYBMONEY , 1 } , { SYBVARBINARY, SYBMONEY4 , 1 } , { SYBVARBINARY, SYBDATETIME , 0 } , { SYBVARBINARY, SYBDATETIME4 , 0 } , { SYBVARBINARY, SYBBOUNDARY , 0 } , { SYBVARBINARY, SYBUNIQUE , 0 } , { SYBVARBINARY, SYBSENSITIVITY , 0 } , { SYBIMAGE, SYBVARCHAR , 1 } , { SYBIMAGE, SYBCHAR , 1 } , { SYBIMAGE, SYBTEXT , 1 } , { SYBIMAGE, SYBBINARY , 1 } , { SYBIMAGE, SYBVARBINARY , 1 } , { SYBIMAGE, SYBIMAGE , 1 } , { SYBIMAGE, SYBINT1 , 1 } , { SYBIMAGE, SYBINT2 , 1 } , { SYBIMAGE, SYBINT4 , 1 } , { SYBIMAGE, SYBINT8 , 1 } , { SYBIMAGE, SYBFLT8 , 1 } , { SYBIMAGE, SYBREAL , 1 } , { SYBIMAGE, SYBNUMERIC , 1 } , { SYBIMAGE, SYBDECIMAL , 1 } , { SYBIMAGE, SYBBIT , 1 } , { SYBIMAGE, SYBMONEY , 1 } , { SYBIMAGE, SYBMONEY4 , 1 } , { SYBIMAGE, SYBDATETIME , 0 } , { SYBIMAGE, SYBDATETIME4 , 0 } , { SYBIMAGE, SYBBOUNDARY , 0 } , { SYBIMAGE, SYBUNIQUE , 0 } , { SYBIMAGE, SYBSENSITIVITY , 0 } , { SYBINT1, SYBVARCHAR , 1 } , { SYBINT1, SYBCHAR , 1 } , { SYBINT1, SYBTEXT , 1 } , { SYBINT1, SYBBINARY , 1 } , { SYBINT1, SYBVARBINARY , 1 } , { SYBINT1, SYBIMAGE , 1 } , { SYBINT1, SYBINT1 , 1 } , { SYBINT1, SYBINT2 , 1 } , { SYBINT1, SYBINT4 , 1 } , { SYBINT1, SYBINT8 , 1 } , { SYBINT1, SYBFLT8 , 1 } , { SYBINT1, SYBREAL , 1 } , { SYBINT1, SYBNUMERIC , 1 } , { SYBINT1, SYBDECIMAL , 1 } , { SYBINT1, SYBBIT , 1 } , { SYBINT1, SYBMONEY , 1 } , { SYBINT1, SYBMONEY4 , 1 } , { SYBINT1, SYBDATETIME , 0 } , { SYBINT1, SYBDATETIME4 , 0 } , { SYBINT1, SYBBOUNDARY , 0 } , { SYBINT1, SYBUNIQUE , 0 } , { SYBINT1, SYBSENSITIVITY , 0 } , { SYBINT2, SYBVARCHAR , 1 } , { SYBINT2, SYBCHAR , 1 } , { SYBINT2, SYBTEXT , 1 } , { SYBINT2, SYBBINARY , 1 } , { SYBINT2, SYBVARBINARY , 1 } , { SYBINT2, SYBIMAGE , 1 } , { SYBINT2, SYBINT1 , 1 } , { SYBINT2, SYBINT2 , 1 } , { SYBINT2, SYBINT4 , 1 } , { SYBINT2, SYBINT8 , 1 } , { SYBINT2, SYBFLT8 , 1 } , { SYBINT2, SYBREAL , 1 } , { SYBINT2, SYBNUMERIC , 1 } , { SYBINT2, SYBDECIMAL , 1 } , { SYBINT2, SYBBIT , 1 } , { SYBINT2, SYBMONEY , 1 } , { SYBINT2, SYBMONEY4 , 1 } , { SYBINT2, SYBDATETIME , 0 } , { SYBINT2, SYBDATETIME4 , 0 } , { SYBINT2, SYBBOUNDARY , 0 } , { SYBINT2, SYBUNIQUE , 0 } , { SYBINT2, SYBSENSITIVITY , 0 } , { SYBINT4, SYBVARCHAR , 1 } , { SYBINT4, SYBCHAR , 1 } , { SYBINT4, SYBTEXT , 1 } , { SYBINT4, SYBBINARY , 1 } , { SYBINT4, SYBVARBINARY , 1 } , { SYBINT4, SYBIMAGE , 1 } , { SYBINT4, SYBINT1 , 1 } , { SYBINT4, SYBINT2 , 1 } , { SYBINT4, SYBINT4 , 1 } , { SYBINT4, SYBINT8 , 1 } , { SYBINT4, SYBFLT8 , 1 } , { SYBINT4, SYBREAL , 1 } , { SYBINT4, SYBNUMERIC , 1 } , { SYBINT4, SYBDECIMAL , 1 } , { SYBINT4, SYBBIT , 1 } , { SYBINT4, SYBMONEY , 1 } , { SYBINT4, SYBMONEY4 , 1 } , { SYBINT4, SYBDATETIME , 0 } , { SYBINT4, SYBDATETIME4 , 0 } , { SYBINT4, SYBBOUNDARY , 0 } , { SYBINT4, SYBUNIQUE , 0 } , { SYBINT4, SYBSENSITIVITY , 0 } , { SYBINT8, SYBVARCHAR , 1 } , { SYBINT8, SYBCHAR , 1 } , { SYBINT8, SYBTEXT , 1 } , { SYBINT8, SYBBINARY , 1 } , { SYBINT8, SYBVARBINARY , 1 } , { SYBINT8, SYBIMAGE , 1 } , { SYBINT8, SYBINT1 , 1 } , { SYBINT8, SYBINT2 , 1 } , { SYBINT8, SYBINT4 , 1 } , { SYBINT8, SYBINT8 , 1 } , { SYBINT8, SYBFLT8 , 1 } , { SYBINT8, SYBREAL , 1 } , { SYBINT8, SYBNUMERIC , 1 } , { SYBINT8, SYBDECIMAL , 1 } , { SYBINT8, SYBBIT , 1 } , { SYBINT8, SYBMONEY , 1 } , { SYBINT8, SYBMONEY4 , 1 } , { SYBINT8, SYBDATETIME , 0 } , { SYBINT8, SYBDATETIME4 , 0 } , { SYBINT8, SYBBOUNDARY , 0 } , { SYBINT8, SYBUNIQUE , 0 } , { SYBINT8, SYBSENSITIVITY , 0 } , { SYBFLT8, SYBVARCHAR , 1 } , { SYBFLT8, SYBCHAR , 1 } , { SYBFLT8, SYBTEXT , 1 } , { SYBFLT8, SYBBINARY , 1 } , { SYBFLT8, SYBVARBINARY , 1 } , { SYBFLT8, SYBIMAGE , 1 } , { SYBFLT8, SYBINT1 , 1 } , { SYBFLT8, SYBINT2 , 1 } , { SYBFLT8, SYBINT4 , 1 } , { SYBFLT8, SYBINT8 , 1 } , { SYBFLT8, SYBFLT8 , 1 } , { SYBFLT8, SYBREAL , 1 } , { SYBFLT8, SYBNUMERIC , 1 } , { SYBFLT8, SYBDECIMAL , 1 } , { SYBFLT8, SYBBIT , 1 } , { SYBFLT8, SYBMONEY , 1 } , { SYBFLT8, SYBMONEY4 , 1 } , { SYBFLT8, SYBDATETIME , 0 } , { SYBFLT8, SYBDATETIME4 , 0 } , { SYBFLT8, SYBBOUNDARY , 0 } , { SYBFLT8, SYBUNIQUE , 0 } , { SYBFLT8, SYBSENSITIVITY , 0 } , { SYBREAL, SYBVARCHAR , 1 } , { SYBREAL, SYBCHAR , 1 } , { SYBREAL, SYBTEXT , 1 } , { SYBREAL, SYBBINARY , 1 } , { SYBREAL, SYBVARBINARY , 1 } , { SYBREAL, SYBIMAGE , 1 } , { SYBREAL, SYBINT1 , 1 } , { SYBREAL, SYBINT2 , 1 } , { SYBREAL, SYBINT4 , 1 } , { SYBREAL, SYBINT8 , 1 } , { SYBREAL, SYBFLT8 , 1 } , { SYBREAL, SYBREAL , 1 } , { SYBREAL, SYBNUMERIC , 1 } , { SYBREAL, SYBDECIMAL , 1 } , { SYBREAL, SYBBIT , 1 } , { SYBREAL, SYBMONEY , 1 } , { SYBREAL, SYBMONEY4 , 1 } , { SYBREAL, SYBDATETIME , 0 } , { SYBREAL, SYBDATETIME4 , 0 } , { SYBREAL, SYBBOUNDARY , 0 } , { SYBREAL, SYBUNIQUE , 0 } , { SYBREAL, SYBSENSITIVITY , 0 } , { SYBNUMERIC, SYBVARCHAR , 1 } , { SYBNUMERIC, SYBCHAR , 1 } , { SYBNUMERIC, SYBTEXT , 1 } , { SYBNUMERIC, SYBBINARY , 1 } , { SYBNUMERIC, SYBVARBINARY , 1 } , { SYBNUMERIC, SYBIMAGE , 1 } , { SYBNUMERIC, SYBINT1 , 1 } , { SYBNUMERIC, SYBINT2 , 1 } , { SYBNUMERIC, SYBINT4 , 1 } , { SYBNUMERIC, SYBINT8 , 1 } , { SYBNUMERIC, SYBFLT8 , 1 } , { SYBNUMERIC, SYBREAL , 1 } , { SYBNUMERIC, SYBNUMERIC , 1 } , { SYBNUMERIC, SYBDECIMAL , 1 } , { SYBNUMERIC, SYBBIT , 1 } , { SYBNUMERIC, SYBMONEY , 1 } , { SYBNUMERIC, SYBMONEY4 , 1 } , { SYBNUMERIC, SYBDATETIME , 0 } , { SYBNUMERIC, SYBDATETIME4 , 0 } , { SYBNUMERIC, SYBBOUNDARY , 0 } , { SYBNUMERIC, SYBUNIQUE , 0 } , { SYBNUMERIC, SYBSENSITIVITY , 0 } , { SYBDECIMAL, SYBVARCHAR , 1 } , { SYBDECIMAL, SYBCHAR , 1 } , { SYBDECIMAL, SYBTEXT , 1 } , { SYBDECIMAL, SYBBINARY , 1 } , { SYBDECIMAL, SYBVARBINARY , 1 } , { SYBDECIMAL, SYBIMAGE , 1 } , { SYBDECIMAL, SYBINT1 , 1 } , { SYBDECIMAL, SYBINT2 , 1 } , { SYBDECIMAL, SYBINT4 , 1 } , { SYBDECIMAL, SYBINT8 , 1 } , { SYBDECIMAL, SYBFLT8 , 1 } , { SYBDECIMAL, SYBREAL , 1 } , { SYBDECIMAL, SYBNUMERIC , 1 } , { SYBDECIMAL, SYBDECIMAL , 1 } , { SYBDECIMAL, SYBBIT , 1 } , { SYBDECIMAL, SYBMONEY , 1 } , { SYBDECIMAL, SYBMONEY4 , 1 } , { SYBDECIMAL, SYBDATETIME , 0 } , { SYBDECIMAL, SYBDATETIME4 , 0 } , { SYBDECIMAL, SYBBOUNDARY , 0 } , { SYBDECIMAL, SYBUNIQUE , 0 } , { SYBDECIMAL, SYBSENSITIVITY , 0 } , { SYBBIT, SYBVARCHAR , 1 } , { SYBBIT, SYBCHAR , 1 } , { SYBBIT, SYBTEXT , 1 } , { SYBBIT, SYBBINARY , 1 } , { SYBBIT, SYBVARBINARY , 1 } , { SYBBIT, SYBIMAGE , 1 } , { SYBBIT, SYBINT1 , 1 } , { SYBBIT, SYBINT2 , 1 } , { SYBBIT, SYBINT4 , 1 } , { SYBBIT, SYBINT8 , 1 } , { SYBBIT, SYBFLT8 , 1 } , { SYBBIT, SYBREAL , 1 } , { SYBBIT, SYBNUMERIC , 1 } , { SYBBIT, SYBDECIMAL , 1 } , { SYBBIT, SYBBIT , 1 } , { SYBBIT, SYBMONEY , 1 } , { SYBBIT, SYBMONEY4 , 1 } , { SYBBIT, SYBDATETIME , 0 } , { SYBBIT, SYBDATETIME4 , 0 } , { SYBBIT, SYBBOUNDARY , 0 } , { SYBBIT, SYBUNIQUE , 0 } , { SYBBIT, SYBSENSITIVITY , 0 } , { SYBMONEY, SYBVARCHAR , 1 } , { SYBMONEY, SYBCHAR , 1 } , { SYBMONEY, SYBTEXT , 1 } , { SYBMONEY, SYBBINARY , 1 } , { SYBMONEY, SYBVARBINARY , 1 } , { SYBMONEY, SYBIMAGE , 1 } , { SYBMONEY, SYBINT1 , 1 } , { SYBMONEY, SYBINT2 , 1 } , { SYBMONEY, SYBINT4 , 1 } , { SYBMONEY, SYBINT8 , 1 } , { SYBMONEY, SYBFLT8 , 1 } , { SYBMONEY, SYBREAL , 1 } , { SYBMONEY, SYBNUMERIC , 1 } , { SYBMONEY, SYBDECIMAL , 1 } , { SYBMONEY, SYBBIT , 1 } , { SYBMONEY, SYBMONEY , 1 } , { SYBMONEY, SYBMONEY4 , 1 } , { SYBMONEY, SYBDATETIME , 0 } , { SYBMONEY, SYBDATETIME4 , 0 } , { SYBMONEY, SYBBOUNDARY , 0 } , { SYBMONEY, SYBUNIQUE , 0 } , { SYBMONEY, SYBSENSITIVITY , 0 } , { SYBMONEY4, SYBVARCHAR , 1 } , { SYBMONEY4, SYBCHAR , 1 } , { SYBMONEY4, SYBTEXT , 1 } , { SYBMONEY4, SYBBINARY , 1 } , { SYBMONEY4, SYBVARBINARY , 1 } , { SYBMONEY4, SYBIMAGE , 1 } , { SYBMONEY4, SYBINT1 , 1 } , { SYBMONEY4, SYBINT2 , 1 } , { SYBMONEY4, SYBINT4 , 1 } , { SYBMONEY4, SYBINT8 , 1 } , { SYBMONEY4, SYBFLT8 , 1 } , { SYBMONEY4, SYBREAL , 1 } , { SYBMONEY4, SYBNUMERIC , 1 } , { SYBMONEY4, SYBDECIMAL , 1 } , { SYBMONEY4, SYBBIT , 1 } , { SYBMONEY4, SYBMONEY , 1 } , { SYBMONEY4, SYBMONEY4 , 1 } , { SYBMONEY4, SYBDATETIME , 0 } , { SYBMONEY4, SYBDATETIME4 , 0 } , { SYBMONEY4, SYBBOUNDARY , 0 } , { SYBMONEY4, SYBUNIQUE , 0 } , { SYBMONEY4, SYBSENSITIVITY , 0 } , { SYBDATETIME, SYBVARCHAR , 1 } , { SYBDATETIME, SYBCHAR , 1 } , { SYBDATETIME, SYBTEXT , 1 } , { SYBDATETIME, SYBBINARY , 1 } , { SYBDATETIME, SYBVARBINARY , 1 } , { SYBDATETIME, SYBIMAGE , 1 } , { SYBDATETIME, SYBINT1 , 0 } , { SYBDATETIME, SYBINT2 , 0 } , { SYBDATETIME, SYBINT4 , 0 } , { SYBDATETIME, SYBINT8 , 0 } , { SYBDATETIME, SYBFLT8 , 0 } , { SYBDATETIME, SYBREAL , 0 } , { SYBDATETIME, SYBNUMERIC , 0 } , { SYBDATETIME, SYBDECIMAL , 0 } , { SYBDATETIME, SYBBIT , 0 } , { SYBDATETIME, SYBMONEY , 0 } , { SYBDATETIME, SYBMONEY4 , 0 } , { SYBDATETIME, SYBDATETIME , 1 } , { SYBDATETIME, SYBDATETIME4 , 1 } , { SYBDATETIME, SYBBOUNDARY , 0 } , { SYBDATETIME, SYBUNIQUE , 0 } , { SYBDATETIME, SYBSENSITIVITY , 0 } , { SYBDATETIME4, SYBVARCHAR , 1 } , { SYBDATETIME4, SYBCHAR , 1 } , { SYBDATETIME4, SYBTEXT , 1 } , { SYBDATETIME4, SYBBINARY , 1 } , { SYBDATETIME4, SYBVARBINARY , 1 } , { SYBDATETIME4, SYBIMAGE , 1 } , { SYBDATETIME4, SYBINT1 , 0 } , { SYBDATETIME4, SYBINT2 , 0 } , { SYBDATETIME4, SYBINT4 , 0 } , { SYBDATETIME4, SYBINT8 , 0 } , { SYBDATETIME4, SYBFLT8 , 0 } , { SYBDATETIME4, SYBREAL , 0 } , { SYBDATETIME4, SYBNUMERIC , 0 } , { SYBDATETIME4, SYBDECIMAL , 0 } , { SYBDATETIME4, SYBBIT , 0 } , { SYBDATETIME4, SYBMONEY , 0 } , { SYBDATETIME4, SYBMONEY4 , 0 } , { SYBDATETIME4, SYBDATETIME , 1 } , { SYBDATETIME4, SYBDATETIME4 , 1 } , { SYBDATETIME4, SYBBOUNDARY , 0 } , { SYBDATETIME4, SYBUNIQUE , 0 } , { SYBDATETIME4, SYBSENSITIVITY , 0 } , { SYBBOUNDARY, SYBVARCHAR , 1 } , { SYBBOUNDARY, SYBCHAR , 1 } , { SYBBOUNDARY, SYBTEXT , 1 } , { SYBBOUNDARY, SYBBINARY , 0 } , { SYBBOUNDARY, SYBVARBINARY , 0 } , { SYBBOUNDARY, SYBIMAGE , 0 } , { SYBBOUNDARY, SYBINT1 , 0 } , { SYBBOUNDARY, SYBINT2 , 0 } , { SYBBOUNDARY, SYBINT4 , 0 } , { SYBBOUNDARY, SYBINT8 , 0 } , { SYBBOUNDARY, SYBFLT8 , 0 } , { SYBBOUNDARY, SYBREAL , 0 } , { SYBBOUNDARY, SYBNUMERIC , 0 } , { SYBBOUNDARY, SYBDECIMAL , 0 } , { SYBBOUNDARY, SYBBIT , 0 } , { SYBBOUNDARY, SYBMONEY , 0 } , { SYBBOUNDARY, SYBMONEY4 , 0 } , { SYBBOUNDARY, SYBDATETIME , 0 } , { SYBBOUNDARY, SYBDATETIME4 , 0 } , { SYBBOUNDARY, SYBBOUNDARY , 1 } , { SYBBOUNDARY, SYBUNIQUE , 0 } , { SYBBOUNDARY, SYBSENSITIVITY , 0 } , { SYBUNIQUE, SYBVARCHAR , 1 } , { SYBUNIQUE, SYBCHAR , 1 } , { SYBUNIQUE, SYBTEXT , 1 } , { SYBUNIQUE, SYBBINARY , 0 } , { SYBUNIQUE, SYBVARBINARY , 0 } , { SYBUNIQUE, SYBIMAGE , 0 } , { SYBUNIQUE, SYBINT1 , 0 } , { SYBUNIQUE, SYBINT2 , 0 } , { SYBUNIQUE, SYBINT4 , 0 } , { SYBUNIQUE, SYBINT8 , 0 } , { SYBUNIQUE, SYBFLT8 , 0 } , { SYBUNIQUE, SYBREAL , 0 } , { SYBUNIQUE, SYBNUMERIC , 0 } , { SYBUNIQUE, SYBDECIMAL , 0 } , { SYBUNIQUE, SYBBIT , 0 } , { SYBUNIQUE, SYBMONEY , 0 } , { SYBUNIQUE, SYBMONEY4 , 0 } , { SYBUNIQUE, SYBDATETIME , 0 } , { SYBUNIQUE, SYBDATETIME4 , 0 } , { SYBUNIQUE, SYBBOUNDARY , 0 } , { SYBUNIQUE, SYBUNIQUE , 1 } , { SYBUNIQUE, SYBSENSITIVITY , 0 } , { SYBSENSITIVITY, SYBVARCHAR , 0 } , { SYBSENSITIVITY, SYBCHAR , 0 } , { SYBSENSITIVITY, SYBTEXT , 0 } , { SYBSENSITIVITY, SYBBINARY , 0 } , { SYBSENSITIVITY, SYBVARBINARY , 0 } , { SYBSENSITIVITY, SYBIMAGE , 0 } , { SYBSENSITIVITY, SYBINT1 , 0 } , { SYBSENSITIVITY, SYBINT2 , 0 } , { SYBSENSITIVITY, SYBINT4 , 0 } , { SYBSENSITIVITY, SYBINT8 , 0 } , { SYBSENSITIVITY, SYBFLT8 , 0 } , { SYBSENSITIVITY, SYBREAL , 0 } , { SYBSENSITIVITY, SYBNUMERIC , 0 } , { SYBSENSITIVITY, SYBDECIMAL , 0 } , { SYBSENSITIVITY, SYBBIT , 0 } , { SYBSENSITIVITY, SYBMONEY , 0 } , { SYBSENSITIVITY, SYBMONEY4 , 0 } , { SYBSENSITIVITY, SYBDATETIME , 0 } , { SYBSENSITIVITY, SYBDATETIME4 , 0 } , { SYBSENSITIVITY, SYBBOUNDARY , 0 } , { SYBSENSITIVITY, SYBUNIQUE , 0 } , { SYBSENSITIVITY, SYBSENSITIVITY , 0 } freetds-0.91/src/tds/encodings.h100664 001750 000144 00000057451 11623073520 0012315/* * This file produced from ../../../src/tds/encodings.pl on Wed Aug 17 22:22:08 2011 * $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 */ {"", 0, 0, 0} }; 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-0.91/src/tds/num_limits.h100664 001750 000144 00000046560 11623073521 0012524#ifndef HAVE_INT64 #define LIMIT_INDEXES_ADJUST 6 static const signed char limit_indexes[79]= { 0, /* 0 */ -5, /* 1 */ -10, /* 2 */ -15, /* 3 */ -20, /* 4 */ -25, /* 5 */ -29, /* 6 */ -33, /* 7 */ -37, /* 8 */ -41, /* 9 */ -45, /* 10 */ -48, /* 11 */ -51, /* 12 */ -54, /* 13 */ -57, /* 14 */ -60, /* 15 */ -62, /* 16 */ -65, /* 17 */ -68, /* 18 */ -71, /* 19 */ -74, /* 20 */ -76, /* 21 */ -78, /* 22 */ -80, /* 23 */ -82, /* 24 */ -84, /* 25 */ -85, /* 26 */ -86, /* 27 */ -87, /* 28 */ -88, /* 29 */ -88, /* 30 */ -88, /* 31 */ -88, /* 32 */ -89, /* 33 */ -90, /* 34 */ -90, /* 35 */ -90, /* 36 */ -90, /* 37 */ -90, /* 38 */ -90, /* 39 */ -89, /* 40 */ -88, /* 41 */ -87, /* 42 */ -86, /* 43 */ -85, /* 44 */ -83, /* 45 */ -81, /* 46 */ -79, /* 47 */ -77, /* 48 */ -76, /* 49 */ -74, /* 50 */ -72, /* 51 */ -70, /* 52 */ -68, /* 53 */ -65, /* 54 */ -62, /* 55 */ -59, /* 56 */ -56, /* 57 */ -53, /* 58 */ -49, /* 59 */ -45, /* 60 */ -41, /* 61 */ -37, /* 62 */ -33, /* 63 */ -28, /* 64 */ -24, /* 65 */ -20, /* 66 */ -16, /* 67 */ -12, /* 68 */ -7, /* 69 */ -2, /* 70 */ 3, /* 71 */ 8, /* 72 */ 13, /* 73 */ 19, /* 74 */ 25, /* 75 */ 31, /* 76 */ 37, /* 77 */ 43, /* 78 */ }; static const TDS_WORD limits[]= { 0x0001u, /* 0 */ 0x000au, /* 1 */ 0x0064u, /* 2 */ 0x03e8u, /* 3 */ 0x2710u, /* 4 */ 0x0001u, /* 5 */ 0x86a0u, /* 6 */ 0x000fu, /* 7 */ 0x4240u, /* 8 */ 0x0098u, /* 9 */ 0x9680u, /* 10 */ 0x05f5u, /* 11 */ 0xe100u, /* 12 */ 0x3b9au, /* 13 */ 0xca00u, /* 14 */ 0x0002u, /* 15 */ 0x540bu, /* 16 */ 0xe400u, /* 17 */ 0x0017u, /* 18 */ 0x4876u, /* 19 */ 0xe800u, /* 20 */ 0x00e8u, /* 21 */ 0xd4a5u, /* 22 */ 0x1000u, /* 23 */ 0x0918u, /* 24 */ 0x4e72u, /* 25 */ 0xa000u, /* 26 */ 0x5af3u, /* 27 */ 0x107au, /* 28 */ 0x4000u, /* 29 */ 0x0003u, /* 30 */ 0x8d7eu, /* 31 */ 0xa4c6u, /* 32 */ 0x8000u, /* 33 */ 0x0023u, /* 34 */ 0x86f2u, /* 35 */ 0x6fc1u, /* 36 */ 0x0163u, /* 37 */ 0x4578u, /* 38 */ 0x5d8au, /* 39 */ 0x0de0u, /* 40 */ 0xb6b3u, /* 41 */ 0xa764u, /* 42 */ 0x8ac7u, /* 43 */ 0x2304u, /* 44 */ 0x89e8u, /* 45 */ 0x0005u, /* 46 */ 0x6bc7u, /* 47 */ 0x5e2du, /* 48 */ 0x6310u, /* 49 */ 0x0036u, /* 50 */ 0x35c9u, /* 51 */ 0xadc5u, /* 52 */ 0xdea0u, /* 53 */ 0x021eu, /* 54 */ 0x19e0u, /* 55 */ 0xc9bau, /* 56 */ 0xb240u, /* 57 */ 0x152du, /* 58 */ 0x02c7u, /* 59 */ 0xe14au, /* 60 */ 0xf680u, /* 61 */ 0xd3c2u, /* 62 */ 0x1bceu, /* 63 */ 0xccedu, /* 64 */ 0xa100u, /* 65 */ 0x0008u, /* 66 */ 0x4595u, /* 67 */ 0x1614u, /* 68 */ 0x0148u, /* 69 */ 0x4a00u, /* 70 */ 0x0052u, /* 71 */ 0xb7d2u, /* 72 */ 0xdcc8u, /* 73 */ 0x0cd2u, /* 74 */ 0xe400u, /* 75 */ 0x033bu, /* 76 */ 0x2e3cu, /* 77 */ 0x9fd0u, /* 78 */ 0x803cu, /* 79 */ 0xe800u, /* 80 */ 0x204fu, /* 81 */ 0xce5eu, /* 82 */ 0x3e25u, /* 83 */ 0x0261u, /* 84 */ 0x1000u, /* 85 */ 0x0001u, /* 86 */ 0x431eu, /* 87 */ 0x0faeu, /* 88 */ 0x6d72u, /* 89 */ 0x17cau, /* 90 */ 0xa000u, /* 91 */ 0x000cu, /* 92 */ 0x9f2cu, /* 93 */ 0x9cd0u, /* 94 */ 0x4674u, /* 95 */ 0xedeau, /* 96 */ 0x4000u, /* 97 */ 0x007eu, /* 98 */ 0x37beu, /* 99 */ 0x2022u, /* 100 */ 0xc091u, /* 101 */ 0x4b26u, /* 102 */ 0x8000u, /* 103 */ 0x04eeu, /* 104 */ 0x2d6du, /* 105 */ 0x415bu, /* 106 */ 0x85acu, /* 107 */ 0xef81u, /* 108 */ 0x314du, /* 109 */ 0xc644u, /* 110 */ 0x8d93u, /* 111 */ 0x38c1u, /* 112 */ 0x5b0au, /* 113 */ 0x0001u, /* 114 */ 0xed09u, /* 115 */ 0xbeadu, /* 116 */ 0x87c0u, /* 117 */ 0x378du, /* 118 */ 0x8e64u, /* 119 */ 0x0013u, /* 120 */ 0x4261u, /* 121 */ 0x72c7u, /* 122 */ 0x4d82u, /* 123 */ 0x2b87u, /* 124 */ 0x8fe8u, /* 125 */ 0x00c0u, /* 126 */ 0x97ceu, /* 127 */ 0x7bc9u, /* 128 */ 0x0715u, /* 129 */ 0xb34bu, /* 130 */ 0x9f10u, /* 131 */ 0x0785u, /* 132 */ 0xee10u, /* 133 */ 0xd5dau, /* 134 */ 0x46d9u, /* 135 */ 0x00f4u, /* 136 */ 0x36a0u, /* 137 */ 0x4b3bu, /* 138 */ 0x4ca8u, /* 139 */ 0x5a86u, /* 140 */ 0xc47au, /* 141 */ 0x098au, /* 142 */ 0x2240u, /* 143 */ 0x0002u, /* 144 */ 0xf050u, /* 145 */ 0xfe93u, /* 146 */ 0x8943u, /* 147 */ 0xacc4u, /* 148 */ 0x5f65u, /* 149 */ 0x5680u, /* 150 */ 0x001du, /* 151 */ 0x6329u, /* 152 */ 0xf1c3u, /* 153 */ 0x5ca4u, /* 154 */ 0xbfabu, /* 155 */ 0xb9f5u, /* 156 */ 0x6100u, /* 157 */ 0x0125u, /* 158 */ 0xdfa3u, /* 159 */ 0x71a1u, /* 160 */ 0x9e6fu, /* 161 */ 0x7cb5u, /* 162 */ 0x4395u, /* 163 */ 0xca00u, /* 164 */ 0x0b7au, /* 165 */ 0xbc62u, /* 166 */ 0x7050u, /* 167 */ 0x305au, /* 168 */ 0xdf14u, /* 169 */ 0xa3d9u, /* 170 */ 0xe400u, /* 171 */ 0x72cbu, /* 172 */ 0x5bd8u, /* 173 */ 0x6321u, /* 174 */ 0xe38cu, /* 175 */ 0xb6ceu, /* 176 */ 0x6682u, /* 177 */ 0xe800u, /* 178 */ 0x0004u, /* 179 */ 0x7bf1u, /* 180 */ 0x9673u, /* 181 */ 0xdf52u, /* 182 */ 0xe37fu, /* 183 */ 0x2410u, /* 184 */ 0x011du, /* 185 */ 0x1000u, /* 186 */ 0x002cu, /* 187 */ 0xd76fu, /* 188 */ 0xe086u, /* 189 */ 0xb93cu, /* 190 */ 0xe2f7u, /* 191 */ 0x68a0u, /* 192 */ 0x0b22u, /* 193 */ 0xa000u, /* 194 */ 0x01c0u, /* 195 */ 0x6a5eu, /* 196 */ 0xc543u, /* 197 */ 0x3c60u, /* 198 */ 0xddaau, /* 199 */ 0x1640u, /* 200 */ 0x6f5au, /* 201 */ 0x4000u, /* 202 */ 0x1184u, /* 203 */ 0x27b3u, /* 204 */ 0xb4a0u, /* 205 */ 0x5bc8u, /* 206 */ 0xa8a4u, /* 207 */ 0xde84u, /* 208 */ 0x5986u, /* 209 */ 0x8000u, /* 210 */ 0xaf29u, /* 211 */ 0x8d05u, /* 212 */ 0x0e43u, /* 213 */ 0x95d6u, /* 214 */ 0x9670u, /* 215 */ 0xb12bu, /* 216 */ 0x7f41u, /* 217 */ 0x0006u, /* 218 */ 0xd79fu, /* 219 */ 0x8232u, /* 220 */ 0x8ea3u, /* 221 */ 0xda61u, /* 222 */ 0xe066u, /* 223 */ 0xebb2u, /* 224 */ 0xf88au, /* 225 */ 0x0044u, /* 226 */ 0x6c3bu, /* 227 */ 0x15f9u, /* 228 */ 0x9266u, /* 229 */ 0x87d2u, /* 230 */ 0xc405u, /* 231 */ 0x34fdu, /* 232 */ 0xb564u, /* 233 */ 0x02acu, /* 234 */ 0x3a4eu, /* 235 */ 0xdbbfu, /* 236 */ 0xb801u, /* 237 */ 0x4e3bu, /* 238 */ 0xa834u, /* 239 */ 0x11e9u, /* 240 */ 0x15e8u, /* 241 */ 0x1abau, /* 242 */ 0x4714u, /* 243 */ 0x957du, /* 244 */ 0x300du, /* 245 */ 0x0e54u, /* 246 */ 0x9208u, /* 247 */ 0xb31au, /* 248 */ 0xdb10u, /* 249 */ 0x0001u, /* 250 */ 0x0b46u, /* 251 */ 0xc6cdu, /* 252 */ 0xd6e3u, /* 253 */ 0xe082u, /* 254 */ 0x8f4du, /* 255 */ 0xb456u, /* 256 */ 0xff0cu, /* 257 */ 0x8ea0u, /* 258 */ 0x000au, /* 259 */ 0x70c3u, /* 260 */ 0xc40au, /* 261 */ 0x64e6u, /* 262 */ 0xc519u, /* 263 */ 0x9909u, /* 264 */ 0x0b65u, /* 265 */ 0xf67du, /* 266 */ 0x9240u, /* 267 */ 0x0068u, /* 268 */ 0x67a5u, /* 269 */ 0xa867u, /* 270 */ 0xf103u, /* 271 */ 0xb2ffu, /* 272 */ 0xfa5au, /* 273 */ 0x71fbu, /* 274 */ 0xa0e7u, /* 275 */ 0xb680u, /* 276 */ 0x0414u, /* 277 */ 0x0c78u, /* 278 */ 0x940fu, /* 279 */ 0x6a24u, /* 280 */ 0xfdffu, /* 281 */ 0xc788u, /* 282 */ 0x73d4u, /* 283 */ 0x490du, /* 284 */ 0x2100u, /* 285 */ 0x28c8u, /* 286 */ 0x7cb5u, /* 287 */ 0xc89au, /* 288 */ 0x2571u, /* 289 */ 0xebfdu, /* 290 */ 0xcb54u, /* 291 */ 0x864au, /* 292 */ 0xda83u, /* 293 */ 0x4a00u, /* 294 */ 0x0001u, /* 295 */ 0x97d4u, /* 296 */ 0xdf19u, /* 297 */ 0xd605u, /* 298 */ 0x7673u, /* 299 */ 0x37e9u, /* 300 */ 0xf14du, /* 301 */ 0x3eecu, /* 302 */ 0x8920u, /* 303 */ 0xe400u, /* 304 */ 0x000fu, /* 305 */ 0xee50u, /* 306 */ 0xb702u, /* 307 */ 0x5c36u, /* 308 */ 0xa080u, /* 309 */ 0x2f23u, /* 310 */ 0x6d04u, /* 311 */ 0x753du, /* 312 */ 0x5b48u, /* 313 */ 0xe800u, /* 314 */ 0x009fu, /* 315 */ 0x4f27u, /* 316 */ 0x2617u, /* 317 */ 0x9a22u, /* 318 */ 0x4501u, /* 319 */ 0xd762u, /* 320 */ 0x422cu, /* 321 */ 0x9465u, /* 322 */ 0x90d9u, /* 323 */ 0x1000u, /* 324 */ 0x0639u, /* 325 */ 0x1787u, /* 326 */ 0x7cecu, /* 327 */ 0x0556u, /* 328 */ 0xb212u, /* 329 */ 0x69d6u, /* 330 */ 0x95bdu, /* 331 */ 0xcbf7u, /* 332 */ 0xa87au, /* 333 */ 0xa000u, /* 334 */ 0x3e3au, /* 335 */ 0xeb4au, /* 336 */ 0xe138u, /* 337 */ 0x3562u, /* 338 */ 0xf4b8u, /* 339 */ 0x2261u, /* 340 */ 0xd969u, /* 341 */ 0xf7acu, /* 342 */ 0x94cau, /* 343 */ 0x4000u, /* 344 */ 0x0002u, /* 345 */ 0x6e4du, /* 346 */ 0x30ecu, /* 347 */ 0xcc32u, /* 348 */ 0x15ddu, /* 349 */ 0x8f31u, /* 350 */ 0x57d2u, /* 351 */ 0x7e23u, /* 352 */ 0xacbdu, /* 353 */ 0xcfe6u, /* 354 */ 0x8000u, /* 355 */ 0x0018u, /* 356 */ 0x4f03u, /* 357 */ 0xe93fu, /* 358 */ 0xf9f4u, /* 359 */ 0xdaa7u, /* 360 */ 0x97edu, /* 361 */ 0x6e38u, /* 362 */ 0xed64u, /* 363 */ 0xbf6au, /* 364 */ 0x1f01u, /* 365 */ 0x00f3u, /* 366 */ 0x1627u, /* 367 */ 0x1c7fu, /* 368 */ 0xc390u, /* 369 */ 0x8a8bu, /* 370 */ 0xef46u, /* 371 */ 0x4e39u, /* 372 */ 0x45efu, /* 373 */ 0x7a25u, /* 374 */ 0x360au, /* 375 */ 0x097eu, /* 376 */ 0xdd87u, /* 377 */ 0x1cfdu, /* 378 */ 0xa3a5u, /* 379 */ 0x6977u, /* 380 */ 0x58bfu, /* 381 */ 0x0e3cu, /* 382 */ 0xbb5au, /* 383 */ 0xc574u, /* 384 */ 0x1c64u, /* 385 */ 0x5ef4u, /* 386 */ 0xa747u, /* 387 */ 0x21e8u, /* 388 */ 0x6476u, /* 389 */ 0x1ea9u, /* 390 */ 0x7776u, /* 391 */ 0x8e5fu, /* 392 */ 0x518bu, /* 393 */ 0xb689u, /* 394 */ 0x1be8u, /* 395 */ 0x0003u, /* 396 */ 0xb58eu, /* 397 */ 0x88c7u, /* 398 */ 0x5313u, /* 399 */ 0xec9du, /* 400 */ 0x329eu, /* 401 */ 0xaaa1u, /* 402 */ 0x8fb9u, /* 403 */ 0x2f75u, /* 404 */ 0x215bu, /* 405 */ 0x1710u, /* 406 */ 0x0025u, /* 407 */ 0x1791u, /* 408 */ 0x57c9u, /* 409 */ 0x3ec7u, /* 410 */ 0x3e23u, /* 411 */ 0xfa32u, /* 412 */ 0xaa4fu, /* 413 */ 0x9d3bu, /* 414 */ 0xda93u, /* 415 */ 0x4d8eu, /* 416 */ 0xe6a0u, /* 417 */ 0x0172u, /* 418 */ 0xebadu, /* 419 */ 0x6ddcu, /* 420 */ 0x73c8u, /* 421 */ 0x6d67u, /* 422 */ 0xc5fau, /* 423 */ 0xa71cu, /* 424 */ 0x2456u, /* 425 */ 0x89c1u, /* 426 */ 0x0795u, /* 427 */ 0x0240u, /* 428 */ 0x0e7du, /* 429 */ 0x34c6u, /* 430 */ 0x4a9cu, /* 431 */ 0x85d4u, /* 432 */ 0x460du, /* 433 */ 0xbbcau, /* 434 */ 0x8719u, /* 435 */ 0x6b61u, /* 436 */ 0x618au, /* 437 */ 0x4bd2u, /* 438 */ 0x1680u, /* 439 */ 0x90e4u, /* 440 */ 0x0fbeu, /* 441 */ 0xea1du, /* 442 */ 0x3a4au, /* 443 */ 0xbc89u, /* 444 */ 0x55e9u, /* 445 */ 0x46feu, /* 446 */ 0x31cdu, /* 447 */ 0xcf66u, /* 448 */ 0xf634u, /* 449 */ 0xe100u, /* 450 */ 0x0005u, /* 451 */ 0xa8e8u, /* 452 */ 0x9d75u, /* 453 */ 0x2524u, /* 454 */ 0x46ebu, /* 455 */ 0x5d5du, /* 456 */ 0x5b1cu, /* 457 */ 0xc5edu, /* 458 */ 0xf20au, /* 459 */ 0x1a05u, /* 460 */ 0x9e10u, /* 461 */ 0xca00u, /* 462 */ 0x0038u, /* 463 */ 0x9916u, /* 464 */ 0x2693u, /* 465 */ 0x736au, /* 466 */ 0xc531u, /* 467 */ 0xa5a5u, /* 468 */ 0x8f1fu, /* 469 */ 0xbb4bu, /* 470 */ 0x7465u, /* 471 */ 0x0438u, /* 472 */ 0x2ca7u, /* 473 */ 0xe400u, /* 474 */ 0x0235u, /* 475 */ 0xfaddu, /* 476 */ 0x81c2u, /* 477 */ 0x822bu, /* 478 */ 0xb3f0u, /* 479 */ 0x7877u, /* 480 */ 0x973du, /* 481 */ 0x50f2u, /* 482 */ 0x8bf2u, /* 483 */ 0x2a31u, /* 484 */ 0xbe8eu, /* 485 */ 0xe800u, /* 486 */ 0x161bu, /* 487 */ 0xcca7u, /* 488 */ 0x1199u, /* 489 */ 0x15b5u, /* 490 */ 0x0764u, /* 491 */ 0xb4abu, /* 492 */ 0xe865u, /* 493 */ 0x2979u, /* 494 */ 0x7775u, /* 495 */ 0xa5f1u, /* 496 */ 0x7195u, /* 497 */ 0x1000u, /* 498 */ 0xdd15u, /* 499 */ 0xfe86u, /* 500 */ 0xaffau, /* 501 */ 0xd912u, /* 502 */ 0x49efu, /* 503 */ 0x0eb7u, /* 504 */ 0x13f3u, /* 505 */ 0x9ebeu, /* 506 */ 0xaa98u, /* 507 */ 0x7b6eu, /* 508 */ 0x6fd2u, /* 509 */ 0xa000u, /* 510 */ }; #else #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 */ }; #endif freetds-0.91/src/tds/tds_types.h100664 001750 000144 00000005535 11623073521 0012357/* * This file produced from ../../../src/tds/types.pl * CVS Id: types.pl,v 1.3 2010/10/29 08:49:30 freddy77 Exp */ /** * Return the number of bytes needed by specified type. */ int tds_get_size_by_type(int 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 SYBDATE: case SYBDATEN: case SYBDATETIME4: case SYBINT4: case SYBMONEY4: case SYBREAL: case SYBTIME: case SYBTIMEN: case SYBUINT4: return 4; case SYB5INT8: case SYBDATETIME: case SYBFLT8: case SYBINT8: case SYBINTERVAL: case SYBMONEY: case SYBUINT8: return 8; case SYBUNIQUE: return 16; default: return -1; } } /** * 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(TDSSOCKET * tds, 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(tds)) { 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 SYBMSXML: return 8; } } else if (IS_TDS50(tds)) { 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 */ int tds_get_conversion_type(int 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; } return srctype; } freetds-0.91/src/tds/Makefile.am100644 001750 000144 00000003722 11557650317 0012230# $Id: Makefile.am,v 1.72.2.1 2011/04/22 14:14:16 freddy77 Exp $ 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 \ tds_checks.c tds_checks.h enum_cap.h log.c \ bulk.c win_mutex.c \ $(AUTH_FILES) libtds_la_LDFLAGS= libtds_la_LIBADD= 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 \ TDS.vcproj ptw32_MCS_lock.c $(AUTH_FILES_DIST) if HAVE_DOXYGEN doxyfile: $(srcdir)/tds.dox cp $(srcdir)/tds.dox doxyfile ## The doxygen configuration file understands environment variables. doxy: doxyfile $(libtds_la_SOURCES) SRCDIR=$(srcdir); \ TOP_SRCDIR=$(top_srcdir); \ export SRCDIR TOP_SRCDIR; \ $(DOXYGEN) doxyfile endif # Perl is needed to build from a CVS 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 > $@.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 ../../misc/types.txt perl $(srcdir)/types.pl < $(srcdir)/../../misc/types.txt > $@.tmp mv $@.tmp $@ endif freetds-0.91/src/tds/Makefile.in100664 001750 000144 00000064546 11623070620 0012241# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.72.2.1 2011/04/22 14:14:16 freddy77 Exp $ VPATH = @srcdir@ 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 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtds_la_DEPENDENCIES = 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 \ tds_checks.c tds_checks.h enum_cap.h log.c bulk.c win_mutex.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 tds_checks.lo log.lo bulk.lo win_mutex.lo \ $(am__objects_1) libtds_la_OBJECTS = $(am_libtds_la_OBJECTS) libtds_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libtds_la_LDFLAGS) $(LDFLAGS) -o $@ 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtds_la_SOURCES) DIST_SOURCES = $(am__libtds_la_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-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 uninstall-recursive HEADERS = $(noinst_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) 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@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 \ tds_checks.c tds_checks.h enum_cap.h log.c \ bulk.c win_mutex.c \ $(AUTH_FILES) libtds_la_LDFLAGS = libtds_la_LIBADD = 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 \ TDS.vcproj ptw32_MCS_lock.c $(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 .PRECIOUS: 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)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtds.la: $(libtds_la_OBJECTS) $(libtds_la_DEPENDENCIES) $(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)/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)/query.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sspi.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)/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)/win_mutex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(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. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; 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" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) 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; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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 \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ ctags-recursive install install-am install-strip \ tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic clean-libtool \ clean-local clean-noinstLTLIBRARIES ctags ctags-recursive \ 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-recursive uninstall uninstall-am @HAVE_DOXYGEN_TRUE@doxyfile: $(srcdir)/tds.dox @HAVE_DOXYGEN_TRUE@ cp $(srcdir)/tds.dox doxyfile @HAVE_DOXYGEN_TRUE@doxy: doxyfile $(libtds_la_SOURCES) @HAVE_DOXYGEN_TRUE@ SRCDIR=$(srcdir); \ @HAVE_DOXYGEN_TRUE@ TOP_SRCDIR=$(top_srcdir); \ @HAVE_DOXYGEN_TRUE@ export SRCDIR TOP_SRCDIR; \ @HAVE_DOXYGEN_TRUE@ $(DOXYGEN) doxyfile # Perl is needed to build from a CVS 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 > $@.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 ../../misc/types.txt @HAVE_PERL_SOURCES_TRUE@ perl $(srcdir)/types.pl < $(srcdir)/../../misc/types.txt > $@.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-0.91/src/tds/mem.c100644 001750 000144 00000122102 11623070342 0011074/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include "tds.h" #include "tdsiconv.h" #include "tds_checks.h" #include "tdsstring.h" #include "replacements.h" #include "enum_cap.h" #ifdef STRING_H #include #endif #ifdef HAVE_LOCALE_H #include #endif /* HAVE_LOCALE_H */ #ifdef HAVE_LANGINFO_H #include #endif /* HAVE_LANGINFO_H */ #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: mem.c,v 1.208.2.1 2011/08/12 16:29:36 freddy77 Exp $"); static void tds_free_env(TDSSOCKET * tds); 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;} #define tds_alloc_column() ((TDSCOLUMN*) calloc(1, sizeof(TDSCOLUMN))) /** * \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 int inc_num = 1; /** * Get an id for dynamic query based on TDS information * \param tds state information for the socket and the TDS protocol * \return TDS_FAIL or TDS_SUCCEED */ static char * tds_get_dynid(TDSSOCKET * tds, char *id) { unsigned long n; int i; char *p; char c; CHECK_TDS_EXTRA(tds); inc_num = (inc_num + 1) & 0xffff; /* some version of Sybase require length <= 10, so we code id */ n = (unsigned long) (TDS_INTPTR) tds; 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; } /** * \fn TDSDYNAMIC *tds_alloc_dynamic(TDSSOCKET *tds, const char *id) * \brief Allocate a dynamic statement. * \param tds 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(TDSSOCKET * tds, const char *id) { TDSDYNAMIC *dyn; char tmp_id[30]; if (id) { /* check to see if id already exists (shouldn't) */ if (tds_lookup_dynamic(tds, id)) return NULL; } else { unsigned int n; id = tmp_id; for (n = 0;;) { if (!tds_lookup_dynamic(tds, tds_get_dynid(tds, tmp_id))) break; if (++n == 256) return NULL; } } dyn = (TDSDYNAMIC *) calloc(1, sizeof(TDSDYNAMIC)); if (!dyn) return NULL; /* insert into list */ dyn->next = tds->dyns; tds->dyns = dyn; tds_strlcpy(dyn->id, id, TDS_MAX_DYNID_LEN); return dyn; } /** * \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; } } /** * \fn void tds_free_dynamic(TDSSOCKET *tds, TDSDYNAMIC *dyn) * \brief Frees dynamic statement and remove from TDS * \param tds state information for the socket and the TDS protocol * \param dyn dynamic statement to be freed. */ void tds_free_dynamic(TDSSOCKET * tds, TDSDYNAMIC * dyn) { TDSDYNAMIC **pcurr; /* avoid pointer to garbage */ if (tds->cur_dyn == dyn) tds->cur_dyn = NULL; if (tds->current_results == dyn->res_info) tds->current_results = NULL; /* free from tds */ for (pcurr = &tds->dyns; *pcurr != NULL; pcurr = &(*pcurr)->next) if (dyn == *pcurr) { *pcurr = dyn->next; break; } 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; TDSCOLUMN **cols; colinfo = tds_alloc_column(); if (!colinfo) return NULL; if (!old_param || !old_param->num_cols) { cols = (TDSCOLUMN **) malloc(sizeof(TDSCOLUMN *)); } else { cols = (TDSCOLUMN **) realloc(old_param->columns, sizeof(TDSCOLUMN *) * (old_param->num_cols + 1)); } if (!cols) goto Cleanup; if (!old_param) { param_info = (TDSPARAMINFO *) calloc(1, sizeof(TDSPARAMINFO)); if (!param_info) { free(cols); goto Cleanup; } param_info->ref_count = 1; } else { param_info = old_param; } param_info->columns = cols; param_info->columns[param_info->num_cols++] = colinfo; return param_info; Cleanup: 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 && param_info->columns) 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 */ free(col->table_column_name); free(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); if (is_numeric_type(curparam->column_type)) { data_size = sizeof(TDS_NUMERIC); } else if (is_blob_col(curparam)) { data_size = sizeof(TDSBLOB); } else { data_size = curparam->column_size; } /* 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 = 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(int num_cols, int by_cols) { int col; TDSCOMPUTEINFO *info; TEST_MALLOC(info, TDSCOMPUTEINFO); info->ref_count = 1; TEST_CALLOC(info->columns, TDSCOLUMN *, num_cols); tdsdump_log(TDS_DBG_INFO1, "alloc_compute_result. point 1\n"); info->num_cols = num_cols; for (col = 0; col < num_cols; col++) if (!(info->columns[col] = tds_alloc_column())) goto Cleanup; tdsdump_log(TDS_DBG_INFO1, "alloc_compute_result. point 2\n"); if (by_cols) { TEST_CALLOC(info->bycolumns, TDS_SMALLINT, by_cols); tdsdump_log(TDS_DBG_INFO1, "alloc_compute_result. point 3\n"); info->by_cols = by_cols; } return info; Cleanup: tds_free_compute_result(info); return NULL; } TDSCOMPUTEINFO ** tds_alloc_compute_results(TDSSOCKET * tds, int num_cols, int by_cols) { int n; TDSCOMPUTEINFO **comp_info; TDSCOMPUTEINFO *cur_comp_info; tdsdump_log(TDS_DBG_INFO1, "alloc_compute_result. num_cols = %d bycols = %d\n", num_cols, by_cols); tdsdump_log(TDS_DBG_INFO1, "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; if (n == 0) comp_info = (TDSCOMPUTEINFO **) malloc(sizeof(TDSCOMPUTEINFO *)); else comp_info = (TDSCOMPUTEINFO **) realloc(tds->comp_info, sizeof(TDSCOMPUTEINFO *) * (n + 1)); 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 + 1; tdsdump_log(TDS_DBG_INFO1, "alloc_compute_result. num_comp_info = %d\n", tds->num_comp_info); return comp_info; } TDSRESULTINFO * tds_alloc_results(int num_cols) { TDSRESULTINFO *res_info; int col; TEST_MALLOC(res_info, TDSRESULTINFO); res_info->ref_count = 1; 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; } 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 */ int 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; if (is_numeric_type(col->column_type)) { row_size += sizeof(TDS_NUMERIC); } else if (is_blob_col(col)) { row_size += sizeof(TDSBLOB); } else { row_size += col->column_size; } row_size += (TDS_ALIGN_SIZE - 1); row_size -= row_size % TDS_ALIGN_SIZE; } res_info->row_size = row_size; ptr = (unsigned char *) malloc(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; if (is_numeric_type(col->column_type)) { row_size += sizeof(TDS_NUMERIC); } else if (is_blob_col(col)) { row_size += sizeof(TDSBLOB); } else { row_size += col->column_size; } row_size += (TDS_ALIGN_SIZE - 1); row_size -= row_size % TDS_ALIGN_SIZE; } memset(ptr, '\0', res_info->row_size); return TDS_SUCCEED; } int 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) { int i; TDSCOMPUTEINFO ** comp_info = tds->comp_info; TDS_INT 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]) { if (tds->current_results == comp_info[i]) tds->current_results = NULL; 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; 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) { free(curcol->table_column_name); free(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"); if (tds->current_results == tds->res_info) tds->current_results = NULL; tds_free_results(tds->res_info); tds->res_info = NULL; if (tds->current_results == tds->param_info) tds->current_results = NULL; tds_free_param_results(tds->param_info); tds->param_info = NULL; tds_free_compute_results(tds); tds->has_status = 0; tds->ret_status = 0; } /* * Return 1 if winsock is initialized, else 0. */ static int winsock_initialized(void) { #if defined(_WIN32) || defined(_WIN64) WSADATA wsa_data; int erc; WSAPROTOCOL_INFO protocols[64]; DWORD how_much = sizeof(protocols); WORD requested_version = MAKEWORD(2, 2); if (SOCKET_ERROR != WSAEnumProtocols(NULL, protocols, &how_much)) return 1; if (WSANOTINITIALISED != (erc = WSAGetLastError())) { fprintf(stderr, "tds_init_winsock: WSAEnumProtocols failed with %d (%s)\n", erc, tds_prwsaerror(erc) ); return 0; } if (SOCKET_ERROR == (erc = WSAStartup(requested_version, &wsa_data))) { fprintf(stderr, "tds_init_winsock: WSAStartup failed with %d (%s)\n", erc, tds_prwsaerror(erc) ); 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 = calloc(1, sizeof(TDSCONTEXT))) == 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; } static const unsigned char defaultcaps[] = { /* type, len, data, data, data, data, data, data, data, data, data (9 bytes) */ 0x01, 0x09, 0x00, 0x08, 0x0E, 0x6D, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x02, 0x68, 0x00, 0x00, 0x00 }; #if ENABLE_EXTRA_CHECKS /* * Default capabilities as of December 2006. */ static const TDS_TINYINT request_capabilities[] = { /* no zero */ TDS_REQ_LANG, TDS_REQ_RPC, TDS_REQ_EVT, TDS_REQ_MSTMT, TDS_REQ_BCP, TDS_REQ_CURSOR, TDS_REQ_DYNF /* capability.data[8] */ , TDS_REQ_MSG, TDS_REQ_PARAM, TDS_REQ_DATA_INT1, TDS_REQ_DATA_INT2, TDS_REQ_DATA_INT4, TDS_REQ_DATA_BIT, TDS_REQ_DATA_CHAR, TDS_REQ_DATA_VCHAR /* capability.data[7] */ , TDS_REQ_DATA_BIN, TDS_REQ_DATA_VBIN, TDS_REQ_DATA_MNY8, TDS_REQ_DATA_MNY4, TDS_REQ_DATA_DATE8, TDS_REQ_DATA_DATE4, TDS_REQ_DATA_FLT4, TDS_REQ_DATA_FLT8 /* capability.data[6] */ , TDS_REQ_DATA_NUM, TDS_REQ_DATA_TEXT, TDS_REQ_DATA_IMAGE, TDS_REQ_DATA_DEC, TDS_REQ_DATA_LCHAR, TDS_REQ_DATA_LBIN, TDS_REQ_DATA_INTN, TDS_REQ_DATA_DATETIMEN /* capability.data[5] */ , TDS_REQ_DATA_MONEYN, TDS_REQ_CSR_PREV, TDS_REQ_CSR_FIRST, TDS_REQ_CSR_LAST, TDS_REQ_CSR_ABS, TDS_REQ_CSR_REL, TDS_REQ_CSR_MULTI /* capability.data[4] */ , TDS_REQ_CON_INBAND, TDS_REQ_PROTO_TEXT, TDS_REQ_PROTO_BULK, TDS_REQ_DATA_SENSITIVITY, TDS_REQ_DATA_BOUNDARY /* capability.data[3] */ , TDS_REQ_DATA_FLTN, TDS_REQ_DATA_BITN, TDS_REQ_DATA_INT8 /* capability.data[2] */ , TDS_REQ_WIDETABLE /* capability.data[1] */ }; static const TDS_TINYINT response_capabilities[] = { TDS_RES_CON_NOOOB , TDS_RES_PROTO_NOTEXT , TDS_RES_PROTO_NOBULK , TDS_RES_NOTDSDEBUG }; /* * The TDSLOGIN::capabilities member is a little wrong because it includes the type and typelen members. * The 22 bytes are structured as: * offset name value meaning * ------ ---- ----- -------------------------- * 0 type 1 request * 1 len 9 9 capability bytes follow * 2-10 data * 11 type 2 response * 12 len 9 9 capability bytes follow * 13-21 data * * This function manipulates the data portion without altering the length. * * \param capabilities address of the data portion in the TDSLOGIN member to be affected. * \param capability capability to set or reset. Pass as negative to reset. */ static unsigned char * tds_capability_set(unsigned char capabilities[], unsigned int cap, size_t len) { int index = (len - cap/8u) - 1; unsigned char mask = 1 << ((8u+cap) % 8u); assert(0 < index && (unsigned) index < len); capabilities[index] |= mask; return capabilities; } static void tds_capability_test(void) { unsigned char buf_capabilities[TDS_MAX_CAPABILITY]; unsigned char *capabilities[2]; int i, c, ncap; const TDS_TINYINT* pcap; /* * Set the capabilities using the enumerated types, one at a time. */ memset(buf_capabilities, 0, TDS_MAX_CAPABILITY); capabilities[0] = buf_capabilities; capabilities[1] = buf_capabilities + TDS_MAX_CAPABILITY / 2; pcap = request_capabilities; ncap = TDS_VECTOR_SIZE(request_capabilities); for (c=0; c < 2; c++) { const int bufsize = TDS_MAX_CAPABILITY / 2 - 2; capabilities[c][0] = 1 + c; /* request/response */ capabilities[c][1] = bufsize; for (i=0; i < ncap; i++) { tds_capability_set(capabilities[c]+2, pcap[i], bufsize); } pcap = response_capabilities; ncap = TDS_VECTOR_SIZE(response_capabilities); } /* * For now, we test to make sure the enumerated set yields the same bit pattern * that we used to create with magic numbers. Eventually we can delete defaultcaps and the below assertion. */ assert(0 == memcmp(buf_capabilities, defaultcaps, TDS_MAX_CAPABILITY)); } #endif /** * Allocate space for configure structure and initialize with default values * @param locale locale information (copied to configuration information) * @result allocated structure or NULL if out of memory */ TDSCONNECTION * tds_alloc_connection(TDSLOCALE * locale) { TDSCONNECTION *connection; char hostname[128]; #if HAVE_NL_LANGINFO && defined(CODESET) char *charset; #else char *lc_all, *tok = NULL; #endif TEST_MALLOC(connection, TDSCONNECTION); tds_dstr_init(&connection->server_name); tds_dstr_init(&connection->language); tds_dstr_init(&connection->server_charset); tds_dstr_init(&connection->client_host_name); tds_dstr_init(&connection->server_host_name); tds_dstr_init(&connection->app_name); tds_dstr_init(&connection->user_name); tds_dstr_init(&connection->password); tds_dstr_init(&connection->library); tds_dstr_init(&connection->ip_addr); tds_dstr_init(&connection->database); tds_dstr_init(&connection->dump_file); tds_dstr_init(&connection->client_charset); tds_dstr_init(&connection->instance_name); tds_dstr_init(&connection->server_realm_name); /* fill in all hardcoded defaults */ if (!tds_dstr_copy(&connection->server_name, TDS_DEF_SERVER)) goto Cleanup; /* * TDS 7.0: * 0x02 indicates ODBC driver * 0x01 means change to initial language must succeed */ connection->option_flag2 = 0x03; connection->tds_version = TDS_DEFAULT_VERSION; connection->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(&connection->client_charset, charset)) goto Cleanup;; #else if (!tds_dstr_copy(&connection->client_charset, "ISO-8859-1")) goto Cleanup; if ((lc_all = strdup(setlocale(LC_ALL, NULL))) == NULL) goto Cleanup; 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(&connection->client_charset, encoding)) goto Cleanup; } } free(lc_all); #endif if (locale) { if (locale->language) if (!tds_dstr_copy(&connection->language, locale->language)) goto Cleanup; if (locale->server_charset) if (!tds_dstr_copy(&connection->server_charset, locale->server_charset)) goto Cleanup; } if (tds_dstr_isempty(&connection->language)) { if (!tds_dstr_copy(&connection->language, TDS_DEF_LANG)) goto Cleanup; } memset(hostname, '\0', sizeof(hostname)); gethostname(hostname, sizeof(hostname)); hostname[sizeof(hostname) - 1] = '\0'; /* make sure it's truncated */ if (!tds_dstr_copy(&connection->client_host_name, hostname)) goto Cleanup; #if ENABLE_EXTRA_CHECKS tds_capability_test(); #endif memcpy(connection->capabilities, defaultcaps, TDS_MAX_CAPABILITY); return connection; Cleanup: tds_free_connection(connection); return NULL; } 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; if ( tds->cursors == NULL ) { tds->cursors = cursor; } else { pcursor = tds->cursors; for (;;) { tdsdump_log(TDS_DBG_FUNC, "tds_alloc_cursor() : stepping thru existing cursors\n"); if (pcursor->next == NULL) break; pcursor = pcursor->next; } pcursor->next = cursor; } /* take into account reference in tds list */ ++cursor->ref_count; TEST_CALLOC(cursor->cursor_name, char, namelen + 1); strcpy(cursor->cursor_name, name); cursor->cursor_name_len = namelen; TEST_CALLOC(cursor->query, char, querylen + 1); strcpy(cursor->query, query); cursor->query_len = querylen; return cursor; Cleanup: if (cursor) tds_cursor_deallocated(tds, cursor); tds_release_cursor(tds, cursor); return NULL; } /* * Called when cursor got deallocated from server */ void tds_cursor_deallocated(TDSSOCKET *tds, TDSCURSOR *cursor) { TDSCURSOR *victim = NULL; TDSCURSOR *prev = NULL; TDSCURSOR *next = NULL; tdsdump_log(TDS_DBG_FUNC, "tds_cursor_deallocated() : freeing cursor_id %d\n", cursor->cursor_id); if (tds->cur_cursor == cursor) { tds_release_cursor(tds, cursor); tds->cur_cursor = NULL; } victim = tds->cursors; if (victim == NULL) { tdsdump_log(TDS_DBG_FUNC, "tds_cursor_deallocated() : no allocated cursors %d\n", cursor->cursor_id); return; } for (;;) { if (victim == cursor) break; prev = victim; victim = victim->next; if (victim == NULL) { tdsdump_log(TDS_DBG_FUNC, "tds_cursor_deallocated() : cannot find cursor_id %d\n", cursor->cursor_id); return; } } tdsdump_log(TDS_DBG_FUNC, "tds_cursor_deallocated() : cursor_id %d found\n", cursor->cursor_id); next = victim->next; tdsdump_log(TDS_DBG_FUNC, "tds_cursor_deallocated() : relinking list\n"); if (prev) prev->next = next; else tds->cursors = next; tdsdump_log(TDS_DBG_FUNC, "tds_cursor_deallocated() : relinked list\n"); tds_release_cursor(tds, 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(TDSSOCKET *tds, TDSCURSOR *cursor) { 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"); if (tds->current_results == cursor->res_info) tds->current_results = NULL; 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(void) { TDSLOGIN *tds_login = NULL; const char *server_name = "SYBASE"; char *s; TEST_MALLOC(tds_login, TDSLOGIN); tds_dstr_init(&tds_login->server_name); tds_dstr_init(&tds_login->language); tds_dstr_init(&tds_login->server_charset); tds_dstr_init(&tds_login->client_host_name); tds_dstr_init(&tds_login->app_name); tds_dstr_init(&tds_login->user_name); tds_dstr_init(&tds_login->password); tds_dstr_init(&tds_login->library); tds_dstr_init(&tds_login->client_charset); if ((s=getenv("DSQUERY")) != NULL) server_name = s; if ((s=getenv("TDSQUERY")) != NULL) server_name = s; if (!tds_dstr_copy(&tds_login->server_name, server_name)) { free(tds_login); return NULL; } memcpy(tds_login->capabilities, defaultcaps, TDS_MAX_CAPABILITY); Cleanup: return tds_login; } void tds_free_login(TDSLOGIN * login) { if (login) { /* for security reason clear memory */ tds_dstr_zero(&login->password); tds_dstr_free(&login->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); free(login); } } TDSSOCKET * tds_alloc_socket(TDSCONTEXT * context, int bufsize) { TDSSOCKET *tds_socket; TEST_MALLOC(tds_socket, TDSSOCKET); tds_socket->tds_ctx = context; tds_socket->in_buf_max = 0; TEST_CALLOC(tds_socket->out_buf, unsigned char, bufsize + TDS_ADDITIONAL_SPACE); tds_socket->parent = NULL; tds_socket->env.block_size = bufsize; tds_socket->use_iconv = 1; if (tds_iconv_alloc(tds_socket)) goto Cleanup; /* Jeff's hack, init to no timeout */ tds_socket->query_timeout = 0; tds_init_write_buf(tds_socket); tds_socket->s = INVALID_SOCKET; tds_socket->state = TDS_DEAD; tds_socket->env_chg_func = NULL; return tds_socket; Cleanup: tds_free_socket(tds_socket); return NULL; } TDSSOCKET * tds_realloc_socket(TDSSOCKET * tds, size_t bufsize) { unsigned char *new_out_buf; assert(tds && tds->out_buf); if (tds->env.block_size == bufsize) return tds; if (tds->out_pos <= bufsize && bufsize > 0 && (new_out_buf = (unsigned char *) realloc(tds->out_buf, bufsize + TDS_ADDITIONAL_SPACE)) != NULL) { tds->out_buf = new_out_buf; tds->env.block_size = (int)bufsize; return tds; } return NULL; } void tds_free_socket(TDSSOCKET * tds) { if (tds) { if (tds->authentication) tds->authentication->free(tds, tds->authentication); tds->authentication = NULL; tds_free_all_results(tds); tds_free_env(tds); while (tds->dyns) tds_free_dynamic(tds, tds->dyns); while (tds->cursors) tds_cursor_deallocated(tds, tds->cursors); free(tds->in_buf); free(tds->out_buf); #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) tds_ssl_deinit(tds); #endif tds_close_socket(tds); tds_iconv_free(tds); free(tds->product_name); free(tds); } } void tds_free_locale(TDSLOCALE * locale) { if (!locale) return; free(locale->language); free(locale->server_charset); free(locale->date_fmt); free(locale); } void tds_free_connection(TDSCONNECTION * connection) { if (!connection) return; tds_dstr_free(&connection->server_name); tds_dstr_free(&connection->client_host_name); tds_dstr_free(&connection->server_host_name); tds_dstr_free(&connection->language); tds_dstr_free(&connection->server_charset); tds_dstr_free(&connection->ip_addr); tds_dstr_free(&connection->database); tds_dstr_free(&connection->dump_file); tds_dstr_free(&connection->client_charset); tds_dstr_free(&connection->app_name); tds_dstr_free(&connection->user_name); /* cleared for security reason */ tds_dstr_zero(&connection->password); tds_dstr_free(&connection->password); tds_dstr_free(&connection->library); tds_dstr_free(&connection->instance_name); tds_dstr_init(&connection->server_realm_name); free(connection); } static void tds_free_env(TDSSOCKET * tds) { if (tds->env.language) TDS_ZERO_FREE(tds->env.language); if (tds->env.charset) TDS_ZERO_FREE(tds->env.charset); if (tds->env.database) TDS_ZERO_FREE(tds->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; if (message->message) TDS_ZERO_FREE(message->message); if (message->server) TDS_ZERO_FREE(message->server); if (message->proc_name) TDS_ZERO_FREE(message->proc_name); if (message->sql_state) TDS_ZERO_FREE(message->sql_state); } } #define SQLS_ENTRY(number,state) case number: p = state; break char * tds_alloc_client_sqlstate(int msgno) { 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(int column_size) { BCPCOLDATA *coldata; TEST_MALLOC(coldata, BCPCOLDATA); 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); } /** @} */ freetds-0.91/src/tds/token.c100644 001750 000144 00000271440 11562376772 0011472/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include "tds.h" #include "tdsstring.h" #include "tdsconvert.h" #include "tdsiconv.h" #include "tds_checks.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: token.c,v 1.396.2.3 2011/05/10 13:21:30 freddy77 Exp $"); #define USE_ICONV tds->use_iconv static int tds_process_msg(TDSSOCKET * tds, int marker); static int tds_process_compute_result(TDSSOCKET * tds); static int tds_process_compute_names(TDSSOCKET * tds); static int tds7_process_compute_result(TDSSOCKET * tds); static int tds_process_result(TDSSOCKET * tds); static int tds_process_col_name(TDSSOCKET * tds); static int tds_process_col_fmt(TDSSOCKET * tds); static int tds_process_tabname(TDSSOCKET *tds); static int tds_process_colinfo(TDSSOCKET * tds, char **names, int num_names); static int tds_process_compute(TDSSOCKET * tds, TDS_INT * computeid); static int tds_process_cursor_tokens(TDSSOCKET * tds); static int tds_process_row(TDSSOCKET * tds); static int tds_process_param_result(TDSSOCKET * tds, TDSPARAMINFO ** info); static int tds7_process_result(TDSSOCKET * tds); static TDSDYNAMIC *tds_process_dynamic(TDSSOCKET * tds); static int tds_process_auth(TDSSOCKET * tds); static int tds_process_env_chg(TDSSOCKET * tds); static int tds_process_param_result_tokens(TDSSOCKET * tds); static int tds_process_params_result_token(TDSSOCKET * tds); static int tds_process_dyn_result(TDSSOCKET * tds); static int tds5_process_result(TDSSOCKET * tds); static int tds5_process_dyn_result2(TDSSOCKET * tds); static int tds_process_default_tokens(TDSSOCKET * tds, int marker); static int tds5_process_optioncmd(TDSSOCKET * tds); static int tds_process_end(TDSSOCKET * tds, int marker, /*@out@*/ int *flags_parm); static int tds_get_data(TDSSOCKET * tds, TDSCOLUMN * curcol); static int 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); static 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, int len) /*allocates *string*/; #if ENABLE_EXTRA_CHECKS #if defined(__GNUC__) && __GNUC__ >= 2 #define COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] __attribute__ ((unused)) #else #define COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] #endif #endif /** * \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 */ static int tds_process_default_tokens(TDSSOCKET * tds, int marker) { int tok_size; int done_flags; TDS_INT ret_status; 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_FUNC, "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_msg(tds, marker); break; case TDS_CAPABILITY_TOKEN: /* TODO split two part of capability and use it */ tok_size = tds_get_smallint(tds); /* vicm */ /* * Sybase 11.0 servers return the wrong length in the capability packet, causing use to read * past the done packet. */ if (!TDS_IS_MSSQL(tds) && tds->product_version < TDS_SYB_VER(12, 0, 0)) { unsigned char type, size, *p, *pend; p = tds->capabilities; pend = tds->capabilities + TDS_MAX_CAPABILITY; do { type = tds_get_byte(tds); size = tds_get_byte(tds); if ((p + 2) > pend) break; *p++ = type; *p++ = size; if ((p + size) > pend) break; if (tds_get_n(tds, p, size) == NULL) return TDS_FAIL; } while (type != 2); } else { const int len = tok_size < TDS_MAX_CAPABILITY? tok_size : TDS_MAX_CAPABILITY; if (tds_get_n(tds, tds->capabilities, len) == NULL) return TDS_FAIL; } 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 tds_process_result(tds); break; case TDS_ROWFMT2_TOKEN: return tds5_process_result(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->cur_dyn = NULL; return tds_process_dyn_result(tds); break; case TDS5_PARAMFMT2_TOKEN: tds->cur_dyn = NULL; 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 TDS5_DYNAMIC_TOKEN: case TDS_LOGINACK_TOKEN: case TDS_ORDERBY_TOKEN: case TDS_CONTROL_TOKEN: tdsdump_log(TDS_DBG_WARN, "Eating %s token\n", tds_token_name(marker)); tds_get_n(tds, NULL, tds_get_smallint(tds)); 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_ORDERBY2_TOKEN: tdsdump_log(TDS_DBG_WARN, "Eating %s token\n", tds_token_name(marker)); tds_get_n(tds, NULL, tds_get_int(tds)); break; case TDS_NBC_ROW_TOKEN: tdsdump_log(TDS_DBG_ERROR, "error: cannot process TDS_NBC_ROW_TOKEN %d(%x)!\n", marker, (unsigned char) marker); /* fall out */ default: tds_close_socket(tds); tdserror(tds->tds_ctx, tds, TDSEBTOK, 0); tdsdump_log(TDS_DBG_ERROR, "Unknown marker: %d(%x)!!\n", marker, (unsigned char) marker); return TDS_FAIL; } return TDS_SUCCEED; } static int tds_set_spid(TDSSOCKET * tds) { TDS_INT result_type; TDS_INT done_flags; TDS_INT rc; TDSCOLUMN *curcol; CHECK_TDS_EXTRA(tds); if (tds_submit_query(tds, "select @@spid") != TDS_SUCCEED) { return TDS_FAIL; } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_RETURN_ROWFMT|TDS_RETURN_ROW|TDS_RETURN_DONE)) == TDS_SUCCEED) { switch (result_type) { case TDS_ROWFMT_RESULT: if (tds->res_info->num_cols != 1) return TDS_FAIL; break; case TDS_ROW_RESULT: curcol = tds->res_info->columns[0]; if (curcol->column_type == SYBINT2 || (curcol->column_type == SYBINTN && curcol->column_size == 2)) { tds->spid = *((TDS_USMALLINT *) curcol->column_data); } else if (curcol->column_type == SYBINT4 || (curcol->column_type == SYBINTN && curcol->column_size == 4)) { tds->spid = *((TDS_UINT *) curcol->column_data); } else return TDS_FAIL; break; case TDS_DONE_RESULT: if ((done_flags & TDS_DONE_ERROR) != 0) return TDS_FAIL; break; default: break; } } if (rc != TDS_NO_MORE_RESULTS) return TDS_FAIL; return TDS_SUCCEED; } /** * 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 */ int tds_process_login_tokens(TDSSOCKET * tds) { int succeed = TDS_FAIL; int marker; 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"); /* get_incoming(tds->s); */ do { struct { unsigned char major, minor, tiny[2]; unsigned int reported; 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->tds71rev1 = 0; len = tds_get_smallint(tds); 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->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->product_name); if (ver.major >= 7u) { product_version = 0x80000000u; memrc += tds_alloc_get_string(tds, &tds->product_name, len / 2); } else if (ver.major >= 5) { memrc += tds_alloc_get_string(tds, &tds->product_name, len); } else { memrc += tds_alloc_get_string(tds, &tds->product_name, len); if (tds->product_name != NULL && strstr(tds->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->product_version = 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_SUCCEED; /* authentication is now useless */ if (tds->authentication) { tds->authentication->free(tds, tds->authentication); tds->authentication = NULL; } break; default: if (tds_process_default_tokens(tds, marker) == TDS_FAIL) return TDS_FAIL; break; } } while (marker != TDS_DONE_TOKEN); /* TODO why ?? */ tds->spid = tds->rows_affected; if (tds->spid == 0) { if (tds_set_spid(tds) != TDS_SUCCEED) { tdsdump_log(TDS_DBG_ERROR, "tds_set_spid() failed\n"); succeed = TDS_FAIL; } } if (memrc != 0) succeed = TDS_FAIL; tdsdump_log(TDS_DBG_FUNC, "tds_process_login_tokens() returning %s\n", (succeed == TDS_SUCCEED)? "TDS_SUCCEED" : "TDS_FAIL"); return succeed; } static int tds_process_auth(TDSSOCKET * tds) { int pdu_size; CHECK_TDS_EXTRA(tds); #if ENABLE_EXTRA_CHECKS if (!IS_TDS7_PLUS(tds)) tdsdump_log(TDS_DBG_ERROR, "Called auth on TDS version < 7\n"); #endif pdu_size = tds_get_smallint(tds); tdsdump_log(TDS_DBG_INFO1, "TDS_AUTH_TOKEN PDU size %d\n", pdu_size); if (!tds->authentication) return TDS_FAIL; return tds->authentication->handle_next(tds, tds->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) * @param tds A pointer to the TDSSOCKET structure managing a client/server operation. * @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 flag Flags to select token type to stop/return * @todo Complete TDS_DESCRIBE_RESULT description * @retval TDS_SUCCEED 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. :-( */ int tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag) { int marker; TDSPARAMINFO *pinfo = NULL; TDSCOLUMN *curcol; int rc; TDS_INT8 saved_rows_affected = tds->rows_affected; TDS_INT ret_status; int cancel_seen = 0; unsigned return_flag = 0; #define SET_RETURN(ret, f) \ *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"); \ break; \ } 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) { 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_SUCCEED; 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->internal_sp_called == TDS_SP_CURSORFETCH) { rc = tds7_process_result(tds); marker = tds_get_byte(tds); if (marker != TDS_TABNAME_TOKEN) tds_unget_byte(tds); else rc = tds_process_tabname(tds); } else { SET_RETURN(TDS_ROWFMT_RESULT, ROWFMT); rc = tds7_process_result(tds); /* handle browse information (if presents) */ marker = tds_get_byte(tds); if (marker != TDS_TABNAME_TOKEN) { tds_unget_byte(tds); rc = TDS_SUCCEED; break; } rc = tds_process_tabname(tds); } break; case TDS_RESULT_TOKEN: SET_RETURN(TDS_ROWFMT_RESULT, ROWFMT); rc = tds_process_result(tds); break; case TDS_ROWFMT2_TOKEN: SET_RETURN(TDS_ROWFMT_RESULT, ROWFMT); rc = tds5_process_result(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); /* handle browse information (if present) */ marker = tds_get_byte(tds); if (marker != TDS_TABNAME_TOKEN) { tds_unget_byte(tds); break; } rc = tds_process_tabname(tds); break; case TDS_PARAM_TOKEN: tds_unget_byte(tds); if (tds->internal_sp_called) { tdsdump_log(TDS_DBG_FUNC, "processing parameters for sp %d\n", tds->internal_sp_called); while ((marker = tds_get_byte(tds)) == TDS_PARAM_TOKEN) { tdsdump_log(TDS_DBG_INFO1, "calling tds_process_param_result\n"); tds_process_param_result(tds, &pinfo); } 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->internal_sp_called == TDS_SP_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->internal_sp_called == TDS_SP_PREPARE || tds->internal_sp_called == TDS_SP_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; } } 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: /* overstepped the mark... */ if (tds->cur_cursor) { TDSCURSOR *cursor = tds->cur_cursor; tds->current_results = 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->current_results = 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); rc = tds_process_row(tds); 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, NULL); 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->internal_sp_called) { /* 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_SUCCEED; } break; case TDS5_DYNAMIC_TOKEN: /* process acknowledge dynamic */ tds->cur_dyn = 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_msg(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); break; case TDS_DONEPROC_TOKEN: SET_RETURN(TDS_DONEPROC_RESULT, DONE); rc = tds_process_end(tds, marker, done_flags); switch (tds->internal_sp_called) { case 0: case TDS_SP_PREPARE: case TDS_SP_PREPEXEC: case TDS_SP_EXECUTE: case TDS_SP_UNPREPARE: case TDS_SP_EXECUTESQL: break; case TDS_SP_CURSOROPEN: *result_type = TDS_DONE_RESULT; tds->rows_affected = saved_rows_affected; break; case TDS_SP_CURSORCLOSE: tdsdump_log(TDS_DBG_FUNC, "TDS_SP_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, cursor); } } *result_type = TDS_NO_MORE_RESULTS; rc = TDS_NO_MORE_RESULTS; break; default: *result_type = TDS_NO_MORE_RESULTS; rc = TDS_NO_MORE_RESULTS; break; } break; case TDS_DONEINPROC_TOKEN: switch(tds->internal_sp_called) { case TDS_SP_CURSOROPEN: case TDS_SP_CURSORFETCH: case TDS_SP_PREPARE: case TDS_SP_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; default: SET_RETURN(TDS_OTHERS_RESULT, OTHERS); rc = tds_process_default_tokens(tds, marker); break; } if (rc == TDS_FAIL) { tds_set_state(tds, TDS_PENDING); 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) 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) */ int tds_process_simple_query(TDSSOCKET * tds) { TDS_INT res_type; TDS_INT done_flags; int rc; int ret = TDS_SUCCEED; CHECK_TDS_EXTRA(tds); while ((rc = tds_process_tokens(tds, &res_type, &done_flags, TDS_RETURN_DONE)) == TDS_SUCCEED) { 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 (rc != TDS_NO_MORE_RESULTS) { ret = TDS_FAIL; } return ret; } struct namelist { char *name; struct namelist *next; }; 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); } } 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) { int namelen; prev = cur; if (!(cur = (struct namelist *) malloc(sizeof(struct namelist)))) { tds_free_namelist(head); return -1; } cur->next = NULL; if (prev) prev->next = cur; else head = cur; if (large) { namelen = tds_get_smallint(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)) 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 */ static int tds_process_col_name(TDSSOCKET * tds) { int hdrsize; int col, num_names = 0; struct namelist *head = NULL, *cur = NULL, *prev; TDSCOLUMN *curcol; TDSRESULTINFO *info; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_smallint(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) { tds->current_results = tds->res_info = info; cur = head; for (col = 0; col < num_names; ++col) { curcol = info->columns[col]; tds_strlcpy(curcol->column_name, cur->name, sizeof(curcol->column_name)); curcol->column_namelen = (TDS_SMALLINT)strlen(curcol->column_name); prev = cur; cur = cur->next; free(prev->name); free(prev); } return TDS_SUCCEED; } 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 */ static int tds_process_col_fmt(TDSSOCKET * tds) { int col, hdrsize; TDSCOLUMN *curcol; TDSRESULTINFO *info; TDS_SMALLINT tabnamesize; int bytes_read = 0; int rest; TDS_SMALLINT flags; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_smallint(tds); /* TODO use current_results instead of res_info ?? */ info = tds->res_info; 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_smallint(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_set_column_type(tds, curcol, tds_get_byte(tds)); 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); switch (curcol->column_varint_size) { case 4: curcol->column_size = tds_get_int(tds); /* junk the table name -- for now */ tabnamesize = tds_get_smallint(tds); tds_get_n(tds, NULL, tabnamesize); bytes_read += 5 + 4 + 2 + tabnamesize; break; case 1: curcol->column_size = tds_get_byte(tds); bytes_read += 5 + 1; break; case 0: bytes_read += 5 + 0; break; } /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; adjust_character_column_size(tds, curcol); } /* get the rest of the bytes */ rest = hdrsize - bytes_read; if (rest > 0) { tdsdump_log(TDS_DBG_INFO1, "NOTE:tds_process_col_fmt: draining %d bytes\n", rest); tds_get_n(tds, NULL, rest); } return tds_alloc_row(info); } static int tds8_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 namelen, elements, i, len; char *partials[4], *p; prev = cur; if (!(cur = (struct namelist *) malloc(sizeof(struct namelist)))) { 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) { namelen = tds_get_smallint(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 = (char *) malloc(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; } static int tds_process_tabname(TDSSOCKET *tds) { struct namelist *head, *cur; int num_names, hdrsize, i; char **names; unsigned char marker; int rc; hdrsize = tds_get_smallint(tds); /* different structure for tds8 */ /* hdrsize check is required for tds7.1 revision 1 (mssql without SPs) */ if (IS_TDS71_PLUS(tds) && (!IS_TDS71(tds) || !tds->tds71rev1)) num_names = tds8_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 = (char **) malloc(num_names * sizeof(char*)); 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_SUCCEED; 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; } static int tds_process_colinfo(TDSSOCKET * tds, char **names, int num_names) { int hdrsize; TDSCOLUMN *curcol; TDSRESULTINFO *info; int bytes_read = 0; unsigned char col_info[3], l; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_smallint(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) { tds_strlcpy(curcol->table_name, names[col_info[1] - 1], sizeof(curcol->table_name)); curcol->table_namelen = (TDS_SMALLINT)strlen(curcol->table_name); } } /* read real column name */ if (col_info[2] & 0x20) { l = tds_get_byte(tds); if (curcol) { if (curcol->table_column_name) TDS_ZERO_FREE(curcol->table_column_name); tds_alloc_get_string(tds, &curcol->table_column_name, l); if (IS_TDS7_PLUS(tds)) l *= 2; } else { if (IS_TDS7_PLUS(tds)) l *= 2; /* discard silently */ tds_get_n(tds, NULL, l); } bytes_read += l + 1; } } return TDS_SUCCEED; } /** * 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. */ static int tds_process_param_result(TDSSOCKET * tds, TDSPARAMINFO ** pinfo) { int hdrsize; TDSCOLUMN *curparam; TDSPARAMINFO *info; int token; 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) */ hdrsize = tds_get_smallint(tds); 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 ?? */ tds_get_data_info(tds, curparam, 1); curparam->column_cur_size = curparam->column_size; /* needed ?? */ if (tds_alloc_param_data(curparam) == NULL) return TDS_FAIL; token = tds_get_data(tds, curparam); 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 (curparam->column_namelen > 0 && curparam->column_name[0] != '@') tds_free_param_result(*pinfo); return token; } static int tds_process_param_result_tokens(TDSSOCKET * tds) { int marker; TDSPARAMINFO **pinfo; 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) { tds_process_param_result(tds, pinfo); } if (!marker) { tdsdump_log(TDS_DBG_FUNC, "error: tds_process_param_result() returned TDS_FAIL\n"); return TDS_FAIL; } tds->current_results = *pinfo; tds_unget_byte(tds); return TDS_SUCCEED; } /** * tds_process_params_result_token() processes params on TDS5. */ static int tds_process_params_result_token(TDSSOCKET * tds) { int i; TDSCOLUMN *curcol; 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++) { curcol = info->columns[i]; if (tds_get_data(tds, curcol) != TDS_SUCCEED) return TDS_FAIL; } return TDS_SUCCEED; } /** * 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. */ static int tds_process_compute_result(TDSSOCKET * tds) { int hdrsize; int col, num_cols; TDS_TINYINT by_cols = 0; TDS_SMALLINT *cur_by_col; TDS_SMALLINT compute_id = 0; TDSCOLUMN *curcol; TDSCOMPUTEINFO *info; int i; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_smallint(tds); /* * compute statement id which this relates * to. You can have more than one compute * statement in a SQL statement */ compute_id = tds_get_smallint(tds); tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. compute_id = %d\n", compute_id); /* * number of compute columns returned - so * COMPUTE SUM(x), AVG(x)... would return * num_cols = 2 */ num_cols = tds_get_byte(tds); for (i = 0;; ++i) { if (i >= tds->num_comp_info) return TDS_FAIL; info = tds->comp_info[i]; tdsdump_log(TDS_DBG_FUNC, "in dbaltcolid() found computeid = %d\n", info->computeid); if (info->computeid == compute_id) break; } tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. num_cols = %d\n", num_cols); 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_byte(tds); /* * if no name has been defined for the compute column, * put in "max", "avg" etc. */ if (curcol->column_namelen == 0) { strcpy(curcol->column_name, tds_pr_op(curcol->column_operator)); curcol->column_namelen = (TDS_SMALLINT)strlen(curcol->column_name); } /* User defined data type of the column */ curcol->column_usertype = tds_get_int(tds); tds_set_column_type(tds, curcol, tds_get_byte(tds)); tds_data_get_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; /* TODO check if this column can have collation information associated */ adjust_character_column_size(tds, curcol); /* skip locale */ if (!IS_TDS42(tds)) 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_SMALLINT *) calloc(by_cols, sizeof(TDS_SMALLINT))) == 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); } /** * Read data information from wire * \param tds state information for the socket and the TDS protocol * \param curcol column where to store information */ static int tds7_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol) { int colnamelen; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); /* User defined data type of the column */ curcol->column_usertype = IS_TDS72_PLUS(tds) ? 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_set_column_type(tds, curcol, tds_get_byte(tds)); /* sets "cardinal" type */ curcol->column_timestamp = (curcol->column_type == SYBBINARY && curcol->column_usertype == TDS_UT_TIMESTAMP); tds_data_get_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 */ colnamelen = tds_get_string(tds, tds_get_byte(tds), curcol->column_name, sizeof(curcol->column_name) - 1); curcol->column_name[colnamelen] = 0; curcol->column_namelen = colnamelen; tdsdump_log(TDS_DBG_INFO1, "tds7_get_data_info: \n" "\tcolname = %s (%d bytes)\n" "\ttype = %d (%s)\n" "\tserver's type = %d (%s)\n" "\tcolumn_varint_size = %d\n" "\tcolumn_size = %d (%d on server)\n", curcol->column_name, curcol->column_namelen, 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_SUCCEED; } /** * 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 */ static int tds7_process_result(TDSSOCKET * tds) { int col, num_cols, 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 == -1) { tdsdump_log(TDS_DBG_INFO1, "no meta data\n"); return TDS_SUCCEED; } tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; if ((info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; tds->current_results = 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]; tds7_get_data_info(tds, curcol); } if (num_cols > 0) { static 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++) { char name[TDS_SYSNAME_SIZE] = {'\0'}; TDSCOLUMN *curcol = info->columns[col]; if (curcol->column_namelen > 0) { memcpy(name, curcol->column_name, curcol->column_namelen); name[curcol->column_namelen] = '\0'; } tdsdump_log(TDS_DBG_INFO1, " %-20s %7d/%-7d %7d/%-7d %7d\n", 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; } /** * Read data information from wire * \param tds state information for the socket and the TDS protocol * \param curcol column where to store information */ static int 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]" : ""); curcol->column_namelen = tds_get_string(tds, tds_get_byte(tds), curcol->column_name, sizeof(curcol->column_name) - 1); curcol->column_name[curcol->column_namelen] = '\0'; 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)) 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)) { 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)) { 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_set_column_type(tds, curcol, tds_get_byte(tds)); 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_data_get_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_SUCCEED; } /** * tds_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 */ static int tds_process_result(TDSSOCKET * tds) { int hdrsize; int col, num_cols; TDSCOLUMN *curcol; TDSRESULTINFO *info; TDSCURSOR *cursor; CHECK_TDS_EXTRA(tds); tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; hdrsize = tds_get_smallint(tds); /* read number of columns and allocate the columns structure */ num_cols = tds_get_smallint(tds); if (tds->cur_cursor) { cursor = tds->cur_cursor; if ((cursor->res_info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; info = cursor->res_info; tds->current_results = cursor->res_info; } else { if ((tds->res_info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; info = tds->res_info; tds->current_results = tds->res_info; } /* * loop through the columns populating COLINFO struct from * server response */ for (col = 0; col < info->num_cols; col++) { curcol = info->columns[col]; tds_get_data_info(tds, curcol, 0); /* 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_result() 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 */ static int tds5_process_result(TDSSOCKET * tds) { int hdrsize; int colnamelen; int col, num_cols; TDSCOLUMN *curcol; TDSRESULTINFO *info; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_INFO1, "tds5_process_result\n"); /* * free previous resultset */ tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; /* * read length of packet (4 bytes) */ hdrsize = tds_get_int(tds); /* read number of columns and allocate the columns structure */ num_cols = tds_get_smallint(tds); if ((info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; tds->current_results = 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 */ curcol->column_namelen = tds_get_string(tds, tds_get_byte(tds), curcol->column_name, sizeof(curcol->column_name) - 1); curcol->column_name[curcol->column_namelen] = '\0'; /* 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 */ curcol->table_namelen = tds_get_string(tds, tds_get_byte(tds), curcol->table_name, sizeof(curcol->table_name) - 1); curcol->table_name[curcol->table_namelen] = '\0'; /* table column name */ if (curcol->table_column_name) TDS_ZERO_FREE(curcol->table_column_name); tds_alloc_get_string(tds, &curcol->table_column_name, tds_get_byte(tds)); /* if label is empty, use the table column name */ if (!curcol->column_namelen && curcol->table_column_name) { tds_strlcpy(curcol->column_name, curcol->table_column_name, sizeof(curcol->column_name)); curcol->column_namelen = (TDS_SMALLINT)strlen(curcol->column_name); } /* 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_set_column_type(tds, curcol, tds_get_byte(tds)); tds_data_get_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", 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. */ static int tds_process_compute(TDSSOCKET * tds, TDS_INT * pcomputeid) { 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->current_results = info; for (i = 0; i < info->num_cols; i++) { curcol = info->columns[i]; if (tds_get_data(tds, curcol) != TDS_SUCCEED) { tdsdump_log(TDS_DBG_INFO1, "tds_process_compute() FAIL: tds_get_data() failed\n"); return TDS_FAIL; } } if (pcomputeid) *pcomputeid = id; return TDS_SUCCEED; } static int tds9_get_varmax(TDSSOCKET * tds, TDSCOLUMN * curcol) { TDS_INT8 len = tds_get_int8(tds); TDS_INT chunk_len; TDS_CHAR **p; size_t offset; /* NULL */ if (len == -1) { curcol->column_cur_size = -1; return TDS_SUCCEED; } curcol->column_cur_size = 0; offset = 0; p = &(((TDSBLOB*) curcol->column_data)->textvalue); for (;;) { TDS_CHAR *tmp; chunk_len = tds_get_int(tds); if (chunk_len <= 0) { curcol->column_cur_size = offset; return TDS_SUCCEED; } if (*p == NULL) tmp = (TDS_CHAR*) malloc(chunk_len); else tmp = (TDS_CHAR*) realloc(*p, offset + chunk_len); if (!tmp) return TDS_FAIL; *p = tmp; tds_get_n(tds, *p + offset, chunk_len); offset += chunk_len; } return TDS_SUCCEED; } #if ENABLE_EXTRA_CHECKS COMPILE_CHECK(tds_variant_size, sizeof(((TDSVARIANT*)0)->data) == sizeof(((TDSBLOB*)0)->textvalue)); COMPILE_CHECK(tds_variant_offset,(TDS_INTPTR)(&((TDSVARIANT*)0)->data) == (TDS_INTPTR)(&((TDSBLOB*)0)->textvalue)); #endif static int tds7_get_variant(TDSSOCKET * tds, TDSCOLUMN * curcol) { int colsize = tds_get_int(tds), varint; TDS_UCHAR type, info_len; TDSVARIANT *v; /* NULL */ curcol->column_cur_size = -1; if (colsize < 2) { tds_get_n(tds, NULL, colsize); return TDS_SUCCEED; } v = (TDSVARIANT*) curcol->column_data; v->type = type = tds_get_byte(tds); info_len = tds_get_byte(tds); 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->char_convs[client2ucs2] : tds_iconv_from_collate(tds, 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_NUMERIC*) calloc(1, sizeof(TDS_NUMERIC)); v->data = (TDS_CHAR *) num; num->precision = tds_get_byte(tds); num->scale = tds_get_byte(tds); colsize -= 2; /* FIXME check prec/scale, don't let server crash us */ 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)) tds_swap_numeric(num); return TDS_SUCCEED; } varint = (type == SYBUNIQUE) ? 0 : tds_get_varint_size(tds, type); if (varint != info_len) 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) { if (USE_ICONV && curcol->char_conv) { curcol->column_cur_size = determine_adjusted_size(curcol->char_conv, colsize); v->data = (TDS_CHAR*) malloc(curcol->column_cur_size); if (!v->data) return TDS_FAIL; if (tds_get_char_data(tds, (char *) v, colsize, curcol) == TDS_FAIL) return TDS_FAIL; colsize = curcol->column_cur_size; v->type = tds_get_cardinal_type(type, 0); } else { v->data = (TDS_CHAR*) malloc(colsize); if (!v->data) return TDS_FAIL; tds_get_n(tds, v->data, colsize); } } v->data_len = colsize; return TDS_SUCCEED; 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_SUCCEED */ static int tds_get_data(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: /* * TODO finish * 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 */ if (curcol->column_type == SYBVARIANT) return tds7_get_variant(tds, curcol); /* * LONGBINARY * This type just stores a 4-byte length */ if (curcol->column_type == SYBLONGBINARY) { colsize = tds_get_int(tds); break; } /* 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); colsize = tds_get_int(tds); } else { colsize = -1; } break; case 5: blob = (TDSBLOB *) curcol->column_data; colsize = tds_get_int(tds); if (colsize == 0) colsize = -1; break; case 8: return tds9_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_SUCCEED; } /* * 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_numeric_type(curcol->column_type)) { /* * Handling NUMERIC datatypes: * 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. */ TDS_NUMERIC *num = (TDS_NUMERIC *) dest; 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); /* corrected colsize for column_cur_size */ colsize = sizeof(TDS_NUMERIC); if (IS_TDS7_PLUS(tds)) { tdsdump_log(TDS_DBG_INFO1, "swapping numeric data...\n"); tds_swap_numeric(num); } curcol->column_cur_size = colsize; } else if (is_blob_col(curcol)) { TDS_CHAR *p; int new_blob_size; assert(blob == (TDSBLOB *) dest); /* cf. column_varint_size case 4, above */ /* * 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. * Here we allocate memory, if need be. */ /* TODO this can lead to a big waste of memory */ if (USE_ICONV) new_blob_size = determine_adjusted_size(curcol->char_conv, colsize); else new_blob_size = colsize; if (new_blob_size == 0) { curcol->column_cur_size = 0; if (blob->textvalue) TDS_ZERO_FREE(blob->textvalue); return TDS_SUCCEED; } p = blob->textvalue; /* save pointer in case realloc fails */ if (!p) { p = (TDS_CHAR *) malloc(new_blob_size); } else { /* TODO perhaps we should store allocated bytes too ? */ if (new_blob_size > curcol->column_cur_size || (curcol->column_cur_size - new_blob_size) > 10240) { p = (TDS_CHAR *) realloc(p, new_blob_size); } } if (!p) return TDS_FAIL; blob->textvalue = p; curcol->column_cur_size = new_blob_size; /* read the data */ if (USE_ICONV && curcol->char_conv) { if (tds_get_char_data(tds, (char *) blob, colsize, curcol) == TDS_FAIL) return TDS_FAIL; } else { assert(colsize == new_blob_size); tds_get_n(tds, blob->textvalue, colsize); } } else { /* non-numeric and non-blob */ curcol->column_cur_size = colsize; if (USE_ICONV && curcol->char_conv) { if (tds_get_char_data(tds, (char *) dest, colsize, curcol) == TDS_FAIL) 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; } if (curcol->column_type == SYBDATETIME4) { tdsdump_log(TDS_DBG_INFO1, "datetime4 %d %d %d %d\n", dest[0], dest[1], dest[2], dest[3]); } } #ifdef WORDS_BIGENDIAN /* * MS SQL Server 7.0 has broken date types from big endian * machines, this swaps the low and high halves of the * affected datatypes * * Thought - this might be because we don't have the * right flags set on login. -mjs * * Nope its an actual MS SQL bug -bsb */ /* TODO test on login, remove configuration -- freddy77 */ if (tds->broken_dates && (curcol->column_type == SYBDATETIME || curcol->column_type == SYBDATETIME4 || curcol->column_type == SYBDATETIMN || curcol->column_type == SYBMONEY || curcol->column_type == SYBMONEY4 || (curcol->column_type == SYBMONEYN && curcol->column_size > 4))) /* * above line changed -- don't want this for 4 byte SYBMONEYN * values (mlilback, 11/7/01) */ { unsigned char temp_buf[8]; memcpy(temp_buf, dest, colsize / 2); memcpy(dest, &dest[colsize / 2], colsize / 2); memcpy(&dest[colsize / 2], temp_buf, colsize / 2); } if (tds->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_SUCCEED; } /** * tds_process_row() processes rows and places them in the row buffer. */ static int tds_process_row(TDSSOCKET * tds) { int i; TDSCOLUMN *curcol; TDSRESULTINFO *info; CHECK_TDS_EXTRA(tds); info = tds->current_results; if (!info) return TDS_FAIL; assert(info->num_cols > 0); info->row_count++; 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_get_data(tds, curcol) != TDS_SUCCEED) return TDS_FAIL; } return TDS_SUCCEED; } /** * 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 int tds_process_end(TDSSOCKET * tds, int marker, int *flags_parm) { int more_results, was_cancelled, error, done_count_valid; int tmp, state; TDS_INT8 rows_affected; CHECK_TDS_EXTRA(tds); tmp = tds_get_smallint(tds); state = tds_get_smallint(tds); 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); if (tds->res_info) { tds->res_info->more_results = more_results; if (tds->current_results == NULL) tds->current_results = tds->res_info; } if (flags_parm) *flags_parm = tmp; 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; tds_set_state(tds, TDS_IDLE); } 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. */ rows_affected = IS_TDS72_PLUS(tds) ? tds_get_int8(tds) : tds_get_int(tds); tdsdump_log(TDS_DBG_FUNC, " rows_affected = %" PRId64 "\n", rows_affected); 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_SUCCEED; } /** * 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. */ static int tds_process_env_chg(TDSSOCKET * tds) { int size, 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_smallint(tds); /* * 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->collation was", tds->collation, 5); memset(tds->collation, 0, 5); if (size < 5) { tds_get_n(tds, tds->collation, size); } else { tds_get_n(tds, tds->collation, 5); tds_get_n(tds, NULL, size - 5); lcid = (tds->collation[0] + ((int) tds->collation[1] << 8) + ((int) tds->collation[2] << 16)) & 0xffffflu; tds7_srv_charset_changed(tds, tds->collation[4], lcid); } tdsdump_dump_buf(TDS_DBG_NETWORK, "tds->collation now", tds->collation, 5); /* discard old one */ tds_get_n(tds, NULL, tds_get_byte(tds)); return TDS_SUCCEED; } if (type == TDS_ENV_BEGINTRANS) { size = tds_get_byte(tds); tds_get_n(tds, tds->tds9_transaction, 8); tds_get_n(tds, NULL, tds_get_byte(tds)); return TDS_SUCCEED; } if (type == TDS_ENV_COMMITTRANS || type == TDS_ENV_ROLLBACKTRANS) { memset(tds->tds9_transaction, 0, 8); tds_get_n(tds, NULL, tds_get_byte(tds)); tds_get_n(tds, NULL, tds_get_byte(tds)); return TDS_SUCCEED; } /* discard byte values, not still supported */ /* TODO support them */ if (IS_TDS71_PLUS(tds) && type > TDS_ENV_PACKSIZE) { /* discard new one */ tds_get_n(tds, NULL, tds_get_byte(tds)); /* discard old one */ tds_get_n(tds, NULL, tds_get_byte(tds)); return TDS_SUCCEED; } /* 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->env.database; break; case TDS_ENV_LANG: dest = &tds->env.language; break; case TDS_ENV_CHARSET: tdsdump_log(TDS_DBG_FUNC, "server indicated charset change to \"%s\"\n", newval); dest = &tds->env.charset; tds_srv_charset_changed(tds, newval); break; } if (tds->env_chg_func) { (*(tds->env_chg_func)) (tds, type, oldval, newval); } free(oldval); if (newval) { if (dest) { if (*dest) free(*dest); *dest = newval; } else free(newval); } return TDS_SUCCEED; } /** * tds_process_msg() is called for MSG, ERR, or EED tokens and is responsible * for calling the CLI's message handling routine * returns TDS_SUCCEED if informational, TDS_FAIL if error. */ static int tds_process_msg(TDSSOCKET * tds, int marker) { int rc; int len; int len_sqlstate; int has_eed = 0; TDSMESSAGE msg; CHECK_TDS_EXTRA(tds); /* make sure message has been freed */ memset(&msg, 0, sizeof(TDSMESSAGE)); /* packet length */ len = tds_get_smallint(tds); /* message number */ rc = tds_get_int(tds); msg.msgno = rc; /* 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 = (char *) malloc(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_msg() called with unknown marker '%d'!\n", (int) marker); tds_free_msg(&msg); return TDS_FAIL; } tdsdump_log(TDS_DBG_ERROR, "tds_process_msg() reading message %d from server\n", msg.msgno); rc = 0; /* the message */ rc += tds_alloc_get_string(tds, &msg.message, tds_get_smallint(tds)); /* server name */ rc += tds_alloc_get_string(tds, &msg.server, tds_get_byte(tds)); if ((!msg.server || !msg.server[0]) && tds->connection) { TDS_ZERO_FREE(msg.server); if (-1 == asprintf(&msg.server, "[%s]", tds_dstr_cstr(&tds->connection->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) ? 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_process_default_tokens(tds, next_marker) != TDS_SUCCEED) --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; } else if (marker == TDS_INFO_TOKEN && msg.msgno == 16954 && TDS_IS_MSSQL(tds) && tds->internal_sp_called == TDS_SP_CURSOROPEN && tds->cur_cursor) { /* here mssql say "Executing SQL directly; no cursor." opening cursor */ } else { /* EED can be followed to PARAMFMT/PARAMS, do not store it in dynamic */ tds->cur_dyn = NULL; if (tds->tds_ctx->msg_handler) { tdsdump_log(TDS_DBG_ERROR, "tds_process_msg() calling client msg handler\n"); tds->tds_ctx->msg_handler(tds->tds_ctx, 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); } } tds_free_msg(&msg); tdsdump_log(TDS_DBG_ERROR, "tds_process_msg() returning TDS_SUCCEED\n"); return TDS_SUCCEED; } /** * Read a string from wire in a new allocated buffer * \param tds state information for the socket and the TDS protocol * \param len length of string to read */ static int tds_alloc_get_string(TDSSOCKET * tds, char **string, int len) { char *s; int out_len; CHECK_TDS_EXTRA(tds); if (len < 0) { *string = NULL; return 0; } /* assure sufficient space for every conversion */ s = (char *) malloc(len * 4 + 1); out_len = tds_get_string(tds, len, s, len * 4); if (!s) { *string = NULL; return -1; } s = 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. */ int tds_process_cancel(TDSSOCKET * tds) { CHECK_TDS_EXTRA(tds); /* silly cases, nothing to do */ if (!tds->in_cancel) return TDS_SUCCEED; /* TODO handle cancellation sending data */ if (tds->state != TDS_PENDING) return TDS_SUCCEED; /* 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_SUCCEED: case TDS_NO_MORE_RESULTS: return TDS_SUCCEED; } } } /** * Find a dynamic given string id * \return dynamic or NULL is not found * \param tds state information for the socket and the TDS protocol * \param id dynamic id to search */ TDSDYNAMIC * tds_lookup_dynamic(TDSSOCKET * tds, const char *id) { TDSDYNAMIC *curr; CHECK_TDS_EXTRA(tds); for (curr = tds->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 */ static TDSDYNAMIC * tds_process_dynamic(TDSSOCKET * tds) { int token_sz; unsigned char type, status; int id_len; char id[TDS_MAX_DYNID_LEN + 1]; int drain = 0; CHECK_TDS_EXTRA(tds); token_sz = tds_get_smallint(tds); type = tds_get_byte(tds); status = tds_get_byte(tds); /* handle only acknowledge */ if (type != 0x20) { 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_string(tds, drain, NULL, drain); } return tds_lookup_dynamic(tds, id); } static int tds_process_dyn_result(TDSSOCKET * tds) { int hdrsize; int col, num_cols; TDSCOLUMN *curcol; TDSPARAMINFO *info; TDSDYNAMIC *dyn; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_smallint(tds); num_cols = tds_get_smallint(tds); if (tds->cur_dyn) { dyn = tds->cur_dyn; tds_free_param_results(dyn->res_info); /* read number of columns and allocate the columns structure */ if ((dyn->res_info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; info = dyn->res_info; } else { tds_free_param_results(tds->param_info); if ((tds->param_info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; info = tds->param_info; } tds->current_results = info; for (col = 0; col < info->num_cols; col++) { curcol = info->columns[col]; tds_get_data_info(tds, curcol, 1); /* skip locale information */ tds_get_n(tds, NULL, tds_get_byte(tds)); } return tds_alloc_row(info); } /** * New TDS 5.0 token for describing output parameters */ static int tds5_process_dyn_result2(TDSSOCKET * tds) { int hdrsize; int col, num_cols; TDSCOLUMN *curcol; TDSPARAMINFO *info; TDSDYNAMIC *dyn; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_int(tds); num_cols = tds_get_smallint(tds); if (tds->cur_dyn) { dyn = tds->cur_dyn; tds_free_param_results(dyn->res_info); /* read number of columns and allocate the columns structure */ if ((dyn->res_info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; info = dyn->res_info; } else { tds_free_param_results(tds->param_info); if ((tds->param_info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; info = tds->param_info; } tds->current_results = info; for (col = 0; col < info->num_cols; col++) { curcol = info->columns[col]; /* TODO reuse tds_get_data_info code, sligthly different */ /* column name */ curcol->column_namelen = tds_get_string(tds, tds_get_byte(tds), curcol->column_name, sizeof(curcol->column_name) - 1); curcol->column_name[curcol->column_namelen] = '\0'; /* 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_set_column_type(tds, curcol, tds_get_byte(tds)); tds_data_get_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", 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 */ 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; } } #ifdef WORDS_BIGENDIAN void tds_swap_datatype(int coltype, unsigned char *buf) { switch (coltype) { case SYBINT2: tds_swap_bytes(buf, 2); break; case SYBINT4: case SYBMONEY4: case SYBREAL: tds_swap_bytes(buf, 4); break; case SYBINT8: case SYBFLT8: tds_swap_bytes(buf, 8); break; case SYBMONEY: case SYBDATETIME: tds_swap_bytes(buf, 4); tds_swap_bytes(&buf[4], 4); break; case SYBDATETIME4: tds_swap_bytes(buf, 2); tds_swap_bytes(&buf[2], 2); break; case SYBUNIQUE: tds_swap_bytes(buf, 4); tds_swap_bytes(&buf[4], 2); tds_swap_bytes(&buf[6], 2); break; } } #endif 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); } /** * tds_process_compute_names() processes compute result sets. */ static int tds_process_compute_names(TDSSOCKET * tds) { int hdrsize; int num_cols = 0; TDS_SMALLINT compute_id = 0; TDSCOMPUTEINFO *info; struct namelist *head = NULL, *cur, *next; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_smallint(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_smallint(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) { int col; 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->current_results = info; info->computeid = compute_id; cur = head; for (col = 0; col < num_cols; col++) { TDSCOLUMN *curcol = info->columns[col]; assert(strlen(curcol->column_name) == curcol->column_namelen); tds_strlcpy(curcol->column_name, cur->name, sizeof(curcol->column_name)); curcol->column_namelen = (TDS_SMALLINT)strlen(curcol->column_name); next = cur->next; free(cur->name); free(cur); cur = next; } return TDS_SUCCEED; } 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. */ static int tds7_process_compute_result(TDSSOCKET * tds) { int col, num_cols; TDS_TINYINT by_cols; TDS_SMALLINT *cur_by_col; TDS_SMALLINT compute_id; TDSCOLUMN *curcol; TDSCOMPUTEINFO *info; CHECK_TDS_EXTRA(tds); /* * number of compute columns returned - so * COMPUTE SUM(x), AVG(x)... would return * num_cols = 2 */ num_cols = tds_get_smallint(tds); tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. num_cols = %d\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_smallint(tds); tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. compute_id = %d\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->current_results = 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); tds7_get_data_info(tds, curcol); if (!curcol->column_namelen) { strcpy(curcol->column_name, tds_pr_op(curcol->column_operator)); curcol->column_namelen = (TDS_SMALLINT)strlen(curcol->column_name); } } /* 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); } static int tds_process_cursor_tokens(TDSSOCKET * tds) { TDS_SMALLINT hdrsize; TDS_INT rowcount; TDS_INT cursor_id; TDS_TINYINT namelen; unsigned char cursor_cmd; TDS_SMALLINT cursor_status; TDSCURSOR *cursor; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_smallint(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; } cursor_cmd = tds_get_byte(tds); cursor_status = tds_get_smallint(tds); hdrsize -= 3; if (hdrsize == sizeof(TDS_INT)) rowcount = tds_get_int(tds); 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, cursor); } return TDS_SUCCEED; } static int tds5_process_optioncmd(TDSSOCKET * tds) { TDS_SMALLINT length; TDS_INT command; TDS_INT option; TDS_INT argsize; TDS_INT arg; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_INFO1, "tds5_process_optioncmd()\n"); assert(IS_TDS50(tds)); length = tds_get_smallint(tds); 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_SUCCEED; } static const char * tds_pr_op(int op) { #define TYPE(con, s) case con: return s; break 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 } const char * tds_prtype(int token) { #define TYPE(con, s) case con: return s; break switch (token) { 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(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"); default: break; } return ""; #undef TYPE } /** @} */ static const char * tds_token_name(unsigned char marker) { switch (marker) { case 0x20: return "TDS5_PARAMFMT2"; case 0x22: return "ORDERBY2"; case 0x61: return "ROWFMT2"; case 0x71: return "LOGOUT"; case 0x79: return "RETURNSTATUS"; case 0x7C: return "PROCID"; case 0x81: return "TDS7_RESULT"; case 0x83: return "TDS_CURINFO"; case 0x88: return "TDS7_COMPUTE_RESULT"; case 0xA0: return "COLNAME"; case 0xA1: return "COLFMT"; case 0xA3: return "DYNAMIC2"; case 0xA4: return "TABNAME"; case 0xA5: return "COLINFO"; case 0xA7: return "COMPUTE_NAMES"; case 0xA8: return "COMPUTE_RESULT"; case 0xA9: return "ORDERBY"; case 0xAA: return "ERROR"; case 0xAB: return "INFO"; case 0xAC: return "PARAM"; case 0xAD: return "LOGINACK"; case 0xAE: return "CONTROL"; case 0xD1: return "ROW"; case 0xD3: return "CMP_ROW"; case 0xD7: return "TDS5_PARAMS"; case 0xE2: return "CAPABILITY"; case 0xE3: return "ENVCHANGE"; case 0xE5: return "EED"; case 0xE6: return "DBRPC"; case 0xE7: return "TDS5_DYNAMIC"; case 0xEC: return "TDS5_PARAMFMT"; case 0xED: return "AUTH"; case 0xEE: return "RESULT"; case 0xFD: return "DONE"; case 0xFE: return "DONEPROC"; case 0xFF: return "DONEINPROC"; default: break; } return ""; } /** * Adjust column size according to client's encoding */ 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->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, tds->char_convs[client2ucs2]->client_charset.name, sybase_utf); /* fallback to UCS-2LE */ /* FIXME should be useless. Does not works always */ if (!curcol->char_conv) curcol->char_conv = tds->char_convs[client2ucs2]; } /* FIXME: and sybase ?? */ if (!curcol->char_conv && IS_TDS7_PLUS(tds) && is_ascii_type(curcol->on_server.column_type)) curcol->char_conv = tds->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->server_charset.name, curcol->on_server.column_size, curcol->char_conv->client_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. */ static 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->client_charset.max_bytes_per_char; if (size % char_conv->server_charset.min_bytes_per_char) size += char_conv->server_charset.min_bytes_per_char; size /= char_conv->server_charset.min_bytes_per_char; return size; } freetds-0.91/src/tds/util.c100664 001750 000144 00000030433 11422774163 0011313/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include #endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 "tds.h" #include "tds_checks.h" #include "tdsthread.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: util.c,v 1.93 2010/07/25 08:40:19 freddy77 Exp $"); void tds_set_parent(TDSSOCKET * tds, void *the_parent) { if (tds) tds->parent = the_parent; } /** * 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) { const TDS_STATE prior_state = tds->state; static const char state_names[][10] = { "IDLE", "QUERYING", "PENDING", "READING", "DEAD" }; assert(state < TDS_VECTOR_SIZE(state_names)); assert(tds->state < TDS_VECTOR_SIZE(state_names)); if (state == tds->state) return state; switch(state) { /* transition to READING are valid only from PENDING */ case TDS_PENDING: if (tds->state != TDS_READING && tds->state != TDS_QUERYING) { tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); return tds->state; } tds->state = state; break; case TDS_READING: if (tds->state != TDS_PENDING) { tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); return tds->state; } tds->state = state; break; case TDS_IDLE: if (tds->state == TDS_DEAD && TDS_IS_SOCKET_INVALID(tds->s)) { tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); return tds->state; } case TDS_DEAD: tds->state = state; break; case TDS_QUERYING: CHECK_TDS_EXTRA(tds); if (tds->state == TDS_DEAD) { 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->tds_ctx, tds, TDSEWRIT, 0); break; } else if (tds->state != TDS_IDLE) { 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->tds_ctx, tds, TDSERPND, 0); break; } /* TODO check this code, copied from tds_submit_prepare */ tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; tds_release_cursor(tds, tds->cur_cursor); tds->cur_cursor = NULL; tds->internal_sp_called = 0; tds->state = state; break; default: assert(0); break; } 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 tds->state; } int tds_swap_bytes(unsigned char *buf, int bytes) { unsigned char tmp; int i; /* if (bytes % 2) { return 0 }; */ for (i = 0; i < bytes / 2; i++) { tmp = buf[i]; buf[i] = buf[bytes - i - 1]; buf[bytes - i - 1] = tmp; } return bytes; } /** * 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". */ int tds_version(TDSSOCKET * tds_socket, char *pversion_string) { int iversion = 0; if (tds_socket) { iversion = 10 * TDS_MAJOR(tds_socket) + TDS_MINOR(tds_socket); if (pversion_string) { sprintf(pversion_string, "%d.%d", TDS_MAJOR(tds_socket), TDS_MINOR(tds_socket)); } } return iversion; } 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 } /* * 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; 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" } /* last, with masgno == 0 */ , { 0, 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; ++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 = err->msgtext; msg.sql_state = tds_alloc_client_sqlstate(msg.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_FUNC, 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; } freetds-0.91/src/tds/login.c100644 001750 000144 00000077147 11550671702 0011456/* 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 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tds.h" #include "tdsiconv.h" #include "tdsstring.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: login.c,v 1.202.2.1 2011/04/11 13:33:41 freddy77 Exp $"); static int tds_send_login(TDSSOCKET * tds, TDSCONNECTION * connection); static int tds8_do_login(TDSSOCKET * tds, TDSCONNECTION * connection); static int tds7_send_login(TDSSOCKET * tds, TDSCONNECTION * connection); 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; } void tds_set_passwd(TDSLOGIN * tds_login, const char *password) { if (password) { tds_dstr_zero(&tds_login->password); tds_dstr_copy(&tds_login->password, password); } } void tds_set_bulk(TDSLOGIN * tds_login, TDS_TINYINT enabled) { tds_login->bulk_copy = enabled ? 0 : 1; } void tds_set_user(TDSLOGIN * tds_login, const char *username) { tds_dstr_copy(&tds_login->user_name, username); } void tds_set_host(TDSLOGIN * tds_login, const char *hostname) { tds_dstr_copy(&tds_login->client_host_name, hostname); } void tds_set_app(TDSLOGIN * tds_login, const char *application) { 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. */ void 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) tds_dstr_copy(&tds_login->server_name, server); } void tds_set_library(TDSLOGIN * tds_login, const char *library) { tds_dstr_copy(&tds_login->library, library); } void tds_set_client_charset(TDSLOGIN * tds_login, const char *charset) { tds_dstr_copy(&tds_login->client_charset, charset); } void tds_set_language(TDSLOGIN * tds_login, const char *language) { tds_dstr_copy(&tds_login->language, language); } void tds_set_database_name(TDSLOGIN * tds_login, const char *dbname) { tds_dstr_copy(&tds_login->database, dbname); } void tds_set_capabilities(TDSLOGIN * tds_login, unsigned char *capabilities, int size) { memcpy(tds_login->capabilities, capabilities, size > TDS_MAX_CAPABILITY ? TDS_MAX_CAPABILITY : size); } 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->tds_ctx->msg_handler != tds_save_msg) return; ctx = (TDSSAVECONTEXT *) tds->tds_ctx; 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->tds_ctx->msg_handler) tds->tds_ctx->msg_handler(tds->tds_ctx, tds, &ctx->msgs[n].msg); } else { if (tds->tds_ctx->err_handler) tds->tds_ctx->err_handler(tds->tds_ctx, 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); } /** * Do a connection to socket * @param tds connection structure. This should be a non-connected connection. * @param connection info for connection * @return TDS_FAIL or TDS_SUCCEED if a connection was made to the server's port. * @return TDSERROR enumerated type if no TCP/IP connection could be formed. * @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, TDSCONNECTION * connection, int *p_oserr) { int erc = TDSEFCON; int connect_timeout = 0; int db_selected = 0; /* * 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[] = { 0x702 , 0x701 , 0x700 , 0x500 , 0x402 }; /* disable tds9 if iconv wanted, currently not supported */ if (IS_TDS72_PLUS(connection) && tds->use_iconv) { connection->tds_version = 0x701; tdserror(tds->tds_ctx, tds, TDSEVERDOWN, 0); } if (TDS_MAJOR(connection) == 0) { unsigned int i; TDSSAVECONTEXT save_ctx; const TDSCONTEXT *old_ctx = tds->tds_ctx; 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->tds_ctx; err_handler_t err_handler = tds->tds_ctx->err_handler; init_save_context(&save_ctx, old_ctx); tds->tds_ctx = &save_ctx.ctx; tds->env_chg_func = tds_save_env; mod_ctx->err_handler = NULL; for (i = tds->use_iconv? 1 : 0; i < TDS_VECTOR_SIZE(versions); ++i) { connection->tds_version = versions[i]; reset_save_context(&save_ctx); if ((erc = tds_connect(tds, connection, p_oserr)) != TDS_SUCCEED) { 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->tds_ctx = old_ctx; replay_save_context(tds, &save_ctx); free_save_context(&save_ctx); if (erc != TDS_SUCCEED) tdserror(tds->tds_ctx, tds, erc, *p_oserr); return erc; } /* * 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)); } tds->connection = connection; tds->tds_version = connection->tds_version; tds->emul_little_endian = connection->emul_little_endian; #ifdef WORDS_BIGENDIAN if (IS_TDS7_PLUS(tds)) { /* TDS 7/8 only supports little endian */ tds->emul_little_endian = 1; } #endif /* set up iconv if not already initialized*/ if (tds->char_convs[client2ucs2]->to_wire == (iconv_t) -1) { if (!tds_dstr_isempty(&connection->client_charset)) { tds_iconv_open(tds, tds_dstr_cstr(&connection->client_charset)); } } connect_timeout = connection->connect_timeout; /* Jeff's hack - begin */ tds->query_timeout = connect_timeout ? connect_timeout : connection->query_timeout; /* end */ /* verify that ip_addr is not empty */ if (tds_dstr_isempty(&connection->ip_addr)) { tdserror(tds->tds_ctx, tds, TDSEUHST, 0 ); tdsdump_log(TDS_DBG_ERROR, "IP address pointer is empty\n"); if (!tds_dstr_isempty(&connection->server_name)) { tdsdump_log(TDS_DBG_ERROR, "Server %s not found!\n", tds_dstr_cstr(&connection->server_name)); } else { tdsdump_log(TDS_DBG_ERROR, "No server specified!\n"); } return TDSECONN; } if (!IS_TDS50(tds) && !tds_dstr_isempty(&connection->instance_name) && !connection->port) connection->port = tds7_get_instance_port(tds_dstr_cstr(&connection->ip_addr), tds_dstr_cstr(&connection->instance_name)); if (connection->port < 1) { tdsdump_log(TDS_DBG_ERROR, "invalid port number\n"); return TDSECONN; } memcpy(tds->capabilities, connection->capabilities, TDS_MAX_CAPABILITY); if ((erc = tds_open_socket(tds, tds_dstr_cstr(&connection->ip_addr), connection->port, connect_timeout, p_oserr)) != TDSEOK) { tdserror(tds->tds_ctx, 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); if (IS_TDS71_PLUS(tds)) { erc = tds8_do_login(tds, connection); db_selected = 1; } else if (IS_TDS7_PLUS(tds)) { erc = tds7_send_login(tds, connection); db_selected = 1; } else { tds->out_flag = TDS_LOGIN; erc = tds_send_login(tds, connection); } if (erc == TDS_FAIL || !tds_process_login_tokens(tds)) { tdsdump_log(TDS_DBG_ERROR, "login packet %s\n", erc==TDS_SUCCEED? "accepted":"rejected"); tds_close_socket(tds); tdserror(tds->tds_ctx, tds, TDSEFCON, 0); /* "Adaptive Server connection failed" */ return TDSEFCON; } if (connection->text_size || (!db_selected && !tds_dstr_isempty(&connection->database))) { char *str; int len; len = 64 + tds_quote_id(tds, NULL, tds_dstr_cstr(&connection->database),-1); if ((str = (char *) malloc(len)) == NULL) return TDS_FAIL; str[0] = 0; if (connection->text_size) { sprintf(str, "set textsize %d ", connection->text_size); } if (!db_selected && !tds_dstr_isempty(&connection->database)) { strcat(str, "use "); tds_quote_id(tds, strchr(str, 0), tds_dstr_cstr(&connection->database), -1); } erc = tds_submit_query(tds, str); free(str); if (erc != TDS_SUCCEED) return TDS_FAIL; if (tds_process_simple_query(tds) != TDS_SUCCEED) return TDS_FAIL; } tds->query_timeout = connection->query_timeout; tds->connection = NULL; return TDS_SUCCEED; } int tds_connect_and_login(TDSSOCKET * tds, TDSCONNECTION * connection) { int oserr = 0; return tds_connect(tds, connection, &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 int tds_send_login(TDSSOCKET * tds, TDSCONNECTION * connection) { #ifdef WORDS_BIGENDIAN static const unsigned char be1[] = { 0x02, 0x00, 0x06, 0x04, 0x08, 0x01 }; #endif static const unsigned char le1[] = { 0x03, 0x01, 0x06, 0x0a, 0x09, 0x01 }; static const unsigned char magic2[] = { 0x00, 0x00 }; static const unsigned char magic3[] = { 0x00, 0x00, 0x00 }; /* these seem to endian flags as well 13,17 on intel/alpha 12,16 on power */ #ifdef WORDS_BIGENDIAN static const unsigned char be2[] = { 0x00, 12, 16 }; #endif static const unsigned char le2[] = { 0x00, 13, 17 }; /* * the former byte 0 of magic5 causes the language token and message to be * absent from the login acknowledgement if set to 1. There must be a way * of setting this in the client layer, but I am not aware of any thing of * the sort -- bsb 01/17/99 */ static const unsigned char magic5[] = { 0x00, 0x00 }; static const unsigned char magic6[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const unsigned char magic42[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const unsigned char magic50[] = { 0x00, 0x00, 0x00, 0x00 }; /* * 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]; const char *server_charset; int len; char blockstr[16]; /* override lservname field for ASA servers */ const char *lservname = getenv("ASA_DATABASE")? getenv("ASA_DATABASE") : tds_dstr_cstr(&connection->server_name); if (strchr(tds_dstr_cstr(&connection->user_name), '\\') != NULL) { tdsdump_log(TDS_DBG_ERROR, "NT login not support using TDS 4.x or 5.0\n"); return TDS_FAIL; } if (IS_TDS42(tds)) { memcpy(protocol_version, "\004\002\000\000", 4); memcpy(program_version, "\004\002\000\000", 4); } else if (IS_TDS46(tds)) { memcpy(protocol_version, "\004\006\000\000", 4); memcpy(program_version, "\004\002\000\000", 4); } else if (IS_TDS50(tds)) { 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(&connection->client_host_name), TDS_MAX_LOGIN_STR_SZ); /* client host name */ tds_put_login_string(tds, tds_dstr_cstr(&connection->user_name), TDS_MAX_LOGIN_STR_SZ); /* account name */ tds_put_login_string(tds, tds_dstr_cstr(&connection->password), TDS_MAX_LOGIN_STR_SZ); /* account password */ sprintf(blockstr, "%d", (int) getpid()); tds_put_login_string(tds, blockstr, TDS_MAX_LOGIN_STR_SZ); /* host process */ #ifdef WORDS_BIGENDIAN if (tds->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, connection->bulk_copy); tds_put_n(tds, magic2, 2); if (IS_TDS42(tds)) { tds_put_int(tds, 512); } else { tds_put_int(tds, 0); } tds_put_n(tds, magic3, 3); tds_put_login_string(tds, tds_dstr_cstr(&connection->app_name), TDS_MAX_LOGIN_STR_SZ); tds_put_login_string(tds, lservname, TDS_MAX_LOGIN_STR_SZ); if (IS_TDS42(tds)) { tds_put_login_string(tds, tds_dstr_cstr(&connection->password), 255); } else { len = (int)tds_dstr_len(&connection->password); if (len > 253) len = 0; tds_put_byte(tds, 0); tds_put_byte(tds, len); tds_put_n(tds, tds_dstr_cstr(&connection->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(&connection->library), 10); /* client program name */ if (IS_TDS42(tds)) { tds_put_int(tds, 0); } else { tds_put_n(tds, program_version, 4); /* program version ? */ } #ifdef WORDS_BIGENDIAN if (tds->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(&connection->language), TDS_MAX_LOGIN_STR_SZ); /* language */ tds_put_byte(tds, connection->suppress_language); tds_put_n(tds, magic5, 2); tds_put_byte(tds, connection->encryption_level ? 1 : 0); tds_put_n(tds, magic6, 10); /* use charset nearest to client or nothing */ server_charset = NULL; if (!tds_dstr_isempty(&connection->server_charset)) server_charset = tds_dstr_cstr(&connection->server_charset); else server_charset = tds_sybase_charset_name(tds_dstr_cstr(&connection->client_charset)); if (!server_charset) server_charset = ""; tds_put_login_string(tds, server_charset, TDS_MAX_LOGIN_STR_SZ); /* 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 (connection->block_size < 65536 && connection->block_size > 0) sprintf(blockstr, "%d", connection->block_size); else strcpy(blockstr, "512"); tds_put_login_string(tds, blockstr, 6); if (IS_TDS42(tds)) { tds_put_n(tds, magic42, 8); } else if (IS_TDS46(tds)) { tds_put_n(tds, magic42, 4); } else if (IS_TDS50(tds)) { tds_put_n(tds, magic50, 4); tds_put_byte(tds, TDS_CAPABILITY_TOKEN); tds_put_smallint(tds, TDS_MAX_CAPABILITY); tds_put_n(tds, tds->capabilities, TDS_MAX_CAPABILITY); } 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 int tds7_send_login(TDSSOCKET * tds, TDSCONNECTION * connection) { int rc; static const unsigned char client_progver[] = { 6, 0x83, 0xf2, 0xf8 }; static const unsigned char tds70Version[] = { 0x00, 0x00, 0x00, 0x70 }; static const unsigned char tds71Version[] = { 0x01, 0x00, 0x00, 0x71 }; static const unsigned char tds72Version[] = { 0x02, 0x00, 0x09, 0x72 }; static const unsigned char connection_id[] = { 0x00, 0x00, 0x00, 0x00 }; unsigned char option_flag1 = 0x00; unsigned char option_flag2 = connection->option_flag2; static const unsigned char sql_type_flag = 0x00; static const unsigned char reserved_flag = 0x00; static const unsigned char time_zone[] = { 0x88, 0xff, 0xff, 0xff }; static const unsigned char collation[] = { 0x36, 0x04, 0x00, 0x00 }; unsigned char hwaddr[6]; /* 0xb4,0x00,0x30,0x00,0xe4,0x00,0x00,0x00; */ char unicode_string[256]; char *punicode; size_t unicode_left; size_t packet_size; TDS_INT block_size; size_t current_pos; const char *user_name = tds_dstr_cstr(&connection->user_name); // FIXME: These are defined as size_t, but should be TDS_SMALLINT. size_t user_name_len = strlen(user_name); size_t host_name_len = tds_dstr_len(&connection->client_host_name); size_t app_name_len = tds_dstr_len(&connection->app_name); size_t password_len = tds_dstr_len(&connection->password); size_t server_name_len = tds_dstr_len(&connection->server_name); size_t library_len = tds_dstr_len(&connection->library); size_t language_len = tds_dstr_len(&connection->language); size_t database_len = tds_dstr_len(&connection->database); size_t auth_len = 0; tds->out_flag = TDS7_LOGIN; /* discard possible previous authentication */ if (tds->authentication) { tds->authentication->free(tds, tds->authentication); tds->authentication = NULL; } /* avoid overflow limiting password */ if (password_len > 128) password_len = 128; current_pos = IS_TDS72_PLUS(tds) ? 86 + 8 : 86; /* ? */ packet_size = current_pos + (host_name_len + app_name_len + server_name_len + library_len + language_len + database_len) * 2; /* check ntlm */ #ifdef HAVE_SSPI if (strchr(user_name, '\\') != NULL || user_name_len == 0) { tds->authentication = tds_sspi_get_auth(tds); if (!tds->authentication) return TDS_FAIL; auth_len = tds->authentication->packet_len; packet_size += auth_len; #else if (strchr(user_name, '\\') != NULL) { tds->authentication = tds_ntlm_get_auth(tds); if (!tds->authentication) return TDS_FAIL; auth_len = tds->authentication->packet_len; packet_size += auth_len; } else if (user_name_len == 0) { # ifdef ENABLE_KRB5 /* try kerberos */ tds->authentication = tds_gss_get_auth(tds); if (!tds->authentication) return TDS_FAIL; auth_len = tds->authentication->packet_len; packet_size += auth_len; # else return TDS_FAIL; # endif #endif } else packet_size += (user_name_len + password_len) * 2; #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); if (IS_TDS72_PLUS(tds)) { tds_put_n(tds, tds72Version, 4); } else if (IS_TDS71_PLUS(tds)) { tds_put_n(tds, tds71Version, 4); } else { tds_put_n(tds, tds70Version, 4); } if (connection->block_size < 1000000 && connection->block_size >= 512) block_size = connection->block_size; else block_size = 4096; /* SQL server default */ tds_put_int(tds, block_size); /* desired packet size being requested by client */ if (block_size > tds->env.block_size) tds_realloc_socket(tds, block_size); tds_put_n(tds, client_progver, 4); /* client program version ? */ tds_put_int(tds, getpid()); /* process id of this process */ tds_put_n(tds, connection_id, 4); option_flag1 |= 0x80; /* enable warning messages if SET LANGUAGE issued */ option_flag1 |= 0x40; /* change to initial database must succeed */ option_flag1 |= 0x20; /* enable warning messages if USE issued */ tds_put_byte(tds, option_flag1); if (tds->authentication) option_flag2 |= 0x80; /* enable domain login security */ tds_put_byte(tds, option_flag2); tds_put_byte(tds, sql_type_flag); tds_put_byte(tds, reserved_flag); tds_put_n(tds, time_zone, 4); tds_put_n(tds, collation, 4); /* host name */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, host_name_len); current_pos += host_name_len * 2; if (tds->authentication) { tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); } else { /* username */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, user_name_len); current_pos += user_name_len * 2; /* password */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, password_len); current_pos += password_len * 2; } /* app name */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, app_name_len); current_pos += app_name_len * 2; /* server name */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, server_name_len); current_pos += server_name_len * 2; /* unknown */ tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); /* library name */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, library_len); current_pos += library_len * 2; /* language - kostya@warmcat.excom.spb.su */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, language_len); current_pos += language_len * 2; /* database name */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, database_len); current_pos += database_len * 2; /* MAC address */ tds_getmac(tds->s, hwaddr); tds_put_n(tds, hwaddr, 6); /* authentication stuff */ TDS_PUT_SMALLINT(tds, current_pos); TDS_PUT_SMALLINT(tds, auth_len); /* this matches numbers at end of packet */ current_pos += auth_len; /* db file */ TDS_PUT_SMALLINT(tds, current_pos); tds_put_smallint(tds, 0); if (IS_TDS72_PLUS(tds)) { /* new password */ TDS_PUT_SMALLINT(tds, current_pos); tds_put_smallint(tds, 0); /* SSPI long */ tds_put_int(tds, 0); } /* FIXME here we assume single byte, do not use *2 to compute bytes, convert before !!! */ tds_put_string(tds, tds_dstr_cstr(&connection->client_host_name), (int)host_name_len); if (!tds->authentication) { const char *p; TDSICONV *char_conv = tds->char_convs[client2ucs2]; tds_put_string(tds, tds_dstr_cstr(&connection->user_name), (int)user_name_len); p = tds_dstr_cstr(&connection->password); punicode = unicode_string; unicode_left = sizeof(unicode_string); memset(&char_conv->suppress, 0, sizeof(char_conv->suppress)); if (tds_iconv(tds, tds->char_convs[client2ucs2], to_server, &p, &password_len, &punicode, &unicode_left) == (size_t) - 1) { tdsdump_log(TDS_DBG_INFO1, "password \"%s\" could not be converted to UCS-2\n", p); assert(0); } password_len = punicode - unicode_string; tds7_crypt_pass((unsigned char *) unicode_string, password_len, (unsigned char *) unicode_string); tds_put_n(tds, unicode_string, password_len); } tds_put_string(tds, tds_dstr_cstr(&connection->app_name), (int)app_name_len); tds_put_string(tds, tds_dstr_cstr(&connection->server_name), (int)server_name_len); tds_put_string(tds, tds_dstr_cstr(&connection->library), (int)library_len); tds_put_string(tds, tds_dstr_cstr(&connection->language), (int)language_len); tds_put_string(tds, tds_dstr_cstr(&connection->database), (int)database_len); if (tds->authentication) tds_put_n(tds, tds->authentication->packet, auth_len); rc = tds_flush_packet(tds); tdsdump_on(); 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 */ unsigned char * 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; return crypt_pass; } static int tds8_do_login(TDSSOCKET * tds, TDSCONNECTION * connection) { int i, len; const char *instance_name = tds_dstr_isempty(&connection->instance_name) ? "MSSQLServer" : tds_dstr_cstr(&connection->instance_name); int instance_name_len = strlen(instance_name) + 1; TDS_CHAR crypt_flag; unsigned int start_pos = 21; #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) int ret; #endif #define START_POS 21 #define UI16BE(n) ((n) >> 8), ((n) & 0xffu) #define SET_UI16BE(i,n) do { buf[i] = ((n) >> 8); buf[i+1] = ((n) & 0xffu); } while(0) 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), /* ???? unknown ??? */ 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)) { 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->env.block_size < 4096) tds_realloc_socket(tds, 4096); /* do prelogin */ tds->out_flag = TDS8_PRELOGIN; tds_put_n(tds, buf, start_pos); /* netlib version */ tds_put_n(tds, IS_TDS72_PLUS(tds) ? netlib9 : netlib8, 6); /* encryption */ #if !defined(HAVE_GNUTLS) && !defined(HAVE_OPENSSL) /* not supported */ tds_put_byte(tds, 2); #else tds_put_byte(tds, connection->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)) tds_put_byte(tds, 0); if (tds_flush_packet(tds) == TDS_FAIL) return TDS_FAIL; /* now process reply from server */ len = tds_read_packet(tds); if (len <= 0 || tds->in_flag != 4) return TDS_FAIL; 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, l; if (i >= len) return TDS_FAIL; type = p[i]; if (type == 0xff) break; /* check packet */ if (i+4 >= len) return TDS_FAIL; off = (((int) p[i+1]) << 8) | p[i+2]; l = (((int) p[i+3]) << 8) | p[i+4]; if (off > len || (off+l) > len) return TDS_FAIL; if (type == 1 && l >= 1) { crypt_flag = p[off]; } } /* we readed all packet */ tds->in_pos += 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 (connection->encryption_level >= TDS_ENCRYPTION_REQUIRE) return TDS_FAIL; return tds7_send_login(tds, connection); } #if !defined(HAVE_GNUTLS) && !defined(HAVE_OPENSSL) tdsdump_log(TDS_DBG_ERROR, "server required encryption but support is not compiled in\n"); return TDS_FAIL; #else /* * if server has a certificate it require at least a crypted login * (even if data is not encrypted) */ /* here we have to do encryption ... */ if (tds_ssl_init(tds) != TDS_SUCCEED) return TDS_FAIL; ret = tds7_send_login(tds, connection); /* if flag is 0 it means that after login server continue not encrypted */ if (crypt_flag == 0 || ret != TDS_SUCCEED) tds_ssl_deinit(tds); return ret; #endif } freetds-0.91/src/tds/read.c100664 001750 000144 00000025073 11424500156 0011244/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2005, 2006, 2007, 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. */ #if HAVE_CONFIG_H #include #endif #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 "tds.h" #include "tdsiconv.h" #include "tdsbytes.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: read.c,v 1.112 2010/07/30 07:34:06 freddy77 Exp $"); static int read_and_convert(TDSSOCKET * tds, const 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 */ 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. */ void tds_unget_byte(TDSSOCKET * tds) { /* this is a one trick pony...don't call it twice */ tds->in_pos--; } 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_SMALLINT tds_get_smallint(TDSSOCKET * tds) { unsigned char bytes[2]; tds_get_n(tds, bytes, 2); #if WORDS_BIGENDIAN if (tds->emul_little_endian) return (TDS_SMALLINT) TDS_GET_A2LE(bytes); #endif return (TDS_SMALLINT) TDS_GET_A2(bytes); } /** * Get an int32 from the server. */ TDS_INT tds_get_int(TDSSOCKET * tds) { unsigned char bytes[4]; tds_get_n(tds, bytes, 4); #if WORDS_BIGENDIAN if (tds->emul_little_endian) return (TDS_INT) TDS_GET_A4LE(bytes); #endif return (TDS_INT) TDS_GET_A4(bytes); } TDS_INT8 tds_get_int8(TDSSOCKET * tds) { TDS_INT h; TDS_UINT l; unsigned char bytes[8]; tds_get_n(tds, bytes, 8); #if WORDS_BIGENDIAN if (tds->emul_little_endian) { l = TDS_GET_A4LE(bytes); h = (TDS_INT) TDS_GET_A4LE(bytes+4); } else { h = (TDS_INT) TDS_GET_A4(bytes); l = TDS_GET_A4(bytes+4); } #else l = TDS_GET_A4(bytes); h = (TDS_INT) TDS_GET_A4(bytes+4); #endif return (((TDS_INT8) h) << 32) | l; } #if ENABLE_EXTRA_CHECKS # define TEMP_INIT(s) char* temp = (char*)malloc(32); const size_t temp_size = 32 # 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 /** * 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 */ int tds_get_string(TDSSOCKET * tds, int string_len, char *dest, size_t dest_size) { size_t wire_bytes; /* * FIX: 02-Jun-2000 by Scott C. Gray (SCG) * Bug to malloc(0) on some platforms. */ if (string_len == 0) { return 0; } assert(string_len >= 0 && dest_size >= 0); wire_bytes = IS_TDS7_PLUS(tds) ? string_len * 2 : string_len; if (IS_TDS7_PLUS(tds)) { if (dest == NULL) { tds_get_n(tds, NULL, (int)wire_bytes); return string_len; } return read_and_convert(tds, tds->char_convs[client2ucs2], &wire_bytes, &dest, &dest_size); } else { /* FIXME convert to client charset */ assert(dest_size >= (size_t) string_len); tds_get_n(tds, dest, string_len); return string_len; } } /** * 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_SUCCEED or TDS_FAIL (probably memory error on text data) * \todo put a TDSICONV structure in every TDSCOLUMN */ int tds_get_char_data(TDSSOCKET * tds, char *row_buffer, size_t wire_size, TDSCOLUMN * curcol) { size_t in_left; TDSBLOB *blob = NULL; char *dest = row_buffer; if (is_blob_col(curcol)) { blob = (TDSBLOB *) row_buffer; dest = blob->textvalue; } /* * dest is usually a column buffer, allocated when the column's metadata are processed * and reused for each row. * For blobs, dest is blob->textvalue, and can be reallocated or freed * TODO: reallocate if blob and no space */ /* silly case, empty string */ if (wire_size == 0) { curcol->column_cur_size = 0; if (blob) TDS_ZERO_FREE(blob->textvalue); return TDS_SUCCEED; } if (curcol->char_conv) { /* * TODO The conversion should be selected from curcol and tds version * TDS8/single -> use curcol collation * TDS7/single -> use server single byte * TDS7+/unicode -> use server (always unicode) * TDS5/4.2 -> use server * TDS5/UTF-8 -> use server * TDS5/UTF-16 -> use UTF-16 */ in_left = blob ? curcol->column_cur_size : curcol->column_size; curcol->column_cur_size = read_and_convert(tds, curcol->char_conv, &wire_size, &dest, &in_left); if (wire_size > 0) { 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; } } else { curcol->column_cur_size = (TDS_INT)wire_size; if (tds_get_n(tds, dest, (int)wire_size) == NULL) { tdsdump_log(TDS_DBG_NETWORK, "error: tds_get_char_data: failed to read %u from wire. \n", (unsigned int) wire_size); return TDS_FAIL; } } return TDS_SUCCEED; } /** * 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, int need) { assert(need >= 0); for (;;) { 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_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. */ static int read_and_convert(TDSSOCKET * tds, const TDSICONV * char_conv, size_t * wire_size, char **outbuf, size_t * outbytesleft) { TEMP_INIT(256); /* * 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 *bufp; size_t bufleft = 0; const size_t max_output = *outbytesleft; /* 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 (bufp = temp; *wire_size > 0 && *outbytesleft > 0; bufp = temp + bufleft) { assert(bufp >= temp); /* read a chunk of data */ bufleft = TEMP_SIZE - bufleft; if (bufleft > *wire_size) bufleft = *wire_size; tds_get_n(tds, (char *) bufp, (int)bufleft); *wire_size -= bufleft; bufleft += bufp - temp; /* Convert chunk and write to dest. */ bufp = temp; /* always convert from start of buffer */ suppress->einval = *wire_size > 0; /* EINVAL matters only on the last chunk. */ if ((size_t)-1 == tds_iconv(tds, char_conv, to_client, &bufp, &bufleft, outbuf, outbytesleft)) { tdsdump_log(TDS_DBG_NETWORK, "Error: read_and_convert: tds_iconv returned errno %d\n", errno); if (errno != EILSEQ) { tdsdump_log(TDS_DBG_NETWORK, "Error: read_and_convert: " "Gave up converting %u bytes due to error %d.\n", (unsigned int) bufleft, errno); tdsdump_dump_buf(TDS_DBG_NETWORK, "Troublesome bytes:", bufp, bufleft); } if (bufp == temp) { /* tds_iconv did not convert anything, avoid infinite loop */ tdsdump_log(TDS_DBG_NETWORK, "No conversion possible: draining remaining %u bytes.\n", (unsigned int) *wire_size); tds_get_n(tds, NULL, (int)(*wire_size)); /* perhaps we should read unconverted data into outbuf? */ *wire_size = 0; break; } if (bufleft) { memmove(temp, bufp, bufleft); } } } assert(*wire_size == 0 || *outbytesleft == 0); TEMP_FREE; return (int)(max_output - *outbytesleft); } /** @} */ freetds-0.91/src/tds/write.c100664 001750 000144 00000017012 11343414431 0011455/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tds.h" #include "tdsiconv.h" #include "tdsbytes.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: write.c,v 1.79 2010/03/03 08:08:57 freddy77 Exp $"); /** * \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;) { left = tds->env.block_size - tds->out_pos; if (left <= 0) { tds_write_packet(tds, 0x0); continue; } 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) { TDS_ENCODING *client, *server; char outbuf[256], *poutbuf; size_t inbytesleft, outbytesleft, bytes_out = 0; client = &tds->char_convs[client2ucs2]->client_charset; server = &tds->char_convs[client2ucs2]->server_charset; if (len < 0) { 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)) { tds_put_n(tds, s, len); return len; } memset(&tds->char_convs[client2ucs2]->suppress, 0, sizeof(tds->char_convs[client2ucs2]->suppress)); tds->char_convs[client2ucs2]->suppress.e2big = 1; inbytesleft = len; while (inbytesleft) { tdsdump_log(TDS_DBG_NETWORK, "tds_put_string converting %d bytes of \"%.*s\"\n", (int) inbytesleft, (int) inbytesleft, s); outbytesleft = sizeof(outbuf); poutbuf = outbuf; if ((size_t)-1 == tds_iconv(tds, tds->char_convs[client2ucs2], to_server, &s, &inbytesleft, &poutbuf, &outbytesleft)) { if (errno == EINVAL) { tdsdump_log(TDS_DBG_NETWORK, "tds_put_string: tds_iconv() encountered partial sequence. " "%d bytes remain.\n", (int) inbytesleft); /* TODO return some sort or error ?? */ break; } else if (errno != E2BIG) { /* It's not an incomplete multibyte sequence, or it IS, but we're not anticipating one. */ tdsdump_log(TDS_DBG_NETWORK, "Error: tds_put_string: " "Gave up converting %d bytes due to error %d.\n", (int) inbytesleft, errno); tdsdump_dump_buf(TDS_DBG_NETWORK, "Troublesome bytes", s, inbytesleft); } if (poutbuf == outbuf) { /* tds_iconv did not convert anything, avoid infinite loop */ tdsdump_log(TDS_DBG_NETWORK, "Error: tds_put_string: No conversion possible, giving up.\n"); break; } } bytes_out += poutbuf - outbuf; tds_put_n(tds, outbuf, poutbuf - outbuf); } tdsdump_log(TDS_DBG_NETWORK, "tds_put_string wrote %d bytes\n", (int) bytes_out); return (int)bytes_out; } 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 WORDS_BIGENDIAN TDS_UINT h; if (tds->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)); } int tds_put_int(TDSSOCKET * tds, TDS_INT i) { #if TDS_ADDITIONAL_SPACE == 0 #if WORDS_BIGENDIAN if (tds->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->env.block_size) tds_write_packet(tds, 0x0); p = &tds->out_buf[tds->out_pos]; #if WORDS_BIGENDIAN if (tds->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 == 0 #if WORDS_BIGENDIAN if (tds->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->env.block_size) tds_write_packet(tds, 0x0); p = &tds->out_buf[tds->out_pos]; #if WORDS_BIGENDIAN if (tds->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->env.block_size) tds_write_packet(tds, 0x0); tds->out_buf[tds->out_pos++] = c; return 0; } int tds_init_write_buf(TDSSOCKET * tds) { /* TODO needed ?? */ memset(tds->out_buf, '\0', tds->env.block_size); tds->out_pos = 8; return 0; } /** * Flush packet to server * @return TDS_FAIL or TDS_SUCCEED */ int tds_flush_packet(TDSSOCKET * tds) { int result = TDS_FAIL; /* GW added check for tds->s */ if (!IS_TDSDEAD(tds)) result = tds_write_packet(tds, 0x01); return result; } /** @} */ freetds-0.91/src/tds/convert.c100664 001750 000144 00000216046 11506373026 0012020/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 "tds.h" #include "tdsconvert.h" #include "tdsbytes.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: convert.c,v 1.196 2010/12/28 14:37:10 freddy77 Exp $"); typedef unsigned short utf16_t; static TDS_INT tds_convert_int1(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_int2(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_int4(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_int8(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr); static int string_to_datetime(const char *datestr, int desttype, CONV_RESULT * cr); static int is_dd_mon_yyyy(char *t); static int store_dd_mon_yyy_date(char *datestr, struct tds_time *t); #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 ) /* * 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_INT8_MAX ((((TDS_INT8) 0x7fffffffl) << 32) + 0xfffffffflu) #define TDS_INT8_MIN (((TDS_INT8) (-0x7fffffffl-1)) << 32) #define IS_INT8(x) (TDS_INT8_MIN <= (x) && (x) <= TDS_INT8_MAX) /** * \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 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 int is_timeformat(const char *); static int is_numeric(const char *); static int is_alphabetic(const char *); static int is_ampm(const char *); #define is_monthname(s) (store_monthname(s, NULL) >= 0) static int 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[16] = "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_CHAR *) malloc(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_CHAR *) malloc(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 binary_to_result(data, len, cr) \ binary_to_result(desttype, data, len, cr) #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 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(int srctype, 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_CHAR *) malloc((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 CASE_ALL_BINARY: return binary_to_result(src, srclen, cr); break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: 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(int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr) { unsigned int i, j; TDS_INT8 mymoney; char mynumber[39]; const char *ptr, *pend; int point_found; unsigned int places; TDS_INT tds_i; TDS_INT8 tds_i8; TDS_INT rc; TDS_CHAR *ib; 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_CHAR *) malloc(srclen + 1); test_alloc(cr->c); memcpy(cr->c, src, srclen); cr->c[srclen] = 0; return srclen; break; case CASE_ALL_BINARY: /* 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_CHAR *) malloc((srclen + 1u) / 2u); test_alloc(cr->ib); ib = cr->ib; } return tds_char2hex(ib, desttype == TDS_CONVERT_BINARY ? cr->cb.len : 0xffffffffu, src, srclen); break; case SYBINT1: 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 SYBINT4: if ((rc = string_to_int(src, src + srclen, &tds_i)) < 0) return rc; cr->i = tds_i; return sizeof(TDS_INT); 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 SYBFLT8: /* FIXME not null terminated */ /* TODO check syntax and overflow */ cr->f = atof(src); return sizeof(TDS_FLOAT); break; case SYBREAL: /* FIXME not null terminated */ /* TODO check syntax and overflow */ cr->r = (TDS_REAL)atof(src); return sizeof(TDS_REAL); 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: /* TODO code similar to string_to_numeric... */ i = 0; places = 0; point_found = 0; pend = src + srclen; /* skip leading blanks */ for (ptr = src; ptr != pend && *ptr == ' '; ++ptr); switch (ptr != pend ? *ptr : 0) { case '-': mynumber[i++] = '-'; /* fall through */ case '+': ptr++; for (; ptr != pend && *ptr == ' '; ++ptr); break; } for (; ptr != pend; ptr++) { /* deal with the rest */ if (isdigit((unsigned char) *ptr)) { /* it's a number */ /* no more than 4 decimal digits */ if (places < 4) mynumber[i++] = *ptr; /* assure not buffer overflow */ if (i == 30) return TDS_CONVERT_OVERFLOW; if (point_found) { /* if we passed a decimal point */ /* count digits after that point */ ++places; } } else if (*ptr == '.') { /* found a decimal point */ if (point_found) /* already had one. error */ return TDS_CONVERT_SYNTAX; point_found = 1; } else /* first invalid character */ return TDS_CONVERT_SYNTAX; /* lose the rest. */ } for (j = places; j < 4; j++) mynumber[i++] = '0'; mynumber[i] = 0; /* FIXME overflow not handled */ if (desttype == SYBMONEY) { mymoney = atoll(mynumber); cr->m.mny = mymoney; return sizeof(TDS_MONEY); } else { cr->m4.mny4 = atol(mynumber); return sizeof(TDS_MONEY4); } break; case SYBDATETIME: /* FIXME not null terminated */ return string_to_datetime(src, SYBDATETIME, cr); break; case SYBDATETIME4: /* FIXME not null terminated */ return string_to_datetime(src, SYBDATETIME4, 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(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { int canonic = src[0] ? 1 : 0; switch (desttype) { case TDS_CONVERT_CHAR: if (cr->cc.len) cr->cc.c[0] = '0' + canonic; return 1; case CASE_ALL_CHAR: cr->c = (TDS_CHAR *) malloc(2); test_alloc(cr->c); cr->c[0] = '0' + canonic; cr->c[1] = 0; return 1; break; case CASE_ALL_BINARY: return binary_to_result(src, 1, cr); break; case SYBINT1: cr->ti = canonic; return sizeof(TDS_TINYINT); break; case SYBINT2: cr->si = canonic; return sizeof(TDS_SMALLINT); break; case SYBINT4: cr->i = canonic; return sizeof(TDS_INT); break; case SYBINT8: cr->bi = canonic; return sizeof(TDS_INT8); break; case SYBFLT8: cr->f = canonic; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = (TDS_REAL) canonic; return sizeof(TDS_REAL); break; case SYBBIT: case SYBBITN: cr->ti = src[0]; return sizeof(TDS_TINYINT); break; case SYBMONEY: case SYBMONEY4: return tds_convert_int1(SYBINT1, (src[0]) ? "\1" : "\0", desttype, cr); break; case SYBNUMERIC: case SYBDECIMAL: return stringz_to_numeric(canonic ? "1" : "0", cr); break; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_int1(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { TDS_TINYINT buf; TDS_CHAR tmp_str[5]; buf = *((TDS_TINYINT *) src); switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%d", buf); return string_to_result(tmp_str, cr); break; case CASE_ALL_BINARY: return binary_to_result(src, 1, cr); break; case SYBINT1: cr->ti = buf; return sizeof(TDS_TINYINT); break; case SYBINT2: cr->si = buf; return sizeof(TDS_SMALLINT); break; case SYBINT4: cr->i = buf; return sizeof(TDS_INT); break; case SYBINT8: cr->bi = buf; return sizeof(TDS_INT8); break; case SYBBIT: case SYBBITN: cr->ti = buf ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = buf; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = buf; return sizeof(TDS_REAL); break; case SYBMONEY4: cr->m4.mny4 = buf * 10000; return sizeof(TDS_MONEY4); break; case SYBMONEY: cr->m.mny = buf * 10000; return sizeof(TDS_MONEY); break; case SYBNUMERIC: case SYBDECIMAL: sprintf(tmp_str, "%d", buf); return stringz_to_numeric(tmp_str, cr); break; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_int2(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { TDS_SMALLINT buf; TDS_CHAR tmp_str[16]; memcpy(&buf, src, sizeof(buf)); switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%d", buf); return string_to_result(tmp_str, cr); break; case CASE_ALL_BINARY: return binary_to_result(src, 2, cr); break; case SYBINT1: if (!IS_TINYINT(buf)) return TDS_CONVERT_OVERFLOW; cr->ti = (TDS_TINYINT) buf; return sizeof(TDS_TINYINT); break; case SYBINT2: cr->si = buf; return sizeof(TDS_SMALLINT); break; case SYBINT4: cr->i = buf; return sizeof(TDS_INT); break; case SYBINT8: cr->bi = buf; return sizeof(TDS_INT8); break; case SYBBIT: case SYBBITN: cr->ti = buf ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = buf; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = buf; return sizeof(TDS_REAL); break; case SYBMONEY4: cr->m4.mny4 = buf * 10000; return sizeof(TDS_MONEY4); break; case SYBMONEY: cr->m.mny = buf * 10000; return sizeof(TDS_MONEY); break; case SYBNUMERIC: case SYBDECIMAL: sprintf(tmp_str, "%d", buf); return stringz_to_numeric(tmp_str, cr); break; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_int4(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { TDS_INT buf; TDS_CHAR tmp_str[16]; memcpy(&buf, src, sizeof(buf)); switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%d", buf); return string_to_result(tmp_str, cr); break; case CASE_ALL_BINARY: return binary_to_result(src, 4, cr); break; case SYBINT1: if (!IS_TINYINT(buf)) return TDS_CONVERT_OVERFLOW; cr->ti = buf; return sizeof(TDS_TINYINT); break; case SYBINT2: if (!IS_SMALLINT(buf)) return TDS_CONVERT_OVERFLOW; cr->si = buf; return sizeof(TDS_SMALLINT); break; case SYBINT4: cr->i = buf; return sizeof(TDS_INT); break; case SYBINT8: cr->bi = buf; return sizeof(TDS_INT8); break; case SYBBIT: case SYBBITN: cr->ti = buf ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = buf; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = (TDS_REAL) buf; return sizeof(TDS_REAL); break; case SYBMONEY4: if (buf > 214748 || buf < -214748) return TDS_CONVERT_OVERFLOW; cr->m4.mny4 = buf * 10000; return sizeof(TDS_MONEY4); break; case SYBMONEY: cr->m.mny = (TDS_INT8) buf *10000; return sizeof(TDS_MONEY); break; case SYBNUMERIC: case SYBDECIMAL: sprintf(tmp_str, "%d", buf); return stringz_to_numeric(tmp_str, cr); break; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_int8(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { TDS_INT8 buf; TDS_CHAR tmp_str[24]; memcpy(&buf, src, sizeof(buf)); switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%" PRId64, buf); return string_to_result(tmp_str, cr); break; case CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_INT8), cr); break; case SYBINT1: if (!IS_TINYINT(buf)) return TDS_CONVERT_OVERFLOW; cr->ti = (TDS_TINYINT) buf; return sizeof(TDS_TINYINT); break; case SYBINT2: if (!IS_SMALLINT(buf)) return TDS_CONVERT_OVERFLOW; cr->si = (TDS_SMALLINT) buf; return sizeof(TDS_SMALLINT); break; case SYBINT4: if (!IS_INT(buf)) return TDS_CONVERT_OVERFLOW; cr->i = (TDS_INT) buf; return sizeof(TDS_INT); break; case SYBINT8: cr->bi = buf; return sizeof(TDS_INT8); break; case SYBBIT: case SYBBITN: cr->ti = buf ? 1 : 0; 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 SYBMONEY4: if (buf > 214748 || buf < -214748) return TDS_CONVERT_OVERFLOW; cr->m4.mny4 = (TDS_INT) (buf * 10000); return sizeof(TDS_MONEY4); 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: sprintf(tmp_str, "%" PRId64, buf); return stringz_to_numeric(tmp_str, 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(int srctype, const TDS_NUMERIC * src, TDS_INT srclen, 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 CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_NUMERIC), cr); break; case SYBINT1: 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 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 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 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 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(int srctype, const TDS_CHAR * src, int srclen, int desttype, CONV_RESULT * cr) { TDS_MONEY4 mny; long dollars, fraction; char tmp_str[33]; char *p; memcpy(&mny, src, sizeof(mny)); 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 CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_MONEY4), cr); break; case SYBINT1: 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 SYBINT4: cr->i = mny.mny4 / 10000; return sizeof(TDS_INT); break; case SYBINT8: cr->bi = mny.mny4 / 10000; return sizeof(TDS_INT8); 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; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: break; case SYBDECIMAL: case SYBNUMERIC: dollars = mny.mny4 / 10000; fraction = mny.mny4 % 10000; if (fraction < 0) { fraction = -fraction; } sprintf(tmp_str, "%ld.%04lu", dollars, fraction); return stringz_to_numeric(tmp_str, cr); default: return TDS_CONVERT_NOAVAIL; break; } return TDS_CONVERT_FAIL; } static TDS_INT tds_convert_money(int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { char *s; TDS_INT8 mymoney, dollars; char tmpstr[64]; tdsdump_log(TDS_DBG_FUNC, "tds_convert_money()\n"); #if defined(WORDS_BIGENDIAN) || !defined(HAVE_INT64) memcpy(&mymoney, src, sizeof(TDS_INT8)); #else memcpy(((char *) &mymoney) + 4, src, 4); memcpy(&mymoney, src + 4, 4); #endif 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 CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_MONEY), cr); break; case SYBINT1: 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 SYBINT4: dollars = mymoney / 10000; if (!IS_INT(dollars)) return TDS_CONVERT_OVERFLOW; cr->i = (TDS_INT) dollars; return sizeof(TDS_INT); break; case SYBINT8: cr->bi = mymoney / 10000; return sizeof(TDS_INT8); 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: s = tds_money_to_string((const TDS_MONEY *) src, tmpstr); return stringz_to_numeric(tmpstr, cr); break; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_datetime(const TDSCONTEXT * tds_ctx, int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { TDS_INT dt_days, dt_time; char whole_date_string[30]; TDSDATEREC when; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: memset(&when, 0, sizeof(when)); tds_datecrack(SYBDATETIME, src, &when); tds_strftime(whole_date_string, sizeof(whole_date_string), tds_ctx->locale->date_fmt, &when); return string_to_result(whole_date_string, cr); break; case CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_DATETIME), cr); break; case SYBDATETIME: memcpy(&cr->dt, src, sizeof(TDS_DATETIME)); return sizeof(TDS_DATETIME); break; case SYBDATETIME4: memcpy(&dt_days, src, 4); memcpy(&dt_time, src + 4, 4); cr->dt4.days = dt_days; cr->dt4.minutes = (dt_time / 300) / 60; return sizeof(TDS_DATETIME4); break; /* conversions not allowed */ case SYBUNIQUE: case SYBBIT: case SYBBITN: case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBMONEY4: case SYBMONEY: case SYBNUMERIC: case SYBDECIMAL: default: break; } return TDS_CONVERT_NOAVAIL; } /* static int days_this_year (int years) { int year; year = 1900 + years; if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) return 366; else return 365; } */ static TDS_INT tds_convert_datetime4(const TDSCONTEXT * tds_ctx, int srctype, const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { TDS_USMALLINT dt_days, dt_mins; char whole_date_string[30]; TDSDATEREC when; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: memset(&when, 0, sizeof(when)); tds_datecrack(SYBDATETIME4, src, &when); tds_strftime(whole_date_string, sizeof(whole_date_string), tds_ctx->locale->date_fmt, &when); return string_to_result(whole_date_string, cr); break; case CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_DATETIME4), cr); break; case SYBDATETIME: memcpy(&dt_days, src, 2); memcpy(&dt_mins, src + 2, 2); cr->dt.dtdays = dt_days; cr->dt.dttime = (dt_mins * 60) * 300; return sizeof(TDS_DATETIME); break; case SYBDATETIME4: memcpy(&cr->dt4, src, sizeof(TDS_DATETIME4)); return sizeof(TDS_DATETIME4); break; /* conversions not allowed */ case SYBUNIQUE: case SYBBIT: case SYBBITN: case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBMONEY4: case SYBMONEY: case SYBNUMERIC: case SYBDECIMAL: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_real(int srctype, const TDS_CHAR * 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; memcpy(&the_value, src, 4); switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%.7g", the_value); return string_to_result(tmp_str, cr); break; case CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_REAL), cr); break; case SYBINT1: 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 SYBINT4: if (!IS_INT(the_value)) return TDS_CONVERT_OVERFLOW; cr->i = (TDS_INT) the_value; return sizeof(TDS_INT); 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 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(int srctype, const TDS_CHAR * 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, "%.16g", the_value); return string_to_result(tmp_str, cr); break; case CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_FLOAT), cr); break; case SYBINT1: 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 SYBINT4: if (!IS_INT(the_value)) return TDS_CONVERT_OVERFLOW; cr->i = (TDS_INT) the_value; return sizeof(TDS_INT); 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 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(int srctype, const TDS_CHAR * src, TDS_INT srclen, 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 CASE_ALL_BINARY: return binary_to_result(src, sizeof(TDS_UNIQUE), 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 SYBINT2: case SYBINT4: case SYBINT8: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: case SYBREAL: case SYBFLT8: default: break; } return TDS_CONVERT_NOAVAIL; } /** * 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 (srctype) { case CASE_ALL_CHAR: length = tds_convert_char(srctype, src, srclen, desttype, cr); break; case SYBMONEY4: length = tds_convert_money4(srctype, src, srclen, desttype, cr); break; case SYBMONEY: length = tds_convert_money(srctype, src, desttype, cr); break; case SYBNUMERIC: case SYBDECIMAL: length = tds_convert_numeric(srctype, (const TDS_NUMERIC *) src, srclen, desttype, cr); break; case SYBBIT: case SYBBITN: length = tds_convert_bit(srctype, src, desttype, cr); break; case SYBINT1: length = tds_convert_int1(srctype, src, desttype, cr); break; case SYBINT2: length = tds_convert_int2(srctype, src, desttype, cr); break; case SYBINT4: length = tds_convert_int4(srctype, src, desttype, cr); break; case SYBINT8: length = tds_convert_int8(srctype, src, desttype, cr); break; case SYBREAL: length = tds_convert_real(srctype, src, desttype, cr); break; case SYBFLT8: length = tds_convert_flt8(srctype, src, desttype, cr); break; case SYBDATETIME: length = tds_convert_datetime(tds_ctx, srctype, src, desttype, cr); break; case SYBDATETIME4: length = tds_convert_datetime4(tds_ctx, srctype, src, desttype, cr); break; case SYBLONGBINARY: case CASE_ALL_BINARY: length = tds_convert_binary(srctype, (const TDS_UCHAR *) src, srclen, desttype, cr); break; case SYBUNIQUE: length = tds_convert_unique(srctype, src, srclen, desttype, cr); break; case SYBNVARCHAR: case SYBNTEXT: default: return TDS_CONVERT_NOAVAIL; break; } /* fix MONEY case */ #if !defined(WORDS_BIGENDIAN) && defined(HAVE_INT64) 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, 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 mytime; struct tds_time *t; unsigned int dt_time; TDS_INT dt_days; int i; int current_state; memset(&mytime, '\0', sizeof(struct tds_time)); mytime.tm_mday = 1; t = &mytime; in = (char *) malloc(strlen(instr) + 1); test_alloc(in); strcpy(in, instr); 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 + 300 + i) / 4 + (367 * (t->tm_mon - 1 - 12 * i)) / 12 - (3 * ((t->tm_year + 400 + i) / 100)) / 4 + t->tm_mday - 109544; free(in); /* TODO check for overflow */ if (desttype == SYBDATETIME) { cr->dt.dtdays = dt_days; dt_time = (t->tm_hour * 60 + t->tm_min) * 60 + t->tm_sec; cr->dt.dttime = dt_time * 300 + (t->tm_ms * 300 + 150) / 1000; return sizeof(TDS_DATETIME); } else { /* SYBDATETIME4 */ cr->dt4.days = dt_days; cr->dt4.minutes = t->tm_hour * 60 + t->tm_min; return sizeof(TDS_DATETIME4); } } 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; const char *pstr; int old_digits_left, digits_left, digit_found = 0; int i = 0; int j = 0; int bytes, places; unsigned char sign; /* FIXME: application can pass invalid value for precision and scale ?? */ if (cr->n.precision > 77) return TDS_CONVERT_FAIL; if (cr->n.precision == 0) cr->n.precision = 77; /* assume max precision */ if (cr->n.scale > cr->n.precision) return TDS_CONVERT_FAIL; /* skip leading blanks */ for (pstr = instr;; ++pstr) { if (pstr == pend) return TDS_CONVERT_SYNTAX; if (*pstr != ' ') break; } sign = 0; if (*pstr == '-' || *pstr == '+') { /* deal with a leading sign */ if (*pstr == '-') sign = 1; pstr++; } cr->n.array[0] = sign; /* * skip leading zeroes * Not skipping them cause numbers like "000000000000" to * appear like overflow */ for (; pstr != pend && *pstr == '0'; ++pstr) digit_found = 1; /* * 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'; places = 0; old_digits_left = 0; digits_left = cr->n.precision - cr->n.scale; for (; pstr != pend; ++pstr) { /* deal with the rest */ if (*pstr >= '0' && *pstr <= '9') { /* it's a number */ /* copy digit to destination */ if (--digits_left >= 0) *ptr++ = *pstr; digit_found = 1; } else if (*pstr == '.') { /* found a decimal point */ if (places) /* found a decimal point previously: return error */ return TDS_CONVERT_SYNTAX; old_digits_left = digits_left; digits_left = cr->n.scale; places = 1; } else if (*pstr == ' ') { for (; pstr != pend && *pstr == ' '; ++pstr) ; /* skip contiguous blanks */ if (pstr == pend) break; /* success: found only trailing blanks */ return TDS_CONVERT_SYNTAX; /* bzzt: found something after the blank(s) */ } else { /* first invalid character */ return TDS_CONVERT_SYNTAX; } } /* no digits? no number! */ if (!digit_found) return TDS_CONVERT_SYNTAX; if (!places) { old_digits_left = digits_left; digits_left = cr->n.scale; } /* too many digits, error */ if (old_digits_left < 0) return TDS_CONVERT_OVERFLOW; /* fill up decimal digits */ while (--digits_left >= 0) *ptr++ = '0'; /* * 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 * 10 + *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 (;;) { char is_zero = 1; TDS_UINT carry = 0; i = j; if (!packed_num[j]) --j; do { TDS_UINT tmp = packed_num[i]; if (tmp) is_zero = 0; /* 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 int is_numeric_dateformat(const char *t) { const char *instr; int ret = 1; 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 != '.') { ret = 0; break; } if (*instr == '/') slashes++; else if (*instr == '-') hyphens++; else if (*instr == '.') periods++; else digits++; } if (hyphens + slashes + periods != 2) ret = 0; if (hyphens == 1 || slashes == 1 || periods == 1) ret = 0; if (digits < 4 || digits > 8) ret = 0; return (ret); } /* 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 int is_dd_mon_yyyy(char *t) { char *instr; char month[4]; instr = t; if (!isdigit((unsigned char) *instr)) return (0); instr++; if (!isdigit((unsigned char) *instr)) return (0); instr++; if (*instr == '-') { instr++; strncpy(month, instr, 3); month[3] = '\0'; if (!is_monthname(month)) return (0); instr += 3; if (*instr != '-') return (0); instr++; if (!isdigit((unsigned char) *instr)) return (0); instr++; if (!isdigit((unsigned char) *instr)) return (0); instr++; if (*instr) { if (!isdigit((unsigned char) *instr)) return (0); instr++; if (!isdigit((unsigned char) *instr)) return (0); } } else { strncpy(month, instr, 3); month[3] = '\0'; if (!is_monthname(month)) return (0); instr += 3; if (!isdigit((unsigned char) *instr)) return (0); instr++; if (!isdigit((unsigned char) *instr)) return (0); instr++; if (*instr) { if (!isdigit((unsigned char) *instr)) return (0); instr++; if (!isdigit((unsigned char) *instr)) return (0); } } return (1); } static int is_ampm(const char *datestr) { int ret = 0; if (strcasecmp(datestr, "am") == 0) ret = 1; else if (strcasecmp(datestr, "pm") == 0) ret = 1; else ret = 0; return ret; } static int is_alphabetic(const char *datestr) { const char *s; int ret = 1; for (s = datestr; *s; s++) { if (!isalpha((unsigned char) *s)) ret = 0; } return (ret); } static int is_numeric(const char *datestr) { const char *s; int ret = 1; for (s = datestr; *s; s++) { if (!isdigit((unsigned char) *s)) ret = 0; } return (ret); } static int is_timeformat(const char *datestr) { const char *s; int ret = 1; for (s = datestr; *s; s++) { if (!isdigit((unsigned char) *s) && *s != ':' && *s != '.') break; } if (*s) { if (strcasecmp(s, "am") != 0 && strcasecmp(s, "pm") != 0) ret = 0; } return (ret); } 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]; char yyyy[5]; int year; tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: %s\n", datestr); strncpy(dd, datestr, 2); dd[2] = '\0'; mday = atoi(dd); if (mday > 0 && mday < 32) t->tm_mday = mday; else return 0; if (datestr[2] == '-') { strncpy(mon, &datestr[3], 3); mon[3] = '\0'; if (store_monthname(mon, t) < 0) { tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: store_monthname failed\n"); return 0; } strcpy(yyyy, &datestr[7]); year = atoi(yyyy); tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: year %d\n", year); return store_year(year, t); } else { strncpy(mon, &datestr[2], 3); mon[3] = '\0'; if (store_monthname(mon, t) < 0) { tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: store_monthname failed\n"); return 0; } strcpy(yyyy, &datestr[5]); year = atoi(yyyy); 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; int hours = 0, minutes = 0, seconds = 0, millisecs = 0; int ret = 1; int ms_len = 0; for (s = datestr; *s && strchr("apmAPM", (int) *s) == NULL; s++) { if (*s == ':' || *s == '.') { last_sep = *s; state++; } else switch (state) { case TDS_HOURS: hours = (hours * 10) + (*s - '0'); break; case TDS_MINUTES: minutes = (minutes * 10) + (*s - '0'); break; case TDS_SECONDS: seconds = (seconds * 10) + (*s - '0'); break; case TDS_FRACTIONS: millisecs = (millisecs * 10) + (*s - '0'); ms_len++; 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 > 0 && hours < 12) t->tm_hour = hours + 12; else t->tm_hour = hours; } } else { if (hours >= 0 && hours < 24) t->tm_hour = hours; else ret = 0; } if (minutes >= 0 && minutes < 60) t->tm_min = minutes; else ret = 0; if (seconds >= 0 && seconds < 60) t->tm_sec = seconds; else ret = 0; tdsdump_log(TDS_DBG_FUNC, "store_time() millisecs = %d\n", millisecs); if (millisecs) { if (millisecs >= 0 && millisecs < 1000) { if (last_sep == ':') t->tm_ms = millisecs; else { if (ms_len == 1) t->tm_ms = millisecs * 100; else if (ms_len == 2) t->tm_ms = millisecs * 10; else t->tm_ms = millisecs; } } 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_INT tds_get_null_type(int srctype) { switch (srctype) { case SYBCHAR: return SYBVARCHAR; break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: 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; 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 milliseconds * @param dr date to convert * @return length of string returned, 0 for error */ size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * dr) { struct tm tm; size_t length; char *our_format; char *pz = NULL; assert(buf); assert(format); assert(dr); assert(0 <= dr->millisecond && dr->millisecond < 1000); 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 /* one more character is required because we replace %z with 3 digits */ our_format = malloc(strlen(format) + 2); 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) { sprintf(pz, "%03d", dr->millisecond % 1000); strcat(our_format, format + (pz - our_format) + 2); #if 0 tdsdump_log(TDS_DBG_INFO1, "tds_strftime: our_format '%s', tail '%s'\n", our_format, format + (pz - our_format) + 2); #endif } 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++); return p - s; } #endif /** * 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) { typedef struct { int srctype; int desttype; int yn; } ANSWER; static const ANSWER answers[] = { # include "tds_willconvert.h" }; unsigned int i; const ANSWER *p = NULL; tdsdump_log(TDS_DBG_FUNC, "tds_willconvert(%d, %d)\n", srctype, desttype); for (i = 0; i < sizeof(answers) / sizeof(ANSWER); i++) { if (srctype == answers[i].srctype && desttype == answers[i].desttype) { tdsdump_log(TDS_DBG_FUNC, "tds_willconvert(%d, %d) returns %s\n", answers[i].srctype, answers[i].desttype, answers[i].yn? "yes":"no"); p = &answers[i]; break; } } if (!p) return 0; if (is_fixed_type(p->desttype) || !p->yn) return p->yn; /* * Return the number of bytes needed to represent the srctype as a string. * This allows an application to use "tds_willconvert(SYBINT4, SYBCHAR)" to * discover he'll need an 11-byte buffer. * * Sizes exclude null terminators but allow for a '-' sign for negative numbers. * If the srctype is also variable, there is no per-type answer; it depends * on the declared length of the input. We just return 0xFF. */ switch (p->srctype) { case SYBBIT: return 1; case SYBSINT1: case SYBUINT1: case SYBINT1: return 3; case SYBUINT2: case SYBINT2: return 6; case SYBUINT4: case SYBINT4: return 11; case SYB5INT8: case SYBUINT8: case SYBINT8: return 21; case SYBREAL: case SYBFLT8: return 11; case SYBDECIMAL: case SYBNUMERIC: return 46; case SYBDATETIME: case SYBDATETIME4: return 26; case SYBMONEY: case SYBMONEY4: return 12; /* TODO SYBBLOB has the same value */ case SYBUNIQUE: return 36; /* non-fixed types have variable data sizes, just return 0xff */ case SYBCHAR: case SYBBINARY: case SYBIMAGE: case SYBLONGBINARY: case SYBLONGCHAR: case SYBTEXT: case SYBVARBINARY: case SYBVARCHAR: case SYBNTEXT: case SYBNVARCHAR: return 0xFF; default: assert(0 == p->srctype); } return 0; #if 0 /* Other, unmentionable types */ case SYBBOUNDARY: case SYBDATE: case SYBINTERVAL: case SYBSENSITIVITY: case SYBTIME: case SYBUNITEXT: case SYBVARIANT: case SYBVOID: case SYBXML: case XSYBBINARY: case XSYBCHAR: case XSYBNCHAR: case XSYBNVARCHAR: case XSYBVARBINARY: case XSYBVARCHAR: #endif } #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_SUCCEED */ TDS_INT tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC * dr) { const TDS_DATETIME *dt; const TDS_DATETIME4 *dt4; int dt_days; unsigned int dt_time; int years, months, days, ydays, wday, hours, mins, secs, ms; int l, n, i, j; if (datetype == SYBDATETIME) { dt = (const TDS_DATETIME *) di; dt_time = dt->dttime; ms = ((dt_time % 300) * 1000 + 150) / 300; dt_time = dt_time / 300; secs = dt_time % 60; dt_time = dt_time / 60; dt_days = dt->dtdays; } else if (datetype == SYBDATETIME4) { dt4 = (const TDS_DATETIME4 *) di; secs = 0; ms = 0; dt_days = dt4->days; dt_time = dt4->minutes; } 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; 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 + 15) + 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->week = -1; dr->weekday = wday; dr->hour = hours; dr->minute = mins; dr->second = secs; dr->millisecond = ms; return TDS_SUCCEED; } /** * \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) { enum { blank = ' ' }; const char *p; int sign; unsigned int num; /* we use unsigned here for best overflow check */ p = buf; /* ignore leading spaces */ while (p != pend && *p == blank) ++p; if (p == pend) { *res = 0; return TDS_SUCCEED; } /* check for sign */ sign = 0; switch (*p) { case '-': sign = 1; /* fall thru */ case '+': /* skip spaces between sign and number */ ++p; while (p != pend && *p == blank) ++p; break; } /* a digit must be present */ if (p == pend) return TDS_CONVERT_SYNTAX; num = 0; for (; p != pend; ++p) { /* check for trailing spaces */ if (*p == blank) { while (++p != pend && *p == blank); if (p != pend) return TDS_CONVERT_SYNTAX; break; } /* must be a digit */ if (!isdigit((unsigned char) *p)) return TDS_CONVERT_SYNTAX; /* 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 + (*p - '0'); } /* check for overflow and convert unsigned to signed */ if (sign) { if (num > 2147483648u) return TDS_CONVERT_OVERFLOW; *res = 0 - num; } else { if (num >= 2147483648u) return TDS_CONVERT_OVERFLOW; *res = num; } return TDS_SUCCEED; } /** * \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) { enum { blank = ' ' }; const char *p; int sign; TDS_UINT8 num; /* we use unsigned here for best overflow check */ p = buf; /* ignore leading spaces */ while (p != pend && *p == blank) ++p; if (p == pend) { *res = 0; return TDS_SUCCEED; } /* check for sign */ sign = 0; switch (*p) { case '-': sign = 1; /* fall thru */ case '+': /* skip spaces between sign and number */ ++p; while (p != pend && *p == blank) ++p; break; } /* a digit must be present */ if (p == pend) return TDS_CONVERT_SYNTAX; num = 0; for (; p != pend; ++p) { /* check for trailing spaces */ if (*p == blank) { while (p != pend && *++p == blank); if (p != pend) return TDS_CONVERT_SYNTAX; break; } /* must be a digit */ if (!isdigit((unsigned char) *p)) return TDS_CONVERT_SYNTAX; /* add a digit to number and check for overflow */ if (num > ((((TDS_UINT8) 1) << 63) / ((TDS_UINT8) 10))) return TDS_CONVERT_OVERFLOW; num = num * 10u + (*p - '0'); } /* check for overflow and convert unsigned to signed */ if (sign) { 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 TDS_SUCCEED; } /** @} */ freetds-0.91/src/tds/numeric.c100664 001750 000144 00000033073 11506373026 0011777/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: numeric.c,v 1.47 2010/12/28 14:37:10 freddy77 Exp $"); /* * these routines use arrays of unsigned char to handle arbitrary * precision numbers. All-in-all it's probably pretty slow, but it * does work. I just heard of a GNU lib for arb. precision math, so * that might be an option in the future. */ #ifndef HAVE_INT64 static int multiply_byte(unsigned char *product, int num, unsigned char *multiplier); static int do_carry(unsigned char *product); static char *array_to_string(unsigned char *array, int scale, char *s); #endif /** * 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 }; #if ENABLE_EXTRA_CHECKS #if defined(__GNUC__) && __GNUC__ >= 2 #define COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] __attribute__ ((unused)) #else #define COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] #endif COMPILE_CHECK(maxprecision, MAXPRECISION < TDS_VECTOR_SIZE(tds_numeric_bytes_per_prec) ); #endif /* * money is a special case of numeric really...that why its here */ char * tds_money_to_string(const TDS_MONEY * money, char *s) { #ifdef HAVE_INT64 int frac; TDS_INT8 mymoney; TDS_UINT8 n; char *p; /* sometimes money it's only 4-byte aligned so always compute 64-bit */ /* FIXME align money/double/bigint in row to 64-bit */ mymoney = (((TDS_INT8)(((TDS_INT*)money)[0])) << 32) | ((TDS_UINT*) money)[1]; 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; #else unsigned char multiplier[MAXPRECISION], temp[MAXPRECISION]; unsigned char product[MAXPRECISION]; const unsigned char *number; unsigned char tmpnumber[8]; int i, num_bytes = 8; int pos, neg = 0; memset(multiplier, 0, MAXPRECISION); memset(product, 0, MAXPRECISION); multiplier[0] = 1; number = (const unsigned char *) money; #ifdef WORDS_BIGENDIAN /* big endian makes things easy */ memcpy(tmpnumber, number, 8); #else /* * money is two 32 bit ints and thus is out of order on * little endian machines. Proof of the superiority of * big endian design. ;) */ for (i = 0; i < 4; i++) tmpnumber[3 - i] = number[i]; for (i = 4; i < 8; i++) tmpnumber[7 - i + 4] = number[i]; #endif if (tmpnumber[0] & 0x80) { /* negative number -- preform two's complement */ neg = 1; for (i = 0; i < 8; i++) { tmpnumber[i] = ~tmpnumber[i]; } for (i = 7; i >= 0; i--) { tmpnumber[i] += 1; if (tmpnumber[i] != 0) break; } } for (pos = num_bytes - 1; pos >= 0; pos--) { multiply_byte(product, tmpnumber[pos], multiplier); memcpy(temp, multiplier, MAXPRECISION); memset(multiplier, 0, MAXPRECISION); multiply_byte(multiplier, 256, temp); } if (neg) { s[0] = '-'; array_to_string(product, 4, &s[1]); } else { array_to_string(product, 4, s); } /* round to two decimal places */ if (s) { sprintf(s, "%.02f", atof(s)); } return s; #endif } #ifndef HAVE_INT64 static int multiply_byte(unsigned char *product, int num, unsigned char *multiplier) { unsigned char number[3]; int i, top, j, start; number[0] = num % 10; number[1] = (num / 10) % 10; number[2] = (num / 100) % 10; for (top = MAXPRECISION - 1; top >= 0 && !multiplier[top]; top--); start = 0; for (i = 0; i <= top; i++) { for (j = 0; j < 3; j++) { product[j + start] += multiplier[i] * number[j]; } do_carry(product); start++; } return 0; } static int do_carry(unsigned char *product) { int j; for (j = 0; j < MAXPRECISION; j++) { if (product[j] > 9) { product[j + 1] += product[j] / 10; product[j] = product[j] % 10; } } return 0; } static char * array_to_string(unsigned char *array, int scale, char *s) { int top, i, j; for (top = MAXPRECISION - 1; top >= 0 && top > scale && !array[top]; top--); if (top == -1) { s[0] = '0'; s[1] = '\0'; return s; } j = 0; for (i = top; i >= 0; i--) { if (top + 1 - j == scale) s[j++] = '.'; s[j++] = array[i] + '0'; } s[j] = '\0'; return s; } #endif 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 TDS_SUCCEED; } } 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 TDS_SUCCEED; } #ifndef HAVE_INT64 #define TDS_WORD TDS_USMALLINT #define TDS_DWORD TDS_UINT #define TDS_WORD_DDIGIT 4 #else #define TDS_WORD TDS_UINT #define TDS_DWORD TDS_UINT8 #define TDS_WORD_DDIGIT 9 #endif /* 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, #ifdef HAVE_INT64 100000, 1000000, 10000000, 100000000, 1000000000 #endif }; 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 > 77 || numeric->scale > numeric->precision) return TDS_CONVERT_FAIL; if (new_prec < 1 || new_prec > 77 || 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 */ #ifndef HAVE_INT64 packet[i] = TDS_GET_UA2BE(&numeric->array[bytes-1]); #else packet[i] = TDS_GET_UA4BE(&numeric->array[bytes-3]); #endif ++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__) && defined(HAVE_INT64) --i; __asm__ __volatile__ ("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] = 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) { #ifndef HAVE_INT64 TDS_PUT_UA2BE(&numeric->array[bytes-1], packet[i]); #else TDS_PUT_UA4BE(&numeric->array[bytes-3], packet[i]); #endif } if (bytes) { TDS_WORD remainder = packet[i]; do { numeric->array[bytes] = (TDS_UCHAR) remainder; remainder >>= 8; } while (--bytes); } return sizeof(TDS_NUMERIC); } freetds-0.91/src/tds/config.c100644 001750 000144 00000105021 11623070341 0011563/* 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. */ #if HAVE_CONFIG_H #include #endif #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 "tds.h" #include "tds_configs.h" #include "tdsstring.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: config.c,v 1.162.2.3 2011/08/12 16:29:36 freddy77 Exp $"); static void tds_config_login(TDSCONNECTION * connection, TDSLOGIN * login); static void tds_config_env_tdsdump(TDSCONNECTION * connection); static void tds_config_env_tdsver(TDSCONNECTION * connection); static void tds_config_env_tdsport(TDSCONNECTION * connection); static void tds_config_env_tdshost(TDSCONNECTION * connection); static int tds_read_conf_sections(FILE * in, const char *server, TDSCONNECTION * connection); static int tds_read_interfaces(const char *server, TDSCONNECTION * connection); static int parse_server_name_for_port(TDSCONNECTION * connection, TDSLOGIN * login); static int tds_lookup_port(const char *portname); static void tds_config_encryption(const char * value, TDSCONNECTION * connection); 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 int tds_default_port(int major, int minor) { switch(major) { case 4: if (minor == 6) break; case 5: return 4000; } return 1433; } /** * \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. */ TDSCONNECTION * tds_read_config_info(TDSSOCKET * tds, TDSLOGIN * login, TDSLOCALE * locale) { TDSCONNECTION *connection; char *s; char *path; pid_t pid; int opened = 0, found; /* allocate a new structure with hard coded and build-time defaults */ connection = tds_alloc_connection(locale); if (!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)) { char ip_addr[256]; 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_lookup_host(tds_dstr_cstr(&connection->server_name), ip_addr) == TDS_SUCCEED) { tds_dstr_dup(&connection->server_host_name, &connection->server_name); tds_dstr_copy(&connection->ip_addr, ip_addr); 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 (tds_dstr_isempty(&connection->ip_addr)) tdserror(tds->tds_ctx, tds, TDSEINTF, 0); } } /* Override config file settings with environment variables. */ tds_fix_connection(connection); /* And finally apply anything from the login structure */ tds_config_login(connection, login); if (opened) { 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)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "ip_addr", tds_dstr_cstr(&connection->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 = %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", "broken_dates", connection->broken_dates); 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_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_connection(TDSCONNECTION * connection) { /* Now check the environment variables */ tds_config_env_tdsver(connection); tds_config_env_tdsdump(connection); tds_config_env_tdsport(connection); tds_config_env_tdshost(connection); } static int tds_try_conf_file(const char *path, const char *how, const char *server, TDSCONNECTION * connection) { 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, connection); 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 connection where to store configuration * @param server section of file configuration that hold * configuration for a server */ int tds_read_conf_file(TDSCONNECTION * connection, 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, connection); } /* 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, connection); } 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, connection); 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, connection); 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, connection); } return found; } static int tds_read_conf_sections(FILE * in, const char *server, TDSCONNECTION * connection) { DSTR default_instance; int default_port; int found; tds_read_conf_section(in, "global", tds_parse_conf_section, connection); if (!server[0]) return 0; rewind(in); tds_dstr_init(&default_instance); tds_dstr_dup(&default_instance, &connection->instance_name); default_port = connection->port; found = tds_read_conf_section(in, server, tds_parse_conf_section, connection); /* * 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(&connection->instance_name) && connection->port && !(!tds_dstr_isempty(&default_instance) || default_port)) { tdsdump_log(TDS_DBG_ERROR, "error: cannot specify both port %d and instance %s.\n", connection->port, tds_dstr_cstr(&connection->instance_name)); /* tdserror(tds->tds_ctx, 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_config_boolean(const char *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; } tdsdump_log(TDS_DBG_INFO1, "UNRECOGNIZED boolean value: '%s'. Treating as 'no'.\n", value); return 0; } static void tds_config_encryption(const char * value, TDSCONNECTION * connection) { 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_INFO1, "UNRECOGNIZED option value '%s'...ignoring.\n", value); connection->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++; } option[i] = '\0'; /* skip if empty option */ if (!i) continue; /* skip the = */ if (*s) s++; /* 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) { TDSCONNECTION *connection = (TDSCONNECTION *) param; tdsdump_log(TDS_DBG_INFO1, "\t%s = '%s'\n", option, value); if (!strcmp(option, TDS_STR_VERSION)) { tds_config_verstr(value, connection); } else if (!strcmp(option, TDS_STR_BLKSZ)) { int val = atoi(value); if (val >= 512 && val < 65536) connection->block_size = val; } else if (!strcmp(option, TDS_STR_SWAPDT)) { connection->broken_dates = tds_config_boolean(value); } else if (!strcmp(option, TDS_GSSAPI_DELEGATION)) { /* gssapi flag addition */ connection->gssapi_use_delegation = tds_config_boolean(value); } else if (!strcmp(option, TDS_STR_DUMPFILE)) { tds_dstr_copy(&connection->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) connection->debug_flags = flags; } else if (!strcmp(option, TDS_STR_TIMEOUT) || !strcmp(option, TDS_STR_QUERY_TIMEOUT)) { if (atoi(value)) connection->query_timeout = atoi(value); } else if (!strcmp(option, TDS_STR_CONNTIMEOUT)) { if (atoi(value)) connection->connect_timeout = atoi(value); } else if (!strcmp(option, TDS_STR_HOST)) { char tmp[256]; tdsdump_log(TDS_DBG_INFO1, "Found host entry %s.\n", value); tds_dstr_copy(&connection->server_host_name, value); tds_lookup_host(value, tmp); tds_dstr_copy(&connection->ip_addr, tmp); tdsdump_log(TDS_DBG_INFO1, "IP addr is %s.\n", tds_dstr_cstr(&connection->ip_addr)); } else if (!strcmp(option, TDS_STR_PORT)) { if (atoi(value)) connection->port = atoi(value); } else if (!strcmp(option, TDS_STR_EMUL_LE)) { connection->emul_little_endian = tds_config_boolean(value); } else if (!strcmp(option, TDS_STR_TEXTSZ)) { if (atoi(value)) connection->text_size = atoi(value); } else if (!strcmp(option, TDS_STR_CHARSET)) { tds_dstr_copy(&connection->server_charset, value); tdsdump_log(TDS_DBG_INFO1, "%s is %s.\n", option, tds_dstr_cstr(&connection->server_charset)); } else if (!strcmp(option, TDS_STR_CLCHARSET)) { tds_dstr_copy(&connection->client_charset, value); tdsdump_log(TDS_DBG_INFO1, "tds_parse_conf_section: %s is %s.\n", option, tds_dstr_cstr(&connection->client_charset)); } else if (!strcmp(option, TDS_STR_LANGUAGE)) { tds_dstr_copy(&connection->language, value); } else if (!strcmp(option, TDS_STR_APPENDMODE)) { tds_g_append_mode = tds_config_boolean(value); } else if (!strcmp(option, TDS_STR_INSTANCE)) { tds_dstr_copy(&connection->instance_name, value); } else if (!strcmp(option, TDS_STR_ENCRYPTION)) { tds_config_encryption(value, connection); } else if (!strcmp(option, TDS_STR_ASA_DATABASE)) { tds_dstr_copy(&connection->server_name, value); } else if (!strcmp(option, TDS_STR_USENTLMV2)) { connection->use_ntlmv2 = tds_config_boolean(value); } else if (!strcmp(option, TDS_STR_REALM)) { tds_dstr_copy(&connection->server_realm_name, value); } else { tdsdump_log(TDS_DBG_INFO1, "UNRECOGNIZED option '%s' ... ignoring.\n", option); } } static void tds_config_login(TDSCONNECTION * connection, TDSLOGIN * login) { if (!tds_dstr_isempty(&login->server_name)) { if (1 || tds_dstr_isempty(&connection->server_name)) tds_dstr_dup(&connection->server_name, &login->server_name); } if (login->tds_version) connection->tds_version = login->tds_version; if (!tds_dstr_isempty(&login->language)) { tds_dstr_dup(&connection->language, &login->language); } if (!tds_dstr_isempty(&login->server_charset)) { tds_dstr_dup(&connection->server_charset, &login->server_charset); } if (!tds_dstr_isempty(&login->client_charset)) { 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 (!tds_dstr_isempty(&login->database)) { 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 (!tds_dstr_isempty(&login->client_host_name)) { tds_dstr_dup(&connection->client_host_name, &login->client_host_name); } if (!tds_dstr_isempty(&login->app_name)) { tds_dstr_dup(&connection->app_name, &login->app_name); } if (!tds_dstr_isempty(&login->user_name)) { tds_dstr_dup(&connection->user_name, &login->user_name); } if (!tds_dstr_isempty(&login->password)) { /* for security reason clear memory */ tds_dstr_zero(&connection->password); tds_dstr_dup(&connection->password, &login->password); } if (!tds_dstr_isempty(&login->library)) { 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 = 1; } 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; /* copy other info not present in configuration file */ memcpy(connection->capabilities, login->capabilities, TDS_MAX_CAPABILITY); } static void tds_config_env_tdsdump(TDSCONNECTION * connection) { char *s; char *path; pid_t pid = 0; if ((s = getenv("TDSDUMP"))) { if (!strlen(s)) { pid = getpid(); if (asprintf(&path, pid_logpath, pid) >= 0) tds_dstr_set(&connection->dump_file, path); } else { tds_dstr_copy(&connection->dump_file, s); } tdsdump_log(TDS_DBG_INFO1, "Setting 'dump_file' to '%s' from $TDSDUMP.\n", tds_dstr_cstr(&connection->dump_file)); } } static void tds_config_env_tdsport(TDSCONNECTION * connection) { char *s; if ((s = getenv("TDSPORT"))) { connection->port = tds_lookup_port(s); tds_dstr_copy(&connection->instance_name, ""); tdsdump_log(TDS_DBG_INFO1, "Setting 'port' to %s from $TDSPORT.\n", s); } return; } static void tds_config_env_tdsver(TDSCONNECTION * connection) { char *tdsver; if ((tdsver = getenv("TDSVER"))) { tds_config_verstr(tdsver, connection); tdsdump_log(TDS_DBG_INFO1, "Setting 'tdsver' to %s from $TDSVER.\n", tdsver); } return; } /* TDSHOST env var, pkleef@openlinksw.com 01/21/02 */ static void tds_config_env_tdshost(TDSCONNECTION * connection) { char *tdshost; char tmp[256]; if ((tdshost = getenv("TDSHOST"))) { tds_dstr_copy(&connection->server_host_name, tdshost); tds_lookup_host(tdshost, tmp); tds_dstr_copy(&connection->ip_addr, tmp); tdsdump_log(TDS_DBG_INFO1, "Setting 'ip_addr' to %s (%s) from $TDSHOST.\n", tmp, tdshost); } } /** * Set TDS version from given string * @param tdsver tds string version * @param connection where to store information * @return as encoded hex value: high nybble major, low nybble minor. */ TDS_USMALLINT tds_config_verstr(const char *tdsver, TDSCONNECTION * connection) { TDS_USMALLINT version; if (!strcmp(tdsver, "42") || !strcmp(tdsver, "4.2")) version = 0x402; else if (!strcmp(tdsver, "46") || !strcmp(tdsver, "4.6")) version = 0x406; else if (!strcmp(tdsver, "50") || !strcmp(tdsver, "5.0")) version = 0x500; else if (!strcmp(tdsver, "70") || !strcmp(tdsver, "7.0")) version = 0x700; else if (!strcmp(tdsver, "80") || !strcmp(tdsver, "8.0") || !strcmp(tdsver, "7.1")) version = 0x701; else if (!strcmp(tdsver, "7.2")) version = 0x702; else if (!strcmp(tdsver, "0.0")) version = 0; else return 0; if (connection) connection->tds_version = version; tdsdump_log(TDS_DBG_INFO1, "Setting tds version to %s (0x%0x) from $TDSVER.\n", tdsver, version); return version; } /** * Set the full name of interface file * @param interf file name */ int 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_SUCCEED; } /* Set to new value */ if ((interf_file = strdup(interf)) == NULL) { return TDS_FAIL; } return TDS_SUCCEED; } /** * 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 */ int tds_lookup_host(const char *servername, /* (I) name of the server */ char *ip /* (O) dotted-decimal ip address of server */ ) { struct hostent *host = NULL; unsigned int ip_addr = 0; /* Storage for reentrant getaddrby* calls */ struct hostent result; char buffer[4096]; int h_errnop; /* * Call gethostbyname(3) only if servername is not an ip address. * This call takes a while and is useless for an ip address. * mlilback 3/2/02 */ ip_addr = inet_addr(servername); if (ip_addr != INADDR_NONE) { tds_strlcpy(ip, servername, 17); return TDS_SUCCEED; } host = tds_gethostbyname_r(servername, &result, buffer, sizeof(buffer), &h_errnop); ip[0] = '\0'; if (host) { struct in_addr *ptr = (struct in_addr *) host->h_addr; tds_inet_ntoa_r(*ptr, ip, 17); return TDS_SUCCEED; } 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 = 0; if (portname) { num = atoi(portname); if (!num) { char buffer[4096]; struct servent serv_result; struct servent *service = tds_getservbyname_r(portname, "tcp", &serv_result, buffer, sizeof(buffer)); if (service) num = ntohs(service->s_port); } } 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 'connection' * * \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(TDSCONNECTION * connection, 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 = (char *) malloc(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) { tds_dstr_copy(&connection->server_host_name, tmp_ip); tds_lookup_host(tmp_ip, line); tdsdump_log(TDS_DBG_INFO1, "Resolved IP as '%s'.\n", line); tds_dstr_copy(&connection->ip_addr, line); if (tmp_port[0]) connection->port = tds_lookup_port(tmp_port); if (tmp_ver[0]) tds_config_verstr(tmp_ver, connection); } 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, TDSCONNECTION * connection) { 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(connection, "", 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(connection, "", 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(connection, 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) { char ip_addr[255]; int ip_port; const char *env_port; /* * Make a guess about the port number */ if (connection->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 = connection->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 */ tds_lookup_host(server, ip_addr); if (ip_addr[0]) { tds_dstr_copy(&connection->server_host_name, server); tds_dstr_copy(&connection->ip_addr, ip_addr); } if (ip_port) connection->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(TDSCONNECTION * connection, TDSLOGIN * login) { const char *pSep; const char *server; /* seek the ':' in login server_name */ server = tds_dstr_cstr(&login->server_name); 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_copy(&connection->instance_name, ""); } else { /* handle instance name */ pSep = strrchr(server, '\\'); if (!pSep || pSep == server) return 0; tds_dstr_copy(&connection->instance_name, pSep + 1); 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 TDS46 , "4.6" # elif TDS50 , "5.0" # elif TDS70 , "7.0" # elif TDS71 , "7.1" # elif TDS72 , "7.2" # else , "4.2" # endif # ifdef IODBC , 1 # else , 0 # endif # ifdef UNIXODBC , 1 # else , 0 # endif }; assert(settings.tdsver); return &settings; } /** @} */ freetds-0.91/src/tds/query.c100644 001750 000144 00000266614 11623070342 0011504/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "tds.h" #include "tdsiconv.h" #include "tdsconvert.h" #include "tds_checks.h" #include "replacements.h" #ifdef DMALLOC #include #endif #include TDS_RCSID(var, "$Id: query.c,v 1.247.2.2 2011/06/06 12:39:24 freddy77 Exp $"); 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 int tds_put_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int flags); static int 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 size_t tds_fix_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol); static int tds_put_param_as_string(TDSSOCKET * tds, TDSPARAMINFO * params, int n); static int tds_send_emulated_execute(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params); static const char *tds_skip_comment(const char *s); 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 #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; } #define TDS_PUT_N_AS_UCS2(tds, s) do { \ char buffer[sizeof(s)*2-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 */ static const char * tds_convert_string(TDSSOCKET * tds, const 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) : 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->server_charset.max_bytes_per_char / char_conv->client_charset.min_bytes_per_char + 1; buf = (char *) malloc(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 static void tds_convert_string_free(const char *original, const char *converted) { if (original != converted) free((char *) converted); } #else #define tds_convert_string_free(original, converted) \ do { if (original != converted) free((char*) converted); } while(0) #endif static int tds_query_flush_packet(TDSSOCKET *tds) { /* TODO depend on result ?? */ tds_set_state(tds, TDS_PENDING); return tds_flush_packet(tds); } /** * 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. * \param tds state information for the socket and the TDS protocol * \param query language query to submit * \return TDS_FAIL or TDS_SUCCEED */ int tds_submit_query(TDSSOCKET * tds, const char *query) { return tds_submit_query_params(tds, query, NULL); } 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 *out = (char *) malloc(size); if (!out) return NULL; pos = 0; s = query; for (i = 0;; ++i) { e = tds_next_placeholder(s); len = e ? e - s : strlen(s); if (pos + len + 12 >= size) { char *p; size = pos + len + 30; p = realloc(out, size); if (!p) { free(out); return NULL; } out = p; } memcpy(out + pos, s, len); pos += len; if (!e) break; pos += sprintf(out + pos, "@P%d", i + 1); if (i >= params->num_cols) { free(out); return NULL; } sprintf(params->columns[i]->column_name, "@P%d", i + 1); params->columns[i]->column_namelen = (TDS_SMALLINT)strlen(params->columns[i]->column_name); s = e + 1; } out[pos] = 0; *query_len = pos; return out; } static const TDS_UCHAR tds9_query_start[] = { /* total length */ 0x16, 0, 0, 0, /* length */ 0x12, 0, 0, 0, /* type */ 0x02, 0, /* transaction */ 0, 0, 0, 0, 0, 0, 0, 0, /* request count */ 1, 0, 0, 0 }; #define START_QUERY \ do { \ if (IS_TDS72_PLUS(tds)) \ tds_start_query(tds); \ } while(0) static void tds_start_query(TDSSOCKET *tds) { tds_put_n(tds, tds9_query_start, 10); tds_put_n(tds, tds->tds9_transaction, 8); tds_put_n(tds, tds9_query_start + 10 + 8, 4); } /** * 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. * \param tds state information for the socket and the TDS protocol * \param query language query to submit * \param params parameters of query * \return TDS_FAIL or TDS_SUCCEED */ int tds_submit_query_params(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params) { 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; query_len = strlen(query); if (IS_TDS50(tds)) { 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, params->columns[0]->column_name[0] ? TDS_PUT_DATA_USE_NAME : 0); } free(new_query); } else if (!IS_TDS7_PLUS(tds) || !params || !params->num_cols) { tds->out_flag = TDS_QUERY; START_QUERY; 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->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); if (!param_definition) { tds_convert_string_free(query, converted_query); tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } } 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_set_state(tds, TDS_IDLE); return TDS_FAIL; } } tds->out_flag = TDS_RPC; START_QUERY; /* procedure name */ if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_EXECUTESQL); } else { tds_put_smallint(tds, 13); 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)) tds_put_n(tds, tds->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, (int)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); /* FIXME handle error */ tds_put_data(tds, param); } tds->internal_sp_called = TDS_SP_EXECUTESQL; } return tds_query_flush_packet(tds); } int tds_submit_queryf(TDSSOCKET * tds, const char *queryf, ...) { va_list ap; char *query = NULL; int 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; } static 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 (should be '," or [) * @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 */ 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; } } 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; } 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; } 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; } 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)") * \param tds state information for the socket and the TDS protocol * \param curcol column * \param out buffer to hold declaration * \return TDS_FAIL or TDS_SUCCEED */ static int 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) ? 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 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 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_SUCCEED; break; case SYBUNIQUE: if (IS_TDS7_PLUS(tds)) fmt = "UNIQUEIDENTIFIER"; break; case SYBNTEXT: if (IS_TDS7_PLUS(tds)) fmt = "NTEXT"; break; case SYBNVARCHAR: case XSYBNVARCHAR: if (curcol->column_varint_size == 8) { fmt = "NVARCHAR(MAX)"; } else if (IS_TDS7_PLUS(tds)) { fmt = "NVARCHAR(%u)"; max_len = 4000; size /= 2u; } break; case XSYBNCHAR: if (IS_TDS7_PLUS(tds)) { fmt = "NCHAR(%u)"; max_len = 4000; size /= 2u; } break; case SYBVARIANT: if (IS_TDS7_PLUS(tds)) fmt = "SQL_VARIANT"; break; /* nullable types should not occur here... */ case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: case SYBBITN: case SYBINTN: assert(0); /* TODO... */ case SYBVOID: case SYBSINT1: case SYBUINT2: case SYBUINT4: case SYBUINT8: 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_SUCCEED; } out[0] = 0; return TDS_FAIL; } /** * Return string with parameters definition, useful for TDS7+ * \param tds state information for the socket and the TDS protocol * \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, *p; char declaration[40]; int i, count; assert(IS_TDS7_PLUS(tds)); 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 = (char *) malloc(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 * 40u)) > size) { p = (char *) realloc(param_str, size += 512u); if (!p) goto Cleanup; param_str = p; } /* get this parameter declaration */ sprintf(declaration, "@P%d ", i+1); if (params && i < params->num_cols) { if (tds_get_column_declaration(tds, params->columns[i], declaration + strlen(declaration)) == TDS_FAIL) 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 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 *p; 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)); assert(out_len); CHECK_TDS_EXTRA(tds); if (params) CHECK_PARAMINFO_EXTRA(params); param_str = (char *) malloc(512); if (!param_str) return NULL; /* try to detect missing names */ if (params->num_cols) { ids = (struct tds_ids *) calloc(params->num_cols, sizeof(struct tds_ids)); if (!ids) goto Cleanup; if (!params->columns[0]->column_name[0]) { 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 * params->columns[i]->column_namelen; while ((l + (2u * 26u) + il) > size) { p = (char *) realloc(param_str, size += 512); if (!p) goto Cleanup; param_str = p; } /* this part of buffer can be not-ascii compatible, use all ucs2... */ if (ids[i].len) { memcpy(param_str + l, ids[i].p, ids[i].len); l += ids[i].len; } else { ib = params->columns[i]->column_name; il = params->columns[i]->column_namelen; ob = param_str + l; ol = size - l; memset(&tds->char_convs[iso2server_metadata]->suppress, 0, sizeof(tds->char_convs[iso2server_metadata]->suppress)); if (tds_iconv(tds, tds->char_convs[iso2server_metadata], 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); *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)); /* 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)) tds_put_n(tds, tds->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; } } 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)) tds_put_n(tds, tds->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_SUCCEED */ /* TODO parse all results ?? */ int tds_submit_prepare(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params) { int id_len, query_len; int rc; TDSDYNAMIC *dyn; CHECK_TDS_EXTRA(tds); if (params) CHECK_PARAMINFO_EXTRA(params); if (!query) return TDS_FAIL; /* allocate a structure for this thing */ dyn = tds_alloc_dynamic(tds, id); if (!dyn) return TDS_FAIL; /* TDS5 sometimes cannot accept prepare so we need to store query */ if (!IS_TDS7_PLUS(tds)) { dyn->query = strdup(query); if (!dyn->query) { tds_free_dynamic(tds, dyn); return TDS_FAIL; } } tds->cur_dyn = dyn; if (dyn_out) *dyn_out = dyn; if (!IS_TDS50(tds) && !IS_TDS7_PLUS(tds)) { dyn->emulated = 1; return TDS_SUCCEED; } if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) goto failure_nostate; query_len = (int)strlen(query); if (IS_TDS7_PLUS(tds)) { 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->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->out_flag = TDS_RPC; START_QUERY; /* procedure name */ if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_PREPARE); } else { tds_put_smallint(tds, 10); 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->internal_sp_called = TDS_SP_PREPARE; } else { tds->out_flag = TDS_NORMAL; id_len = (int)strlen(dyn->id); tds_put_byte(tds, TDS5_DYNAMIC_TOKEN); tds_put_smallint(tds, query_len + id_len * 2 + 21); tds_put_byte(tds, 0x01); 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 ? */ 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); tds_put_n(tds, query, query_len); } rc = tds_query_flush_packet(tds); if (rc != TDS_FAIL) return rc; failure: /* TODO correct if writing fail ?? */ tds_set_state(tds, TDS_IDLE); failure_nostate: tds->cur_dyn = NULL; tds_free_dynamic(tds, dyn); if (dyn_out) *dyn_out = NULL; return TDS_FAIL; } /** * 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_SUCCEED */ int tds_submit_execdirect(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params) { 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)) { 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; converted_query = tds_convert_string(tds, tds->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; } tds->out_flag = TDS_RPC; START_QUERY; /* procedure name */ if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_EXECUTESQL); } else { tds_put_smallint(tds, 13); 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++) { param = params->columns[i]; /* TODO check error */ tds_put_data_info(tds, param, 0); /* FIXME handle error */ tds_put_data(tds, param); } tds->internal_sp_called = TDS_SP_EXECUTESQL; return tds_query_flush_packet(tds); } /* allocate a structure for this thing */ dyn = tds_alloc_dynamic(tds, NULL); if (!dyn) return TDS_FAIL; /* check is 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) || params) { int ret = TDS_SUCCEED; dyn->emulated = 1; dyn->params = params; dyn->query = strdup(query); if (!dyn->query) ret = TDS_FAIL; if (ret != TDS_FAIL) if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) ret = TDS_FAIL; if (ret != TDS_FAIL) { ret = tds_send_emulated_execute(tds, dyn->query, dyn->params); if (ret == TDS_SUCCEED) ret = tds_query_flush_packet(tds); } /* do not free our parameters */ dyn->params = NULL; tds_free_dynamic(tds, dyn); return ret; } tds->cur_dyn = dyn; if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) 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, 0x08); 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); } /** * tds8_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_SUCCEED */ int tds8_submit_prepexec(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params) { int query_len; int rc; 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 || !IS_TDS7_PLUS(tds)) return TDS_FAIL; /* allocate a structure for this thing */ dyn = tds_alloc_dynamic(tds, id); if (!dyn) return TDS_FAIL; tds->cur_dyn = dyn; if (dyn_out) *dyn_out = dyn; if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) goto failure_nostate; query_len = (int)strlen(query); converted_query = tds_convert_string(tds, tds->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->out_flag = TDS_RPC; START_QUERY; /* procedure name */ if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_PREPEXEC); } else { tds_put_smallint(tds, 10); 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); /* FIXME handle error */ tds_put_data(tds, param); } } tds->internal_sp_called = TDS_SP_PREPEXEC; rc = tds_query_flush_packet(tds); if (rc != TDS_FAIL) return rc; failure: /* TODO correct if writing fail ?? */ tds_set_state(tds, TDS_IDLE); failure_nostate: tds->cur_dyn = NULL; tds_free_dynamic(tds, dyn); if (dyn_out) *dyn_out = NULL; return TDS_FAIL; } /** * Get column size for wire */ static 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) { default: case 0: return size; case 1: size = MAX(MIN(size, 255), 1); break; case 2: 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 = MAX(MIN(size, 0x7ffffffeu), 2u); else size = MAX(MIN(size, 0x7fffffffu), 1u); break; } /* return curcol->on_server.column_size = size; */ 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_SUCCEED or TDS_FAIL */ static int 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 = curcol->column_namelen; tdsdump_log(TDS_DBG_ERROR, "tds_put_data_info putting param_name \n"); if (IS_TDS7_PLUS(tds)) { size_t converted_param_len; const char *converted_param; /* TODO use a fixed buffer to avoid error ? */ converted_param = tds_convert_string(tds, tds->char_convs[client2ucs2], 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(curcol->column_name, converted_param); } else { /* TODO ICONV convert */ tds_put_byte(tds, len); /* param name len */ tds_put_n(tds, 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"); tds_put_byte(tds, curcol->column_output); /* status (input) */ if (!IS_TDS7_PLUS(tds)) tds_put_int(tds, curcol->column_usertype); /* usertype */ /* FIXME: column_type is wider than one byte. Do something sensible, not just lop off the high byte. */ tds_put_byte(tds, curcol->on_server.column_type); if (is_numeric_type(curcol->on_server.column_type)) { #if 1 tds_put_byte(tds, tds_numeric_bytes_per_prec[curcol->column_prec]); tds_put_byte(tds, curcol->column_prec); tds_put_byte(tds, curcol->column_scale); #else TDS_NUMERIC *num = (TDS_NUMERIC *) curcol->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 } else { size_t size = tds_fix_column_size(tds, curcol); switch (curcol->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; } } /* TDS8 output collate information */ if (IS_TDS71_PLUS(tds) && is_collate_type(curcol->on_server.column_type)) tds_put_n(tds, tds->collation, 5); /* TODO needed in TDS4.2 ?? now is called only is TDS >= 5 */ if (!IS_TDS7_PLUS(tds)) { tdsdump_log(TDS_DBG_ERROR, "HERE! \n"); tds_put_byte(tds, 0x00); /* locale info length */ } return TDS_SUCCEED; } /** * 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 TDS_SUCCEED or TDS_FAIL */ 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)) 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 += curcol->column_namelen; if (is_numeric_type(curcol->on_server.column_type)) len += 2; if (curcol->column_varint_size == 5) return len + 4; return len + curcol->column_varint_size; } /** * 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_SUCCEED */ static int tds_put_data(TDSSOCKET * tds, TDSCOLUMN * curcol) { 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_put_data: colsize = %d\n", (int) curcol->column_cur_size); if (curcol->column_cur_size < 0) { tdsdump_log(TDS_DBG_INFO1, "tds_put_data: null param\n"); switch (curcol->column_varint_size) { case 5: tds_put_int(tds, 0); break; case 4: 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_SUCCEED; } 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 (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)) { tdsdump_log(TDS_DBG_INFO1, "tds_put_data: not null param varint_size = %d\n", curcol->column_varint_size); switch (curcol->column_varint_size) { case 8: tds_put_int8(tds, colsize); tds_put_int(tds, colsize); break; case 4: /* It's a BLOB... */ colsize = MIN(colsize, size); /* mssql require only size */ tds_put_int(tds, colsize); break; case 2: colsize = MIN(colsize, size); tds_put_smallint(tds, colsize); break; case 1: colsize = MIN(colsize, size); if (is_numeric_type(curcol->on_server.column_type)) colsize = tds_numeric_bytes_per_prec[((TDS_NUMERIC *) src)->precision]; 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 (is_numeric_type(curcol->on_server.column_type)) { TDS_NUMERIC buf; memcpy(&buf, src, sizeof(buf)); tdsdump_log(TDS_DBG_INFO1, "swapping numeric data...\n"); tds_swap_numeric(&buf); tds_put_n(tds, buf.array, colsize); } else if (blob) { tds_put_n(tds, s, colsize); } else { #ifdef WORDS_BIGENDIAN unsigned char buf[64]; if (tds->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 (is_numeric_type(curcol->column_type)) colsize = tds_numeric_bytes_per_prec[((TDS_NUMERIC *) src)->precision]; if (!colsize) { tds_put_byte(tds, 1); if (is_char_type(curcol->column_type)) tds_put_byte(tds, ' '); else tds_put_byte(tds, 0); return TDS_SUCCEED; } 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 (is_numeric_type(curcol->column_type)) { TDS_NUMERIC *num = (TDS_NUMERIC *) src; tds_put_n(tds, num->array, colsize); } else if (blob) { tds_put_n(tds, s, colsize); } else { #ifdef WORDS_BIGENDIAN unsigned char buf[64]; if (tds->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) tds_convert_string_free((char*)src, s); return TDS_SUCCEED; } static void tds7_send_execute(TDSSOCKET * tds, TDSDYNAMIC * dyn) { TDSCOLUMN *param; TDSPARAMINFO *info; int i; /* procedure name */ tds_put_smallint(tds, 10); /* 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->internal_sp_called = TDS_SP_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. */ int 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds->cur_dyn = dyn; if (IS_TDS7_PLUS(tds)) { /* check proper id */ if (dyn->num_id == 0) { tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } /* RPC on sp_execute */ tds->out_flag = TDS_RPC; START_QUERY; tds7_send_execute(tds, dyn); return tds_query_flush_packet(tds); } if (dyn->emulated) { if (tds_send_emulated_execute(tds, dyn->query, dyn->params) != TDS_SUCCEED) return TDS_FAIL; 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); } static void tds_put_params(TDSSOCKET * tds, TDSPARAMINFO * info, int flags) { int i, len; CHECK_TDS_EXTRA(tds); CHECK_PARAMINFO_EXTRA(info); /* column descriptions */ tds_put_byte(tds, 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); 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]); } } int tds_needs_unprepare(TDSSOCKET * tds, TDSDYNAMIC * dyn) { CHECK_TDS_EXTRA(tds); CHECK_DYNAMIC_EXTRA(dyn); // check if statement is prepared if (IS_TDS7_PLUS(tds) && !dyn->num_id) return 0; if (dyn->emulated) return 0; return 1; } /** * 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_SUCCEED or TDS_FAIL */ int 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds->cur_dyn = dyn; if (IS_TDS7_PLUS(tds)) { /* RPC on sp_execute */ tds->out_flag = TDS_RPC; START_QUERY; /* procedure name */ if (IS_TDS71_PLUS(tds)) { /* save some byte for mssql2k */ tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_UNPREPARE); } else { tds_put_smallint(tds, 12); 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->internal_sp_called = TDS_SP_UNPREPARE; return tds_query_flush_packet(tds); } if (dyn->emulated) { tds->out_flag = TDS_QUERY; START_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, 0x04); 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 */ return tds_query_flush_packet(tds); } static int 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 (param->column_namelen > 0) { tds_put_string(tds, param->column_name, param->column_namelen); 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 */ int tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params) { 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; /* distinguish from dynamic query */ tds->cur_dyn = NULL; rpc_name_len = (int)strlen(rpc_name); if (IS_TDS7_PLUS(tds)) { const char *converted_name; size_t converted_name_len; tds->out_flag = TDS_RPC; /* procedure name */ converted_name = tds_convert_string(tds, tds->char_convs[client2ucs2], rpc_name, rpc_name_len, &converted_name_len); if (!converted_name) { tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } START_QUERY; 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)) { 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->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. */ int tds_send_cancel(TDSSOCKET * tds) { 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_SUCCEED; tds->out_flag = TDS_CANCEL; tds->in_cancel = 1; tdsdump_log(TDS_DBG_FUNC, "tds_send_cancel: sending cancel packet\n"); return tds_flush_packet(tds); } static int tds_quote(TDSSOCKET * tds, char *buffer, char quoting, const char *id, int len) { int i; const char *src, *pend; char *dst; CHECK_TDS_EXTRA(tds); pend = id + len; /* quote */ src = id; if (!buffer) { i = 2 + len; for (; src != pend; ++src) if (*src == quoting) ++i; return i; } dst = buffer; *dst++ = (quoting == ']') ? '[' : quoting; for (; src != pend; ++src) { if (*src == quoting) *dst++ = quoting; *dst++ = *src; } *dst++ = quoting; *dst = 0; return (int)(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 * \result written chars (not including needed terminator) */ int tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id, int idlen) { int i; CHECK_TDS_EXTRA(tds); if (idlen < 0) idlen = (int)strlen(id); /* quote always for mssql */ if (TDS_IS_MSSQL(tds) || tds->product_version >= TDS_SYB_VER(12, 5, 1)) return tds_quote(tds, buffer, ']', id, idlen); /* need quote ?? */ for (i = 0; i < idlen; ++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, idlen); } if (buffer) { memcpy(buffer, id, idlen); buffer[idlen] = '\0'; } return idlen; } /** * 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) */ int tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str, int len) { return tds_quote(tds, buffer, '\'', str, len < 0 ? (int)strlen(str) : len); } static inline void tds_set_cur_cursor(TDSSOCKET *tds, TDSCURSOR *cursor) { ++cursor->ref_count; if (tds->cur_cursor) tds_release_cursor(tds, tds->cur_cursor); tds->cur_cursor = cursor; } int 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)) { 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)) { if (!*something_to_send) { if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds->out_flag = TDS_NORMAL; } if (tds->state != TDS_QUERYING || 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_SUCCEED; } int 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; } if (tds->state != TDS_QUERYING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); if (IS_TDS50(tds)) { 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)) { 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->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->out_flag = TDS_RPC; START_QUERY; /* procedure identifier by number */ if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSOROPEN); } else { tds_put_smallint(tds, 13); 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)) tds_put_n(tds, tds->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->internal_sp_called = TDS_SP_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_SUCCEED; } int 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)) { 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)) { if (!*something_to_send) { if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds->out_flag = TDS_NORMAL; } if (tds->state != TDS_QUERYING || 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_SUCCEED; } 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)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSORFETCH); } else { tds_put_smallint(tds, 14); 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); } int 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); if (IS_TDS50(tds)) { 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)) { /* 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->out_flag = TDS_RPC; START_QUERY; /* 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) ? 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->internal_sp_called = TDS_SP_CURSORFETCH; return tds_query_flush_packet(tds); } tds_set_state(tds, TDS_IDLE); return TDS_SUCCEED; } int tds_cursor_get_cursor_info(TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *prow_number, TDS_UINT *prow_count) { int done_flags, 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)) { /* Change state to querying */ if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) 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->out_flag = TDS_RPC; START_QUERY; /* Create and send query to server */ if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSORFETCH); } else { tds_put_smallint(tds, 14); 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->internal_sp_called = 0; if ( (retcode=tds_query_flush_packet(tds)) != TDS_SUCCEED ) 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_SUCCEED; case TDS_CANCELLED: case TDS_FAIL: return TDS_FAIL; case TDS_SUCCEED: 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); } } } } } } return TDS_SUCCEED; } int 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); if (IS_TDS50(tds)) { 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)) { /* RPC call to sp_cursorclose */ tds->out_flag = TDS_RPC; START_QUERY; if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSORCLOSE); } else { tds_put_smallint(tds, 14); 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->internal_sp_called = TDS_SP_CURSORCLOSE; } return tds_query_flush_packet(tds); } int 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)) return TDS_SUCCEED; if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); /* RPC call to sp_cursoroption */ tds->out_flag = TDS_RPC; START_QUERY; if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSOROPTION); } else { tds_put_smallint(tds, 14); 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)) tds_put_n(tds, tds->collation, 5); tds_put_smallint(tds, len); tds_put_n(tds, cursor->cursor_name, len); tds->internal_sp_called = TDS_SP_CURSOROPTION; return tds_query_flush_packet(tds); } int 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_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); if (IS_TDS50(tds)) { tds->out_flag = TDS_NORMAL; /* FIXME finish*/ tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } if (IS_TDS7_PLUS(tds)) { /* RPC call to sp_cursorclose */ tds->out_flag = TDS_RPC; START_QUERY; if (IS_TDS71_PLUS(tds)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSOR); } else { tds_put_smallint(tds, 14); 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 (param->table_namelen > 0) { table_name = param->table_name; break; } } if (table_name) { converted_table = tds_convert_string(tds, tds->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)) tds_put_n(tds, tds->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->internal_sp_called = TDS_SP_CURSOR; } return tds_query_flush_packet(tds); } /** * Send a deallocation request to server * libTDS care for all deallocation stuff (memory and server cursor) * Caller should not use cursor pointer anymore */ int tds_cursor_dealloc(TDSSOCKET * tds, TDSCURSOR * cursor) { int res = TDS_SUCCEED; CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; if (cursor->srv_status == TDS_CUR_ISTAT_UNUSED || (cursor->srv_status & TDS_CUR_ISTAT_DEALLOC) != 0 || (IS_TDS7_PLUS(tds) && (cursor->srv_status & TDS_CUR_ISTAT_CLOSED) != 0)) { tds_cursor_deallocated(tds, cursor); tds_release_cursor(tds, cursor); return TDS_SUCCEED; } tdsdump_log(TDS_DBG_INFO1, "tds_cursor_dealloc() cursor id = %d\n", cursor->cursor_id); if (IS_TDS50(tds)) { if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) 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)) { 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"); } } /* client will not use cursor anymore */ tds_release_cursor(tds, cursor); return res; } 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); } static int 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 and 5 TEXT/IMAGE cannot be NULL, use empty */ if (!IS_TDS7_PLUS(tds) && (curcol->column_type == SYBIMAGE || curcol->column_type == SYBTEXT)) tds_put_string(tds, "''", 2); else tds_put_string(tds, "NULL", 4); return TDS_SUCCEED; } 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: /* TODO use an ISO context */ case SYBUNIQUE: quote = 1; default: res = tds_convert(tds->tds_ctx, tds_get_conversion_type(curcol->column_type, curcol->column_size), src, src_len, SYBCHAR, &cr); if (res < 0) 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_SUCCEED; } /** * Emulate prepared execute traslating to a normal language */ static int 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->out_flag = TDS_QUERY; START_QUERY; if (!num_placeholders) { tds_put_string(tds, query, -1); return TDS_SUCCEED; } 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_SUCCEED; } enum { MUL_STARTED = 1 }; int tds_multiple_init(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type) { multiple->type = type; multiple->flags = 0; if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds->out_flag = TDS_QUERY; switch (type) { case TDS_MULTIPLE_QUERY: break; case TDS_MULTIPLE_EXECUTE: case TDS_MULTIPLE_RPC: if (IS_TDS7_PLUS(tds)) tds->out_flag = TDS_RPC; break; } START_QUERY; return TDS_SUCCEED; } int tds_multiple_done(TDSSOCKET *tds, TDSMULTIPLE *multiple) { assert(tds && multiple); return tds_query_flush_packet(tds); } int 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); } int tds_multiple_execute(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC * dyn) { assert(multiple->type == TDS_MULTIPLE_EXECUTE); if (IS_TDS7_PLUS(tds)) { if (multiple->flags & MUL_STARTED) { /* TODO define constant */ tds_put_byte(tds, IS_TDS72_PLUS(tds) ? 0xff : 0x80); } multiple->flags |= MUL_STARTED; tds7_send_execute(tds, dyn); return TDS_SUCCEED; } if (multiple->flags & MUL_STARTED) tds_put_string(tds, " ", 1); multiple->flags |= MUL_STARTED; return tds_send_emulated_execute(tds, dyn->query, dyn->params); } int tds_submit_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size) { char cmd[128]; char datefmt[4]; TDS_INT resulttype; TDSCOLUMN *col; CONV_RESULT dres; int ctype; unsigned char*src; int srclen; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_FUNC, "tds_submit_optioncmd() \n"); if (IS_TDS50(tds)) { if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) 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); if (tds_process_simple_query(tds) == TDS_FAIL) { return TDS_FAIL; } } if (IS_TDS7_PLUS(tds)) { if (command == TDS_OPT_SET) { 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); if (tds_process_simple_query(tds) == TDS_FAIL) { return TDS_FAIL; } } if (command == TDS_OPT_LIST) { int optionval = 0; 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_SUCCEED) { 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_SUCCEED) { 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->tds_ctx, 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_SUCCEED; } /* * TODO add function to return type suitable for param * ie: * sybvarchar -> sybvarchar / xsybvarchar * sybint4 -> sybintn */ /** @} */ freetds-0.91/src/tds/iconv.c100664 001750 000144 00000117637 11516634760 0011472/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_ERRNO_H #include #endif #include "tds.h" #include "tdsiconv.h" #if HAVE_ICONV #include #endif #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: iconv.c,v 1.148 2011/01/22 20:11:28 jklowden Exp $"); #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->server_charset.min_bytes_per_char = 1; conv->server_charset.max_bytes_per_char = 1; conv->client_charset.min_bytes_per_char = 1; conv->client_charset.max_bytes_per_char = 1; conv->server_charset.name = conv->client_charset.name = ""; conv->server_charset.canonic = conv->client_charset.canonic = 0; conv->to_wire = (iconv_t) -1; conv->to_wire2 = (iconv_t) -1; conv->from_wire = (iconv_t) -1; conv->from_wire2 = (iconv_t) -1; } /** * Allocate iconv stuff * \return 0 for success */ int tds_iconv_alloc(TDSSOCKET * tds) { int i; TDSICONV *char_conv; assert(!tds->char_convs); if (!(tds->char_convs = (TDSICONV **) malloc(sizeof(TDSICONV *) * (initial_char_conv_count + 1)))) return 1; char_conv = (TDSICONV *) calloc(initial_char_conv_count, sizeof(TDSICONV)); if (!char_conv) { TDS_ZERO_FREE(tds->char_convs); return 1; } tds->char_conv_count = initial_char_conv_count + 1; for (i = 0; i < initial_char_conv_count; ++i) { tds->char_convs[i] = &char_conv[i]; tds_iconv_reset(&char_conv[i]); } /* chardata is just a pointer to another iconv info */ tds->char_convs[initial_char_conv_count] = tds->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) * \li 2. ISO8859-1 <-> server meta data (iso2server_metadata) * * 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. */ void tds_iconv_open(TDSSOCKET * tds, const char *charset) { static const char UCS_2LE[] = "UCS-2LE"; int canonic; int canonic_charset = tds_canonical_charset(charset); int canonic_env_charset = tds->env.charset ? tds_canonical_charset(tds->env.charset) : -1; int fOK, ret; TDS_ENCODING *client = &tds->char_convs[client2ucs2]->client_charset; TDS_ENCODING *server = &tds->char_convs[client2ucs2]->server_charset; tdsdump_log(TDS_DBG_FUNC, "tds_iconv_open(%p, %s)\n", tds, 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]); assert(ret == 0); return; } 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 = tds_iconv_info_init(tds->char_convs[client2ucs2], canonic_charset, TDS_CHARSET_UCS_2LE); if (!fOK) return; /* * 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. */ tds->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, tds->env.charset); fOK = tds_iconv_info_init(tds->char_convs[client2server_chardata], canonic_charset, canonic_env_charset); if (!fOK) return; } else { tds->char_convs[client2server_chardata]->client_charset = canonic_charsets[canonic_charset]; tds->char_convs[client2server_chardata]->server_charset = canonic_charsets[canonic_charset]; } /* * ISO8859-1 <-> server meta data */ canonic = TDS_CHARSET_UCS_2LE; if (!IS_TDS7_PLUS(tds)) { canonic = TDS_CHARSET_ISO_8859_1; if (canonic_env_charset >= 0) canonic = canonic_env_charset; } tdsdump_log(TDS_DBG_FUNC, "preparing iconv for \"%s\" <-> \"%s\" conversion\n", "ISO-8859-1", canonic_charsets[canonic].name); fOK = tds_iconv_info_init(tds->char_convs[iso2server_metadata], TDS_CHARSET_ISO_8859_1, canonic); tdsdump_log(TDS_DBG_FUNC, "tds_iconv_open: done\n"); } /** * 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->client_charset; TDS_ENCODING *server = &char_conv->server_charset; assert(char_conv->to_wire == (iconv_t) -1); assert(char_conv->to_wire2 == (iconv_t) -1); assert(char_conv->from_wire == (iconv_t) -1); assert(char_conv->from_wire2 == (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_wire = (iconv_t) -1; char_conv->from_wire = (iconv_t) -1; char_conv->flags = TDS_ENCODING_MEMCPY; return 1; } char_conv->flags = 0; if (!iconv_names[server_canonical]) { switch (server_canonical) { case POS_UCS2LE: server_canonical = POS_UCS2BE; char_conv->flags = TDS_ENCODING_SWAPBYTE; break; case POS_UCS2BE: server_canonical = POS_UCS2LE; char_conv->flags = TDS_ENCODING_SWAPBYTE; break; } } /* 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_wire = tds_sys_iconv_open(iconv_names[server_canonical], iconv_names[client_canonical]); if (char_conv->to_wire == (iconv_t) -1) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_info_init: cannot convert \"%s\"->\"%s\"\n", client->name, server->name); } char_conv->from_wire = tds_sys_iconv_open(iconv_names[client_canonical], iconv_names[server_canonical]); if (char_conv->from_wire == (iconv_t) -1) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_info_init: cannot convert \"%s\"->\"%s\"\n", server->name, client->name); } /* try indirect conversions */ if (char_conv->to_wire == (iconv_t) -1 || char_conv->from_wire == (iconv_t) -1) { tds_iconv_info_close(char_conv); /* TODO reuse some conversion, client charset is usually constant in all connection (or ISO8859-1) */ char_conv->to_wire = tds_sys_iconv_open(iconv_names[POS_UTF8], iconv_names[client_canonical]); char_conv->to_wire2 = tds_sys_iconv_open(iconv_names[server_canonical], iconv_names[POS_UTF8]); char_conv->from_wire = tds_sys_iconv_open(iconv_names[POS_UTF8], iconv_names[server_canonical]); char_conv->from_wire2 = tds_sys_iconv_open(iconv_names[client_canonical], iconv_names[POS_UTF8]); if (char_conv->to_wire == (iconv_t) -1 || char_conv->to_wire2 == (iconv_t) -1 || char_conv->from_wire == (iconv_t) -1 || char_conv->from_wire2 == (iconv_t) -1) { tds_iconv_info_close(char_conv); tdsdump_log(TDS_DBG_FUNC, "tds_iconv_info_init: cannot convert \"%s\"->\"%s\" indirectly\n", server->name, client->name); return 0; } char_conv->flags |= TDS_ENCODING_INDIRECT; } /* 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_wire); _iconv_close(&char_conv->to_wire2); _iconv_close(&char_conv->from_wire); _iconv_close(&char_conv->from_wire2); } void tds_iconv_close(TDSSOCKET * tds) { int i; for (i = 0; i < tds->char_conv_count; ++i) { tds_iconv_info_close(tds->char_convs[i]); } } #define CHUNK_ALLOC 4 void tds_iconv_free(TDSSOCKET * tds) { int i; if (!tds->char_convs) return; tds_iconv_close(tds); free(tds->char_convs[0]); for (i = initial_char_conv_count + 1; i < tds->char_conv_count; i += CHUNK_ALLOC) free(tds->char_convs[i]); TDS_ZERO_FREE(tds->char_convs); tds->char_conv_count = 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, const 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; const TDS_ENCODING *input_charset = NULL; const char *output_charset_name = NULL; iconv_t cd = invalid, cd2 = invalid; 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; char *p; int eilseq_raised = 0; /* cast away const-ness */ TDS_ERRNO_MESSAGE_FLAGS *suppress = (TDS_ERRNO_MESSAGE_FLAGS*) &conv->suppress; assert(inbuf && inbytesleft && outbuf && outbytesleft); switch (io) { case to_server: cd = conv->to_wire; cd2 = conv->to_wire2; input_charset = &conv->client_charset; output_charset_name = conv->server_charset.name; break; case to_client: cd = conv->from_wire; cd2 = conv->from_wire2; input_charset = &conv->server_charset; output_charset_name = conv->client_charset.name; 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 || 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. */ errno = 0; p = *outbuf; for (;;) { if (conv->flags & TDS_ENCODING_INDIRECT) { #if ENABLE_EXTRA_CHECKS char tmp[8]; #else char tmp[128]; #endif char *pb = tmp; size_t l = sizeof(tmp); int temp_errno; size_t temp_irreversible; temp_irreversible = tds_sys_iconv(cd, (ICONV_CONST char **) inbuf, inbytesleft, &pb, &l); temp_errno = errno; /* convert partial */ pb = tmp; l = sizeof(tmp) - l; for (;;) { errno = 0; irreversible = tds_sys_iconv(cd2, (ICONV_CONST char **) &pb, &l, outbuf, outbytesleft); if (irreversible != (size_t) - 1) { if (inbytesleft && *inbytesleft) break; goto end_loop; } /* EINVAL should be impossible, all characters came from previous iconv... */ if (errno == E2BIG || errno == EINVAL) goto end_loop; /* * error should be EILSEQ, not convertible sequence * skip UTF-8 sequence */ /* avoid infinite recursion */ eilseq_raised = 1; if (*pb == '?') goto end_loop; *pb = (char) 0x80; while(l && (*pb & 0xC0) == 0x80) ++pb, --l; --pb; ++l; *pb = '?'; } if (temp_errno == E2BIG) { errno = 0; continue; } errno = temp_errno; irreversible = temp_irreversible; break; } else if (io == to_client && conv->flags & TDS_ENCODING_SWAPBYTE && inbuf) { /* swap bytes if necessary */ #if ENABLE_EXTRA_CHECKS char tmp[8]; #else char tmp[128]; #endif char *pib = tmp; size_t il = *inbytesleft > sizeof(tmp) ? sizeof(tmp) : *inbytesleft; size_t n; for (n = 0; n < il; n += 2) { tmp[n] = (*inbuf)[n + 1]; tmp[n + 1] = (*inbuf)[n]; } irreversible = tds_sys_iconv(cd, (ICONV_CONST char **) &pib, &il, outbuf, outbytesleft); il = pib - tmp; *inbuf += il; *inbytesleft -= il; if (irreversible != (size_t) - 1 && *inbytesleft) continue; } else { irreversible = tds_sys_iconv(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; } if (errno == EILSEQ) eilseq_raised = 1; if (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(cd, input_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(output_charset_name, iconv_names[POS_UTF8]); if (error_cd == invalid) { break; /* what to do? */ } } lquest_mark = 1; pquest_mark = quest_mark; p = *outbuf; irreversible = tds_sys_iconv(error_cd, &pquest_mark, &lquest_mark, outbuf, outbytesleft); if (irreversible == (size_t) - 1) break; if (!*inbytesleft) break; } end_loop: /* swap bytes if necessary */ if (io == to_server && conv->flags & TDS_ENCODING_SWAPBYTE) { assert((*outbuf - p) % 2 == 0); for (; p < *outbuf; p += 2) { char tmp = p[0]; p[0] = p[1]; p[1] = tmp; } } if (eilseq_raised && !suppress->eilseq) { /* invalid multibyte input sequence encountered */ if (io == to_client) { if (irreversible == (size_t) - 1) { tdserror(tds->tds_ctx, tds, TDSEICONV2BIG, 0); } else { tdserror(tds->tds_ctx, tds, TDSEICONVI, 0); errno = 0; } } else { tdserror(tds->tds_ctx, tds, TDSEICONVO, 0); } suppress->eilseq = 1; } switch (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 */ tdserror(tds->tds_ctx, tds, TDSEICONVAVAIL, 0); suppress->einval = 1; break; case E2BIG: /* output buffer has no more room */ if (suppress->e2big) break; tdserror(tds->tds_ctx, tds, TDSEICONVIU, 0); suppress->e2big = 1; break; default: break; } if (error_cd != invalid) { tds_sys_iconv_close(error_cd); } return irreversible; } /** * Read a data file, passing the data through iconv(). * \return Count of bytes either not read, or read but not converted. Returns zero on success. */ size_t tds_iconv_fread(iconv_t cd, FILE * stream, size_t field_len, size_t term_len, char *outbuf, size_t * outbytesleft) { #ifdef ENABLE_EXTRA_CHECKS char buffer[16]; #else char buffer[16000]; #endif char *ib; size_t isize = 0, nonreversible_conversions = 0; /* * If cd isn't valid, it's just an indication that this column needs no conversion. */ if (cd == (iconv_t) -1) { assert(field_len <= *outbytesleft); if (field_len > 0) { if (1 != fread(outbuf, field_len, 1, stream)) { return field_len + term_len; /* unable to read */ } } /* prepare to read the terminator and return */ *outbytesleft -= field_len; /* as iconv would have done */ isize = 0; /* as iconv would have done */ field_len = 0; /* as the loop would have done */ goto READ_TERMINATOR; } /* * Read in chunks. * field_len is the total size to read * isize is the size of the current chunk (which might be the whole thing). * They are decremented as they are successfully processed. * On success, we exit the loop with both equal to zero, indicating nothing we * were asked to read remains unread. */ isize = (sizeof(buffer) < field_len) ? sizeof(buffer) : field_len; for (ib = buffer; isize && (isize = fread(ib, 1, isize, stream)) > 0;) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_fread: read %u of %u bytes; outbuf has %u left.\n", (unsigned int) isize, (unsigned int) field_len, (unsigned int) *outbytesleft); field_len -= isize; isize += ib - buffer; ib = buffer; nonreversible_conversions += tds_sys_iconv(cd, (ICONV_CONST char **) &ib, &isize, &outbuf, outbytesleft); if (isize != 0) { memmove(buffer, ib, isize); switch (errno) { case EINVAL: /* incomplete multibyte sequence encountered in input */ break; case E2BIG: /* insufficient room in output buffer */ case EILSEQ: /* invalid multibyte sequence encountered in input */ default: /* FIXME: emit message */ tdsdump_log(TDS_DBG_FUNC, "tds_iconv_fread: error %d: %s.\n", errno, strerror(errno)); break; } } ib = buffer + isize; isize = sizeof(buffer) - isize; if (isize > field_len) isize = field_len; } READ_TERMINATOR: if (term_len > 0 && !feof(stream)) { isize += term_len; if (term_len && 1 == fread(buffer, term_len, 1, stream)) { isize -= term_len; } else { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_fread: cannot read %u-byte terminator\n", (unsigned int) term_len); } } return field_len + isize; } /** * Get a iconv info structure, allocate and initialize if needed */ static TDSICONV * tds_iconv_get_info(TDSSOCKET * tds, int canonic_client, int canonic_server) { TDSICONV *info; int i; /* search a charset from already allocated charsets */ for (i = tds->char_conv_count; --i >= initial_char_conv_count;) if (canonic_client == tds->char_convs[i]->client_charset.canonic && canonic_server == tds->char_convs[i]->server_charset.canonic) return tds->char_convs[i]; /* allocate a new iconv structure */ if (tds->char_conv_count % CHUNK_ALLOC == ((initial_char_conv_count + 1) % CHUNK_ALLOC)) { TDSICONV **p; TDSICONV *infos; infos = (TDSICONV *) malloc(sizeof(TDSICONV) * CHUNK_ALLOC); if (!infos) return NULL; p = (TDSICONV **) realloc(tds->char_convs, sizeof(TDSICONV *) * (tds->char_conv_count + CHUNK_ALLOC)); if (!p) { free(infos); return NULL; } tds->char_convs = p; memset(infos, 0, sizeof(TDSICONV) * CHUNK_ALLOC); for (i = 0; i < CHUNK_ALLOC; ++i) { tds->char_convs[i + tds->char_conv_count] = &infos[i]; tds_iconv_reset(&infos[i]); } } info = tds->char_convs[tds->char_conv_count++]; /* init */ if (tds_iconv_info_init(info, canonic_client, canonic_server)) return info; tds_iconv_info_close(info); --tds->char_conv_count; return NULL; } TDSICONV * tds_iconv_get(TDSSOCKET * tds, 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(tds, canonic_client_charset_num, canonic_server_charset_num); } /* change singlebyte conversions according to server */ static void tds_srv_charset_changed_num(TDSSOCKET * tds, int canonic_charset_num) { TDSICONV *char_conv = tds->char_convs[client2server_chardata]; if (IS_TDS7_PLUS(tds) && 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->server_charset.canonic) return; /* find and set conversion */ char_conv = tds_iconv_get_info(tds, tds->char_convs[client2ucs2]->client_charset.canonic, canonic_charset_num); if (char_conv) tds->char_convs[client2server_chardata] = char_conv; /* if sybase change also server conversions */ if (IS_TDS7_PLUS(tds)) return; char_conv = tds->char_convs[iso2server_metadata]; tds_iconv_info_close(char_conv); tds_iconv_info_init(char_conv, TDS_CHARSET_ISO_8859_1, canonic_charset_num); } void tds_srv_charset_changed(TDSSOCKET * tds, 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(tds, n); } /* change singlebyte conversions according to server */ void tds7_srv_charset_changed(TDSSOCKET * tds, int sql_collate, int lcid) { tds_srv_charset_changed_num(tds, 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) { int 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 */ } /** * Determine the name Sybase uses for a character set, given a canonical iconv name. * \returns Sybase name, or NULL if lookup failed. * \remarks Returned name can be sent to Sybase a server. */ const char * tds_sybase_charset_name(const char *charset_name) { int res, i; /* search in sybase */ res = lookup_canonic(iconv_aliases, charset_name); if (res < 0) return NULL; /* special case, ignore ascii_8, take iso_1 instead, note index start from 1 */ assert(strcmp(sybase_aliases[0].alias, "ascii_8") == 0); for (i = 1; sybase_aliases[i].alias; ++i) { if (sybase_aliases[i].canonic == res) return sybase_aliases[i].alias; } return NULL; } 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 0x81a: seem wrong in XP table TODO check */ case 0x104e: /* ?? */ 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 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 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 0x480a: case 0x4c0a: case 0x500a: case 0x807: case 0x809: case 0x80a: case 0x80c: case 0x810: case 0x813: case 0x814: case 0x816: case 0x81d: case 0x83e: 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 0x420: case 0x429: 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(TDSSOCKET * tds, 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 (tds->char_convs[client2server_chardata]->server_charset.canonic == canonic_charset) return tds->char_convs[client2server_chardata]; return tds_iconv_get_info(tds, tds->char_convs[client2ucs2]->client_charset.canonic, canonic_charset); } /** @} */ freetds-0.91/src/tds/locale.c100664 001750 000144 00000006417 11421652242 0011572/* 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. */ #if HAVE_CONFIG_H #include #endif #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 "tds.h" #include "tds_configs.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: locale.c,v 1.30 2010/07/21 20:12:18 freddy77 Exp $"); 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 !!! */ tds_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-0.91/src/tds/threadsafe.c100664 001750 000144 00000032545 11507147510 0012444/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 defined(_WIN32) || defined(_WIN64) #include #include #endif #include "tds.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: threadsafe.c,v 1.50 2010/12/30 18:28:24 freddy77 Exp $"); 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(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); /* 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); /* 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(HAVE_GETADDRINFO) && \ (!defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && \ !defined(__bsdi__) && !defined(__DragonFly__)) static int tds_addrinfo_to_hostent(struct addrinfo *ai, 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; char *p = buffer; int len; char **addresses; struct addrinfo *curr_ai; memset(result, 0, sizeof(struct hostent)); result->h_addrtype = sizeof(struct sockaddr_in); /* count addresses */ for (n = 0, curr_ai = ai; curr_ai; curr_ai = curr_ai->ai_next) { if (curr_ai->ai_family != PF_INET) continue; ++n; } /* copy addresses */ addresses = (char **) p; result->h_addr_list = addresses; result->h_length = sizeof(struct in_addr); len = sizeof(char *) * (n + 1); CHECK_BUF(len); p += len; ALIGN_P; for (n = 0, curr_ai = ai; curr_ai; curr_ai = curr_ai->ai_next) { if (curr_ai->ai_family != PF_INET) continue; addresses[n++] = p; len = sizeof(struct in_addr); CHECK_BUF(len); memcpy(p, &((struct sockaddr_in *) curr_ai->ai_addr)->sin_addr, len); p += len; ALIGN_P; } addresses[n] = NULL; /* copy name */ if (ai->ai_canonname) { n = strlen(ai->ai_canonname) + 1; result->h_name = p; CHECK_BUF(n); memcpy(p, ai->ai_canonname, n); p += n; ALIGN_P; } return 0; } struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop) { struct addrinfo hints, *res; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0; hints.ai_protocol = IPPROTO_TCP; res = NULL; /* default error */ if (h_errnop) *h_errnop = HOST_NOT_FOUND; if (getaddrinfo(servername, NULL, &hints, &res)) return NULL; if (res->ai_family != PF_INET || !res->ai_addr) { freeaddrinfo(res); return NULL; } if (tds_addrinfo_to_hostent(res, result, buffer, buflen)) { errno = ENOMEM; if (h_errnop) *h_errnop = NETDB_INTERNAL; freeaddrinfo(res); return NULL; } freeaddrinfo(res); 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 /* not used by FreeTDS, uncomment if needed */ #ifdef ENABLE_DEVELOPING struct hostent * tds_gethostbyaddr_r(const char *addr, int len, int type, struct hostent *result, char *buffer, int buflen, int *h_errnop) { #if defined(NETDB_REENTRANT) return gethostbyaddr(addr, len, type); #elif defined(HAVE_GETIPNODEBYADDR) struct hostent *he = getipnodebyaddr(addr, len, type, 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_GETHOSTBYADDR_R_8) if (gethostbyaddr_r(addr, len, type, result, buffer, buflen, &result, h_errnop)) return NULL; return result; #elif defined(HAVE_FUNC_GETHOSTBYADDR_R_7) result = gethostbyaddr_r(addr, len, type, result, buffer, buflen, h_errnop); return result; #elif defined(HAVE_FUNC_GETHOSTBYADDR_R_5) struct hostent_data *data = (struct hostent_data *) buffer; memset(buffer, 0, buflen); if (gethostbyaddr_r(addr, len, type, result, data)) { *h_errnop = 0; result = NULL; } return result; #elif defined(TDS_NO_THREADSAFE) return gethostbyaddr(addr, len, type); #else #error gethostbyaddr_r style unknown #endif } #endif const char * tds_inet_ntoa_r(struct in_addr iaddr, char *ip, size_t len) { #if defined(AF_INET) && HAVE_INET_NTOP inet_ntop(AF_INET, &iaddr, ip, len); #elif HAVE_INET_NTOA_R inet_ntoa_r(iaddr, ip, len); #else tds_strlcpy(ip, inet_ntoa(iaddr), len); #endif return ip; } struct servent * tds_getservbyname_r(const char *name, const char *proto, struct servent *result, char *buffer, int buflen) { #if defined(NETDB_REENTRANT) return getservbyname(name, proto); #elif defined(HAVE_FUNC_GETSERVBYNAME_R_6) struct servent result_buf; getservbyname_r(name, proto, &result_buf, buffer, buflen, &result); return result; #elif defined(HAVE_FUNC_GETSERVBYNAME_R_5) getservbyname_r(name, proto, result, buffer, buflen); return result; #elif defined(HAVE_FUNC_GETSERVBYNAME_R_4) struct servent_data data; getservbyname_r(name, proto, result, &data); return result; #elif defined(HAVE_GETADDRINFO) struct addrinfo hints, *res; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; res = NULL; if (getaddrinfo(NULL, name, &hints, &res)) return NULL; if (res->ai_family != PF_INET || !res->ai_addr) { freeaddrinfo(res); return NULL; } memset(result, 0, sizeof(*result)); result->s_port = ((struct sockaddr_in *) res->ai_addr)->sin_port; freeaddrinfo(res); return result; #elif defined(TDS_NO_THREADSAFE) return getservbyname(name, proto); #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-0.91/src/tds/vstrbuild.c100664 001750 000144 00000010414 11134166717 0012351/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds.h" #include "replacements.h" TDS_RCSID(var, "$Id: vstrbuild.c,v 1.16 2009/01/16 20:27:59 jklowden Exp $"); 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, size_t fmtlen) { char *newfmt; char *cp; char skip = 0; if (fmtlen == TDS_NULLTERM) { fmtlen = strlen(fmt); } if ((newfmt = (char *) malloc(fmtlen + 1)) == NULL) { return TDS_FAIL; } 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; } int tds_vstrbuild(char *buffer, int buflen, int *resultlen, 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; int 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 = (struct string_linked_list *) malloc(sizeof(struct string_linked_list))) == NULL) { goto out; } (*tail)->str = token; (*tail)->next = NULL; tail = &((*tail)->next); tokcount++; } if ((string_array = (char **) malloc((tokcount + 1) * sizeof(char *))) == 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_SUCCEED; out: free(string_array); for (item = head; item != NULL; item = head) { head = head->next; free(item); } free(params); return rc; } freetds-0.91/src/tds/tdsstring.c100664 001750 000144 00000011007 11134166716 0012352/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #ifdef DMALLOC #include #endif #include "tds.h" #include "tdsstring.h" TDS_RCSID(var, "$Id: tdsstring.c,v 1.20 2009/01/16 20:27:58 jklowden Exp $"); /** * \ingroup libtds * \defgroup dstring Dynamic string functions * Handle dynamic string. In this string are always valid * (you don't have NULL pointer, only empty string) */ /* This is in a separate module because we use the pointer to discriminate allocated and not allocated */ const char tds_str_empty[1] = ""; /** * \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->dstr_s != tds_str_empty) free(s->dstr_s); s->dstr_size = 0; s->dstr_s = (char*) tds_str_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 (s->dstr_s != tds_str_empty) free(s->dstr_s); if (!length) { s->dstr_s = (char *) tds_str_empty; s->dstr_size = 0; } else { s->dstr_s = (char *) malloc(length + 1); if (!s->dstr_s) { s->dstr_s = (char *) tds_str_empty; s->dstr_size = 0; return NULL; } s->dstr_size = length; memcpy(s->dstr_s, src, length); s->dstr_s[length] = 0; } 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) { size_t len = strlen(src); if (s->dstr_s != tds_str_empty) free(s->dstr_s); s->dstr_s = len ? src : (char *) tds_str_empty; if (!len) free(src); s->dstr_size = len; return s; } /** * 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)); } 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->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) { char *p; if (s->dstr_s != tds_str_empty) free(s->dstr_s); p = (char *) malloc(length + 1); if (!p) { s->dstr_s = (char *) tds_str_empty; s->dstr_size = 0; return NULL; } s->dstr_s = p; s->dstr_s[0] = 0; s->dstr_size = length; return s; } #if ENABLE_EXTRA_CHECKS void tds_dstr_init(DSTR * s) { s->dstr_s = (char *) tds_str_empty; s->dstr_size = 0; } int tds_dstr_isempty(DSTR * s) { return s->dstr_size == 0; } char * tds_dstr_buf(DSTR * s) { return s->dstr_s; } size_t tds_dstr_len(DSTR * s) { return s->dstr_size; } #endif /** @} */ freetds-0.91/src/tds/getmac.c100664 001750 000144 00000003633 11134166716 0011577/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds.h" #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 / 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-0.91/src/tds/data.c100644 001750 000144 00000015466 11557650317 0011261/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds.h" #include "tds_checks.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: data.c,v 1.28.2.1 2011/04/22 14:14:16 freddy77 Exp $"); /** * Set type of column initializing all dependency * @param curcol column to set * @param type type to set */ void tds_set_column_type(TDSSOCKET * tds, TDSCOLUMN * curcol, int type) { /* set type */ curcol->on_server.column_type = 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(tds, 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(TDSSOCKET * tds, TDSCOLUMN * curcol, TDS_SERVER_TYPE type) { if (IS_TDS7_PLUS(tds)) { 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(tds)) { if (type == SYBINT8) type = SYB5INT8; } tds_set_column_type(tds, curcol, type); if (is_collate_type(type)) { curcol->char_conv = tds->char_convs[is_unicode_type(type) ? client2ucs2 : client2server_chardata]; memcpy(curcol->column_collation, tds->collation, sizeof(tds->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(tds)) { curcol->column_varint_size = 8; curcol->on_server.column_type = XSYBNVARCHAR; } break; case SYBTEXT: if (IS_TDS72_PLUS(tds)) { curcol->column_varint_size = 8; curcol->on_server.column_type = XSYBVARCHAR; } break; case SYBIMAGE: if (IS_TDS72_PLUS(tds)) { curcol->column_varint_size = 8; curcol->on_server.column_type = XSYBVARBINARY; } break; default: break; } } int tds_get_cardinal_type(int 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; } return datatype; } TDS_INT tds_data_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); break; case 2: /* assure > 0 */ col->column_size = tds_get_smallint(tds); /* under TDS9 this means ?var???(MAX) */ if (col->column_size < 0 && IS_TDS72_PLUS(tds)) { col->column_size = 0x3ffffffflu; col->column_varint_size = 8; } 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; } /* numeric and decimal have extra info */ if (is_numeric_type(col->column_type)) { col->column_prec = tds_get_byte(tds); /* precision */ col->column_scale = tds_get_byte(tds); /* scale */ /* FIXME check prec/scale, don't let server crash us */ } if (IS_TDS71_PLUS(tds) && 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, 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)) { unsigned char num_parts = tds_get_byte(tds); /* TODO do not discard first ones */ for (; num_parts; --num_parts) { col->table_namelen = tds_get_string(tds, tds_get_smallint(tds), col->table_name, sizeof(col->table_name) - 1); } } else { col->table_namelen = tds_get_string(tds, tds_get_smallint(tds), col->table_name, sizeof(col->table_name) - 1); } } else if (IS_TDS72_PLUS(tds) && 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_smallint(tds), NULL, 0); /* schema collection */ } } return TDS_SUCCEED; } #include "tds_types.h" freetds-0.91/src/tds/net.c100644 001750 000144 00000117057 11623070342 0011121/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Brian Bruns * Copyright (C) 2004-2011 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 */ #include "tds.h" #include "tdsstring.h" #include "replacements.h" #include #include #ifdef HAVE_GNUTLS #if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX) #include "tdsthread.h" #include #endif #include #elif defined(HAVE_OPENSSL) #include #endif #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: net.c,v 1.110.2.2 2011/08/12 11:50:17 freddy77 Exp $"); #define TDSSELREAD POLLIN #define TDSSELWRITE POLLOUT /* error is always returned */ #define TDSSELERR 0 static int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds); /** * \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_MSGMORE #undef USE_CORK #undef USE_NODELAY /* On Linux 2.4.x we can use MSG_MORE */ #if defined(__linux__) && defined(MSG_MORE) #define USE_MSGMORE 1 /* On early Linux use TCP_CORK if available */ #elif 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 #if !defined(_WIN32) typedef unsigned int ioctl_nonblocking_t; #else typedef u_long ioctl_nonblocking_t; #endif TDSERRNO tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int timeout, int *p_oserr) { struct sockaddr_in sin; ioctl_nonblocking_t ioctl_nonblocking; SOCKLEN_T optlen; int retval, len; int tds_error = TDSECONN; char ip[20]; *p_oserr = 0; memset(&sin, 0, sizeof(sin)); sin.sin_addr.s_addr = inet_addr(ip_addr); if (sin.sin_addr.s_addr == INADDR_NONE) { tdsdump_log(TDS_DBG_ERROR, "inet_addr() failed, IP = %s\n", ip_addr); return TDSESOCK; } sin.sin_family = AF_INET; sin.sin_port = htons(port); tdsdump_log(TDS_DBG_INFO1, "Connecting to %s port %d (TDS version %d.%d)\n", tds_inet_ntoa_r(sin.sin_addr, ip, sizeof(ip)), ntohs(sin.sin_port), TDS_MAJOR(tds), TDS_MINOR(tds)); if (TDS_IS_SOCKET_INVALID(tds->s = socket(AF_INET, SOCK_STREAM, 0))) { *p_oserr = sock_errno; tdsdump_log(TDS_DBG_ERROR, "socket creation error: %s\n", sock_strerror(sock_errno)); return TDSESOCK; } #ifdef SO_KEEPALIVE len = 1; setsockopt(tds->s, SOL_SOCKET, SO_KEEPALIVE, (const void *) &len, sizeof(len)); #endif #if defined(__APPLE__) && defined(SO_NOSIGPIPE) len = 1; if (setsockopt(tds->s, SOL_SOCKET, SO_NOSIGPIPE, (const void *) &len, sizeof(len))) { *p_oserr = sock_errno; tds_close_socket(tds); return TDSESOCK; } #endif len = 1; #if defined(USE_NODELAY) || defined(USE_MSGMORE) setsockopt(tds->s, SOL_TCP, TCP_NODELAY, (const void *) &len, sizeof(len)); #elif defined(USE_CORK) if (setsockopt(tds->s, SOL_TCP, TCP_CORK, (const void *) &len, sizeof(len)) < 0) setsockopt(tds->s, SOL_TCP, TCP_NODELAY, (const void *) &len, sizeof(len)); #else #error One should be defined #endif #ifdef DOS32X /* the other connection doesn't work on WATTCP32 */ if (connect(tds->s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { char *message; *p_oserr = sock_errno; if (asprintf(&message, "tds_open_socket(): %s:%d", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)) >= 0) { perror(message); free(message); } tds_close_socket(tds); return TDSECONN; } #else if (!timeout) { /* A timeout of zero means wait forever; 90,000 seconds will feel like forever. */ timeout = 90000; } /* enable non-blocking mode */ ioctl_nonblocking = 1; if (IOCTLSOCKET(tds->s, FIONBIO, &ioctl_nonblocking) < 0) { *p_oserr = sock_errno; tds_close_socket(tds); return TDSEUSCT; /* close enough: "Unable to set communications timer" */ } retval = connect(tds->s, (struct sockaddr *) &sin, sizeof(sin)); if (retval == 0) { tdsdump_log(TDS_DBG_INFO2, "connection established\n"); } else { int err = *p_oserr = sock_errno; tdsdump_log(TDS_DBG_ERROR, "tds_open_socket: connect(2) returned \"%s\"\n", sock_strerror(err)); #if DEBUGGING_CONNECTING_PROBLEM if (err != ECONNREFUSED && err != ENETUNREACH && err != TDSSOCK_EINPROGRESS) { tdsdump_dump_buf(TDS_DBG_ERROR, "Contents of sockaddr_in", &sin, sizeof(sin)); tdsdump_log(TDS_DBG_ERROR, " sockaddr_in:\t" "%s = %x\n" "\t\t\t%s = %x\n" "\t\t\t%s = %x\n" "\t\t\t%s = '%s'\n" , "sin_family", sin.sin_family , "sin_port", sin.sin_port , "sin_addr.s_addr", sin.sin_addr.s_addr , "(param ip_addr)", ip_addr ); } #endif if (err != TDSSOCK_EINPROGRESS) goto not_available; if (tds_select(tds, TDSSELWRITE|TDSSELERR, timeout) <= 0) { tds_error = TDSECONN; goto not_available; } } #endif /* not DOS32X */ /* check socket error */ optlen = sizeof(len); len = 0; if (tds_getsockopt(tds->s, SOL_SOCKET, SO_ERROR, (char *) &len, &optlen) != 0) { *p_oserr = sock_errno; tdsdump_log(TDS_DBG_ERROR, "getsockopt(2) failed: %s\n", sock_strerror(sock_errno)); goto not_available; } if (len != 0) { *p_oserr = len; tdsdump_log(TDS_DBG_ERROR, "getsockopt(2) reported: %s\n", sock_strerror(len)); goto not_available; } tdsdump_log(TDS_DBG_ERROR, "tds_open_socket() succeeded\n"); return TDSEOK; not_available: tds_close_socket(tds); tdsdump_log(TDS_DBG_ERROR, "tds_open_socket() failed\n"); return tds_error; } int tds_close_socket(TDSSOCKET * tds) { int rc = -1; if (!IS_TDSDEAD(tds)) { if ((rc = CLOSESOCKET(tds->s)) == -1) tdserror(tds->tds_ctx, tds, TDSECLOS, sock_errno); tds->s = INVALID_SOCKET; tds_set_state(tds, TDS_DEAD); } return rc; } /** * 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. */ static int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds) { int rc, seconds; unsigned int poll_seconds; static const char method[] = "poll(2)"; 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->tds_ctx && tds->tds_ctx->int_handler)? 1 : timeout_seconds; for (seconds = timeout_seconds; timeout_seconds == 0 || seconds > 0; seconds -= poll_seconds) { struct pollfd fd; int timeout = poll_seconds ? poll_seconds * 1000 : -1; fd.fd = tds->s; fd.events = tds_sel; fd.revents = 0; rc = poll(&fd, 1, timeout); if (rc > 0 ) { return rc; } if (rc < 0) { switch (sock_errno) { case TDSSOCK_EINTR: break; /* let interrupt handler be called */ default: /* documented: EFAULT, EBADF, EINVAL */ tdsdump_log(TDS_DBG_ERROR, "error: %s returned %d, \"%s\"\n", method, sock_errno, sock_strerror(sock_errno)); return rc; } } assert(rc == 0 || (rc < 0 && sock_errno == TDSSOCK_EINTR)); if (tds->tds_ctx && tds->tds_ctx->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->tds_ctx->int_handler) (tds->parent); #if 0 tdsdump_log(TDS_DBG_ERROR, "tds_ctx->int_handler returned %d\n", timeout_action); #endif 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; } /** * Loops until we have received buflen characters * return -1 on failure */ static int tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen, unsigned char unfinished) { int rc, got = 0; if (tds == NULL || buf == NULL || buflen < 1) return -1; for (;;) { int len; if (IS_TDSDEAD(tds)) return -1; if ((len = tds_select(tds, TDSSELREAD, tds->query_timeout)) > 0) { len = READSOCKET(tds->s, buf + got, buflen); if (len < 0 && TDSSOCK_WOULDBLOCK(sock_errno)) continue; /* detect connection close */ if (len <= 0) { tdserror(tds->tds_ctx, tds, len == 0 ? TDSESEOF : TDSEREAD, sock_errno); tds_close_socket(tds); return -1; } } else if (len < 0) { if (TDSSOCK_WOULDBLOCK(sock_errno)) /* shouldn't happen, but OK */ continue; tdserror(tds->tds_ctx, tds, TDSEREAD, sock_errno); tds_close_socket(tds); return -1; } else { /* timeout */ switch (rc = tdserror(tds->tds_ctx, tds, TDSETIME, sock_errno)) { case TDS_INT_CONTINUE: continue; case TDS_INT_TIMEOUT: tds_send_cancel(tds); continue; /* fixme: or return? */ default: case TDS_INT_CANCEL: tds_close_socket(tds); return -1; } assert(0); /* not reached */ } got += len; buflen -= len; /* doing test here reduce number of syscalls required */ if (buflen <= 0) break; if (unfinished && got) break; } return got; } static int goodread(TDSSOCKET * tds, unsigned char *buf, int buflen) { #ifdef HAVE_GNUTLS if (tds->tls_session) return gnutls_record_recv(tds->tls_session, buf, buflen); #elif defined(HAVE_OPENSSL) if (tds->tls_session) return SSL_read((SSL*) tds->tls_session, buf, buflen); #endif return tds_goodread(tds, buf, buflen, 0); } /** * 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) { unsigned char header[8]; int len, have; if (IS_TDSDEAD(tds)) { tdsdump_log(TDS_DBG_NETWORK, "Read attempt when state is TDS_DEAD"); return -1; } /* * Read in the packet header. We use this to figure out our packet length. * Cast to int are needed because some compiler seem to convert * len to unsigned (as FreeBSD 4.5 one) */ if ((len = goodread(tds, header, sizeof(header))) < (int) sizeof(header)) { /* GW ADDED */ if (len < 0) { /* not needed because goodread() already called: tdserror(tds->tds_ctx, tds, TDSEREAD, 0); */ tds_close_socket(tds); tds->in_len = 0; tds->in_pos = 0; return -1; } /* GW ADDED */ /* * Not sure if this is the best way to do the error * handling here but this is the way it is currently * being done. */ tds->in_len = 0; tds->in_pos = 0; if (tds->state != TDS_IDLE && len == 0) { tds_close_socket(tds); } return -1; } tdsdump_dump_buf(TDS_DBG_HEADER, "Received header", header, sizeof(header)); /* Convert our packet length from network to host byte order */ len = (((unsigned int) header[2]) << 8) | header[3]; /* * If this packet size is the largest we have gotten allocate space for it */ if ((unsigned int)len > tds->in_buf_max) { unsigned char *p; if (!tds->in_buf) { p = (unsigned char *) malloc(len); } else { p = (unsigned char *) realloc(tds->in_buf, len); } if (!p) { tds_close_socket(tds); return -1; } tds->in_buf = p; /* Set the new maximum packet size */ tds->in_buf_max = len; } /* Clean out the in_buf so we don't use old stuff by mistake */ memset(tds->in_buf, 0, tds->in_buf_max); memcpy(tds->in_buf, header, 8); /* Now get exactly how many bytes the server told us to get */ have = 8; while (have < len) { int nbytes = goodread(tds, tds->in_buf + have, len - have); if (nbytes < 1) { /* * Not sure if this is the best way to do the error * handling here but this is the way it is currently * being done. */ /* no need to call tdserror(), because goodread() already did */ tds->in_len = 0; tds->in_pos = 0; tds_close_socket(tds); return -1; } have += nbytes; } /* set the received packet type flag */ tds->in_flag = header[0]; /* Set the length and pos (not sure what pos is used for now */ tds->in_len = have; tds->in_pos = 8; tdsdump_dump_buf(TDS_DBG_NETWORK, "Received packet", tds->in_buf, tds->in_len); return (tds->in_len); } int tds_lastpacket(TDSSOCKET * tds) { if (!tds || !tds->in_buf || tds->in_buf_max < 2) return 1; return tds->in_buf[1] != 0; } /** * \param tds the famous socket * \param buffer data to send * \param len bytes in buffer * \param last 1 if this is the last packet, else 0 * \return len on success, <0 on failure */ static int tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer, size_t len, unsigned char last) { const unsigned char *p = buffer; int rc; assert(tds && buffer); /* Fix of SIGSEGV when FD_SET() called with negative fd (Sergey A. Cherukhin, 23/09/2005) */ if (TDS_IS_SOCKET_INVALID(tds->s)) return -1; while (p - buffer < len) { if ((rc = tds_select(tds, TDSSELWRITE, tds->query_timeout)) > 0) { int err; size_t remaining = len - (p - buffer); #ifdef USE_MSGMORE ssize_t nput = send(tds->s, p, remaining, last ? MSG_NOSIGNAL : MSG_NOSIGNAL|MSG_MORE); /* In case the kernel does not support MSG_MORE, try again without it */ if (nput < 0 && errno == EINVAL && !last) nput = send(tds->s, p, remaining, MSG_NOSIGNAL); #elif defined(__APPLE__) && defined(SO_NOSIGPIPE) ssize_t nput = send(tds->s, p, remaining, 0); #else ssize_t nput = WRITESOCKET(tds->s, p, remaining); #endif if (nput > 0) { p += nput; continue; } err = sock_errno; if (0 == nput || TDSSOCK_WOULDBLOCK(err)) continue; assert(nput < 0); tdsdump_log(TDS_DBG_NETWORK, "send(2) failed: %d (%s)\n", err, sock_strerror(err)); tdserror(tds->tds_ctx, tds, TDSEWRIT, err); tds_close_socket(tds); return -1; } else if (rc < 0) { int err = sock_errno; if (TDSSOCK_WOULDBLOCK(err)) /* shouldn't happen, but OK, retry */ continue; tdsdump_log(TDS_DBG_NETWORK, "select(2) failed: %d (%s)\n", err, sock_strerror(err)); tdserror(tds->tds_ctx, tds, TDSEWRIT, err); tds_close_socket(tds); return -1; } else { /* timeout */ tdsdump_log(TDS_DBG_NETWORK, "tds_goodwrite(): timed out, asking client\n"); switch (rc = tdserror(tds->tds_ctx, tds, TDSETIME, sock_errno)) { case TDS_INT_CONTINUE: continue; case TDS_INT_TIMEOUT: /* * "Cancel the operation ... but leave the dbproc in working condition." * We must try to send the cancel packet, else we have to abandon the dbproc. * If it can't be done, a harder error e.g. ECONNRESET will bubble up. */ tds_send_cancel(tds); continue; default: case TDS_INT_CANCEL: tds_close_socket(tds); return -1; } assert(0); /* not reached */ } assert(0); /* not reached */ } #ifdef USE_CORK /* force packet flush */ if (last) { int opt; opt = 0; setsockopt(tds->s, SOL_TCP, TCP_CORK, (const void *) &opt, sizeof(opt)); opt = 1; setsockopt(tds->s, SOL_TCP, TCP_CORK, (const void *) &opt, sizeof(opt)); } #endif return len; } int tds_write_packet(TDSSOCKET * tds, unsigned char final) { int sent; unsigned int left = 0; #if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) && (!defined(__APPLE__) || !defined(SO_NOSIGPIPE)) void (*oldsig) (int); #endif #if TDS_ADDITIONAL_SPACE != 0 if (tds->out_pos > tds->env.block_size) { left = tds->out_pos - tds->env.block_size; tds->out_pos = tds->env.block_size; } #endif tds->out_buf[0] = tds->out_flag; tds->out_buf[1] = final; tds->out_buf[2] = (tds->out_pos) / 256u; tds->out_buf[3] = (tds->out_pos) % 256u; if (IS_TDS7_PLUS(tds) && !tds->connection) tds->out_buf[6] = 0x01; tdsdump_dump_buf(TDS_DBG_NETWORK, "Sending packet", tds->out_buf, tds->out_pos); #if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) && (!defined(__APPLE__) || !defined(SO_NOSIGPIPE)) 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 #ifdef HAVE_GNUTLS if (tds->tls_session) sent = gnutls_record_send(tds->tls_session, tds->out_buf, tds->out_pos); else #elif defined(HAVE_OPENSSL) if (tds->tls_session) sent = SSL_write((SSL*) tds->tls_session, tds->out_buf, tds->out_pos); else #endif sent = tds_goodwrite(tds, tds->out_buf, tds->out_pos, final); #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 #if TDS_ADDITIONAL_SPACE != 0 memcpy(tds->out_buf + 8, tds->out_buf + tds->env.block_size, left); #endif tds->out_pos = left + 8; /* GW added in check for write() returning <0 and SIGPIPE checking */ return sent <= 0 ? TDS_FAIL : TDS_SUCCEED; } /** * 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, const char *ip_addr) { int num_try; struct sockaddr_in sin; ioctl_nonblocking_t ioctl_nonblocking; struct pollfd fd; int retval; TDS_SYS_SOCKET s; char msg[16*1024]; size_t msg_len = 0; int port = 0; tdsdump_log(TDS_DBG_ERROR, "tds7_get_instance_ports(%s)\n", ip_addr); sin.sin_addr.s_addr = inet_addr(ip_addr); if (sin.sin_addr.s_addr == INADDR_NONE) { tdsdump_log(TDS_DBG_ERROR, "inet_addr() failed, IP = %s\n", ip_addr); return 0; } sin.sin_family = AF_INET; sin.sin_port = htons(1434); /* create an UDP socket */ if (TDS_IS_SOCKET_INVALID(s = socket(AF_INET, SOCK_DGRAM, 0))) { tdsdump_log(TDS_DBG_ERROR, "socket creation error: %s\n", sock_strerror(sock_errno)); return 0; } /* * on cluster environment is possible that reply packet came from * different IP so do not filter by ip with connect */ ioctl_nonblocking = 1; if (IOCTLSOCKET(s, FIONBIO, &ioctl_nonblocking) < 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; sendto(s, msg, 1, 0, (struct sockaddr *) &sin, sizeof(sin)); 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 *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(const char *ip_addr, const char *instance) { int num_try; struct sockaddr_in sin; ioctl_nonblocking_t ioctl_nonblocking; struct pollfd fd; int retval; TDS_SYS_SOCKET s; char msg[1024]; size_t msg_len; int port = 0; tdsdump_log(TDS_DBG_ERROR, "tds7_get_instance_port(%s, %s)\n", ip_addr, instance); sin.sin_addr.s_addr = inet_addr(ip_addr); if (sin.sin_addr.s_addr == INADDR_NONE) { tdsdump_log(TDS_DBG_ERROR, "inet_addr() failed, IP = %s\n", ip_addr); return 0; } sin.sin_family = AF_INET; sin.sin_port = htons(1434); /* create an UDP socket */ if (TDS_IS_SOCKET_INVALID(s = socket(AF_INET, SOCK_DGRAM, 0))) { tdsdump_log(TDS_DBG_ERROR, "socket creation error: %s\n", sock_strerror(sock_errno)); return 0; } /* * on cluster environment is possible that reply packet came from * different IP so do not filter by ip with connect */ ioctl_nonblocking = 1; if (IOCTLSOCKET(s, FIONBIO, &ioctl_nonblocking) < 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; tds_strlcpy(msg + 1, instance, sizeof(msg) - 1); sendto(s, msg, (int)strlen(msg) + 1, 0, (struct sockaddr *) &sin, sizeof(sin)); 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) const char * tds_prwsaerror( int erc ) { switch(erc) { case WSAEINTR: /* 10004 */ return "WSAEINTR: Interrupted function call."; case WSAEACCES: /* 10013 */ return "WSAEACCES: Permission denied."; case WSAEFAULT: /* 10014 */ return "WSAEFAULT: Bad address."; case WSAEINVAL: /* 10022 */ return "WSAEINVAL: Invalid argument."; case WSAEMFILE: /* 10024 */ return "WSAEMFILE: Too many open files."; case WSAEWOULDBLOCK: /* 10035 */ return "WSAEWOULDBLOCK: Resource temporarily unavailable."; case WSAEINPROGRESS: /* 10036 */ return "WSAEINPROGRESS: Operation now in progress."; case WSAEALREADY: /* 10037 */ return "WSAEALREADY: Operation already in progress."; case WSAENOTSOCK: /* 10038 */ return "WSAENOTSOCK: Socket operation on nonsocket."; case WSAEDESTADDRREQ: /* 10039 */ return "WSAEDESTADDRREQ: Destination address required."; case WSAEMSGSIZE: /* 10040 */ return "WSAEMSGSIZE: Message too long."; case WSAEPROTOTYPE: /* 10041 */ return "WSAEPROTOTYPE: Protocol wrong type for socket."; case WSAENOPROTOOPT: /* 10042 */ return "WSAENOPROTOOPT: Bad protocol option."; case WSAEPROTONOSUPPORT: /* 10043 */ return "WSAEPROTONOSUPPORT: Protocol not supported."; case WSAESOCKTNOSUPPORT: /* 10044 */ return "WSAESOCKTNOSUPPORT: Socket type not supported."; case WSAEOPNOTSUPP: /* 10045 */ return "WSAEOPNOTSUPP: Operation not supported."; case WSAEPFNOSUPPORT: /* 10046 */ return "WSAEPFNOSUPPORT: Protocol family not supported."; case WSAEAFNOSUPPORT: /* 10047 */ return "WSAEAFNOSUPPORT: Address family not supported by protocol family."; case WSAEADDRINUSE: /* 10048 */ return "WSAEADDRINUSE: Address already in use."; case WSAEADDRNOTAVAIL: /* 10049 */ return "WSAEADDRNOTAVAIL: Cannot assign requested address."; case WSAENETDOWN: /* 10050 */ return "WSAENETDOWN: Network is down."; case WSAENETUNREACH: /* 10051 */ return "WSAENETUNREACH: Network is unreachable."; case WSAENETRESET: /* 10052 */ return "WSAENETRESET: Network dropped connection on reset."; case WSAECONNABORTED: /* 10053 */ return "WSAECONNABORTED: Software caused connection abort."; case WSAECONNRESET: /* 10054 */ return "WSAECONNRESET: Connection reset by peer."; case WSAENOBUFS: /* 10055 */ return "WSAENOBUFS: No buffer space available."; case WSAEISCONN: /* 10056 */ return "WSAEISCONN: Socket is already connected."; case WSAENOTCONN: /* 10057 */ return "WSAENOTCONN: Socket is not connected."; case WSAESHUTDOWN: /* 10058 */ return "WSAESHUTDOWN: Cannot send after socket shutdown."; case WSAETIMEDOUT: /* 10060 */ return "WSAETIMEDOUT: Connection timed out."; case WSAECONNREFUSED: /* 10061 */ return "WSAECONNREFUSED: Connection refused."; case WSAEHOSTDOWN: /* 10064 */ return "WSAEHOSTDOWN: Host is down."; case WSAEHOSTUNREACH: /* 10065 */ return "WSAEHOSTUNREACH: No route to host."; case WSAEPROCLIM: /* 10067 */ return "WSAEPROCLIM: Too many processes."; case WSASYSNOTREADY: /* 10091 */ return "WSASYSNOTREADY: Network subsystem is unavailable."; case WSAVERNOTSUPPORTED: /* 10092 */ return "WSAVERNOTSUPPORTED: Winsock.dll version out of range."; case WSANOTINITIALISED: /* 10093 */ return "WSANOTINITIALISED: Successful WSAStartup not yet performed."; case WSAEDISCON: /* 10101 */ return "WSAEDISCON: Graceful shutdown in progress."; case WSATYPE_NOT_FOUND: /* 10109 */ return "WSATYPE_NOT_FOUND: Class type not found."; case WSAHOST_NOT_FOUND: /* 11001 */ return "WSAHOST_NOT_FOUND: Host not found."; case WSATRY_AGAIN: /* 11002 */ return "WSATRY_AGAIN: Nonauthoritative host not found."; case WSANO_RECOVERY: /* 11003 */ return "WSANO_RECOVERY: This is a nonrecoverable error."; case WSANO_DATA: /* 11004 */ return "WSANO_DATA: Valid name, no data record of requested type."; case WSA_INVALID_HANDLE: /* OS dependent */ return "WSA_INVALID_HANDLE: Specified event object handle is invalid."; case WSA_INVALID_PARAMETER: /* OS dependent */ return "WSA_INVALID_PARAMETER: One or more parameters are invalid."; case WSA_IO_INCOMPLETE: /* OS dependent */ return "WSA_IO_INCOMPLETE: Overlapped I/O event object not in signaled state."; case WSA_IO_PENDING: /* OS dependent */ return "WSA_IO_PENDING: Overlapped operations will complete later."; case WSA_NOT_ENOUGH_MEMORY: /* OS dependent */ return "WSA_NOT_ENOUGH_MEMORY: Insufficient memory available."; case WSA_OPERATION_ABORTED: /* OS dependent */ return "WSA_OPERATION_ABORTED: Overlapped operation aborted."; #if defined(WSAINVALIDPROCTABLE) case WSAINVALIDPROCTABLE: /* OS dependent */ return "WSAINVALIDPROCTABLE: Invalid procedure table from service provider."; #endif #if defined(WSAINVALIDPROVIDER) case WSAINVALIDPROVIDER: /* OS dependent */ return "WSAINVALIDPROVIDER: Invalid service provider version number."; #endif #if defined(WSAPROVIDERFAILEDINIT) case WSAPROVIDERFAILEDINIT: /* OS dependent */ return "WSAPROVIDERFAILEDINIT: Unable to initialize a service provider."; #endif case WSASYSCALLFAILURE: /* OS dependent */ return "WSASYSCALLFAILURE: System call failure."; } return "undocumented WSA error code"; } #endif #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) #ifdef HAVE_GNUTLS static ssize_t tds_pull_func(gnutls_transport_ptr ptr, void* data, size_t len) { TDSSOCKET *tds = (TDSSOCKET *) ptr; #else static int tds_ssl_read(BIO *b, char* data, int len) { TDSSOCKET *tds = (TDSSOCKET *) b->ptr; #endif int have; tdsdump_log(TDS_DBG_INFO1, "in tds_pull_func\n"); /* if we have some data send it */ if (tds->out_pos > 8) tds_flush_packet(tds); if (tds->tls_session) { /* read directly from socket */ return tds_goodread(tds, data, len, 1); } for(;;) { have = tds->in_len - tds->in_pos; tdsdump_log(TDS_DBG_INFO1, "have %d\n", have); assert(have >= 0); if (have > 0) break; tdsdump_log(TDS_DBG_INFO1, "before read\n"); if (tds_read_packet(tds) < 0) return -1; tdsdump_log(TDS_DBG_INFO1, "after read\n"); } if (len > have) len = have; tdsdump_log(TDS_DBG_INFO1, "read %lu bytes\n", (unsigned long int) len); memcpy(data, tds->in_buf + tds->in_pos, len); tds->in_pos += len; return len; } #ifdef HAVE_GNUTLS static ssize_t tds_push_func(gnutls_transport_ptr ptr, const void* data, size_t len) { TDSSOCKET *tds = (TDSSOCKET *) ptr; #else static int tds_ssl_write(BIO *b, const char* data, int len) { TDSSOCKET *tds = (TDSSOCKET *) b->ptr; #endif tdsdump_log(TDS_DBG_INFO1, "in tds_push_func\n"); if (tds->tls_session) { /* write to socket directly */ /* TODO use cork if available here to flush only on last chunk of packet ?? */ return tds_goodwrite(tds, data, len, tds->out_buf[1]); } /* write crypted data inside normal TDS packets */ tds_put_n(tds, data, len); return len; } #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); } static int tls_initialized = 0; #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) 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 int tds_ssl_init(TDSSOCKET *tds) { gnutls_session session; gnutls_certificate_credentials xcred; static const int kx_priority[] = { GNUTLS_KX_RSA_EXPORT, GNUTLS_KX_RSA, GNUTLS_KX_DHE_DSS, GNUTLS_KX_DHE_RSA, 0 }; static const int cipher_priority[] = { GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_AES_128_CBC, GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR_128, #if 0 GNUTLS_CIPHER_ARCFOUR_40, GNUTLS_CIPHER_DES_CBC, #endif 0 }; static const int comp_priority[] = { GNUTLS_COMP_NULL, 0 }; static const int mac_priority[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0 }; int ret; const char *tls_msg; xcred = NULL; session = NULL; tls_msg = "initializing tls"; /* FIXME place somewhere else, deinit at end */ ret = 0; if (!tls_initialized) { tds_gcry_init(); ret = gnutls_global_init(); } if (ret == 0) { tls_initialized = 1; gnutls_global_set_log_level(11); gnutls_global_set_log_function(tds_tls_log); tls_msg = "allocating credentials"; ret = gnutls_certificate_allocate_credentials(&xcred); } if (ret == 0) { /* Initialize TLS session */ tls_msg = "initializing session"; ret = gnutls_init(&session, GNUTLS_CLIENT); } if (ret == 0) { gnutls_transport_set_ptr(session, tds); gnutls_transport_set_pull_function(session, tds_pull_func); gnutls_transport_set_push_function(session, tds_push_func); /* NOTE: there functions return int however they cannot fail */ /* use default priorities... */ gnutls_set_default_priority(session); /* ... but overwrite some */ gnutls_cipher_set_priority(session, cipher_priority); gnutls_compression_set_priority(session, comp_priority); gnutls_kx_set_priority(session, kx_priority); gnutls_mac_set_priority(session, mac_priority); /* 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) { /* Perform the TLS handshake */ tls_msg = "handshake"; ret = gnutls_handshake (session); } if (ret != 0) { 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; } tdsdump_log(TDS_DBG_INFO1, "handshake succeeded!!\n"); tds->tls_session = session; tds->tls_credentials = xcred; return TDS_SUCCEED; } void tds_ssl_deinit(TDSSOCKET *tds) { if (tds->tls_session) { gnutls_deinit(tds->tls_session); tds->tls_session = NULL; } if (tds->tls_credentials) { gnutls_certificate_free_credentials(tds->tls_credentials); tds->tls_credentials = NULL; } } #else static long tds_ssl_ctrl(BIO *b, int cmd, long num, void *ptr) { TDSSOCKET *tds = (TDSSOCKET *) b->ptr; 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; } static BIO_METHOD tds_method = { BIO_TYPE_MEM, "tds", tds_ssl_write, tds_ssl_read, NULL, NULL, tds_ssl_ctrl, NULL, tds_ssl_free, NULL, }; static SSL_CTX *ssl_ctx; static int tds_init_openssl(void) { SSL_METHOD *meth; SSL_library_init (); meth = TLSv1_client_method (); if (meth == NULL) return 1; ssl_ctx = SSL_CTX_new (meth); if (ssl_ctx == NULL) return 1; return 0; } #ifdef TDS_ATTRIBUTE_DESTRUCTOR static void __attribute__((destructor)) tds_tls_deinit(void) { if (ssl_ctx) SSL_CTX_free (ssl_ctx); } #endif int tds_ssl_init(TDSSOCKET *tds) { #define OPENSSL_CIPHERS \ "DHE-RSA-AES256-SHA DHE-DSS-AES256-SHA " \ "AES256-SHA EDH-RSA-DES-CBC3-SHA " \ "EDH-DSS-DES-CBC3-SHA DES-CBC3-SHA " \ "DES-CBC3-MD5 DHE-RSA-AES128-SHA " \ "DHE-DSS-AES128-SHA AES128-SHA RC2-CBC-MD5 RC4-SHA RC4-MD5" SSL *con; BIO *b; int ret; const char *tls_msg; con = NULL; b = NULL; tls_msg = "initializing tls"; /* FIXME place somewhere else, deinit at end */ ret = 0; if (!ssl_ctx) ret = tds_init_openssl(); if (ret == 0) { /* Initialize TLS session */ tls_msg = "initializing session"; con = SSL_new(ssl_ctx); } if (con) { tls_msg = "creating bio"; b = BIO_new(&tds_method); } ret = 0; if (b) { b->shutdown=1; b->init=1; b->num= -1; b->ptr = tds; SSL_set_bio(con, b, b); /* use priorities... */ SSL_set_cipher_list(con, 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 || con->state != SSL_ST_OK; } if (ret != 0) { if (con) { SSL_shutdown(con); SSL_free(con); } tdsdump_log(TDS_DBG_ERROR, "%s failed\n", tls_msg); return TDS_FAIL; } tdsdump_log(TDS_DBG_INFO1, "handshake succeeded!!\n"); tds->tls_session = con; tds->tls_credentials = NULL; return TDS_SUCCEED; } void tds_ssl_deinit(TDSSOCKET *tds) { if (tds->tls_session) { /* NOTE do not call SSL_shutdown here */ SSL_free(tds->tls_session); tds->tls_session = NULL; } } #endif #endif /** @} */ freetds-0.91/src/tds/tds_checks.c100664 001750 000144 00000023272 11303442520 0012436/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #undef NDEBUG #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "tds.h" #include "tdsconvert.h" #include "tdsstring.h" #include "tds_checks.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: tds_checks.c,v 1.29 2009/11/26 09:07:28 freddy77 Exp $"); #if ENABLE_EXTRA_CHECKS void tds_check_tds_extra(const TDSSOCKET * tds) { const int invalid_state = 0; int found, i; int result_found = 0; TDSDYNAMIC *cur_dyn = NULL; TDSCURSOR *cur_cursor = NULL; assert(tds); /* teset state and connection */ switch (tds->state) { case TDS_DEAD: case TDS_QUERYING: case TDS_PENDING: case TDS_IDLE: case TDS_READING: break; default: assert(invalid_state); } assert(tds->state == TDS_DEAD || !TDS_IS_SOCKET_INVALID(tds->s)); assert(tds->state != TDS_DEAD || TDS_IS_SOCKET_INVALID(tds->s)); /* test env */ tds_check_env_extra(&tds->env); /* test buffers and positions */ assert(tds->in_pos <= tds->in_len && tds->in_len <= tds->in_buf_max); /* 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->out_pos <= tds->env.block_size); assert(tds->env.block_size == 0 || tds->out_buf != NULL); assert(tds->in_buf_max == 0 || tds->in_buf != NULL); /* test res_info */ if (tds->res_info) { tds_check_resultinfo_extra(tds->res_info); if (tds->current_results == tds->res_info) result_found = 1; } /* 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]); if (tds->current_results == tds->comp_info[i]) result_found = 1; } /* param_info */ if (tds->param_info) { tds_check_resultinfo_extra(tds->param_info); if (tds->current_results == tds->param_info) result_found = 1; } /* test cursors */ found = 0; for (cur_cursor = tds->cursors; cur_cursor != NULL; cur_cursor = cur_cursor->next) { tds_check_cursor_extra(cur_cursor); if (tds->current_results == cur_cursor->res_info) result_found = 1; if (cur_cursor == tds->cur_cursor) found = 1; } assert(found || tds->cur_cursor == NULL); /* test num_dyms, cur_dyn, dyns */ found = 0; for (cur_dyn = tds->dyns; cur_dyn != NULL; cur_dyn = cur_dyn->next) { if (cur_dyn == tds->cur_dyn) found = 1; tds_check_dynamic_extra(cur_dyn); if (tds->current_results == cur_dyn->res_info) result_found = 1; } assert(found || tds->cur_dyn == NULL); /* test tds_ctx */ tds_check_context_extra(tds->tds_ctx); /* TODO test char_conv_count, char_convs */ /* current_results should be one of res_info, comp_info, param_info or dynamic */ /* * TODO this test was here to check that current_results was an alias * but with cursor and reference counting current_results can point * to a cursor result available on upper layer * Perhaps we should free results on deallocate and enable * assert again? */ /* assert(result_found || tds->current_results == NULL); */ /* 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; TDSSOCKET tds; int varint_ok; assert(column); /* 8 is for varchar(max) or similar */ assert(column->column_varint_size == 8 || (column->column_varint_size <= 5 && column->column_varint_size != 3)); assert(column->column_scale <= column->column_prec); assert(column->column_prec <= 77); /* I don't like this that much... freddy77 */ if (column->column_type == 0) return; assert(column->column_type > 0); assert(strlen(column->table_name) < sizeof(column->table_name)); assert(strlen(column->column_name) < sizeof(column->column_name)); /* check type and server type same or SQLNCHAR -> SQLCHAR */ #define SPECIAL(type, server_type, varint) \ if (column->column_type == type && column->on_server.column_type == server_type && column->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_null_type(column->column_type) == column->on_server.column_type && column->column_varint_size == 1 && is_fixed_type(column->column_type))); varint_ok = 0; if (column->column_varint_size == 8) { assert(column->on_server.column_type == XSYBVARCHAR || column->on_server.column_type == XSYBVARBINARY || column->on_server.column_type == XSYBNVARCHAR || column->on_server.column_type == SYBMSXML); varint_ok = 1; } else if (is_blob_type(column->column_type)) { assert(column->column_varint_size >= 4); } else if (column->column_type == SYBVARIANT) { assert(column->column_varint_size == 4); } tds.tds_version = 0x500; varint_ok = varint_ok || tds_get_varint_size(&tds, column->on_server.column_type) == column->column_varint_size; tds.tds_version = 0x700; varint_ok = varint_ok || tds_get_varint_size(&tds, column->on_server.column_type) == column->column_varint_size; assert(varint_ok); /* check current size <= size */ if (is_numeric_type(column->column_type)) { /* I don't like that much this difference between numeric and not numeric - freddy77 */ /* TODO what should be the size ?? */ assert(column->column_prec >= 1 && column->column_prec <= 77); assert(column->column_scale <= column->column_prec); /* assert(column->column_cur_size == tds_numeric_bytes_per_prec[column->column_prec] + 2 || column->column_cur_size == -1); */ } else { assert(column->column_cur_size <= column->column_size); } /* check size of fixed type correct */ size = tds_get_size_by_type(column->column_type); assert(size != 0 || column->column_type == SYBVOID); if (size >= 0 && column->column_type != SYBBITN) { /* 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->column_varint_size == 1); assert(column->column_size == column->column_cur_size || column->column_cur_size == -1); } else { assert(column->column_varint_size == 0 || (column->column_type == SYBUNIQUE && column->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->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) { } void tds_check_dynamic_extra(const TDSDYNAMIC * dyn) { assert(dyn); 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-0.91/src/tds/tds_checks.h100664 001750 000144 00000004644 11327421727 0012461/* 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 /* $Id: tds_checks.h,v 1.6 2010/01/25 23:05:59 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif #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) #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(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif /* TDS_CHECKS_H */ freetds-0.91/src/tds/enum_cap.h100664 001750 000144 00000013703 10540414344 0012123typedef 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_CAP_MAX = 89 /* 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-0.91/src/tds/log.c100664 001750 000144 00000026230 11360105520 0011101/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2006-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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include #endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 "tds.h" #include "tds_checks.h" #include "tdsthread.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: log.c,v 1.19 2010/04/10 14:29:36 freddy77 Exp $"); /* 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; int tds_write_dump = 0; /* is TDS stream debug log turned on? */ static FILE *g_dumpfile = NULL; /* file pointer for dump log */ static TDS_MUTEX_DEFINE(g_dump_mutex); 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); tds_write_dump = 1; TDS_MUTEX_UNLOCK(&g_dump_mutex); } int tdsdump_isopen() { return NULL != g_dumpfile; } /** * 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; } /* 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 *tm; #ifdef HAVE_LOCALTIME_R struct tm res; #endif time_t t; time(&t); #ifdef HAVE_LOCALTIME_R #if HAVE_FUNC_LOCALTIME_R_TM tm = localtime_r(&t, &res); #elif HAVE_FUNC_LOCALTIME_R_INT tm = NULL; if (!localtime_r(&t, &res)) tm = &res; #else #error One should be defined #endif #else tm = localtime(&t); #endif strftime(today, sizeof(today), "%Y-%m-%d %H:%M:%S", tm); 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); } /** * Dump the contents of data into the log file in a human readable format. * \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() */ #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 if (TDS_UNLIKELY(tds_write_dump)) tdsdump_log /** * Write a column value to the debug log. * \param file name of the log file * \param col column to dump */ void tdsdump_col(const TDSCOLUMN *col) { const char* typename; char* data; TDS_SMALLINT type; assert(col); assert(col->column_data); typename = tds_prtype(col->column_type); type = col->column_type; switch(type) { case SYBINTN: switch(col->column_cur_size) { case sizeof(TDS_INT): type = SYBINT4; break; case sizeof(TDS_SMALLINT): type = SYBINT2; break; case sizeof(TDS_TINYINT): type = SYBINT1; break; } break; case SYBFLTN: switch(col->column_cur_size) { case sizeof(TDS_REAL): type = SYBREAL; break; case sizeof(TDS_FLOAT): type = SYBFLT8; break; } break; } switch(type) { case SYBCHAR: case SYBVARCHAR: if (col->column_cur_size >= 0) { data = calloc(1, 1 + col->column_cur_size); if (!data) { tdsdump_log(TDS_DBG_FUNC, "no memory to log data for type %s\n", typename); return; } memcpy(data, col->column_data, col->column_cur_size); tdsdump_log(TDS_DBG_FUNC, "type %s has value \"%s\"\n", typename, data); free(data); } else { tdsdump_log(TDS_DBG_FUNC, "type %s has value NULL\n", typename); } break; case SYBINT1: tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", typename, (int)*(TDS_TINYINT*)col->column_data); break; case SYBINT2: tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", typename, (int)*(TDS_SMALLINT*)col->column_data); break; case SYBINT4: tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", typename, (int)*(TDS_INT*)col->column_data); break; case SYBREAL: tdsdump_log(TDS_DBG_FUNC, "type %s has value %f\n", typename, (double)*(TDS_REAL*)col->column_data); break; case SYBFLT8: tdsdump_log(TDS_DBG_FUNC, "type %s has value %f\n", typename, (double)*(TDS_FLOAT*)col->column_data); break; default: tdsdump_log(TDS_DBG_FUNC, "cannot log data for type %s\n", typename); break; } } freetds-0.91/src/tds/bulk.c100644 001750 000144 00000077067 11623070341 0011275/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tds.h" #include "tds_checks.h" #include "tdsbytes.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: bulk.c,v 1.11.2.1 2011/06/02 19:19:30 freddy77 Exp $"); #ifndef MAX #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) #endif typedef struct tds_pbcb { char *pb; unsigned int cb; unsigned int from_malloc; } TDSPBCB; static int tds7_bcp_send_colmetadata(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); static int 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); int tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo) { TDSRESULTINFO *resinfo; TDSRESULTINFO *bindinfo = NULL; TDSCOLUMN *curcol; TDS_INT result_type; int i, 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_submit_queryf(tds, fmt, bcpinfo->tablename) == TDS_FAIL) /* TODO return an error ?? */ /* Attempt to use Bulk Copy with a non-existent Server table (might be why ...) */ return TDS_FAIL; /* 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_SUCCEED) { } if (rc != TDS_NO_MORE_RESULTS) return TDS_FAIL; /* 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) goto cleanup; bindinfo->row_size = resinfo->row_size; /* Copy the column metadata */ 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->column_type = resinfo->columns[i]->column_type; curcol->column_usertype = resinfo->columns[i]->column_usertype; curcol->column_flags = resinfo->columns[i]->column_flags; 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->column_namelen = resinfo->columns[i]->column_namelen; 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; memcpy(curcol->column_name, resinfo->columns[i]->column_name, resinfo->columns[i]->column_namelen); TDS_ZERO_FREE(curcol->table_column_name); if (resinfo->columns[i]->table_column_name) curcol->table_column_name = strdup(resinfo->columns[i]->table_column_name); 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)); } } bindinfo->current_row = malloc(bindinfo->row_size); if (!bindinfo->current_row) goto cleanup; bindinfo->row_free = tds_bcp_row_free; if (bcpinfo->identity_insert_on) { if (tds_submit_queryf(tds, "set identity_insert %s on", bcpinfo->tablename) == TDS_FAIL) goto cleanup; /* TODO use tds_process_simple_query */ while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCEED) { } if (rc != TDS_NO_MORE_RESULTS) goto cleanup; } bcpinfo->bindinfo = bindinfo; bcpinfo->bind_count = 0; return TDS_SUCCEED; cleanup: tds_free_results(bindinfo); return TDS_FAIL; } /** * \return TDS_SUCCEED or TDS_FAIL. */ static int tds7_build_bulk_insert_stmt(TDSSOCKET * tds, TDSPBCB * clause, TDSCOLUMN * bcpcol, int first) { char buffer[32]; char *column_type = buffer; tdsdump_log(TDS_DBG_FUNC, "tds7_build_bulk_insert_stmt(%p, %p, %p, %d)\n", tds, clause, bcpcol, first); /* TODO reuse function in tds/query.c */ switch (bcpcol->on_server.column_type) { case SYBINT1: column_type = "tinyint"; break; case SYBBIT: column_type = "bit"; break; case SYBINT2: column_type = "smallint"; break; case SYBINT4: column_type = "int"; break; case SYBINT8: column_type = "bigint"; break; case SYBDATETIME: column_type = "datetime"; break; case SYBDATETIME4: column_type = "smalldatetime"; break; case SYBREAL: column_type = "real"; break; case SYBMONEY: column_type = "money"; break; case SYBMONEY4: column_type = "smallmoney"; break; case SYBFLT8: column_type = "float"; break; case SYBINTN: switch (bcpcol->column_size) { case 1: column_type = "tinyint"; break; case 2: column_type = "smallint"; break; case 4: column_type = "int"; break; case 8: column_type = "bigint"; break; } break; case SYBBITN: column_type = "bit"; break; case SYBFLTN: switch (bcpcol->column_size) { case 4: column_type = "real"; break; case 8: column_type = "float"; break; } break; case SYBMONEYN: switch (bcpcol->column_size) { case 4: column_type = "smallmoney"; break; case 8: column_type = "money"; break; } break; case SYBDATETIMN: switch (bcpcol->column_size) { case 4: column_type = "smalldatetime"; break; case 8: column_type = "datetime"; break; } break; case SYBDECIMAL: sprintf(column_type, "decimal(%d,%d)", bcpcol->column_prec, bcpcol->column_scale); break; case SYBNUMERIC: sprintf(column_type, "numeric(%d,%d)", bcpcol->column_prec, bcpcol->column_scale); break; case XSYBVARBINARY: sprintf(column_type, "varbinary(%d)", bcpcol->column_size); break; case XSYBVARCHAR: sprintf(column_type, "varchar(%d)", bcpcol->column_size); break; case XSYBBINARY: sprintf(column_type, "binary(%d)", bcpcol->column_size); break; case XSYBCHAR: sprintf(column_type, "char(%d)", bcpcol->column_size); break; case SYBTEXT: sprintf(column_type, "text"); break; case SYBIMAGE: sprintf(column_type, "image"); break; case XSYBNVARCHAR: sprintf(column_type, "nvarchar(%d)", bcpcol->column_size); break; case XSYBNCHAR: sprintf(column_type, "nchar(%d)", bcpcol->column_size); break; case SYBNTEXT: sprintf(column_type, "ntext"); break; case SYBUNIQUE: sprintf(column_type, "uniqueidentifier "); break; default: tdserror(tds->tds_ctx, 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, bcpcol->column_name, bcpcol->column_namelen) + strlen(column_type) + ((first) ? 2u : 4u)) { char *temp = malloc(2 * clause->cb); if (!temp) { tdserror(tds->tds_ctx, 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), bcpcol->column_name, bcpcol->column_namelen); strcat(clause->pb, " "); strcat(clause->pb, column_type); return TDS_SUCCEED; } static int tds_bcp_start_insert_stmt(TDSSOCKET * tds, TDSBCPINFO * bcpinfo) { char *query; if (IS_TDS7_PLUS(tds)) { 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", 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", bcpinfo->tablename) < 0) return TDS_FAIL; } /* save the statement for later... */ bcpinfo->insert_stmt = query; return TDS_SUCCEED; } /** * \return TDS_SUCCEED or TDS_FAIL. */ int tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset) { TDSCOLUMN *bindcol; static const TDS_TINYINT textptr_size = 16; static const unsigned char GEN_NULL = 0x00; static const unsigned char CHARBIN_NULL[] = { 0xff, 0xff }; static const unsigned char textptr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static const unsigned char timestamp[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char *record; TDS_INT old_record_size; int i; tdsdump_log(TDS_DBG_FUNC, "tds_bcp_send_bcp_record(%p, %p, %p, %p, %d)\n", tds, bcpinfo, get_col_data, null_error, offset); record = bcpinfo->bindinfo->current_row; old_record_size = bcpinfo->bindinfo->row_size; if (IS_TDS7_PLUS(tds)) { TDS_TINYINT varint_1; for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { 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; } if ((get_col_data(bcpinfo, bindcol, offset)) != TDS_SUCCEED) { tdsdump_log(TDS_DBG_INFO1, "get_col_data (column %d) failed\n", i + 1); return TDS_FAIL; } 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); if (bindcol->bcp_column_data->is_null) { if (bindcol->column_nullable) { switch (bindcol->on_server.column_type) { case XSYBCHAR: case XSYBVARCHAR: case XSYBBINARY: case XSYBVARBINARY: case XSYBNCHAR: case XSYBNVARCHAR: memcpy(record, CHARBIN_NULL, 2); record +=2; break; default: *record = GEN_NULL; record++; break; } } else { /* No value or default value available and NULL not allowed. */ null_error(bcpinfo, i, offset); return TDS_FAIL; } } else { switch (bindcol->column_varint_size) { case 4: if (is_blob_type(bindcol->on_server.column_type)) { *record = textptr_size; record++; memcpy(record, textptr, 16); record += 16; memcpy(record, timestamp, 8); record += 8; } TDS_PUT_UA4LE(record, bindcol->bcp_column_data->datalen); record += 4; break; case 2: TDS_PUT_UA2LE(record, bindcol->bcp_column_data->datalen); record += 2; break; case 1: varint_1 = bindcol->bcp_column_data->datalen; if (is_numeric_type(bindcol->on_server.column_type)) { varint_1 = tds_numeric_bytes_per_prec[bindcol->column_prec]; tdsdump_log(TDS_DBG_INFO1, "numeric type prec = %d varint_1 = %d\n", bindcol->column_prec, varint_1); } else { varint_1 = bindcol->bcp_column_data->datalen; tdsdump_log(TDS_DBG_INFO1, "varint_1 = %d\n", varint_1); } *record = varint_1; record++; break; case 0: break; } tdsdump_log(TDS_DBG_INFO1, "new_record_size = %ld datalen = %d\n", (long int) (record - bcpinfo->bindinfo->current_row), bindcol->bcp_column_data->datalen); #if WORDS_BIGENDIAN tds_swap_datatype(tds_get_conversion_type(bindcol->column_type, bindcol->bcp_column_data->datalen), bindcol->bcp_column_data->data); #endif if (is_numeric_type(bindcol->on_server.column_type)) { TDS_NUMERIC *num = (TDS_NUMERIC *) bindcol->bcp_column_data->data; int size; tdsdump_log(TDS_DBG_INFO1, "numeric type prec = %d\n", num->precision); if (IS_TDS7_PLUS(tds)) tds_swap_numeric(num); size = tds_numeric_bytes_per_prec[num->precision]; memcpy(record, num->array, size); record += size; } else { memcpy(record, bindcol->bcp_column_data->data, bindcol->bcp_column_data->datalen); record += bindcol->bcp_column_data->datalen; } } tdsdump_log(TDS_DBG_INFO1, "old_record_size = %d new size = %ld\n", old_record_size, (long int) (record - bcpinfo->bindinfo->current_row)); } tds_put_byte(tds, TDS_ROW_TOKEN); /* 0xd1 */ tds_put_n(tds, bcpinfo->bindinfo->current_row, record - bcpinfo->bindinfo->current_row); } /* IS_TDS7_PLUS */ else { int row_pos; int row_sz_pos; TDS_SMALLINT row_size; int blob_cols = 0; int var_cols_written = 0; 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; if ((row_pos = tds_bcp_add_fixed_columns(bcpinfo, get_col_data, null_error, offset, record, row_pos)) == TDS_FAIL) return TDS_FAIL; row_sz_pos = row_pos; /* potential variable columns to write */ if (bcpinfo->var_cols) { if ((row_pos = tds_bcp_add_variable_columns(bcpinfo, get_col_data, null_error, offset, record, row_pos, &var_cols_written)) == TDS_FAIL) return TDS_FAIL; } row_size = row_pos; if (var_cols_written) { memcpy(&record[row_sz_pos], &row_size, sizeof(row_size)); record[0] = var_cols_written; } tdsdump_log(TDS_DBG_INFO1, "old_record_size = %d new size = %d \n", old_record_size, row_size); tds_put_smallint(tds, row_size); tds_put_n(tds, record, row_size); /* 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)) { if ((get_col_data(bcpinfo, bindcol, offset)) != TDS_SUCCEED) { return TDS_FAIL; } /* 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++; } } } return TDS_SUCCEED; } /** * Add fixed size columns to the row */ 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) { TDS_NUMERIC *num; int row_pos = start; TDSCOLUMN *bcpcol; int cpbytes; int i, j; assert(bcpinfo); assert(rowbuffer); tdsdump_log(TDS_DBG_FUNC, "tds_bcp_add_fixed_columns(%p, %p, %p, %d, %p, %d)\n", bcpinfo, get_col_data, null_error, 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)) { tdsdump_log(TDS_DBG_FUNC, "tds_bcp_add_fixed_columns column %d is a fixed column\n", i + 1); if ((get_col_data(bcpinfo, bcpcol, offset)) != TDS_SUCCEED) { tdsdump_log(TDS_DBG_INFO1, "get_col_data (column %d) failed\n", i + 1); return TDS_FAIL; } if (bcpcol->bcp_column_data->is_null) { /* No value or default value available and NULL not allowed. */ null_error(bcpinfo, i, offset); return TDS_FAIL; } 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 { 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 */ 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 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 TDS_FAIL. */ 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_SMALLINT offsets[256]; int i, row_pos; 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++) { 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) { tdsdump_log(TDS_DBG_FUNC, "%4d %8d %8d %8d\n", i, ncols, row_pos, cpbytes); if ((get_col_data(bcpinfo, bcpcol, offset)) != TDS_SUCCEED) return TDS_FAIL; /* If it's a NOT NULL column, and we have no data, throw an error. */ 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 TDS_FAIL; } /* 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 *padj = rowbuffer + row_pos; TDS_UCHAR *poff = offsets[ncols] > 0xFF? padj + ncols + 1 : padj; *padj++ = 1 + ncols; *poff++ = 1 + ncols; for (i=0; i <= ncols; i++) { padj[i] = offsets[ncols-i] >> 8; poff[i] = offsets[ncols-i] & 0xFF; } row_pos = (int)(poff + ncols + 1 - 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; } /** * \return TDS_SUCCEED or TDS_FAIL. */ static int 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); /* * Deep joy! For TDS 8 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++) { 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)) 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); switch (bcpcol->column_varint_size) { case 4: tds_put_int(tds, bcpcol->column_size); break; case 2: tds_put_smallint(tds, bcpcol->column_size); break; case 1: tds_put_byte(tds, bcpcol->column_size); break; case 0: break; default: break; } if (is_numeric_type(bcpcol->on_server.column_type)) { tds_put_byte(tds, bcpcol->column_prec); tds_put_byte(tds, bcpcol->column_scale); } if (IS_TDS71_PLUS(tds) && is_collate_type(bcpcol->on_server.column_type)) { tds_put_n(tds, bcpcol->column_collation, 5); } if (is_blob_type(bcpcol->on_server.column_type)) { /* FIXME strlen return len in bytes not in characters required here */ TDS_PUT_SMALLINT(tds, strlen(bcpinfo->tablename)); tds_put_string(tds, bcpinfo->tablename, (int)strlen(bcpinfo->tablename)); } /* FIXME support multibyte string */ tds_put_byte(tds, bcpcol->column_namelen); tds_put_string(tds, bcpcol->column_name, bcpcol->column_namelen); } return TDS_SUCCEED; } int tds_bcp_done(TDSSOCKET *tds, int *rows_copied) { tdsdump_log(TDS_DBG_FUNC, "tds_bcp_done(%p, %p)\n", tds, rows_copied); /* TODO check proper tds state */ tds_flush_packet(tds); tds_set_state(tds, TDS_PENDING); if (tds_process_simple_query(tds) != TDS_SUCCEED) return TDS_FAIL; if (rows_copied) *rows_copied = tds->rows_affected; return TDS_SUCCEED; } int tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo) { tdsdump_log(TDS_DBG_FUNC, "tds_bcp_start(%p, %p)\n", tds, bcpinfo); tds_submit_query(tds, bcpinfo->insert_stmt); /* * In TDS 5 we get the column information as a result set from the "insert bulk" command. * We're going to ignore it. */ if (tds_process_simple_query(tds) != TDS_SUCCEED) return TDS_FAIL; /* TODO problem with thread safety */ tds->out_flag = TDS_BULK; tds_set_state(tds, TDS_QUERYING); if (IS_TDS7_PLUS(tds)) tds7_bcp_send_colmetadata(tds, bcpinfo); return TDS_SUCCEED; } static void tds_bcp_row_free(TDSRESULTINFO* result, unsigned char *row) { result->row_size = 0; TDS_ZERO_FREE(result->current_row); } int 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; tdsdump_log(TDS_DBG_FUNC, "tds_bcp_start_copy_in(%p, %p)\n", tds, bcpinfo); if (tds_bcp_start_insert_stmt(tds, bcpinfo) == TDS_FAIL) return TDS_FAIL; if (tds_bcp_start(tds, bcpinfo) != TDS_SUCCEED) { /* TODO, in CTLib was _ctclient_msg(blkdesc->con, "blk_rowxfer", 2, 5, 1, 140, ""); */ return TDS_FAIL; } /* * Work out the number of "variable" columns. These are either nullable or of * varying length type e.g. varchar. */ bcpinfo->var_cols = 0; if (IS_TDS50(tds)) { 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) { bcpinfo->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 ) + (bcpinfo->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) { /* FIXME remove memory leak */ bcpinfo->bindinfo->current_row = realloc(bcpinfo->bindinfo->current_row, bcp_record_size); bcpinfo->bindinfo->row_free = tds_bcp_row_free; if (bcpinfo->bindinfo->current_row == NULL) { tdsdump_log(TDS_DBG_FUNC, "could not realloc current_row\n"); return TDS_FAIL; } bcpinfo->bindinfo->row_size = bcp_record_size; } } if (IS_TDS7_PLUS(tds)) { for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { 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; } switch (bcpcol->column_varint_size) { case 4: if (is_blob_type(bcpcol->column_type)) { bcp_record_size += 25; } bcp_record_size += 4; break; case 2: bcp_record_size +=2; break; case 1: bcp_record_size++; break; case 0: break; } if (is_numeric_type(bcpcol->column_type)) { bcp_record_size += tds_numeric_bytes_per_prec[bcpcol->column_prec]; } else { bcp_record_size += bcpcol->column_size; } } 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) { bcpinfo->bindinfo->current_row = realloc(bcpinfo->bindinfo->current_row, bcp_record_size); bcpinfo->bindinfo->row_free = tds_bcp_row_free; if (bcpinfo->bindinfo->current_row == NULL) { tdsdump_log(TDS_DBG_FUNC, "could not realloc current_row\n"); return TDS_FAIL; } bcpinfo->bindinfo->row_size = bcp_record_size; } } return TDS_SUCCEED; } int tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size) { if (tds_submit_queryf(tds, "writetext bulk %s 0x%s timestamp = 0x%s%s", objname, textptr, timestamp, with_log ? " with log" : "") != TDS_SUCCEED) { return TDS_FAIL; } /* FIXME in this case processing all results can bring state to IDLE... not threading safe */ /* read the end token */ if (tds_process_simple_query(tds) != TDS_SUCCEED) return TDS_FAIL; /* FIXME better transiction state */ tds->out_flag = TDS_BULK; if (tds_set_state(tds, TDS_QUERYING) != TDS_QUERYING) return TDS_FAIL; tds_put_int(tds, size); return TDS_SUCCEED; } int tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size) { /* TODO check state */ if (tds->out_flag != TDS_BULK) return TDS_FAIL; /* TODO check size letft */ tds_put_n(tds, text, size); return TDS_SUCCEED; } int tds_writetext_end(TDSSOCKET *tds) { /* TODO check state */ if (tds->out_flag != TDS_BULK) return TDS_FAIL; tds_flush_packet(tds); tds_set_state(tds, TDS_PENDING); return TDS_SUCCEED; } freetds-0.91/src/tds/win_mutex.c100664 001750 000144 00000003043 11335225161 0012342/* 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. */ #if HAVE_CONFIG_H #include #endif #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef _WIN32 #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds.h" #include "tdsthread.h" TDS_RCSID(var, "$Id: win_mutex.c,v 1.2 2010/02/12 10:16:17 freddy77 Exp $"); #include "ptw32_MCS_lock.c" void tds_win_mutex_lock(tds_win_mutex_t * 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); } #endif freetds-0.91/src/tds/challenge.c100644 001750 000144 00000051756 11550671702 0012266/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 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. */ #if HAVE_CONFIG_H #include #endif #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 "tds.h" #include "tdsbytes.h" #include "tdsstring.h" #include "md4.h" #include "md5.h" #include "hmac_md5.h" #include "des.h" #include "tdsiconv.h" #if defined(HAVE_OPENSSL) #include #endif #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: challenge.c,v 1.47.2.1 2011/04/11 13:40:45 freddy77 Exp $"); /** * \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 */ #ifndef offsetof # define offsetof(st, m) \ ((size_t) ( (char *)&((st *)(0))->m - (char *)0 )) #endif 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 int tds_answer_challenge(TDSSOCKET * tds, TDSCONNECTION * connection, 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; const TDSICONV * char_conv = tds->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 void generate_random_buffer(unsigned char *out, int len) { int i; #if 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); } static int 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_SUCCEED; } static int 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]; int res; user_name = tds_dstr_cstr(&tds->connection->user_name); user_name_len = strlen(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 = malloc(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 int tds_answer_challenge_ntlmv2(TDSSOCKET * tds, TDSCONNECTION * connection, const unsigned char *challenge, TDS_UINT * flags, const unsigned char *names_blob, TDS_INT names_blob_len, TDSANSWER * answer, unsigned char **ntlm_v2_response) { int res; const char *passwd = tds_dstr_cstr(&connection->password); /* NTLMv2 */ unsigned char *lm_v2_response; unsigned char ntlm_v2_hash[16]; const names_blob_prefix_t *names_blob_prefix; res = make_ntlm_v2_hash(tds, passwd, ntlm_v2_hash); if (res != TDS_SUCCEED) 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_SUCCEED; } /** * 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 int tds_answer_challenge(TDSSOCKET * tds, TDSCONNECTION * connection, 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(&connection->password); DES_KEY ks; unsigned char hash[24], ntlm2_challenge[16]; int res; memset(answer, 0, sizeof(TDSANSWER)); if (connection->use_ntlmv2) { return tds_answer_challenge_ntlmv2(tds, connection, challenge, flags, names_blob, names_blob_len, answer, ntlm_v2_response); } else if ((*flags & 0x80000) != 0) { /* NTLM2 */ MD5_CTX md5_ctx; generate_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 { /* LM */ #if TDS_USE_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)); #endif } *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 int 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, password_len, domain_len; int rc; unsigned char *ntlm_v2_response = NULL; unsigned int ntlm_response_len = 24; const unsigned int lm_response_len = 24; TDSCONNECTION *connection = tds->connection; /* check connection */ if (!connection) return TDS_FAIL; /* parse a bit of config */ user_name = tds_dstr_cstr(&connection->user_name); user_name_len = user_name ? strlen(user_name) : 0; host_name_len = tds_dstr_len(&connection->client_host_name); password_len = tds_dstr_len(&connection->password); /* 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, connection, challenge, &flags, names_blob, names_blob_len, &answer, &ntlm_v2_response); if (rc != TDS_SUCCEED) 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(&connection->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(&connection->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 int tds_ntlm_free(TDSSOCKET * tds, TDSAUTHENTICATION * tds_auth) { TDSNTLMAUTH *auth = (TDSNTLMAUTH *) tds_auth; free(auth->tds_auth.packet); free(auth); return TDS_SUCCEED; } 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, time_t t) { #define TIME_FIXUP_CONSTANT (((TDS_UINT8) 134774U) * 86400U) TDS_UINT8 t2; if (t == (time_t) - 1) { *nt = (TDS_UINT8) - ((TDS_INT8) 1); return; } if (t == 0) { *nt = 0; return; } t2 = t; t2 += TIME_FIXUP_CONSTANT; t2 *= 1000 * 1000 * 10; *nt = t2; } static void fill_names_blob_prefix(names_blob_prefix_t * prefix) { TDS_UINT8 nttime = 0; /* TODO use more precision, not only seconds */ unix_to_nt_time(&nttime, time(NULL)); prefix->response_type = 0x01; prefix->max_response_type = 0x01; prefix->reserved1 = 0x0000; prefix->reserved2 = 0x00000000; #ifdef WORDS_BIGENDIAN tds_swap_bytes((unsigned char *) &nttime, 8); #endif prefix->timestamp = nttime; generate_random_buffer(prefix->challenge, sizeof(prefix->challenge)); prefix->unknown = 0x00000000; } static int 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 domain_len; int data_block_offset; int target_info_len = 0; int target_info_offset; int names_blob_len; unsigned char *names_blob; int 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; domain_len = tds_get_smallint(tds); /* domain len */ 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) { /* 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 = offsetof(names_blob_prefix_t, target_info) + target_info_len + 4; /* read Target Info */ names_blob = (unsigned char *) calloc(names_blob_len, 1); if (!names_blob) return TDS_FAIL; fill_names_blob_prefix((names_blob_prefix_t *) names_blob); tds_get_n(tds, names_blob + offsetof(names_blob_prefix_t, target_info), target_info_len); where += target_info_len; } else { names_blob = NULL; names_blob_len = 0; } /* 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->connection) return NULL; user_name = tds_dstr_cstr(&tds->connection->user_name); host_name_len = (int)tds_dstr_len(&tds->connection->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 = (struct tds_ntlm_auth *) calloc(1, sizeof(struct tds_ntlm_auth)); 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 = malloc(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->connection->client_host_name), host_name_len); memcpy(packet + 40 + host_name_len, domain, domain_len); return (TDSAUTHENTICATION *) auth; } /** @} */ freetds-0.91/src/tds/md4.c100664 001750 000144 00000015430 11134166716 0011021/* * 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) */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds.h" #include "md4.h" TDS_RCSID(var, "$Id: md4.c,v 1.8 2009/01/16 20:27:58 jklowden Exp $"); #undef word32 #define word32 TDS_UINT #ifndef WORDS_BIGENDIAN #define byteReverse(buf, len) /* Nothing */ #else static void byteReverse(unsigned char *buf, unsigned longs); /* * Note: this code is harmless on little-endian machines. */ static void byteReverse(unsigned char *buf, unsigned longs) { word32 t; do { t = (word32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); *(word32 *) buf = t; buf += 4; } while (--longs); } #endif #define rotl32(x,n) (((x) << ((word32)(n))) | ((x) >> (32 - (word32)(n)))) /* * 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->bits[0] = 0; ctx->bits[1] = 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; /* Update bitcount */ t = ctx->bits[0]; if ((ctx->bits[0] = t + ((word32) len << 3)) < t) ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += (TDS_UINT)len >> 29; t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* 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->bits[0] >> 3) & 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] = ctx->bits[0]; ((word32 *) ctx->in)[15] = ctx->bits[1]; 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 */ 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; } freetds-0.91/src/tds/md5.c100664 001750 000144 00000020252 11134166716 0011020/* * 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) */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds.h" #include "md5.h" TDS_RCSID(var, "$Id: md5.c,v 1.3 2009/01/16 20:27:58 jklowden Exp $"); #undef word32 #define word32 TDS_UINT #ifndef WORDS_BIGENDIAN #define byteReverse(buf, len) /* Nothing */ #else static void byteReverse(unsigned char *buf, unsigned longs); /* * Note: this code is harmless on little-endian machines. */ static void byteReverse(unsigned char *buf, unsigned longs) { word32 t; do { t = (word32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); *(word32 *) buf = t; buf += 4; } while (--longs); } #endif /* * 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->bits[0] = 0; ctx->bits[1] = 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; /* Update bitcount */ t = ctx->bits[0]; if ((ctx->bits[0] = t + ((word32) len << 3)) < t) ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += (TDS_UINT)len >> 29; t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* 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->bits[0] >> 3) & 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] = ctx->bits[0]; ((word32 *) ctx->in)[15] = ctx->bits[1]; 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. */ 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; } freetds-0.91/src/tds/des.c100664 001750 000144 00000040224 10263224345 0011102/* * 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tds.h" #include "des.h" TDS_RCSID(var, "$Id: des.c,v 1.15 2005/07/07 13:06:45 freddy77 Exp $"); 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); 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); } } #define byteswap32(x) (TDS_UINT) (((x) & 0xff000000) >> 24 | \ ((x) & 0x00ff0000) >> 8 | \ ((x) & 0x0000ff00) << 8 | \ ((x) & 0x000000ff) << 24) /* 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}, }; /* 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 }; /* 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, 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 */ #ifndef WORDS_BIGENDIAN left = byteswap32(work[0]); right = byteswap32(work[1]); #else left = work[0]; right = work[1]; #endif /* 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 */ #ifndef WORDS_BIGENDIAN work[1] = byteswap32(left); work[0] = byteswap32(right); #else work[0] = right; work[1] = left; #endif 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 */ #ifndef WORDS_BIGENDIAN right = byteswap32(work[0]); left = byteswap32(work[1]); #else right = work[0]; left = work[1]; #endif /* 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); #ifndef WORDS_BIGENDIAN work[0] = byteswap32(left); work[1] = byteswap32(right); #else work[0] = left; work[1] = right; #endif 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 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) { char pbox[32]; int p, i, s, j, rowcol; TDS_UINT val; /* Compute pbox, the inverse of p32i. * This is easier to work with */ for (p = 0; p < 32; p++) { for (i = 0; i < 32; i++) { if (p32i[i] - 1 == p) { pbox[p] = i; break; } } } 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; } } } /* ECB MODE */ int tds_des_ecb_encrypt(const void *plaintext, int len, DES_KEY * akey, des_cblock 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-0.91/src/tds/gssapi.c100644 001750 000144 00000020232 11623070342 0011605/* 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. */ #if HAVE_CONFIG_H #include #endif #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 */ #ifdef ENABLE_KRB5 #include #include "tds.h" #include "tdsstring.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: gssapi.c,v 1.11.2.2 2011/08/12 16:29:36 freddy77 Exp $"); /** * \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 int tds_gss_free(TDSSOCKET * tds, 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_SUCCEED; } static int tds_gss_continue(TDSSOCKET * tds, struct tds_gss_auth *auth, gss_buffer_desc *token_ptr); static int tds_gss_handle_next(TDSSOCKET * tds, struct tds_authentication * auth, size_t len) { int 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 = (char* ) malloc(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 (res != TDS_SUCCEED) return TDS_FAIL; 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_SUCCEED; } /** * 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, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01" }; const char *server_name; /* Storage for reentrant getaddrby* calls */ char buffer[4096]; struct tds_gss_auth *auth = (struct tds_gss_auth *) calloc(1, sizeof(struct tds_gss_auth)); if (!auth || !tds->connection) 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->connection->server_host_name); if (strchr(server_name, '.') == NULL) { struct hostent result; int h_errnop; struct hostent *host = tds_gethostbyname_r(server_name, &result, buffer, sizeof(buffer), &h_errnop); if (host && strchr(host->h_name, '.') != NULL) server_name = host->h_name; } if (tds_dstr_isempty(&tds->connection->server_realm_name)) { if (asprintf(&auth->sname, "MSSQLSvc/%s:%d", server_name, tds->connection->port) < 0) { tds_gss_free(tds, (TDSAUTHENTICATION *) auth); return NULL; } } else { if (asprintf(&auth->sname, "MSSQLSvc/%s:%d@%s", server_name, tds->connection->port, tds_dstr_cstr(&tds->connection->server_realm_name)) < 0) { tds_gss_free(tds, (TDSAUTHENTICATION *) auth); return NULL; } } tdsdump_log(TDS_DBG_NETWORK, "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); if (maj_stat != GSS_S_COMPLETE || tds_gss_continue(tds, auth, GSS_C_NO_BUFFER) == TDS_FAIL) { tds_gss_free(tds, (TDSAUTHENTICATION *) auth); return NULL; } return (TDSAUTHENTICATION *) auth; } static int 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; OM_uint32 ret_flags; int gssapi_flags; 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 may ask for delegation based on config in the tds.conf and other conf files */ /* We always want to ask for the mutual, replay, and integ flags */ gssapi_flags = GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_INTEG_FLAG; if (tds->connection->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_DELEG_FLAG GSS_C_MUTUAL_FLAG ?? */ GSS_C_NULL_OID, gssapi_flags, 0, NULL, /* no channel bindings */ token_ptr, NULL, /* ignore mech type */ &send_tok, &ret_flags, NULL); /* ignore time_rec */ auth->last_stat = maj_stat; if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED) { gss_release_buffer(&min_stat, &send_tok); return TDS_FAIL; } /* if (maj_stat == GSS_S_CONTINUE_NEEDED) { if (recv_token(s, &token_flags, &recv_tok) < 0) { (void) gss_release_name(&min_stat, &target_name); return -1; } token_ptr = &recv_tok; } */ auth->tds_auth.packet = (TDS_UCHAR *) send_tok.value; auth->tds_auth.packet_len = send_tok.length; return TDS_SUCCEED; } #endif /** @} */ freetds-0.91/src/tds/hmac_md5.c100664 001750 000144 00000003704 11321726301 0012001/* 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. */ /* $Id: hmac_md5.c,v 1.2 2010/01/08 22:08:01 jklowden Exp $ */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include "tds.h" #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-0.91/src/tds/sspi.c100664 001750 000144 00000016476 11466265714 0011334/* 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. */ #if HAVE_CONFIG_H #include #endif /* 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 "tds.h" #include "tdsthread.h" #include "tdsstring.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: sspi.c,v 1.9 2010/11/09 15:42:04 freddy77 Exp $"); /** * \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_DEFINE(sec_mutex); static int tds_init_secdll(void) { int res = 0; if (sec_fn) return 1; TDS_MUTEX_LOCK(&sec_mutex); for (;;) { if (!secdll) { OSVERSIONINFO osver; memset(&osver, 0, sizeof(osver)); osver.dwOSVersionInfoSize = sizeof(osver); if (!GetVersionEx(&osver)) break; if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT && osver.dwMajorVersion <= 4) secdll = LoadLibrary("security.dll"); else 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(TDSSOCKET * tds, struct tds_authentication * tds_auth) { TDSSSPIAUTH *auth = (TDSSSPIAUTH *) tds_auth; sec_fn->DeleteSecurityContext(&auth->cred_ctx); sec_fn->FreeCredentialsHandle(&auth->cred); free(auth->tds_auth.packet); free(auth->sname); free(auth); return TDS_SUCCEED; } enum { NTLMBUF_LEN = 4096 }; 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 < 32 || len > NTLMBUF_LEN) return TDS_FAIL; auth_buf = (TDS_UCHAR *) malloc(len); if (!auth_buf) return TDS_FAIL; tds_get_n(tds, auth_buf, (int)len); 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 = auth->tds_auth.packet; out_buf.cbBuffer = NTLMBUF_LEN; status = sec_fn->InitializeSecurityContext(&auth->cred, &auth->cred_ctx, auth->sname, ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONNECTION, 0, SECURITY_NETWORK_DREP, &in_desc, 0, &auth->cred_ctx, &out_desc, &attrs, &ts); free(auth_buf); if (status != SEC_E_OK) return TDS_FAIL; if (out_buf.cbBuffer == 0) return TDS_SUCCEED; 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; TDSSSPIAUTH *auth; TDSCONNECTION *connection = tds->connection; /* check connection */ if (!connection) return NULL; if (!tds_init_secdll()) return NULL; /* parse username/password informations */ memset(&identity, 0, sizeof(identity)); user_name = tds_dstr_cstr(&connection->user_name); if ((p = strchr(user_name, '\\')) != NULL) { identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; identity.Password = (void *) tds_dstr_cstr(&connection->password); identity.PasswordLength = tds_dstr_len(&connection->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 = (TDSSSPIAUTH *) calloc(1, sizeof(TDSSSPIAUTH)); if (!auth || !tds->connection) 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; } /* allocate buffer */ auth->tds_auth.packet = (TDS_UCHAR *) malloc(NTLMBUF_LEN); if (!auth->tds_auth.packet) { sec_fn->FreeCredentialsHandle(&auth->cred); free(auth); return NULL; } desc.ulVersion = SECBUFFER_VERSION; desc.cBuffers = 1; desc.pBuffers = &buf; buf.cbBuffer = NTLMBUF_LEN; buf.BufferType = SECBUFFER_TOKEN; buf.pvBuffer = auth->tds_auth.packet; /* build SPN */ server_name = tds_dstr_cstr(&connection->server_host_name); if (strchr(server_name, '.') == NULL) { struct hostent *host = gethostbyname(server_name); if (host && strchr(host->h_name, '.') != NULL) server_name = host->h_name; } if (strchr(server_name, '.') != NULL) { if (asprintf(&auth->sname, "MSSQLSvc/%s:%d", server_name, connection->port) < 0) { free(auth->tds_auth.packet); sec_fn->FreeCredentialsHandle(&auth->cred); free(auth); return NULL; } tdsdump_log(TDS_DBG_NETWORK, "kerberos name %s\n", auth->sname); } status = sec_fn->InitializeSecurityContext(&auth->cred, NULL, auth->sname, ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONNECTION, 0, SECURITY_NETWORK_DREP, NULL, 0, &auth->cred_ctx, &desc, &attrs, &ts); if (status == SEC_I_COMPLETE_AND_CONTINUE || status == SEC_I_CONTINUE_NEEDED) { sec_fn->CompleteAuthToken(&auth->cred_ctx, &desc); } else if(status != SEC_E_OK) { free(auth->sname); free(auth->tds_auth.packet); sec_fn->FreeCredentialsHandle(&auth->cred); free(auth); return NULL; } auth->tds_auth.packet_len = buf.cbBuffer; return &auth->tds_auth; } #endif /* HAVE_SSPI */ /** @} */ freetds-0.91/src/tds/TDS.vcproj100775 001750 000144 00000020502 11326010000 0012020 freetds-0.91/src/tds/ptw32_MCS_lock.c100664 001750 000144 00000014727 11474462021 0013031/* * 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-0.91/src/tds/unittests/Makefile.am100664 001750 000144 00000002745 11507072544 0014273# $Id: Makefile.am,v 1.28 2010/12/30 12:04:52 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) # 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 numeric_SOURCES = numeric.c iconv_fread_SOURCES = iconv_fread.c toodynamic_SOURCES = toodynamic.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include -I$(srcdir)/.. -I../ 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 $(LIBICONV) @NETWORK_LIBS@ CLEANFILES = tdsdump.out freetds-0.91/src/tds/unittests/Makefile.in100664 001750 000144 00000063324 11623070620 0014274# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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/unittests DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_convert_OBJECTS = convert.$(OBJEXT) convert_OBJECTS = $(am_convert_OBJECTS) convert_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_numeric_OBJECTS = numeric.$(OBJEXT) numeric_OBJECTS = $(am_numeric_OBJECTS) numeric_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) 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(convert_SOURCES) $(dataread_SOURCES) $(dynamic1_SOURCES) \ $(iconv_fread_SOURCES) $(numeric_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 = $(convert_SOURCES) $(dataread_SOURCES) \ $(dynamic1_SOURCES) $(iconv_fread_SOURCES) $(numeric_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) ETAGS = etags CTAGS = ctags am__tty_colors = \ red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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 $(LIBICONV) @NETWORK_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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.28 2010/12/30 12:04:52 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) # 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 numeric_SOURCES = numeric.c iconv_fread_SOURCES = iconv_fread.c toodynamic_SOURCES = toodynamic.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include -I$(srcdir)/.. -I../ @MINGW32_FALSE@AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs @MINGW32_TRUE@AM_LDFLAGS = -no-fast-install CLEANFILES = tdsdump.out 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/tds/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/tds/unittests/Makefile .PRECIOUS: 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 convert$(EXEEXT): $(convert_OBJECTS) $(convert_DEPENDENCIES) @rm -f convert$(EXEEXT) $(LINK) $(convert_OBJECTS) $(convert_LDADD) $(LIBS) dataread$(EXEEXT): $(dataread_OBJECTS) $(dataread_DEPENDENCIES) @rm -f dataread$(EXEEXT) $(LINK) $(dataread_OBJECTS) $(dataread_LDADD) $(LIBS) dynamic1$(EXEEXT): $(dynamic1_OBJECTS) $(dynamic1_DEPENDENCIES) @rm -f dynamic1$(EXEEXT) $(LINK) $(dynamic1_OBJECTS) $(dynamic1_LDADD) $(LIBS) iconv_fread$(EXEEXT): $(iconv_fread_OBJECTS) $(iconv_fread_DEPENDENCIES) @rm -f iconv_fread$(EXEEXT) $(LINK) $(iconv_fread_OBJECTS) $(iconv_fread_LDADD) $(LIBS) numeric$(EXEEXT): $(numeric_OBJECTS) $(numeric_DEPENDENCIES) @rm -f numeric$(EXEEXT) $(LINK) $(numeric_OBJECTS) $(numeric_LDADD) $(LIBS) t0001$(EXEEXT): $(t0001_OBJECTS) $(t0001_DEPENDENCIES) @rm -f t0001$(EXEEXT) $(LINK) $(t0001_OBJECTS) $(t0001_LDADD) $(LIBS) t0002$(EXEEXT): $(t0002_OBJECTS) $(t0002_DEPENDENCIES) @rm -f t0002$(EXEEXT) $(LINK) $(t0002_OBJECTS) $(t0002_LDADD) $(LIBS) t0003$(EXEEXT): $(t0003_OBJECTS) $(t0003_DEPENDENCIES) @rm -f t0003$(EXEEXT) $(LINK) $(t0003_OBJECTS) $(t0003_LDADD) $(LIBS) t0004$(EXEEXT): $(t0004_OBJECTS) $(t0004_DEPENDENCIES) @rm -f t0004$(EXEEXT) $(LINK) $(t0004_OBJECTS) $(t0004_LDADD) $(LIBS) t0005$(EXEEXT): $(t0005_OBJECTS) $(t0005_DEPENDENCIES) @rm -f t0005$(EXEEXT) $(LINK) $(t0005_OBJECTS) $(t0005_LDADD) $(LIBS) t0006$(EXEEXT): $(t0006_OBJECTS) $(t0006_DEPENDENCIES) @rm -f t0006$(EXEEXT) $(LINK) $(t0006_OBJECTS) $(t0006_LDADD) $(LIBS) t0007$(EXEEXT): $(t0007_OBJECTS) $(t0007_DEPENDENCIES) @rm -f t0007$(EXEEXT) $(LINK) $(t0007_OBJECTS) $(t0007_LDADD) $(LIBS) t0008$(EXEEXT): $(t0008_OBJECTS) $(t0008_DEPENDENCIES) @rm -f t0008$(EXEEXT) $(LINK) $(t0008_OBJECTS) $(t0008_LDADD) $(LIBS) toodynamic$(EXEEXT): $(toodynamic_OBJECTS) $(toodynamic_DEPENDENCIES) @rm -f toodynamic$(EXEEXT) $(LINK) $(toodynamic_OBJECTS) $(toodynamic_LDADD) $(LIBS) utf8_1$(EXEEXT): $(utf8_1_OBJECTS) $(utf8_1_DEPENDENCIES) @rm -f utf8_1$(EXEEXT) $(LINK) $(utf8_1_OBJECTS) $(utf8_1_LDADD) $(LIBS) utf8_2$(EXEEXT): $(utf8_2_OBJECTS) $(utf8_2_DEPENDENCIES) @rm -f utf8_2$(EXEEXT) $(LINK) $(utf8_2_OBJECTS) $(utf8_2_LDADD) $(LIBS) utf8_3$(EXEEXT): $(utf8_3_OBJECTS) $(utf8_3_DEPENDENCIES) @rm -f utf8_3$(EXEEXT) $(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)/common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert.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)/numeric.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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ echo "$$grn$$dashes"; \ else \ echo "$$red$$dashes"; \ fi; \ echo "$$banner"; \ test -z "$$skipped" || echo "$$skipped"; \ test -z "$$report" || echo "$$report"; \ echo "$$dashes$$std"; \ test "$$failed" -eq 0; \ else :; fi 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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-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 all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool ctags \ 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 uninstall uninstall-am # 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-0.91/src/tds/unittests/convert.c100664 001750 000144 00000017334 11143044256 0014056/* 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" #if HAVE_SYS_TIME_H #include #endif static char software_version[] = "$Id: convert.c,v 1.26 2009/02/06 14:26:54 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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) { /* the conversion pair matrix */ typedef struct { int srctype; int desttype; int yn; } ANSWER; const static ANSWER answers[] = { # include "tds_willconvert.h" }; /* 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_TINYINT tds_tinyint; TDS_SMALLINT tds_smallint; TDS_INT tds_int; TDS_INT8 tds_int8; 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); } 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 < sizeof(answers) / sizeof(ANSWER); i++) { if (!answers[i].yn) continue; /* don't attempt nonconvertible types */ if (answers[i].srctype == answers[i].desttype) continue; /* don't attempt same types */ cr.n.precision = 8; cr.n.scale = 2; switch (answers[i].srctype) { case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: switch (answers[i].desttype) { case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case SYBDATETIME: case SYBDATETIME4: src = "Jan 1, 1999"; break; case SYBBINARY: case SYBIMAGE: src = "0xbeef"; break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: 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: 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 SYBFLT8: tds_float = 3.14159; src = (char *) &tds_float; srclen = sizeof(tds_float); break; case SYBREAL: 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 SYBUNIQUE: src = (char *) &tds_unique; srclen = sizeof(tds_unique); break; /***** not defined yet case SYBBOUNDARY: case SYBSENSITIVITY: fprintf (stderr, "type %d not supported\n", answers[i].srctype ); continue; break; *****/ default: fprintf(stderr, "no such type %d\n", answers[i].srctype); return -1; } /* * Now at last do the conversion */ result = tds_convert(ctx, answers[i].srctype, src, srclen, answers[i].desttype, &cr); free_convert(answers[i].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, answers[i].srctype, tds_prtype(answers[i].srctype), srclen, answers[i].desttype, tds_prtype(answers[i].desttype)); if (result != TDS_CONVERT_NOAVAIL) return result; } printf("converted %d (%s, %d bytes) : %d (%s, %d bytes).\n", answers[i].srctype, tds_prtype(answers[i].srctype), srclen, answers[i].desttype, tds_prtype(answers[i].desttype), result); /* * In the first iteration, start with varchar -> others. * By saving the output, we initialize subsequent inputs. */ switch (answers[i].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 SYBINT1: 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 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, answers[i].srctype, src, srclen, answers[i].desttype, &cr); free_convert(answers[i].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(answers[i].srctype), tds_prtype(answers[i].desttype)); } } tds_free_context(ctx); return g_result; } freetds-0.91/src/tds/unittests/dataread.c100664 001750 000144 00000014715 11207535204 0014142/* 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 #include static char software_version[] = "$Id: dataread.c,v 1.20 2009/05/28 16:23:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_SUCCEED || tds_process_simple_query(tds) != TDS_SUCCEED) { 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_SUCCEED) { fprintf(stderr, "tds_submit_query() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCEED) { 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_SUCCEED) { 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_SUCCEED && (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)) { 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_SUCCEED) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); exit(1); } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCEED) { 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_SUCCEED) { 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.23", NULL); test("FLOAT", "-49586.345", NULL); /* 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)) { 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); } try_tds_logout(login, tds, 0); return g_result; } freetds-0.91/src/tds/unittests/common.c100664 001750 000144 00000007342 11407073561 0013670#include "common.h" static char software_version[] = "$Id: common.c,v 1.30 2010/06/19 07:53:21 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_SUCCEED; } TDSCONTEXT *test_context = NULL; int try_tds_login(TDSLOGIN ** login, TDSSOCKET ** tds, const char *appname, int verbose) { TDSCONNECTION *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(); if (!*login) { fprintf(stderr, "tds_alloc_login() failed.\n"); return TDS_FAIL; } 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"); 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_SUCCEED) { if (connection) { tds_free_socket(*tds); *tds = NULL; tds_free_connection(connection); } fprintf(stderr, "tds_connect_and_login() failed\n"); return TDS_FAIL; } tds_free_connection(connection); return TDS_SUCCEED; } /* 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_free_socket(tds); tds_free_login(login); tds_free_context(test_context); test_context = NULL; return TDS_SUCCEED; } /* 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_SUCCEED) { 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_SUCCEED) { 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_SUCCEED; } freetds-0.91/src/tds/unittests/common.h100664 001750 000144 00000001673 11507072544 0013677#ifndef COMMON_h #define COMMON_h static char rcsid_common_h[] = "$Id: common.h,v 1.9 2010/12/30 12:04:52 freddy77 Exp $"; static void *no_unused_common_h_warn[] = { rcsid_common_h, no_unused_common_h_warn }; #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include 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-0.91/src/tds/unittests/dynamic1.c100664 001750 000144 00000012020 11134166717 0014075/* 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 char software_version[] = "$Id: dynamic1.c,v 1.19 2009/01/16 20:27:59 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]; curcol->column_type = SYBINTN; curcol->on_server.column_type = SYBINTN; curcol->column_size = sizeof(TDS_INT); curcol->on_server.column_size = sizeof(TDS_INT); curcol->column_varint_size = 1; curcol->column_cur_size = sizeof(TDS_INT); /* TODO test error */ tds_alloc_param_data(curcol); 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, 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_SUCCEED) fatal_error("tds_submit_execute() error"); if (discard_result(tds) != TDS_SUCCEED) 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_SUCCEED) 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_SUCCEED) 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_SUCCEED) fatal_error("tds_submit_prepare() error"); if (discard_result(tds) != TDS_SUCCEED) 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_SUCCEED) 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_SUCCEED) 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_SUCCEED) 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_SUCCEED) 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_SUCCEED) fatal_error("checking rows 3"); if (run_query(tds, "DROP TABLE #dynamic1") != TDS_SUCCEED) fatal_error("dropping table error"); 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_SUCCEED) { 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_SUCCEED; } freetds-0.91/src/tds/unittests/iconv_fread.c100664 001750 000144 00000004615 10722555725 0014665/* 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 */ #include /* test tds_iconv_fread */ static char software_version[] = "$Id: iconv_fread.c,v 1.4 2007/11/26 14:44:37 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char **argv) { iconv_t cd = tds_sys_iconv_open("ISO-8859-1", "UTF-8"); static const char out_file[] = "iconv_fread.out"; char buf[256]; int i; FILE *f; if (cd == (iconv_t) - 1) { fprintf(stderr, "Error creating conversion, giving up!\n"); return 0; } f = fopen(out_file, "w+b"); if (!f) { fprintf(stderr, "Error opening file!\n"); return 1; } for (i = 0; i < 32; ++i) { TDS_CHAR out[512]; size_t out_len = sizeof(out), res; const unsigned char x = 0x90; /* 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); fwrite(buf, 1, i+2, f); if (fseek(f, 0L, SEEK_SET)) { fprintf(stderr, "Error seeking!\n"); return 1; } /* convert it */ memset(out, 'x', sizeof(out)); res = tds_iconv_fread(cd, f, i+2, 0, out, &out_len); printf("res %u out_len %u\n", (unsigned int) res, (unsigned int) out_len); /* test */ memset(buf, 'a', i); buf[i] = 0x90; assert(res == 0); assert(sizeof(out) - out_len == i+1); assert(memcmp(out, buf, i+1) == 0); } fclose(f); unlink(out_file); tds_sys_iconv_close(cd); return 0; } freetds-0.91/src/tds/unittests/numeric.c100664 001750 000144 00000007450 11134166717 0014045/* 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 char software_version[] = "$Id: numeric.c,v 1.5 2009/01/16 20:27:59 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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-0.91/src/tds/unittests/t0001.c100664 001750 000144 00000012523 10540412176 0013135/* 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" static char software_version[] = "$Id: t0001.c,v 1.7 2006/12/15 03:20:30 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define TESTING_CAPABILITY 0 #if TESTING_CAPABILITY #include #include "enum_cap.h" static const unsigned char defaultcaps[] = { /* type, len, data, data, data, data, data, data, data, data, data (9 bytes) */ 0x01, 0x09, 0x00, 0x08, 0x06, 0x6D, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x68, 0x00, 0x00, 0x00 }; static const TDS_REQUEST_CAPABILITY request_capabilities[] = { /* no zero */ TDS_REQ_LANG, TDS_REQ_RPC, TDS_REQ_EVT, TDS_REQ_MSTMT, TDS_REQ_BCP, TDS_REQ_CURSOR, TDS_REQ_DYNF /* capability.data[8] */ , TDS_REQ_MSG, TDS_REQ_PARAM, TDS_REQ_DATA_INT1, TDS_REQ_DATA_INT2, TDS_REQ_DATA_INT4, TDS_REQ_DATA_BIT, TDS_REQ_DATA_CHAR, TDS_REQ_DATA_VCHAR /* capability.data[7] */ , TDS_REQ_DATA_BIN, TDS_REQ_DATA_VBIN, TDS_REQ_DATA_MNY8, TDS_REQ_DATA_MNY4, TDS_REQ_DATA_DATE8, TDS_REQ_DATA_DATE4, TDS_REQ_DATA_FLT4, TDS_REQ_DATA_FLT8 /* capability.data[6] */ , TDS_REQ_DATA_NUM, TDS_REQ_DATA_TEXT, TDS_REQ_DATA_IMAGE, TDS_REQ_DATA_DEC, TDS_REQ_DATA_LCHAR, TDS_REQ_DATA_LBIN, TDS_REQ_DATA_INTN, TDS_REQ_DATA_DATETIMEN /* capability.data[5] */ , TDS_REQ_DATA_MONEYN, TDS_REQ_CSR_PREV, TDS_REQ_CSR_FIRST, TDS_REQ_CSR_LAST, TDS_REQ_CSR_ABS, TDS_REQ_CSR_REL, TDS_REQ_CSR_MULTI /* capability.data[4] */ , TDS_REQ_CON_INBAND, TDS_REQ_PROTO_TEXT, TDS_REQ_PROTO_BULK, TDS_REQ_DATA_SENSITIVITY, TDS_REQ_DATA_BOUNDARY /* capability.data[3] */ , TDS_REQ_DATA_FLTN, TDS_REQ_DATA_BITN /* capability.data[2] */ , TDS_REQ_WIDETABLE /* capability.data[1] */ }; static const TDS_RESPONSE_CAPABILITY response_capabilities[] = { TDS_RES_CON_NOOOB , TDS_RES_PROTO_NOTEXT , TDS_RES_PROTO_NOBULK , TDS_RES_NOTDSDEBUG , TDS_RES_DATA_NOINT8 }; /* * The TDSLOGIN::capabilities member is a little wrong because it includes the type and typelen members. * The 22 bytes are structured as: * offset name value meaning * ------ ---- ----- -------------------------- * 0 type 1 request * 1 len 9 9 capability bytes follow * 2-10 data * 11 type 2 response * 12 len 9 9 capability bytes follow * 13-21 data * * This function manipulates the data portion without altering the length. * * \param capabilities address of the data portion in the TDSLOGIN member to be affected. * \param capability capability to set or reset. Pass as negative to reset. */ static unsigned char * tds_capability_set(unsigned char capabilities[], int capability, size_t len) { int cap = (capability < 0)? -capability : capability; int rindex = cap / 8; int index = (len - cap/8) - 1; unsigned char mask = 1 << ((8+cap) % 8); assert(0 < index && index < len); if (capability < 0) { mask ^= mask; capabilities[index] &= mask; } else { capabilities[index] |= mask; } fprintf(stderr, "capability: %2d, index %u(%u), mask %02x: %02x (default %02x)\n", cap, index, rindex, mask, capabilities[index], defaultcaps[2+index]); return capabilities; } #endif /* TESTING_CAPABILITY */ int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int ret; int verbose = 0; #if TESTING_CAPABILITY int i, c, *pcap, ncap; unsigned char *capabilities[2]; unsigned char caps[TDS_MAX_CAPABILITY]; memset(caps, 0, TDS_MAX_CAPABILITY); capabilities[0] = caps; capabilities[1] = caps + TDS_MAX_CAPABILITY / 2; pcap = (int*)request_capabilities; ncap = TDS_VECTOR_SIZE(request_capabilities); for (c=0; c < 2; c++) { const int bufsize = TDS_MAX_CAPABILITY / 2 - 2; capabilities[c][0] = 1 + c; /* request/response */ capabilities[c][1] = bufsize; for (i=0; i < ncap; i++) { tds_capability_set(capabilities[c]+2, pcap[i], bufsize); } fprintf(stderr, "[%d]\n", ncap); pcap = response_capabilities; ncap = TDS_VECTOR_SIZE(response_capabilities); } for (c=0; c < 2; c++) { int ncap = sizeof(defaultcaps) / 2; for (i=0; i < ncap; i++) { fprintf(stderr, "%02x=%02x ", capabilities[c][i], defaultcaps[c * ncap + i]); } fprintf(stderr, "%d\n", TDS_MAX_CAPABILITY); } assert(0 == memcmp(caps, defaultcaps, sizeof(defaultcaps))); #endif /* TESTING_CAPABILITY */ fprintf(stdout, "%s: Testing login, logout\n", __FILE__); ret = try_tds_login(&login, &tds, __FILE__, verbose); if (ret != TDS_SUCCEED) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } try_tds_logout(login, tds, verbose); return 0; } freetds-0.91/src/tds/unittests/t0002.c100664 001750 000144 00000007341 10365440677 0013154/* 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" static char software_version[] = "$Id: t0002.c,v 1.14 2006/01/24 15:03:27 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; char *value_as_string(TDSSOCKET * tds, int col_idx); 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: strncpy(result, (const char *) value, sizeof(result) - 1); result[sizeof(result) - 1] = '\0'; 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_SUCCEED) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } rc = tds_submit_query(tds, "select db_name() dbname, user_name() username"); if (rc != TDS_SUCCEED) { fprintf(stderr, "tds_submit_query() failed\n"); return 1; } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCEED) { 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->res_info->columns[0]->column_name, "dbname") || strcmp(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_SUCCEED) { 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_SUCCEED) { 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-0.91/src/tds/unittests/t0003.c100664 001750 000144 00000004122 10153613255 0013134/* 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 char software_version[] = "$Id: t0003.c,v 1.17 2004/12/02 13:20:45 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_SUCCEED) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } rc = tds_submit_query(tds, "use tempdb"); if (rc != TDS_SUCCEED) { 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_SUCCEED) { fprintf(stderr, "query results failed\n"); return 1; } if (!tds || !tds->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->env.database); } if (strcmp(tds->env.database, "tempdb")) { fprintf(stderr, "Wrong database, %s != tempdb\n", tds->env.database); return 1; } try_tds_logout(login, tds, verbose); return 0; } freetds-0.91/src/tds/unittests/t0004.c100664 001750 000144 00000007235 10365440677 0013160/* 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" static char software_version[] = "$Id: t0004.c,v 1.20 2006/01/24 15:03:27 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; char *varchar_as_string(TDSSOCKET * tds, int col_idx); char * varchar_as_string(TDSSOCKET * tds, int col_idx) { static char result[256]; const void *value = tds->res_info->columns[col_idx]->column_data; strncpy(result, (const char *) value, sizeof(result) - 1); result[sizeof(result) - 1] = '\0'; return result; } int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 0; int rc; int result_type; int rows_returned = 0; const char *len200 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; char long_query[1000]; sprintf(long_query, "SELECT name FROM #longquerytest WHERE (name = 'A%s' OR name = 'B%s' OR name = 'C%s' OR name = 'correct')", len200, len200, len200); fprintf(stdout, "%s: Test large (>512 bytes) queries\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCEED) { 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_SUCCEED) { return 1; } rc = run_query(tds, "INSERT #longquerytest (name) VALUES ('incorrect')"); if (rc != TDS_SUCCEED) { return 1; } rc = run_query(tds, "INSERT #longquerytest (name) VALUES ('correct')"); if (rc != TDS_SUCCEED) { return 1; } /* * The heart of the test */ if (verbose) { fprintf(stdout, "block size %d\n", tds->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_SUCCEED) { 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); return 0; } freetds-0.91/src/tds/unittests/t0005.c100664 001750 000144 00000007235 10365440700 0013144/* 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" static char software_version[] = "$Id: t0005.c,v 1.18 2006/01/24 15:03:28 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_SUCCEED) { 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_SUCCEED) { return 1; } sprintf(large_sql, "INSERT #test_table (id, name) VALUES (0, 'A%s')", len200); rc = run_query(tds, large_sql); if (rc != TDS_SUCCEED) { return 1; } sprintf(large_sql, "INSERT #test_table (id, name) VALUES (1, 'B%s')", len200); rc = run_query(tds, large_sql); if (rc != TDS_SUCCEED) { return 1; } sprintf(large_sql, "INSERT #test_table (id, name) VALUES (2, 'C%s')", len200); rc = run_query(tds, large_sql); if (rc != TDS_SUCCEED) { 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_SUCCEED) { 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; } 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: strncpy(result, (const char *) value, sizeof(result) - 1); result[sizeof(result) - 1] = '\0'; break; case SYBINT4: sprintf(result, "%d", *(const int *) value); break; default: sprintf(result, "Unexpected column_type %d", type); break; } return result; } freetds-0.91/src/tds/unittests/t0006.c100664 001750 000144 00000013251 10365440700 0013140/* 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 char software_version[] = "$Id: t0006.c,v 1.25 2006/01/24 15:03:28 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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] = 1.1; sybreal[1] = 12345678; sybreal[2] = 0.012345678; sybreal[3] = 1.234567890e+20; sybreal[4] = 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_SUCCEED) { 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_SUCCEED) { return 1; } rc = run_query(tds, "CREATE TABLE #test_table (id int, val real)"); if (rc != TDS_SUCCEED) { 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_SUCCEED) { 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_SUCCEED) { 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_SUCCEED) { return 1; } rc = run_query(tds, "CREATE TABLE #test_table (id int, val float(48))"); if (rc != TDS_SUCCEED) { 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_SUCCEED) { 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_SUCCEED) { 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-0.91/src/tds/unittests/t0007.c100664 001750 000144 00000015064 10752700260 0013145/* 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 software_version[] = "$Id: t0007.c,v 1.16 2008/02/07 22:05:36 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static TDSCONTEXT ctx; void test0(const char *src, int len, int dsttype, const char *result); void test(const char *src, int dsttype, const char *result); void test0(const char *src, int len, int dsttype, const char *result) { int i, res; char buf[256]; CONV_RESULT cr; res = tds_convert(&ctx, SYBVARCHAR, src, len, dsttype, &cr); if (res < 0) strcpy(buf, "error"); else { buf[0] = 0; switch (dsttype) { case SYBINT1: sprintf(buf, "%d", cr.ti); break; case SYBINT2: sprintf(buf, "%d", cr.si); break; case SYBINT4: sprintf(buf, "%d", cr.i); break; case SYBINT8: sprintf(buf, "0x%08x%08x", (unsigned int) ((cr.bi >> 32) & 0xfffffffflu), (unsigned int) (cr.bi & 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 SYBDATETIME: sprintf(buf, "%ld %ld", (long int) cr.dt.dtdays, (long int) cr.dt.dttime); break; } } printf("%s\n", buf); if (strcmp(buf, result) != 0) { fprintf(stderr, "Expected %s\n", result); exit(1); } } void test(const char *src, int dsttype, const char *result) { test0(src, strlen(src), dsttype, result); } int main(int argc, char **argv) { memset(&ctx, 0, sizeof(ctx)); /* test some conversion */ printf("some checks...\n"); test("1234", SYBINT4, "1234"); test("123", SYBINT1, "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("+", 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("+", 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 */ printf("overflow checks...\n"); test("9223372036854775807", SYBINT8, "0x7fffffffffffffff"); test("9223372036854775808", SYBINT8, "error"); test("-9223372036854775808", SYBINT8, "0x8000000000000000"); test("-9223372036854775809", SYBINT8, "error"); test("2147483647", SYBINT4, "2147483647"); test("2147483648", SYBINT4, "error"); test("-2147483648", SYBINT4, "-2147483648"); test("-2147483649", SYBINT4, "error"); test("32767", SYBINT2, "32767"); test("32768", SYBINT2, "error"); test("-32768", SYBINT2, "-32768"); test("-32769", SYBINT2, "error"); test("255", SYBINT1, "255"); test("256", SYBINT1, "error"); test("0", SYBINT1, "0"); test("-1", SYBINT1, "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"); /* test not terminated string */ test0("1234", 2, SYBINT4, "12"); test0("123456", 4, SYBINT8, "0x00000000000004d2"); /* 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"); return 0; } freetds-0.91/src/tds/unittests/t0008.c100664 001750 000144 00000010100 07651013363 0013135/* 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 software_version[] = "$Id: t0008.c,v 1.13 2003/04/21 16:06:11 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int g_result = 0; static TDSCONTEXT ctx; void test(const char *src, const char *intro, const char *cont, int prec, int scale, int n2s); void test(const char *src, const char *intro, const char *cont, int prec, int scale, int n2s) { 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, "Failed! Should be\n%s\n", 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, "Failed! Should be\n%s\n", src); g_result = 1; } } 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); 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-0.91/src/tds/unittests/toodynamic.c100664 001750 000144 00000005737 11104326545 0014551/* 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 char software_version[] = "$Id: toodynamic.c,v 1.1 2008/11/05 14:27:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_SUCCEED) 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_SUCCEED) 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_SUCCEED) fatal_error("tds_submit_prepare() error"); if (tds_process_simple_query(tds) != TDS_SUCCEED) 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, NULL); if (!dyn) fatal_error("create dynamic"); tds_free_dynamic(tds, dyn); } /* this should not cause duplicate IDs or erros*/ for (n = 0; n < 20; ++n) { TDSDYNAMIC *dyn2; if (tds_submit_prepare(tds, "INSERT INTO #test(i,c) VALUES(?,?)", NULL, &dyn2, NULL) != TDS_SUCCEED) fatal_error("tds_submit_prepare() error"); if (dyn == dyn2) fatal_error("got duplicated dynamic"); if (tds_process_simple_query(tds) != TDS_SUCCEED) fatal_error("tds_process_simple_query() error"); if (!dyn2) fatal_error("dynamic not present??"); if (tds_submit_unprepare(tds, dyn2) != TDS_SUCCEED || tds_process_simple_query(tds) != TDS_SUCCEED) fatal_error("unprepare error"); tds_free_dynamic(tds, dyn2); } try_tds_logout(login, tds, verbose); return 0; } freetds-0.91/src/tds/unittests/utf8_1.c100664 001750 000144 00000013641 11507072544 0013506/* 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 char software_version[] = "$Id: utf8_1.c,v 1.14 2010/12/30 12:04:52 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_SUCCEED) { 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_SUCCEED) { fprintf(stderr, "tds_submit_query() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCEED) { 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_SUCCEED) { 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_SUCCEED) { 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_SUCCEED) { 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_SUCCEED) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } if (IS_TDS7_PLUS(tds)) { 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-0.91/src/tds/unittests/utf8.c100664 001750 000144 00000003441 11507073477 0013271/* 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 #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-0.91/src/tds/unittests/utf8_2.c100664 001750 000144 00000015015 11207535204 0013476/* 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 char software_version[] = "$Id: utf8_2.c,v 1.15 2009/05/28 16:23:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_SUCCEED) { fprintf(stderr, "tds_submit_query() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCEED) { 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_SUCCEED) { 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, "UTF-8"); tds->current_results->columns[0]->char_conv = tds->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_SUCCEED) { 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_SUCCEED || 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_SUCCEED) { 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_SUCCEED) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } /* override a const in a safe way */ my_err = &tds->tds_ctx->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-0.91/src/tds/unittests/utf8_3.c100664 001750 000144 00000010020 11507072544 0013474/* 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 static char software_version[] = "$Id: utf8_3.c,v 1.7 2010/12/30 12:04:52 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_SUCCEED) { fprintf(stderr, "tds_submit_query() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCEED) { 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_SUCCEED) { 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_SUCCEED) { TDSCOLUMN *curcol; if (result_type != TDS_ROW_RESULT) break; curcol = tds->current_results->columns[0]; if (strlen(tmp) != curcol->column_namelen || strncmp(tmp, curcol->column_name, curcol->column_namelen) != 0) { int l = curcol->column_namelen; if (l > (sizeof(query) -1)) l = (sizeof(query) -1); strncpy(query, curcol->column_name, l); query[l] = 0; fprintf(stderr, "Wrong result Got: '%s' len %d\n Expected: '%s' len %u\n", query, curcol->column_namelen, tmp, (unsigned int) strlen(tmp)); exit(1); } ++i; } if (rc != TDS_SUCCEED || 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_SUCCEED) { 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_SUCCEED) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } if (IS_TDS7_PLUS(tds)) { 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-0.91/src/ctlib/Makefile.am100664 001750 000144 00000001201 10721240606 0012507# $Id: Makefile.am,v 1.28 2007/11/22 08:44:54 freddy77 Exp $ SUBDIRS = unittests AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libct.la if MINGW32 MINGW_SOURCES = ../../win32/initnet.c else MINGW_SOURCES = endif libct_la_SOURCES= ct.c cs.c blk.c ctutil.c $(MINGW_SOURCES) # version bumped for 0.64, I hope we'll bump it less in the future -- freddy77 if MACOSX SYMBOLS = else SYMBOLS = -export-symbols-regex '^(cs_|ct_|blk_).*' endif libct_la_LDFLAGS= -version-info 4:0:0 $(SYMBOLS) $(FREETDS_SYMBOLIC) libct_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) freetds-0.91/src/ctlib/Makefile.in100664 001750 000144 00000062536 11623070617 0012547# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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__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__DEPENDENCIES_1) am__libct_la_SOURCES_DIST = ct.c cs.c blk.c ctutil.c \ ../../win32/initnet.c @MINGW32_TRUE@am__objects_1 = initnet.lo am_libct_la_OBJECTS = ct.lo cs.lo blk.lo ctutil.lo $(am__objects_1) libct_la_OBJECTS = $(am_libct_la_OBJECTS) libct_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(libct_la_LDFLAGS) \ $(LDFLAGS) -o $@ 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libct_la_SOURCES) DIST_SOURCES = $(am__libct_la_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-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 uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) 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@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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.28 2007/11/22 08:44:54 freddy77 Exp $ SUBDIRS = unittests AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libct.la @MINGW32_FALSE@MINGW_SOURCES = @MINGW32_TRUE@MINGW_SOURCES = ../../win32/initnet.c libct_la_SOURCES = ct.c cs.c blk.c ctutil.c $(MINGW_SOURCES) @MACOSX_FALSE@SYMBOLS = -export-symbols-regex '^(cs_|ct_|blk_).*' # version bumped for 0.64, I hope we'll bump it less in the future -- freddy77 @MACOSX_TRUE@SYMBOLS = libct_la_LDFLAGS = -version-info 4:0:0 $(SYMBOLS) $(FREETDS_SYMBOLIC) libct_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) 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 .PRECIOUS: 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) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @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 " $(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)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libct.la: $(libct_la_OBJECTS) $(libct_la_DEPENDENCIES) $(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)/initnet.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< initnet.lo: ../../win32/initnet.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT initnet.lo -MD -MP -MF $(DEPDIR)/initnet.Tpo -c -o initnet.lo `test -f '../../win32/initnet.c' || echo '$(srcdir)/'`../../win32/initnet.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/initnet.Tpo $(DEPDIR)/initnet.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../win32/initnet.c' object='initnet.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o initnet.lo `test -f '../../win32/initnet.c' || echo '$(srcdir)/'`../../win32/initnet.c 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. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; 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" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) 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; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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 \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \ 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-recursive uninstall uninstall-am \ uninstall-libLTLIBRARIES # 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-0.91/src/ctlib/ct.c100664 001750 000144 00000365261 11452561624 0011260/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tdsstring.h" #include "replacements.h" TDS_RCSID(var, "$Id: ct.c,v 1.207 2010/10/05 08:36:36 freddy77 Exp $"); static 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 int _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_RETCODE _ct_cmd_drop(CS_COMMAND * cmd, CS_INT free_conn_ref); /* 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 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(); if (!login) return CS_FAIL; *con = (CS_CONNECTION *) calloc(1, sizeof(CS_CONNECTION)); 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; /* set default values */ tds_set_library((*con)->tds_login, "CT-Library"); /* 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 = 0, 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; if (property == CS_USERNAME || property == CS_PASSWORD || property == CS_APPNAME || property == CS_HOSTNAME || property == CS_SERVERADDR) { if (buflen == CS_NULLTERM) { maxcp = strlen((char *) buffer); set_buffer = (char *) malloc(maxcp + 1); strcpy(set_buffer, (char *) buffer); } else if (buflen == CS_UNUSED) { return CS_SUCCEED; } else { set_buffer = (char *) malloc(buflen + 1); strncpy(set_buffer, (char *) buffer, buflen); set_buffer[buflen] = '\0'; } } /* * 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: tds_set_user(tds_login, set_buffer); break; case CS_PASSWORD: tds_set_passwd(tds_login, set_buffer); break; case CS_APPNAME: tds_set_app(tds_login, set_buffer); break; case CS_HOSTNAME: 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; int portno; host= strtok_r(set_buffer, " ", &lasts); port= strtok_r(NULL, " ", &lasts); if (!host || !port) return CS_FAIL; portno = (int)strtol(port, NULL, 10); if (portno < 1 || portno >= 65536) 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 { return CS_FAIL; } break; default: tdsdump_log(TDS_DBG_ERROR, "Unknown property %d\n", property); break; } free(set_buffer); } else if (action == CS_GET) { switch (property) { case CS_USERNAME: if (out_len) *out_len = tds_dstr_len(&tds_login->user_name); tds_strlcpy((char *) buffer, tds_dstr_cstr(&tds_login->user_name), buflen); break; case CS_PASSWORD: if (out_len) *out_len = tds_dstr_len(&tds_login->password); tds_strlcpy((char *) buffer, tds_dstr_cstr(&tds_login->password), buflen); break; case CS_APPNAME: if (out_len) *out_len = tds_dstr_len(&tds_login->app_name); tds_strlcpy((char *) buffer, tds_dstr_cstr(&tds_login->app_name), buflen); break; case CS_HOSTNAME: if (out_len) *out_len = tds_dstr_len(&tds_login->client_host_name); tds_strlcpy((char *) buffer, tds_dstr_cstr(&tds_login->client_host_name), buflen); break; case CS_SERVERNAME: if (out_len) *out_len = tds_dstr_len(&tds_login->server_name); tds_strlcpy((char *) buffer, tds_dstr_cstr(&tds_login->server_name), 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: if (!(IS_TDSDEAD(tds))) intval |= CS_CONSTAT_CONNECTED; else intval &= ~CS_CONSTAT_CONNECTED; if (tds && tds->state == TDS_DEAD) intval |= CS_CONSTAT_DEAD; else 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->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_version(tds, NULL)) { case 40: (*(int *) buffer = CS_TDS_40); break; case 42: (*(int *) buffer = CS_TDS_42); break; case 46: (*(int *) buffer = CS_TDS_46); break; case 40 + 95: (*(int *) buffer = CS_TDS_495); break; case 50: (*(int *) buffer = CS_TDS_50); break; case 70: (*(int *) buffer = CS_TDS_70); break; case 80: (*(int *) buffer = CS_TDS_80); 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; TDSCONNECTION *connection; 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 = (char *) malloc(snamelen + 1); needfree++; strncpy(server, servername, snamelen); server[snamelen] = '\0'; } tds_set_server(con->tds_login, server); if (needfree) free(server); 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 (!(connection = 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) tds_dstr_copy(&connection->server_host_name, con->server_addr); /* override locale settings with CS_CONNECTION settings, if any */ if (con->locale) { if (con->locale->charset) { if (!tds_dstr_copy(&connection->server_charset, con->locale->charset)) goto Cleanup; } if (con->locale->language) { if (!tds_dstr_copy(&connection->language, con->locale->language)) goto Cleanup; } if (con->locale->time && con->tds_socket->tds_ctx) { TDSLOCALE *locale = con->tds_socket->tds_ctx->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_connect_and_login(con->tds_socket, connection) != TDS_SUCCEED) goto Cleanup; tds_free_connection(connection); 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_connection(connection); 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 ** cmd) { CS_COMMAND_LIST *command_list; CS_COMMAND_LIST *pcommand; tdsdump_log(TDS_DBG_FUNC, "ct_cmd_alloc(%p, %p)\n", con, cmd); *cmd = (CS_COMMAND *) calloc(1, sizeof(CS_COMMAND)); 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); command_list = calloc(1, sizeof(CS_COMMAND_LIST)); command_list->cmd = *cmd; command_list->next = NULL; if ( con->cmds == NULL ) { tdsdump_log(TDS_DBG_FUNC, "ct_cmd_alloc() : allocating command list to head\n"); con->cmds = command_list; } else { pcommand = con->cmds; for (;;) { tdsdump_log(TDS_DBG_FUNC, "ct_cmd_alloc() : stepping thru existing commands\n"); if (pcommand->next == NULL) break; pcommand = pcommand->next; } pcommand->next = command_list; } 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); /* Unless we are in the process of building a CS_LANG_CMD */ /* type command, then 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; } if (cmd->command_state == _CS_COMMAND_IDLE) { cmd->query = (char *) malloc(query_len + 1); strncpy(cmd->query, (const char *) buffer, query_len); cmd->query[query_len] = '\0'; if (option == CS_MORE) { ct_set_command_state(cmd, _CS_COMMAND_BUILDING); } else { ct_set_command_state(cmd, _CS_COMMAND_READY); } } if (cmd->command_state == _CS_COMMAND_BUILDING) { current_query_len = strlen(cmd->query); cmd->query = (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; default: return CS_FAIL; } break; case CS_RPC_CMD: /* Code changed for RPC functionality -SUHA */ /* RPC code changes starts here */ if (cmd == NULL) return CS_FAIL; cmd->rpc = (CSREMOTE_PROC *) calloc(1, sizeof(CSREMOTE_PROC)); if (cmd->rpc == NULL) return CS_FAIL; if (buflen == CS_NULLTERM) { cmd->rpc->name = strdup(buffer); if (cmd->rpc->name == NULL) return CS_FAIL; } else if (buflen > 0) { cmd->rpc->name = (char *) calloc(1, buflen + 1); if (cmd->rpc->name == NULL) return CS_FAIL; strncpy(cmd->rpc->name, (const char *) buffer, buflen); } 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; CS_RETCODE ret; CSREMOTE_PROC **rpc; TDSPARAMINFO *pparam_info; TDSCURSOR *cursor; TDSDYNAMIC *tdsdyn; tdsdump_log(TDS_DBG_FUNC, "ct_send(%p)\n", cmd); tdsdump_log(TDS_DBG_FUNC, "ct_send() command_type = %d\n", cmd->command_type); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; 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) { if (cmd->dyn == NULL) return CS_FAIL; switch (cmd->dynamic_cmd) { case CS_PREPARE: if (tds_submit_prepare(tds, cmd->dyn->stmt, cmd->dyn->id, NULL, NULL) == TDS_FAIL) return CS_FAIL; ct_set_command_state(cmd, _CS_COMMAND_SENT); return CS_SUCCEED; break; case CS_EXECUTE: pparam_info = paraminfoalloc(tds, cmd->dyn->param_list); tdsdyn = tds_lookup_dynamic(tds, cmd->dyn->id); if (!tdsdyn) { tdsdump_log(TDS_DBG_INFO1, "ct_send(CS_EXECUTE) no tdsdyn!\n"); return CS_FAIL; } tds_free_input_params(tdsdyn); tdsdyn->params = pparam_info; if (tds_submit_execute(tds, tdsdyn) == TDS_FAIL) 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->current_results = tds->cur_dyn->res_info; else tds->current_results = 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->current_results = tds->res_info; break; case CS_DEALLOC: tdsdyn = tds_lookup_dynamic(tds, cmd->dyn->id); if (!tdsdyn) { tdsdump_log(TDS_DBG_INFO1, "ct_send(CS_DEALLOC) no tdsdyn!\n"); return CS_FAIL; } if (tds_submit_unprepare(tds, tdsdyn) == TDS_FAIL) 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) { /* sanity */ if (cmd == NULL || cmd->rpc == NULL /* ct_command should allocate pointer */ || cmd->rpc->name == NULL) { /* can't be ready without a name */ return CS_FAIL; } rpc = &(cmd->rpc); pparam_info = paraminfoalloc(tds, cmd->rpc->param_list); ret = tds_submit_rpc(tds, cmd->rpc->name, pparam_info); tds_free_param_results(pparam_info); ct_set_command_state(cmd, _CS_COMMAND_SENT); if (ret == TDS_FAIL) { return CS_FAIL; } return CS_SUCCEED; } /* RPC Code changes ends here */ if (cmd->command_type == CS_LANG_CMD) { ret = CS_FAIL; if (cmd->input_params) { pparam_info = paraminfoalloc(tds, cmd->input_params); ret = tds_submit_query_params(tds, cmd->query, pparam_info); tds_free_param_results(pparam_info); } else { ret = tds_submit_query(tds, cmd->query); } ct_set_command_state(cmd, _CS_COMMAND_SENT); if (ret == TDS_FAIL) { 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) { /* 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 (cmd == NULL ) { tdsdump_log(TDS_DBG_FUNC, "ct_send() : cmd is null\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 (ret == CS_SUCCEED){ cursor->status.declare = _CS_CURS_TYPE_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 (ret == CS_SUCCEED){ cursor->status.cursor_row = _CS_CURS_TYPE_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 (ret == CS_SUCCEED){ cursor->status.open = _CS_CURS_TYPE_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(tds, cursor); cmd->cursor = cursor = NULL; } else { ret = tds_cursor_close(tds, cursor); cursor->status.close = _CS_CURS_TYPE_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); cmd->cursor = NULL; tds_free_all_results(tds); } 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; int tdsret; CS_INT res_type; CS_INT done_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; break; default: break; } /* * 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. */ for (;;) { tdsret = tds_process_tokens(tds, &res_type, &done_flags, TDS_TOKEN_RESULTS); tdsdump_log(TDS_DBG_FUNC, "ct_results() process_result_tokens returned %d (type %d) \n", tdsret, res_type); switch (tdsret) { case TDS_SUCCEED: cmd->curr_result_type = res_type; switch (res_type) { case CS_COMPUTEFMT_RESULT: case CS_ROWFMT_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_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->current_results = 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_SUCCEED && (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; } 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; cmd->results_state = _CS_RES_RESULTSET_ROWS; } else { *result_type = CS_ROW_RESULT; cmd->results_state = _CS_RES_CMD_DONE; } 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.... */ 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; } else { *result_type = CS_ROW_RESULT; } cmd->results_state = _CS_RES_CMD_DONE; 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 (cmd->results_state == _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; return CS_SUCCEED; } else { if (cmd->command_type == CS_DYNAMIC_CMD) { *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; case TDS_FAIL: 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; TDS_INT 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) || (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_SUCCEED: 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) 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; TDS_INT 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_cursor_fetch(tds, cursor, TDS_CURSOR_FETCH_NEXT, 0) == CS_SUCCEED) { cursor->status.fetch = _CS_CURS_TYPE_SENT; } else { tdsdump_log(TDS_DBG_WARN, "ct_fetch(): cursor fetch failed\n"); return CS_FAIL; } while ((tds_process_tokens(tds, &restype, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCEED) { 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_SUCCEED && (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 (ret != TDS_FAIL) { break; } else { return CS_FAIL; } } } break; case TDS_DONE_RESULT: break; } } if (rows_this_fetch) return CS_SUCCEED; else { 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 = &datalen_dummy; TDS_SMALLINT nullind_dummy, *nullind = &nullind_dummy; 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++) { 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 + (offset * bindcol->column_bindlen); if (bindcol->column_nullbind) { nullind = bindcol->column_nullbind; assert(nullind); nullind += offset; } 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 { src = curcol->column_data; if (is_blob_col(curcol)) src = (unsigned char *) ((TDSBLOB *) src)->textvalue; srcfmt.datatype = _ct_get_client_type(curcol); 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 ((result= cs_convert(ctx, &srcfmt, src, &destfmt, dest, pdatalen) != CS_SUCCEED)) { tdsdump_log(TDS_DBG_FUNC, "cs_convert-result = %d\n", result); 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_RETCODE ret; tdsdump_log(TDS_DBG_FUNC, "ct_cmd_drop(%p)\n", cmd); ret = _ct_cmd_drop(cmd, 1); return ret; } static CS_RETCODE _ct_cmd_drop(CS_COMMAND * cmd, CS_INT free_conn_ref) { CS_COMMAND_LIST *victim = NULL; CS_COMMAND_LIST *prev = NULL; CS_COMMAND_LIST *next = NULL; CS_CONNECTION *con; tdsdump_log(TDS_DBG_FUNC, "_ct_cmd_drop(%p, %d)\n", cmd, free_conn_ref); 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 */ if (free_conn_ref && cmd->con) { con = cmd->con; victim = con->cmds; for (;;) { if (victim->cmd == cmd) break; prev = victim; victim = victim->next; if (victim == NULL) { tdsdump_log(TDS_DBG_FUNC, "ct_cmd_drop() : cannot find command entry in list \n"); return CS_FAIL; } } tdsdump_log(TDS_DBG_FUNC, "ct_cmd_drop() : command entry found in list\n"); next = victim->next; free(victim); tdsdump_log(TDS_DBG_FUNC, "ct_cmd_drop() : relinking list\n"); if (prev) prev->next = next; else con->cmds = next; tdsdump_log(TDS_DBG_FUNC, "ct_cmd_drop() : relinked list\n"); } 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_free_socket(con->tds_socket); con->tds_socket = NULL; return CS_SUCCEED; } CS_RETCODE ct_con_drop(CS_CONNECTION * con) { CS_COMMAND_LIST *currptr, *freeptr; 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); if (con->cmds) { currptr = con->cmds; while (currptr != NULL) { freeptr = currptr; if (currptr->cmd) currptr->cmd->con = NULL; currptr = currptr->next; free(freeptr); } } if (con->locale) _cs_locale_free(con->locale); 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; } return CS_FAIL; } int _ct_get_server_type(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_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; default: return -1; break; } } CS_RETCODE ct_cancel(CS_CONNECTION * conn, CS_COMMAND * cmd, CS_INT type) { CS_RETCODE ret; CS_COMMAND_LIST *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->cmd; 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->cmd; 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; int len; 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]; len = curcol->column_namelen; if (len >= CS_MAX_NAME) len = CS_MAX_NAME - 1; strncpy(datafmt->name, curcol->column_name, len); /* name is always null terminated */ datafmt->name[len] = 0; datafmt->namelen = len; /* need to turn the SYBxxx into a CS_xxx_TYPE */ datafmt->datatype = _ct_get_client_type(curcol); 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: /* TODO 64 -> 32 bit conversion check overflow */ int_val = 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(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) { TDSSOCKET *tds; 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; tds = cmd->con->tds_socket; 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 (len >= buflen) return CS_FAIL; strcpy(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 < (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 = 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); if (cmd->cancel_state == _CS_CANCEL_PENDING) { _ct_cancel_cleanup(cmd); return CS_CANCELED; } /* 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; /* 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 = calloc(1, sizeof(CS_IODESC)); 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 = curcol->table_namelen; if (table_namelen + 2 > sizeof(cmd->iodesc->name)) table_namelen = sizeof(cmd->iodesc->name) - 2; column_namelen = curcol->column_namelen; 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, curcol->table_name, (int) column_namelen, (int) column_namelen, curcol->column_name); cmd->iodesc->namelen = strlen(cmd->iodesc->name); if (blob) { 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) 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_writetext_start(tds, cmd->iodesc->name, textptr_string, timestamp_string, (cmd->iodesc->log_on_update == CS_TRUE), cmd->iodesc->total_txtlen) != TDS_SUCCEED) return CS_FAIL; cmd->send_data_started = 1; } if (tds_writetext_continue(tds, buffer, buflen) != TDS_SUCCEED) 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: free(cmd->iodesc); cmd->iodesc = malloc(sizeof(CS_IODESC)); 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, CS_TS_SIZE); cmd->iodesc->timestamplen = CS_TS_SIZE; memcpy(cmd->iodesc->textptr, iodesc->textptr, CS_TP_SIZE); cmd->iodesc->textptrlen = CS_TP_SIZE; 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; unsigned char *mask; tdsdump_log(TDS_DBG_FUNC, "ct_capability(%p, %d, %d, %d, %p)\n", con, action, type, capability, value); login = (TDSLOGIN *) con->tds_login; mask = login->capabilities; if (type == CS_CAP_RESPONSE) { switch (capability) { case CS_DATA_NOBOUNDARY: idx = 13; bitmask = 0x01; break; case CS_RES_NOTDSDEBUG: idx = 13; bitmask = 0x02; break; case CS_RES_NOSTRIPBLANKS: idx = 13; bitmask = 0x04; break; case CS_DATA_NOINT8: idx = 13; bitmask = 0x08; break; case CS_DATA_NOINTN: idx = 14; bitmask = 0x01; break; case CS_DATA_NODATETIMEN: idx = 14; bitmask = 0x02; break; case CS_DATA_NOMONEYN: idx = 14; bitmask = 0x04; break; case CS_CON_NOOOB: idx = 14; bitmask = 0x08; break; case CS_CON_NOINBAND: idx = 14; bitmask = 0x10; break; case CS_PROTO_NOTEXT: idx = 14; bitmask = 0x20; break; case CS_PROTO_NOBULK: idx = 14; bitmask = 0x40; break; case CS_DATA_NOSENSITIVITY: idx = 14; bitmask = 0x80; break; case CS_DATA_NOFLT4: idx = 15; bitmask = 0x01; break; case CS_DATA_NOFLT8: idx = 15; bitmask = 0x02; break; case CS_DATA_NONUM: idx = 15; bitmask = 0x04; break; case CS_DATA_NOTEXT: idx = 15; bitmask = 0x08; break; case CS_DATA_NOIMAGE: idx = 15; bitmask = 0x10; break; case CS_DATA_NODEC: idx = 15; bitmask = 0x20; break; case CS_DATA_NOLCHAR: idx = 15; bitmask = 0x40; break; case CS_DATA_NOLBIN: idx = 15; bitmask = 0x80; break; case CS_DATA_NOCHAR: idx = 16; bitmask = 0x01; break; case CS_DATA_NOVCHAR: idx = 16; bitmask = 0x02; break; case CS_DATA_NOBIN: idx = 16; bitmask = 0x04; break; case CS_DATA_NOVBIN: idx = 16; bitmask = 0x08; break; case CS_DATA_NOMNY8: idx = 16; bitmask = 0x10; break; case CS_DATA_NOMNY4: idx = 16; bitmask = 0x20; break; case CS_DATA_NODATE8: idx = 16; bitmask = 0x40; break; case CS_DATA_NODATE4: idx = 16; bitmask = 0x80; break; case CS_RES_NOMSG: idx = 17; bitmask = 0x02; break; case CS_RES_NOEED: idx = 17; bitmask = 0x04; break; case CS_RES_NOPARAM: idx = 17; bitmask = 0x08; break; case CS_DATA_NOINT1: idx = 17; bitmask = 0x10; break; case CS_DATA_NOINT2: idx = 17; bitmask = 0x20; break; case CS_DATA_NOINT4: idx = 17; bitmask = 0x40; break; case CS_DATA_NOBIT: idx = 17; bitmask = 0x80; break; default: tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- attempt to set/get a non-existant capability\n"); return CS_FAIL; } /* end capability */ assert(13 <= idx && idx <= 17); assert(bitmask); 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: mask[idx] |= bitmask; break; case CS_FALSE: mask[idx] &= ~bitmask; break; default: tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- unknown value\n"); return CS_FAIL; } break; case CS_GET: *(CS_BOOL *) value = (mask[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 handling CS_CAP_RESPONSE (returned) */ /* * Begin handling CS_CAP_REQUEST * These capabilities describe the types of requests that a server can support. */ switch (capability) { case CS_PROTO_DYNPROC: *(CS_BOOL *) value = mask[2] & 0x01 ? CS_TRUE : CS_FALSE; break; case CS_DATA_FLTN: *(CS_BOOL *) value = mask[2] & 0x02 ? CS_TRUE : CS_FALSE; break; case CS_DATA_BITN: *(CS_BOOL *) value = mask[2] & 0x04 ? CS_TRUE : CS_FALSE; break; case CS_DATA_INT8: *(CS_BOOL *) value = mask[2] & 0x08 ? CS_TRUE : CS_FALSE; break; case CS_DATA_VOID: *(CS_BOOL *) value = mask[2] & 0x10 ? CS_TRUE : CS_FALSE; break; case CS_CON_INBAND: *(CS_BOOL *) value = mask[3] & 0x01 ? CS_TRUE : CS_FALSE; break; case CS_CON_LOGICAL: *(CS_BOOL *) value = mask[3] & 0x02 ? CS_TRUE : CS_FALSE; break; case CS_PROTO_TEXT: *(CS_BOOL *) value = mask[3] & 0x04 ? CS_TRUE : CS_FALSE; break; case CS_PROTO_BULK: *(CS_BOOL *) value = mask[3] & 0x08 ? CS_TRUE : CS_FALSE; break; case CS_REQ_URGNOTIF: *(CS_BOOL *) value = mask[3] & 0x10 ? CS_TRUE : CS_FALSE; break; case CS_DATA_SENSITIVITY: *(CS_BOOL *) value = mask[3] & 0x20 ? CS_TRUE : CS_FALSE; break; case CS_DATA_BOUNDARY: *(CS_BOOL *) value = mask[3] & 0x40 ? CS_TRUE : CS_FALSE; break; case CS_PROTO_DYNAMIC: *(CS_BOOL *) value = mask[3] & 0x80 ? CS_TRUE : CS_FALSE; break; case CS_DATA_MONEYN: *(CS_BOOL *) value = mask[4] & 0x01 ? CS_TRUE : CS_FALSE; break; case CS_CSR_PREV: *(CS_BOOL *) value = mask[4] & 0x02 ? CS_TRUE : CS_FALSE; break; case CS_CSR_FIRST: *(CS_BOOL *) value = mask[4] & 0x04 ? CS_TRUE : CS_FALSE; break; case CS_CSR_LAST: *(CS_BOOL *) value = mask[4] & 0x08 ? CS_TRUE : CS_FALSE; break; case CS_CSR_ABS: *(CS_BOOL *) value = mask[4] & 0x10 ? CS_TRUE : CS_FALSE; break; case CS_CSR_REL: *(CS_BOOL *) value = mask[4] & 0x20 ? CS_TRUE : CS_FALSE; break; case CS_CSR_MULTI: *(CS_BOOL *) value = mask[4] & 0x40 ? CS_TRUE : CS_FALSE; break; case CS_CON_OOB: *(CS_BOOL *) value = mask[4] & 0x80 ? CS_TRUE : CS_FALSE; break; case CS_DATA_NUM: *(CS_BOOL *) value = mask[5] & 0x01 ? CS_TRUE : CS_FALSE; break; case CS_DATA_TEXT: *(CS_BOOL *) value = mask[5] & 0x02 ? CS_TRUE : CS_FALSE; break; case CS_DATA_IMAGE: *(CS_BOOL *) value = mask[5] & 0x04 ? CS_TRUE : CS_FALSE; break; case CS_DATA_DEC: *(CS_BOOL *) value = mask[5] & 0x08 ? CS_TRUE : CS_FALSE; break; case CS_DATA_LCHAR: *(CS_BOOL *) value = mask[5] & 0x10 ? CS_TRUE : CS_FALSE; break; case CS_DATA_LBIN: *(CS_BOOL *) value = mask[5] & 0x20 ? CS_TRUE : CS_FALSE; break; case CS_DATA_INTN: *(CS_BOOL *) value = mask[5] & 0x40 ? CS_TRUE : CS_FALSE; break; case CS_DATA_DATETIMEN: *(CS_BOOL *) value = mask[5] & 0x80 ? CS_TRUE : CS_FALSE; break; case CS_DATA_BIN: *(CS_BOOL *) value = mask[6] & 0x01 ? CS_TRUE : CS_FALSE; break; case CS_DATA_VBIN: *(CS_BOOL *) value = mask[6] & 0x02 ? CS_TRUE : CS_FALSE; break; case CS_DATA_MNY8: *(CS_BOOL *) value = mask[6] & 0x04 ? CS_TRUE : CS_FALSE; break; case CS_DATA_MNY4: *(CS_BOOL *) value = mask[6] & 0x08 ? CS_TRUE : CS_FALSE; break; case CS_DATA_DATE8: *(CS_BOOL *) value = mask[6] & 0x10 ? CS_TRUE : CS_FALSE; break; case CS_DATA_DATE4: *(CS_BOOL *) value = mask[6] & 0x20 ? CS_TRUE : CS_FALSE; break; case CS_DATA_FLT4: *(CS_BOOL *) value = mask[6] & 0x40 ? CS_TRUE : CS_FALSE; break; case CS_DATA_FLT8: *(CS_BOOL *) value = mask[6] & 0x80 ? CS_TRUE : CS_FALSE; break; case CS_REQ_MSG: *(CS_BOOL *) value = mask[7] & 0x01 ? CS_TRUE : CS_FALSE; break; case CS_REQ_PARAM: *(CS_BOOL *) value = mask[7] & 0x02 ? CS_TRUE : CS_FALSE; break; case CS_DATA_INT1: *(CS_BOOL *) value = mask[7] & 0x04 ? CS_TRUE : CS_FALSE; break; case CS_DATA_INT2: *(CS_BOOL *) value = mask[7] & 0x08 ? CS_TRUE : CS_FALSE; break; case CS_DATA_INT4: *(CS_BOOL *) value = mask[7] & 0x10 ? CS_TRUE : CS_FALSE; break; case CS_DATA_BIT: *(CS_BOOL *) value = mask[7] & 0x20 ? CS_TRUE : CS_FALSE; break; case CS_DATA_CHAR: *(CS_BOOL *) value = mask[7] & 0x40 ? CS_TRUE : CS_FALSE; break; case CS_DATA_VCHAR: *(CS_BOOL *) value = mask[7] & 0x80 ? CS_TRUE : CS_FALSE; break; case CS_REQ_LANG: *(CS_BOOL *) value = mask[8] & 0x02 ? CS_TRUE : CS_FALSE; break; case CS_REQ_RPC: *(CS_BOOL *) value = mask[8] & 0x04 ? CS_TRUE : CS_FALSE; break; case CS_REQ_NOTIF: *(CS_BOOL *) value = mask[8] & 0x08 ? CS_TRUE : CS_FALSE; break; case CS_REQ_MSTMT: *(CS_BOOL *) value = mask[8] & 0x10 ? CS_TRUE : CS_FALSE; break; case CS_REQ_BCP: *(CS_BOOL *) value = mask[8] & 0x20 ? CS_TRUE : CS_FALSE; break; case CS_REQ_CURSOR: *(CS_BOOL *) value = mask[8] & 0x40 ? CS_TRUE : CS_FALSE; break; case CS_REQ_DYN: *(CS_BOOL *) value = mask[8] & 0x80 ? CS_TRUE : CS_FALSE; break; default: tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- attempt to get a non-existant capability\n"); return CS_FAIL; break; } /* end capability */ assert(*(CS_BOOL *) value); /* CS_CAP_RESPONSE is read-only */ if (type == CS_CAP_REQUEST && action == CS_GET) { tdsdump_log(TDS_DBG_INFO1, "ct_capability returns success, value %s\n", *(CS_BOOL *)value == CS_TRUE ? "TRUE" : "FALSE"); return CS_SUCCEED; } tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- attempt to set a read-only capability (type %d, action %d)\n", type, action); return CS_FAIL; } /* 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; cmd->command_type = CS_DYNAMIC_CMD; cmd->dynamic_cmd = type; 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 = (char *) malloc(query_len + 1); strncpy(dyn->stmt, (char *) buffer, query_len); dyn->stmt[query_len] = '\0'; 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; } 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 = (CSREMOTE_PROC_PARAM *) calloc(1, sizeof(CSREMOTE_PROC_PARAM)); 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 = (CSREMOTE_PROC_PARAM *) calloc(1, sizeof(CSREMOTE_PROC_PARAM)); 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 = (CS_DYNAMIC_PARAM *) calloc(1, sizeof(CS_DYNAMIC_PARAM)); 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 = (CSREMOTE_PROC_PARAM *) calloc(1, sizeof(CSREMOTE_PROC_PARAM)); 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 = (CS_DYNAMIC_PARAM *) calloc(1, sizeof(CS_DYNAMIC_PARAM)); 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 = (CSREMOTE_PROC_PARAM *) calloc(1, sizeof(CSREMOTE_PROC_PARAM)); 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 = 0; 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 } }; 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; tds = con->tds_socket; /* * 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 * TDS_OPT_TEXTSIZE */ /* * 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) { tds_option = tds_bool_option_map[i].tds_option; break; } } if (tds_option != 0) { /* found a boolean */ 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_ARITHABORT: switch (*(CS_BOOL *) param) { case CS_TRUE: tds_option = TDS_OPT_ARITHABORTON; break; case CS_FALSE: tds_option = TDS_OPT_ARITHABORTOFF; break; default: if (action == CS_SET) return CS_FAIL; tds_option = TDS_OPT_ARITHABORTON; } tds_argument.ti = TDS_OPT_ARITHOVERFLOW | TDS_OPT_NUMERICTRUNC; tds_argsize = (action == CS_SET) ? 1 : 0; break; case CS_OPT_ARITHIGNORE: switch (*(CS_BOOL *) param) { case CS_TRUE: tds_option = TDS_OPT_ARITHIGNOREON; break; case CS_FALSE: tds_option = TDS_OPT_ARITHIGNOREOFF; break; default: if (action == CS_SET) return CS_FAIL; } tds_argument.i = TDS_OPT_ARITHOVERFLOW | TDS_OPT_NUMERICTRUNC; tds_argsize = (action == CS_SET) ? 4 : 0; 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. */ /* no documented value */ tds_option = 0; tds_argument.ti = 0; break; case CS_OPT_LEVEL1: tds_argument.ti = TDS_OPT_LEVEL1; 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_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 = !*(char *) 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_submit_optioncmd(tds, tds_command, tds_option, &tds_argument, tds_argsize) == TDS_FAIL) { 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) + 1 : namelen, text, tlen == CS_NULLTERM ? strlen(text) + 1 : tlen); if (!cursor) return CS_FAIL; cursor->cursor_rows = 1; cursor->options = option; cursor->status.declare = _CS_CURS_TYPE_REQUESTED; cursor->status.cursor_row = _CS_CURS_TYPE_UNACTIONED; cursor->status.open = _CS_CURS_TYPE_UNACTIONED; cursor->status.fetch = _CS_CURS_TYPE_UNACTIONED; cursor->status.close = _CS_CURS_TYPE_UNACTIONED; cursor->status.dealloc = _CS_CURS_TYPE_UNACTIONED; 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 = _CS_CURS_TYPE_REQUESTED; ct_set_command_state(cmd, _CS_COMMAND_READY); return CS_SUCCEED; } else { cursor->status.cursor_row = _CS_CURS_TYPE_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 = _CS_CURS_TYPE_REQUESTED; return CS_SUCCEED; ct_set_command_state(cmd, _CS_COMMAND_READY); } else { cursor->status.open = _CS_CURS_TYPE_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 = _CS_CURS_TYPE_UNACTIONED; cursor->status.open = _CS_CURS_TYPE_UNACTIONED; cursor->status.fetch = _CS_CURS_TYPE_UNACTIONED; cursor->status.close = _CS_CURS_TYPE_REQUESTED; if (option == CS_DEALLOC) { cursor->status.dealloc = _CS_CURS_TYPE_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 = _CS_CURS_TYPE_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 int _ct_process_return_status(TDSSOCKET * tds) { TDSRESULTINFO *info; TDSCOLUMN *curcol; TDS_INT saved_status; 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->current_results = tds->res_info = tds_alloc_results(num_cols); if (!tds->res_info) return TDS_FAIL; info = tds->res_info; curcol = info->columns[0]; tds_set_column_type(tds, 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); if (tds_alloc_row(info) != TDS_SUCCEED) return TDS_FAIL; assert(curcol->column_data != NULL); *(TDS_INT *) curcol->column_data = saved_status; return TDS_SUCCEED; } /* 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 = malloc(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 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; int temp_type, tds_type; CS_BYTE *temp_value; CS_INT temp_datalen; 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; if (!(params = tds_alloc_param_result(params))) { fprintf(stderr, "out of rpc memory!"); return NULL; } /* * 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(p->datatype); if (p->param_by_value == 0) { temp_datalen = 0; temp_value = NULL; /* here's one way of passing a null parameter */ if (*(p->ind) == -1) { temp_value = NULL; temp_datalen = 0; } else { /* and here's another... */ if ((*(p->datalen) == 0 || *(p->datalen) == CS_UNUSED) && p->value == NULL) { temp_value = NULL; temp_datalen = 0; } else { /* 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); } if (p->value) { temp_value = p->value; } else { temp_value = NULL; temp_datalen = 0; } } } } 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 */ pcol->column_namelen = 0; if (p->name) { tds_strlcpy(pcol->column_name, p->name, sizeof(pcol->column_name)); pcol->column_namelen = strlen(pcol->column_name); } tds_set_param_type(tds, 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) 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", pcol->column_namelen, pcol->column_namelen, 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) { fprintf(stderr, "out of memory for rpc row!"); return NULL; } } return params; } 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) { int param_is_null = 0, 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 = calloc(1, datafmt->namelen + 1); if (param->name == NULL) return CS_FAIL; strncpy(param->name, datafmt->name, datafmt->namelen); } 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(datafmt->datatype); 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 > 77 || 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; param_is_null = 1; } 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(data)); *(param->datalen) = strlen(data); } else if (*(param->datalen) < 0) { return CS_FAIL; } param->value = malloc(*(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; param_is_null = 1; } } } else { /* not by value, i.e. by reference */ param->datalen = datalen; param->ind = indicator; param->value = 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 = (struct cs_diag_msg_client *) malloc(sizeof(struct cs_diag_msg_client)); if (*curptr == NULL) { return CS_FAIL; } else { (*curptr)->next = NULL; (*curptr)->clientmsg = malloc(sizeof(CS_CLIENTMSG)); 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 = (struct cs_diag_msg_svr *) malloc(sizeof(struct cs_diag_msg_svr)); if (*curptr == NULL) { return CS_FAIL; } else { (*curptr)->next = NULL; (*curptr)->servermsg = malloc(sizeof(CS_SERVERMSG)); 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 = (CS_DYNAMIC *) calloc(1, sizeof(CS_DYNAMIC)); if (idlen == CS_NULLTERM) id_len = strlen(id); else id_len = idlen; if (dyn != NULL) { dyn->id = malloc(id_len + 1); strncpy(dyn->id, id, id_len); dyn->id[id_len] = '\0'; 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_LIST *victim = NULL; CS_DYNAMIC_LIST *prev = NULL; CS_DYNAMIC_LIST *next = NULL; TDSDYNAMIC *tdsdyn; char myid[256]; tdsdump_log(TDS_DBG_FUNC, "_ct_deallocate_dynamic(%p, %p)\n", con, dyn); strcpy(myid,""); victim = con->dynlist; for (;;) { if (victim == dyn) break; prev = victim; victim = victim->next; if (victim == NULL) { tdsdump_log(TDS_DBG_FUNC, "ct_deallocate_dynamic() : cannot find entry in list\n"); return CS_FAIL; } } tdsdump_log(TDS_DBG_FUNC, "ct_deallocate_dynamic() : command entry found in list\n"); next = victim->next; if (victim->id) { strcpy(myid, victim->id); free(victim->id); } free(victim->stmt); param_clear(victim->param_list); free(victim); tdsdump_log(TDS_DBG_FUNC, "ct_deallocate_dynamic() : relinking list\n"); if (prev) prev->next = next; else con->dynlist = next; tdsdump_log(TDS_DBG_FUNC, "ct_deallocate_dynamic() : relinked list\n"); if (strlen(myid) > 0) { tdsdyn = tds_lookup_dynamic(con->tds_socket, myid); if (tdsdyn) { tds_free_dynamic(con->tds_socket, tdsdyn); } } return CS_SUCCEED; } freetds-0.91/src/ctlib/cs.c100664 001750 000144 00000102536 11452561624 0011251/* 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. */ #if HAVE_CONFIG_H #include #endif #include #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 "tdsconvert.h" #include "replacements.h" TDS_RCSID(var, "$Id: cs.c,v 1.76 2010/10/05 08:36:36 freddy77 Exp $"); static int _cs_datatype_length(int dtype); 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; } /** * returns the fixed length of the specified data type, or 0 if not a * fixed length data type */ static int _cs_datatype_length(int dtype) { tdsdump_log(TDS_DBG_FUNC, "_cs_datatype_length(%d)\n", dtype); switch (dtype) { case SYBINT1: return 1; case SYBINT2: return 2; case SYBINT4: return 4; case SYBINT8: return 8; case SYBFLT8: return 8; case SYBREAL: return 4; case SYBBIT: return 1; case SYBMONEY: return 8; case SYBMONEY4: return 4; case SYBDATETIME: return 8; case SYBDATETIME4: return 4; default: return 0; } } 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 (CS_LOCALE *) calloc(1, sizeof(CS_LOCALE)); } 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 = (CS_CONTEXT *) calloc(1, sizeof(CS_CONTEXT)); 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(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) { int src_type, src_len, desttype, 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(srcfmt->datatype); 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(destfmt->datatype); 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; } 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 SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBREAL: case SYBBIT: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: *resultlen = _cs_datatype_length(src_type); 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: 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: memcpy(dest, &(cres.ti), 1); *resultlen = 1; ret = CS_SUCCEED; break; case SYBINT2: memcpy(dest, &(cres.si), 2); *resultlen = 2; ret = CS_SUCCEED; break; case SYBINT4: memcpy(dest, &(cres.i), 4); *resultlen = 4; ret = CS_SUCCEED; break; case SYBINT8: memcpy(dest, &(cres.bi), 8); *resultlen = 8; ret = CS_SUCCEED; break; case SYBFLT8: memcpy(dest, &(cres.f), 8); *resultlen = 8; ret = CS_SUCCEED; break; case SYBREAL: memcpy(dest, &(cres.r), 4); *resultlen = 4; ret = CS_SUCCEED; break; case SYBMONEY: tdsdump_log(TDS_DBG_FUNC, "cs_convert() copying %d bytes to src\n", (int) sizeof(TDS_MONEY)); memcpy(dest, &(cres.m), sizeof(TDS_MONEY)); *resultlen = sizeof(TDS_MONEY); ret = CS_SUCCEED; break; case SYBMONEY4: memcpy(dest, &(cres.m4), sizeof(TDS_MONEY4)); *resultlen = sizeof(TDS_MONEY4); ret = CS_SUCCEED; break; case SYBDATETIME: memcpy(dest, &(cres.dt), sizeof(TDS_DATETIME)); *resultlen = sizeof(TDS_DATETIME); ret = CS_SUCCEED; break; case SYBDATETIME4: memcpy(dest, &(cres.dt4), sizeof(TDS_DATETIME4)); *resultlen = sizeof(TDS_DATETIME4); 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(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec) { TDS_DATETIME *dt; TDS_DATETIME4 *dt4; TDSDATEREC dr; tdsdump_log(TDS_DBG_FUNC, "cs_dt_crack(%p, %d, %p, %p)\n", ctx, datetype, dateval, daterec); if (datetype == CS_DATETIME_TYPE) { dt = (TDS_DATETIME *) dateval; tds_datecrack(SYBDATETIME, dt, &dr); } else if (datetype == CS_DATETIME4_TYPE) { dt4 = (TDS_DATETIME4 *) dateval; tds_datecrack(SYBDATETIME4, dt4, &dr); } else { return CS_FAIL; } 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.millisecond; daterec->datetzone = 0; return CS_SUCCEED; } 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 = (char *)malloc(buflen + 1); if (!locale->charset) break; strncpy(locale->charset, (char *)buffer, buflen); locale->charset[buflen] = '\0'; code = CS_SUCCEED; break; case CS_SYB_LANG: if (buflen == CS_NULLTERM) { buflen = strlen((char *)buffer); } free(locale->language); locale->language = (char *)malloc(buflen + 1); if (!locale->language) break; strncpy(locale->language, (char *)buffer, buflen); locale->language[buflen] = '\0'; 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 = (char *)malloc(i + 1); if (!locale->language) break; strncpy(locale->language, b, i); locale->language[i] = '\0'; } if (i != (buflen - 1)) { free(locale->charset); locale->charset = (char *)malloc(buflen - i); if (!locale->charset) break; strncpy(locale->charset, b + i + 1, buflen - i - 1); locale->charset[buflen - i - 1] = '\0'; } 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 = (char *)malloc(buflen + 1); if (!locale->collate) break; strncpy(locale->collate, (char *)buffer, buflen); locale->collate[buflen] = '\0'; 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; int 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 rc == TDS_SUCCEED ? 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 = (struct cs_diag_msg *) malloc(sizeof(struct cs_diag_msg)); if (*curptr == NULL) { return CS_FAIL; } else { (*curptr)->next = NULL; (*curptr)->msg = malloc(sizeof(CS_CLIENTMSG)); 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; } freetds-0.91/src/ctlib/blk.c100664 001750 000144 00000046750 11421021617 0011406/* 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. */ #if HAVE_CONFIG_H #include #endif #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" TDS_RCSID(var, "$Id: blk.c,v 1.53 2010/07/19 10:06:07 freddy77 Exp $"); static void _blk_null_error(TDSBCPINFO *bcpinfo, int index, int offset); static int _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); CS_RETCODE blk_alloc(CS_CONNECTION * connection, CS_INT version, CS_BLKDESC ** blk_pointer) { tdsdump_log(TDS_DBG_FUNC, "blk_alloc(%p, %d, %p)\n", connection, version, blk_pointer); *blk_pointer = (CS_BLKDESC *) calloc(1, sizeof(CS_BLKDESC)); /* so we know who we belong to */ (*blk_pointer)->con = connection; 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 = blkdesc->con; 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; int len; 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(blkdesc->con, "blk_describe", 2, 5, 1, 141, "%s, %d", "colnum", item); return CS_FAIL; } curcol = blkdesc->bcpinfo.bindinfo->columns[item - 1]; len = curcol->column_namelen; if (len >= CS_MAX_NAME) len = CS_MAX_NAME - 1; strncpy(datafmt->name, curcol->column_name, len); /* name is always null terminated */ datafmt->name[len] = 0; datafmt->namelen = len; /* need to turn the SYBxxx into a CS_xxx_TYPE */ datafmt->datatype = _ct_get_client_type(curcol); 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 = blkdesc->con->tds_socket; switch (type) { case CS_BLK_BATCH: if (tds_bcp_done(tds, &rows_copied) != TDS_SUCCEED) { _ctclient_msg(blkdesc->con, "blk_done", 2, 5, 1, 140, ""); return CS_FAIL; } if (outrow) *outrow = rows_copied; if (tds_bcp_start(tds, &blkdesc->bcpinfo) != TDS_SUCCEED) { _ctclient_msg(blkdesc->con, "blk_done", 2, 5, 1, 140, ""); return CS_FAIL; } break; case CS_BLK_ALL: if (tds_bcp_done(tds, &rows_copied) != TDS_SUCCEED) { _ctclient_msg(blkdesc->con, "blk_done", 2, 5, 1, 140, ""); return CS_FAIL; } if (outrow) *outrow = rows_copied; /* free allocated storage in blkdesc & initialise flags, etc. */ if (blkdesc->bcpinfo.tablename) TDS_ZERO_FREE(blkdesc->bcpinfo.tablename); if (blkdesc->bcpinfo.insert_stmt) TDS_ZERO_FREE(blkdesc->bcpinfo.insert_stmt); if (blkdesc->bcpinfo.bindinfo) { tds_free_results(blkdesc->bcpinfo.bindinfo); blkdesc->bcpinfo.bindinfo = NULL; } blkdesc->bcpinfo.direction = 0; blkdesc->bcpinfo.bind_count = CS_UNUSED; blkdesc->bcpinfo.xfer_init = 0; blkdesc->bcpinfo.var_cols = 0; break; } return CS_SUCCEED; } CS_RETCODE blk_drop(CS_BLKDESC * blkdesc) { tdsdump_log(TDS_DBG_FUNC, "blk_drop(%p)\n", blkdesc); if (!blkdesc) return CS_SUCCEED; free(blkdesc->bcpinfo.tablename); free(blkdesc->bcpinfo.insert_stmt); tds_free_results(blkdesc->bcpinfo.bindinfo); free(blkdesc); 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(blkdesc->con, "blk_init", 2, 6, 1, 138, ""); return CS_FAIL; } if (!tablename) { _ctclient_msg(blkdesc->con, "blk_init", 2, 6, 1, 139, ""); return CS_FAIL; } if (tnamelen == CS_NULLTERM) tnamelen = strlen(tablename); /* free allocated storage in blkdesc & initialise flags, etc. */ if (blkdesc->bcpinfo.tablename) { tdsdump_log(TDS_DBG_FUNC, "blk_init() freeing tablename\n"); free(blkdesc->bcpinfo.tablename); } if (blkdesc->bcpinfo.insert_stmt) { tdsdump_log(TDS_DBG_FUNC, "blk_init() freeing insert_stmt\n"); TDS_ZERO_FREE(blkdesc->bcpinfo.insert_stmt); } if (blkdesc->bcpinfo.bindinfo) { tdsdump_log(TDS_DBG_FUNC, "blk_init() freeing results\n"); tds_free_results(blkdesc->bcpinfo.bindinfo); blkdesc->bcpinfo.bindinfo = NULL; } /* string can be no-nul terminated so copy with memcpy */ blkdesc->bcpinfo.tablename = (char *) malloc(tnamelen + 1); /* FIXME malloc can fail */ memcpy(blkdesc->bcpinfo.tablename, tablename, tnamelen); blkdesc->bcpinfo.tablename[tnamelen] = 0; blkdesc->bcpinfo.direction = direction; blkdesc->bcpinfo.bind_count = CS_UNUSED; blkdesc->bcpinfo.xfer_init = 0; blkdesc->bcpinfo.var_cols = 0; if (tds_bcp_init(blkdesc->con->tds_socket, &blkdesc->bcpinfo) == TDS_FAIL) { _ctclient_msg(blkdesc->con, "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(blkdesc->con, "blk_props", 2, 5, 1, 141, "%s, %d", "action", action); break; } break; default: _ctclient_msg(blkdesc->con, "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; TDS_INT ret; TDS_INT temp_count; TDS_INT row_of_query; TDS_INT rows_written; tdsdump_log(TDS_DBG_FUNC, "_blk_rowxfer_out(%p, %d, %p)\n", blkdesc, rows_to_xfer, rows_xferred); if (!blkdesc || !blkdesc->con) return CS_FAIL; tds = blkdesc->con->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_submit_queryf(tds, "select * from %s", blkdesc->bcpinfo.tablename) == TDS_FAIL) { _ctclient_msg(blkdesc->con, "blk_rowxfer", 2, 5, 1, 140, ""); return CS_FAIL; } while ((ret = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCEED) { if (result_type == TDS_ROW_RESULT) break; } if (ret != TDS_SUCCEED || result_type != TDS_ROW_RESULT) { _ctclient_msg(blkdesc->con, "blk_rowxfer", 2, 5, 1, 140, ""); return CS_FAIL; } blkdesc->bcpinfo.xfer_init = 1; } row_of_query = 0; rows_written = 0; 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_SUCCEED: if (result_type == TDS_ROW_RESULT || result_type == TDS_COMPUTE_RESULT) { if (result_type == TDS_ROW_RESULT) { if (_ct_bind_data( blkdesc->con->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(blkdesc->con, "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 = blkdesc->con->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_bcp_start_copy_in(tds, &blkdesc->bcpinfo) == TDS_FAIL) { _ctclient_msg(blkdesc->con, "blk_rowxfer", 2, 5, 1, 140, ""); return CS_FAIL; } blkdesc->bcpinfo.xfer_init = 1; } blkdesc->bcpinfo.parent = blkdesc; 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_SUCCEED) { } } return CS_SUCCEED; } static void _blk_null_error(TDSBCPINFO *bcpinfo, int index, int offset) { CS_BLKDESC *blkdesc = (CS_BLKDESC *) bcpinfo->parent; tdsdump_log(TDS_DBG_FUNC, "_blk_null_error(%p, %d, %d)\n", bcpinfo, index, offset); _ctclient_msg(blkdesc->con, "blk_rowxfer", 2, 7, 1, 142, "%d, %d", index + 1, offset + 1); } static int _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->parent; CS_CONTEXT *ctx = blkdesc->con->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; 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; } if (src) { 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_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_TINYINT_TYPE: srclen = 1; 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 == -1) { null_column = 1; } } if (!null_column) { srcfmt.datatype = srctype; srcfmt.maxlength = srclen; destfmt.datatype = _ct_get_client_type(bindcol); 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 CS_SUCCEED; } else { printf("error source field not addressable \n"); return CS_FAIL; } } freetds-0.91/src/ctlib/ctutil.c100664 001750 000144 00000015345 11426211037 0012140/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "cspublic.h" #include "ctlib.h" #include "tds.h" #include "replacements.h" /* #include "fortify.h" */ TDS_RCSID(var, "$Id: ctutil.c,v 1.31 2010/08/04 07:09:19 freddy77 Exp $"); /* * test include consistency * I don't think all compiler are able to compile this code... if not comment it */ #if ENABLE_EXTRA_CHECKS #if defined(__GNUC__) && __GNUC__ >= 2 #define COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] __attribute__ ((unused)) #else #define COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] #endif #define TEST_EQUAL(t,a,b) 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) \ COMPILE_CHECK(t,sizeof(((sa*)0)->fa) == sizeof(((sb*)0)->fb) && (TDS_INTPTR)(&((sa*)0)->fa) == (TDS_INTPTR)(&((sb*)0)->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); TEST_ATTRIBUTE(t33,TDS_VARBINARY,len,CS_VARBINARY,len); TEST_ATTRIBUTE(t34,TDS_VARBINARY,array,CS_VARBINARY,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->parent) { con = (CS_CONNECTION *) tds->parent; } memset(&errmsg, '\0', sizeof(errmsg)); errmsg.msgnumber = msg->msgno; strcpy(errmsg.msgstring, msg->message); errmsg.msgstringlen = strlen(msg->message); 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 */ int _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->parent) { con = (CS_CONNECTION *) tds->parent; } memset(&errmsg, '\0', sizeof(errmsg)); errmsg.msgnumber = msg->msgno; tds_strlcpy(errmsg.text, msg->message, sizeof(errmsg.text)); errmsg.textlen = strlen(errmsg.text); errmsg.sqlstate[0] = 0; if (msg->sql_state) tds_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); tds_strlcpy(errmsg.svrname, msg->server, CS_MAX_NAME); } if (msg->proc_name) { errmsg.proclen = strlen(msg->proc_name); tds_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_SUCCEED : TDS_FAIL; } freetds-0.91/src/ctlib/unittests/Makefile.am100664 001750 000144 00000004470 11424754547 0014603# $Id: Makefile.am,v 1.32 2010/07/31 08:05:59 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) 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 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 $(LIBICONV) @NETWORK_LIBS@ CLEANFILES = tdsdump.out freetds-0.91/src/ctlib/unittests/Makefile.in100664 001750 000144 00000077113 11623070617 0014606# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.32 2010/07/31 08:05:59 freddy77 Exp $ VPATH = @srcdir@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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_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_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_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) 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ 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) \ $(rpc_ct_param_SOURCES) $(rpc_ct_setparam_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) \ $(rpc_ct_param_SOURCES) $(rpc_ct_setparam_SOURCES) \ $(t0001_SOURCES) $(t0002_SOURCES) $(t0003_SOURCES) \ $(t0004_SOURCES) $(t0005_SOURCES) $(t0006_SOURCES) \ $(t0007_SOURCES) $(t0008_SOURCES) $(t0009_SOURCES) ETAGS = etags CTAGS = ctags am__tty_colors = \ red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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 $(LIBICONV) @NETWORK_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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) 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 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 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/ctlib/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/ctlib/unittests/Makefile .PRECIOUS: 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) @rm -f array_bind$(EXEEXT) $(LINK) $(array_bind_OBJECTS) $(array_bind_LDADD) $(LIBS) blk_in$(EXEEXT): $(blk_in_OBJECTS) $(blk_in_DEPENDENCIES) @rm -f blk_in$(EXEEXT) $(LINK) $(blk_in_OBJECTS) $(blk_in_LDADD) $(LIBS) blk_in2$(EXEEXT): $(blk_in2_OBJECTS) $(blk_in2_DEPENDENCIES) @rm -f blk_in2$(EXEEXT) $(LINK) $(blk_in2_OBJECTS) $(blk_in2_LDADD) $(LIBS) blk_out$(EXEEXT): $(blk_out_OBJECTS) $(blk_out_DEPENDENCIES) @rm -f blk_out$(EXEEXT) $(LINK) $(blk_out_OBJECTS) $(blk_out_LDADD) $(LIBS) cancel$(EXEEXT): $(cancel_OBJECTS) $(cancel_DEPENDENCIES) @rm -f cancel$(EXEEXT) $(LINK) $(cancel_OBJECTS) $(cancel_LDADD) $(LIBS) connect_fail$(EXEEXT): $(connect_fail_OBJECTS) $(connect_fail_DEPENDENCIES) @rm -f connect_fail$(EXEEXT) $(LINK) $(connect_fail_OBJECTS) $(connect_fail_LDADD) $(LIBS) cs_config$(EXEEXT): $(cs_config_OBJECTS) $(cs_config_DEPENDENCIES) @rm -f cs_config$(EXEEXT) $(LINK) $(cs_config_OBJECTS) $(cs_config_LDADD) $(LIBS) cs_diag$(EXEEXT): $(cs_diag_OBJECTS) $(cs_diag_DEPENDENCIES) @rm -f cs_diag$(EXEEXT) $(LINK) $(cs_diag_OBJECTS) $(cs_diag_LDADD) $(LIBS) ct_cursor$(EXEEXT): $(ct_cursor_OBJECTS) $(ct_cursor_DEPENDENCIES) @rm -f ct_cursor$(EXEEXT) $(LINK) $(ct_cursor_OBJECTS) $(ct_cursor_LDADD) $(LIBS) ct_cursors$(EXEEXT): $(ct_cursors_OBJECTS) $(ct_cursors_DEPENDENCIES) @rm -f ct_cursors$(EXEEXT) $(LINK) $(ct_cursors_OBJECTS) $(ct_cursors_LDADD) $(LIBS) ct_diagall$(EXEEXT): $(ct_diagall_OBJECTS) $(ct_diagall_DEPENDENCIES) @rm -f ct_diagall$(EXEEXT) $(LINK) $(ct_diagall_OBJECTS) $(ct_diagall_LDADD) $(LIBS) ct_diagclient$(EXEEXT): $(ct_diagclient_OBJECTS) $(ct_diagclient_DEPENDENCIES) @rm -f ct_diagclient$(EXEEXT) $(LINK) $(ct_diagclient_OBJECTS) $(ct_diagclient_LDADD) $(LIBS) ct_diagserver$(EXEEXT): $(ct_diagserver_OBJECTS) $(ct_diagserver_DEPENDENCIES) @rm -f ct_diagserver$(EXEEXT) $(LINK) $(ct_diagserver_OBJECTS) $(ct_diagserver_LDADD) $(LIBS) ct_dynamic$(EXEEXT): $(ct_dynamic_OBJECTS) $(ct_dynamic_DEPENDENCIES) @rm -f ct_dynamic$(EXEEXT) $(LINK) $(ct_dynamic_OBJECTS) $(ct_dynamic_LDADD) $(LIBS) ct_options$(EXEEXT): $(ct_options_OBJECTS) $(ct_options_DEPENDENCIES) @rm -f ct_options$(EXEEXT) $(LINK) $(ct_options_OBJECTS) $(ct_options_LDADD) $(LIBS) datafmt$(EXEEXT): $(datafmt_OBJECTS) $(datafmt_DEPENDENCIES) @rm -f datafmt$(EXEEXT) $(LINK) $(datafmt_OBJECTS) $(datafmt_LDADD) $(LIBS) get_send_data$(EXEEXT): $(get_send_data_OBJECTS) $(get_send_data_DEPENDENCIES) @rm -f get_send_data$(EXEEXT) $(LINK) $(get_send_data_OBJECTS) $(get_send_data_LDADD) $(LIBS) lang_ct_param$(EXEEXT): $(lang_ct_param_OBJECTS) $(lang_ct_param_DEPENDENCIES) @rm -f lang_ct_param$(EXEEXT) $(LINK) $(lang_ct_param_OBJECTS) $(lang_ct_param_LDADD) $(LIBS) rpc_ct_param$(EXEEXT): $(rpc_ct_param_OBJECTS) $(rpc_ct_param_DEPENDENCIES) @rm -f rpc_ct_param$(EXEEXT) $(LINK) $(rpc_ct_param_OBJECTS) $(rpc_ct_param_LDADD) $(LIBS) rpc_ct_setparam$(EXEEXT): $(rpc_ct_setparam_OBJECTS) $(rpc_ct_setparam_DEPENDENCIES) @rm -f rpc_ct_setparam$(EXEEXT) $(LINK) $(rpc_ct_setparam_OBJECTS) $(rpc_ct_setparam_LDADD) $(LIBS) t0001$(EXEEXT): $(t0001_OBJECTS) $(t0001_DEPENDENCIES) @rm -f t0001$(EXEEXT) $(LINK) $(t0001_OBJECTS) $(t0001_LDADD) $(LIBS) t0002$(EXEEXT): $(t0002_OBJECTS) $(t0002_DEPENDENCIES) @rm -f t0002$(EXEEXT) $(LINK) $(t0002_OBJECTS) $(t0002_LDADD) $(LIBS) t0003$(EXEEXT): $(t0003_OBJECTS) $(t0003_DEPENDENCIES) @rm -f t0003$(EXEEXT) $(LINK) $(t0003_OBJECTS) $(t0003_LDADD) $(LIBS) t0004$(EXEEXT): $(t0004_OBJECTS) $(t0004_DEPENDENCIES) @rm -f t0004$(EXEEXT) $(LINK) $(t0004_OBJECTS) $(t0004_LDADD) $(LIBS) t0005$(EXEEXT): $(t0005_OBJECTS) $(t0005_DEPENDENCIES) @rm -f t0005$(EXEEXT) $(LINK) $(t0005_OBJECTS) $(t0005_LDADD) $(LIBS) t0006$(EXEEXT): $(t0006_OBJECTS) $(t0006_DEPENDENCIES) @rm -f t0006$(EXEEXT) $(LINK) $(t0006_OBJECTS) $(t0006_LDADD) $(LIBS) t0007$(EXEEXT): $(t0007_OBJECTS) $(t0007_DEPENDENCIES) @rm -f t0007$(EXEEXT) $(LINK) $(t0007_OBJECTS) $(t0007_LDADD) $(LIBS) t0008$(EXEEXT): $(t0008_OBJECTS) $(t0008_DEPENDENCIES) @rm -f t0008$(EXEEXT) $(LINK) $(t0008_OBJECTS) $(t0008_LDADD) $(LIBS) t0009$(EXEEXT): $(t0009_OBJECTS) $(t0009_DEPENDENCIES) @rm -f t0009$(EXEEXT) $(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)/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)/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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ echo "$$grn$$dashes"; \ else \ echo "$$red$$dashes"; \ fi; \ echo "$$banner"; \ test -z "$$skipped" || echo "$$skipped"; \ test -z "$$report" || echo "$$report"; \ echo "$$dashes$$std"; \ test "$$failed" -eq 0; \ else :; fi 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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-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 all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool ctags \ 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 uninstall uninstall-am # 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-0.91/src/ctlib/unittests/array_bind.c100664 001750 000144 00000012234 10607355144 0015012#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static char software_version[] = "$Id: array_bind.c,v 1.6 2007/04/12 07:06:12 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; int 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[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, &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-0.91/src/ctlib/unittests/common.c100664 001750 000144 00000023106 11361067520 0014164#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 static char software_version[] = "$Id: common.c,v 1.23 2010/04/13 13:19:12 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 = tds_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"); } return ret; } ret = ct_cmd_alloc(*conn, cmd); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Command Alloc failed!\n"); } 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; } freetds-0.91/src/ctlib/unittests/common.h100664 001750 000144 00000002444 11034173150 0014165 #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); #endif freetds-0.91/src/ctlib/unittests/blk_in.h100664 001750 000144 00000006625 10052153556 0014147char 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-0.91/src/ctlib/unittests/blk_in.c100664 001750 000144 00000021125 10117600114 0014117#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 int 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 }; CS_RETCODE ret; /* non nulls */ ret = do_bind(blkdesc, 1, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_bit, &l_not_null_bit, &i_not_null_bit); ret = do_bind(blkdesc, 2, CS_FMT_NULLTERM, CS_CHAR_TYPE, 7, not_null_char, &l_not_null_char, &i_not_null_char); ret = do_bind(blkdesc, 3, CS_FMT_NULLTERM, CS_CHAR_TYPE, 10, not_null_varchar, &l_not_null_varchar, &i_not_null_varchar); ret = do_bind(blkdesc, 4, CS_FMT_NULLTERM, CS_CHAR_TYPE, 20, not_null_datetime, &l_not_null_datetime, &i_not_null_datetime); ret = do_bind(blkdesc, 5, CS_FMT_NULLTERM, CS_CHAR_TYPE, 20, not_null_smalldatetime, &l_not_null_smalldatetime, &i_not_null_smalldatetime); ret = do_bind(blkdesc, 6, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_money, &l_not_null_money, &i_not_null_money); ret = do_bind(blkdesc, 7, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_smallmoney, &l_not_null_smallmoney, &i_not_null_smallmoney); ret = do_bind(blkdesc, 8, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_float, &l_not_null_float, &i_not_null_float); ret = do_bind(blkdesc, 9, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_real, &l_not_null_real, &i_not_null_real); ret = do_bind(blkdesc, 10, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_decimal, &l_not_null_decimal, &i_not_null_decimal); ret = do_bind(blkdesc, 11, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_numeric, &l_not_null_numeric, &i_not_null_numeric); ret = do_bind(blkdesc, 12, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_int, &l_not_null_int, &i_not_null_int); ret = do_bind(blkdesc, 13, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_smallint, &l_not_null_smallint, &i_not_null_smallint); ret = do_bind(blkdesc, 14, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_tinyint, &l_not_null_tinyint, &i_not_null_tinyint); /* nulls */ ret = do_bind(blkdesc, 15, CS_FMT_NULLTERM, CS_CHAR_TYPE, 7, not_null_char, &l_null_char, &i_null_char); ret = do_bind(blkdesc, 16, CS_FMT_NULLTERM, CS_CHAR_TYPE, 10, not_null_varchar, &l_null_varchar, &i_null_varchar); ret = do_bind(blkdesc, 17, CS_FMT_NULLTERM, CS_CHAR_TYPE, 20, not_null_datetime, &l_null_datetime, &i_null_datetime); ret = do_bind(blkdesc, 18, CS_FMT_NULLTERM, CS_CHAR_TYPE, 20, not_null_smalldatetime, &l_null_smalldatetime, &i_null_smalldatetime); ret = do_bind(blkdesc, 19, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_money, &l_null_money, &i_null_money); ret = do_bind(blkdesc, 20, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_smallmoney, &l_null_smallmoney, &i_null_smallmoney); ret = do_bind(blkdesc, 21, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_float, &l_null_float, &i_null_float); ret = do_bind(blkdesc, 22, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_real, &l_null_real, &i_null_real); ret = do_bind(blkdesc, 23, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_decimal, &l_null_decimal, &i_null_decimal); ret = do_bind(blkdesc, 24, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_numeric, &l_null_numeric, &i_null_numeric); ret = do_bind(blkdesc, 25, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_int, &l_null_int, &i_null_int); ret = do_bind(blkdesc, 26, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_smallint, &l_null_smallint, &i_null_smallint); ret = do_bind(blkdesc, 27, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_tinyint, &l_null_tinyint, &i_null_tinyint); } static int 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 CS_FAIL; } 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 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 count = 0; int ret = 0; 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-0.91/src/ctlib/unittests/blk_in2.c100664 001750 000144 00000005153 10575244177 0014231/* * 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.1 2007/03/12 12:33:03 freddy77 Exp $ */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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-0.91/src/ctlib/unittests/blk_out.c100664 001750 000144 00000010321 10367430554 0014334#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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.5 2006/01/30 15:31:56 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-0.91/src/ctlib/unittests/cancel.c100664 001750 000144 00000012144 11461506600 0014117#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include "common.h" static char software_version[] = "$Id: cancel.c,v 1.14 2010/10/26 08:12:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #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-0.91/src/ctlib/unittests/connect_fail.c100664 001750 000144 00000003441 07765627530 0015340#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include "common.h" static char software_version[] = "$Id: connect_fail.c,v 1.4 2003/12/10 14:36:08 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-0.91/src/ctlib/unittests/cs_config.c100664 001750 000144 00000006107 10133707272 0014631#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #ifdef HAVE_STRING_H #include #endif #include #include #include "common.h" static char software_version[] = "$Id: cs_config.c,v 1.5 2004/10/15 08:47:54 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-0.91/src/ctlib/unittests/cs_diag.c100664 001750 000144 00000005623 10077541701 0014272#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #include "common.h" static char software_version[] = "$Id: cs_diag.c,v 1.4 2004/07/21 19:28:01 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-0.91/src/ctlib/unittests/ct_cursor.c100664 001750 000144 00000037200 10367430554 0014705#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #ifdef HAVE_STRING_H #include #endif #include #include "common.h" static char software_version[] = "$Id: ct_cursor.c,v 1.4 2006/01/30 15:31:56 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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; int is_return_status = 0; 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); is_return_status = i + 1; } 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); is_return_status = i + 1; } 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-0.91/src/ctlib/unittests/ct_cursors.c100664 001750 000144 00000023554 10367430554 0015077 #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #ifdef HAVE_STRING_H #include #endif #include #include "common.h" static char software_version[] = "$Id: ct_cursors.c,v 1.3 2006/01/30 15:31:56 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_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; int is_return_status = 0; 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"); } 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_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); is_return_status = i + 1; } 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_SUCCEED: case CS_CMD_DONE: case CS_CMD_FAIL: 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); is_return_status = i + 1; } 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-0.91/src/ctlib/unittests/ct_diagall.c100664 001750 000144 00000015156 10607355144 0014771#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static char software_version[] = "$Id: ct_diagall.c,v 1.7 2007/04/12 07:06:12 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* 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; 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-0.91/src/ctlib/unittests/ct_diagclient.c100664 001750 000144 00000013672 10607355144 0015500#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: ct_diagclient.c,v 1.8 2007/04/12 07:06:12 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* 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; 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, &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-0.91/src/ctlib/unittests/ct_diagserver.c100664 001750 000144 00000004220 10242627104 0015506#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: ct_diagserver.c,v 1.4 2005/05/18 12:00:04 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-0.91/src/ctlib/unittests/ct_dynamic.c100664 001750 000144 00000027331 10421656563 0015021#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: ct_dynamic.c,v 1.3 2006/04/20 10:07:47 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define QUERY_STRING "insert into #ctparam_lang (name,age,cost,bdate,fval) values (@in1, @in2, @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); int insert_test(CS_CONNECTION * conn, CS_COMMAND * cmd, short useNames); int main(int argc, char *argv[]) { int errCode = 0; CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_COMMAND *cmd2; int verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_CHAR cmdbuf[4096]; CS_CHAR name[257]; CS_INT datalength; short int 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; fprintf(stdout, "%s: use ct_dynamic/ct_param to prepare and execute a statement \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); ret = ct_cmd_alloc(conn, &cmd2); if (ret != CS_SUCCEED) { fprintf(stderr, "cmd2_alloc failed\n"); errCode = 1; goto ERR; } /* 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); if (ret != CS_SUCCEED) { fprintf(stderr, "create table failed\n"); errCode = 1; goto ERR; } 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); if (ret != CS_SUCCEED) { fprintf(stderr, "insert table failed\n"); errCode = 1; goto ERR; } 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); if (ret != CS_SUCCEED) { fprintf(stderr, "insert table failed\n"); errCode = 1; goto ERR; } 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); if (ret != CS_SUCCEED) { fprintf(stderr, "insert table failed\n"); errCode = 1; goto ERR; } strcpy(cmdbuf, "select name from #ct_dynamic where age = ?"); ret = ct_dynamic(cmd, CS_PREPARE, "age", CS_NULLTERM, cmdbuf, CS_NULLTERM); if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(CS_PREPARE) failed\n"); errCode = 1; goto ERR; } 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: errCode = 1; goto ERR; } } if (ret != CS_END_RESULTS) { errCode = 1; goto ERR; } ret = ct_dynamic(cmd, CS_DESCRIBE_INPUT, "age", CS_NULLTERM, NULL, CS_UNUSED); if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(CS_DESCRIBE_INPUT) failed\n"); errCode = 1; goto ERR; } 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); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } for (i = 1; i <= num_cols; i++) { ret = ct_describe(cmd, i, &descfmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } 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: errCode = 1; goto ERR; } } ret = ct_dynamic(cmd, CS_DESCRIBE_OUTPUT, "age", CS_NULLTERM, NULL, CS_UNUSED); if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(CS_DESCRIBE_OUTPUT) failed\n"); errCode = 1; goto ERR; } 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); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 1) { fprintf(stderr, "CS_DESCRIBE_OUTPUT showed %d columns , expected 1\n", num_cols); errCode = 1; goto ERR; } for (i = 1; i <= num_cols; i++) { ret = ct_describe(cmd, i, &descfmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } 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: errCode = 1; goto ERR; } } ret = ct_dynamic(cmd2, CS_EXECUTE, "age", CS_NULLTERM, NULL, CS_UNUSED); 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); if (CS_SUCCEED != ret) { fprintf(stderr, "ct_setparam(int) failed\n"); return 1; } if (ct_send(cmd2) != CS_SUCCEED) { fprintf(stderr, "ct_send(CS_EXECUTE) failed\n"); errCode = 1; goto ERR; } while ((results_ret = ct_results(cmd2, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "1: 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(cmd2, 1, &datafmt, name, &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) { if (strcmp(name, "Bill")) { fprintf(stderr, "fetched value '%s' expected 'Bill'\n", name); errCode = 1; goto ERR; } } else { break; } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: 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; } intvar = 32; if (ct_send(cmd2) != CS_SUCCEED) { fprintf(stderr, "ct_send(CS_EXECUTE) failed\n"); errCode = 1; goto ERR; } while ((results_ret = ct_results(cmd2, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "2: 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(cmd2, 1, &datafmt, name, &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) { if (strcmp(name, "Freddy")) { fprintf(stderr, "fetched value '%s' expected 'Freddy'\n", name); errCode = 1; goto ERR; } } else { break; } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: 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; } ret = ct_dynamic(cmd, CS_DEALLOC, "age", CS_NULLTERM, NULL, CS_UNUSED); if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(CS_DEALLOC) failed\n"); errCode = 1; goto ERR; } 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: errCode = 1; goto ERR; } } if (ret != CS_END_RESULTS) { errCode = 1; goto ERR; } ERR: 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 1; } return errCode; } 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-0.91/src/ctlib/unittests/ct_options.c100664 001750 000144 00000006622 10271402044 0015052#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: ct_options.c,v 1.4 2005/07/26 09:36:36 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-0.91/src/ctlib/unittests/datafmt.c100664 001750 000144 00000010347 11415103656 0014320#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include "common.h" static char software_version[] = "$Id: datafmt.c,v 1.4 2010/07/07 13:57:02 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* 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 = 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-0.91/src/ctlib/unittests/get_send_data.c100664 001750 000144 00000014643 10673437312 0015470#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static char software_version[] = "$Id: get_send_data.c,v 1.5 2007/09/17 08:46:02 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 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; 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 = 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-0.91/src/ctlib/unittests/lang_ct_param.c100664 001750 000144 00000022446 11220757301 0015466#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 char software_version[] = "$Id: lang_ct_param.c,v 1.8 2009/06/25 20:32:01 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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; fprintf(stdout, "%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; /* 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); } 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); /* 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-0.91/src/ctlib/unittests/rpc_ct_param.c100664 001750 000144 00000041077 11231261703 0015330#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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.9 2009/07/21 06:44:19 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-0.91/src/ctlib/unittests/rpc_ct_setparam.c100664 001750 000144 00000041724 11311141761 0016043#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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.10 2009/12/13 10:37:37 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-0.91/src/ctlib/unittests/t0001.c100664 001750 000144 00000001631 07765627530 0013457#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include "common.h" static char software_version[] = "$Id: t0001.c,v 1.6 2003/12/10 14:36:08 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-0.91/src/ctlib/unittests/t0002.c100664 001750 000144 00000016757 10260445744 0013464#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #include "common.h" static char software_version[] = "$Id: t0002.c,v 1.9 2005/06/29 07:21:08 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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, is_return_status=0; 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); is_return_status = i+1; /* * 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-0.91/src/ctlib/unittests/t0003.c100664 001750 000144 00000010333 10242627105 0013436#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static char software_version[] = "$Id: t0003.c,v 1.10 2005/05/18 12:00:05 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-0.91/src/ctlib/unittests/t0004.c100664 001750 000144 00000010256 10242627106 0013444#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include "common.h" static char software_version[] = "$Id: t0004.c,v 1.9 2005/05/18 12:00:06 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-0.91/src/ctlib/unittests/t0005.c100664 001750 000144 00000002205 07765627530 0013461#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include "common.h" static char software_version[] = "$Id: t0005.c,v 1.6 2003/12/10 14:36:08 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; int i = 0; /************** ADDED LINE **********************/ fprintf(stdout, "%s: Testing login, logout\n", __FILE__); while (i++ < 100) { /********** ADDED LINE *********************/ 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; } } /**************************** ADDED LINE **********************/ if (verbose) { fprintf(stdout, "Test succeeded\n"); } return 0; } freetds-0.91/src/ctlib/unittests/t0006.c100664 001750 000144 00000026260 11452561624 0013456#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include static char software_version[] = "$Id: t0006.c,v 1.14 2010/10/05 08:36:36 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 = ""; 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) { unsigned 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-0.91/src/ctlib/unittests/t0007.c100664 001750 000144 00000014304 11365254136 0013453#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: t0007.c,v 1.10 2010/04/26 09:09:50 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-0.91/src/ctlib/unittests/t0008.c100664 001750 000144 00000007454 07615026056 0013465#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #include "common.h" static char software_version[] = "$Id: t0008.c,v 1.9 2003/01/26 18:42:54 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-0.91/src/ctlib/unittests/t0009.c100664 001750 000144 00000017721 10242627106 0013455#if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: t0009.c,v 1.12 2005/05/18 12:00:06 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* 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]; 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; } 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; } 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); } } 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; } } } } 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-0.91/src/dblib/Makefile.am100664 001750 000144 00000001463 11326010574 0012501# $Id: Makefile.am,v 1.37 2010/01/21 08:34:04 freddy77 Exp $ SUBDIRS = unittests AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libsybdb.la if SYBASE_COMPAT DBOPEN=dbopen.c endif if MINGW32 MINGW_SOURCES = ../../win32/initnet.c else MINGW_SOURCES = endif EXTRA_DIST = dbopen.c buffering.h db-lib.vcproj libsybdb_la_SOURCES= dblib.c dbutil.c rpc.c bcp.c xact.c $(DBOPEN) $(MINGW_SOURCES) # version bumped for 0.63, I hope we'll bump it less in the future -- freddy77 if MACOSX SYMBOLS = else SYMBOLS = -export-symbols-regex '^(db|bcp_|tdsdump_open|tdsdbopen|.*_xact|close_commit|open_commit|.?asprintf).*' endif libsybdb_la_LDFLAGS= -version-info 5:0:0 $(SYMBOLS) $(FREETDS_SYMBOLIC) libsybdb_la_LIBADD= ../tds/libtds.la ../replacements/libreplacements.la $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) freetds-0.91/src/dblib/Makefile.in100664 001750 000144 00000063460 11623070617 0012523# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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__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__DEPENDENCIES_1) am__libsybdb_la_SOURCES_DIST = dblib.c dbutil.c rpc.c bcp.c xact.c \ dbopen.c ../../win32/initnet.c @SYBASE_COMPAT_TRUE@am__objects_1 = dbopen.lo @MINGW32_TRUE@am__objects_2 = initnet.lo am_libsybdb_la_OBJECTS = dblib.lo dbutil.lo rpc.lo bcp.lo xact.lo \ $(am__objects_1) $(am__objects_2) libsybdb_la_OBJECTS = $(am_libsybdb_la_OBJECTS) libsybdb_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libsybdb_la_LDFLAGS) $(LDFLAGS) -o $@ 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsybdb_la_SOURCES) DIST_SOURCES = $(am__libsybdb_la_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-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 uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) 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@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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.37 2010/01/21 08:34:04 freddy77 Exp $ SUBDIRS = unittests AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libsybdb.la @SYBASE_COMPAT_TRUE@DBOPEN = dbopen.c @MINGW32_FALSE@MINGW_SOURCES = @MINGW32_TRUE@MINGW_SOURCES = ../../win32/initnet.c EXTRA_DIST = dbopen.c buffering.h db-lib.vcproj libsybdb_la_SOURCES = dblib.c dbutil.c rpc.c bcp.c xact.c $(DBOPEN) $(MINGW_SOURCES) @MACOSX_FALSE@SYMBOLS = -export-symbols-regex '^(db|bcp_|tdsdump_open|tdsdbopen|.*_xact|close_commit|open_commit|.?asprintf).*' # version bumped for 0.63, I hope we'll bump it less in the future -- freddy77 @MACOSX_TRUE@SYMBOLS = libsybdb_la_LDFLAGS = -version-info 5:0:0 $(SYMBOLS) $(FREETDS_SYMBOLIC) libsybdb_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) 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 .PRECIOUS: 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) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @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 " $(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)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsybdb.la: $(libsybdb_la_OBJECTS) $(libsybdb_la_DEPENDENCIES) $(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)/dbutil.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initnet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xact.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< initnet.lo: ../../win32/initnet.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT initnet.lo -MD -MP -MF $(DEPDIR)/initnet.Tpo -c -o initnet.lo `test -f '../../win32/initnet.c' || echo '$(srcdir)/'`../../win32/initnet.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/initnet.Tpo $(DEPDIR)/initnet.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../win32/initnet.c' object='initnet.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o initnet.lo `test -f '../../win32/initnet.c' || echo '$(srcdir)/'`../../win32/initnet.c 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. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; 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" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) 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; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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 \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \ 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-recursive uninstall uninstall-am \ uninstall-libLTLIBRARIES # 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-0.91/src/dblib/dblib.c100644 001750 000144 00000750352 11623070341 0011671/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2006-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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 #else static int errno=0; #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 #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: dblib.c,v 1.378.2.4 2011/06/07 08:52:29 freddy77 Exp $"); static RETCODE _dbresults(DBPROCESS * dbproc); static int _db_get_server_type(int bindtype); static int _get_printable_size(TDSCOLUMN * colinfo); static char *_dbprdate(char *timestr); static int _dbnullable(DBPROCESS * dbproc, int column); static char *tds_prdatatype(TDS_SERVER_TYPE datatype_token); static void copy_data_to_host_var(DBPROCESS *, int, const BYTE *, DBINT, int, BYTE *, DBINT, int, DBINT *); static int default_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); static 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_DEFINE(dblib_mutex); static int g_dblib_version = #ifdef TDS42 DBVERSION_42; #endif #ifdef TDS50 DBVERSION_100; #endif #ifdef TDS46 DBVERSION_46; #endif #ifdef TDS70 DBVERSION_70; #endif #ifdef TDS71 DBVERSION_71; #endif #ifdef TDS72 DBVERSION_72; #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 == NULL || tds->parent == NULL ) { return; } dbproc = (DBPROCESS *) tds->parent; dbproc->envchange_rcv |= (1 << (type - 1)); switch (type) { case TDS_ENV_DATABASE: tds_strlcpy(dbproc->dbcurdb, newval, sizeof(dbproc->dbcurdb)); break; case TDS_ENV_CHARSET: tds_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]; info = dbproc->tds_socket->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 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) } /* 19 */ , { NULL, 0 } /* 20 */ , { NULL, 0 } /* 21 */ , { NULL, 0 } /* 22 */ , { NULL, 0 } /* 23 */ , { NULL, 0 } /* 24 */ , { NULL, 0 } /* 25 */ , { NULL, 0 } /* 26 */ , { NULL, 0 } /* 27 */ , { NULL, 0 } /* 28 */ , { NULL, 0 } /* 29 */ , { NULL, 0 } /* BIGINTBIND 30 */ , { (BYTE*) &null_BIGINT, sizeof(null_BIGINT) } /* MAXBINDTYPES 31 */ }; 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 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; 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 */ static RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr) { NULLREP *pnullrep; tdsdump_log(TDS_DBG_FUNC, "dbgetnull(%p, %d, %d, %p)\n", dbproc, bindtype, varlen, varaddr); CHECK_PARAMETER(dbproc, SYBENULL, FAIL); CHECK_PARAMETER(varaddr, SYBENULL, FAIL); CHECK_PARAMETER(!IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE, FAIL); CHECK_PARAMETER(0 <= bindtype && bindtype < MAXBINDTYPES, SYBEBTYP, FAIL); if (!varaddr) { dbperror(dbproc, SYBENULP, 0, "dbgetnull", "varaddr"); return FAIL; } 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 DECIMALBIND: case FLT8BIND: case INTBIND: case MONEYBIND: case NUMERICBIND: case REALBIND: case SMALLBIND: case SMALLDATETIMEBIND: case SMALLMONEYBIND: case TINYBIND: case BIGINTBIND: memcpy(varaddr, pnullrep->bindval, pnullrep->len); return SUCCEED; default: if (pnullrep->bindval && (varlen <= 0 || (size_t)varlen >= pnullrep->len)) { memcpy(varaddr, pnullrep->bindval, pnullrep->len); } } /* * 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) { switch (bindtype) { case STRINGBIND: case NTBSTRINGBIND: varaddr[pnullrep->len] = '\0'; /* fall thru */ case CHARBIND: case VARYCHARBIND: break; #if 0 case BOUNDARYBIND: case SENSITIVITYBIND: #endif default: assert(!"unknown bindtype with unknown varlen"); } return SUCCEED; } 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; 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 = calloc(TDS_MAX_CONN, sizeof(TDSSOCKET *)); 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 = malloc(sizeof(LOGINREC))) == NULL) { dbperror(NULL, SYBEMEM, errno); return NULL; } if ((loginrec->tds_login = tds_alloc_login()) == NULL) { dbperror(NULL, SYBEMEM, errno); free(loginrec); return NULL; } /* set default values for loginrec */ tds_set_library(loginrec->tds_login, "DB-Library"); 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) { 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)) { dbperror(NULL, SYBENTLL, 0); return FAIL; } switch (which) { case DBSETHOST: tds_set_host(login->tds_login, value); return SUCCEED; break; case DBSETUSER: tds_set_user(login->tds_login, value); return SUCCEED; break; case DBSETPWD: tds_set_passwd(login->tds_login, value); return SUCCEED; break; case DBSETAPP: tds_set_app(login->tds_login, value); return SUCCEED; break; case DBSETCHARSET: tds_set_client_charset(login->tds_login, value ? value : ""); return SUCCEED; break; case DBSETNATLANG: tds_set_language(login->tds_login, value); return SUCCEED; break; case DBSETDBNAME: tds_set_database_name(login->tds_login, value ? value : ""); return SUCCEED; break; default: dbperror(NULL, SYBEASUL, 0); /* Attempt to set unknown LOGINREC field */ return FAIL; break; } } /** \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 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_71: tds_set_version(login->tds_login, 7, 1); return SUCCEED; case DBVERSION_72: tds_set_version(login->tds_login, 7, 2); 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 = malloc(sizeof(DBSTRING))) == NULL) { dbperror(NULL, SYBEMEM, errno); return FAIL; } (*strp)->strtotlen = (DBINT)strlen(p); if (((*strp)->strtext = malloc((*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 = malloc(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 = calloc(DBNUMOPTIONS, sizeof(DBOPTION))) == NULL) { dbperror(NULL, SYBEMEM, errno); return NULL; } for (i = 0; i < DBNUMOPTIONS; i++) { tds_strlcpy(dbopts[i].text, opttext[i], sizeof(dbopts[i].text)); 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; TDSCONNECTION *connection; tdsdump_log(TDS_DBG_FUNC, "dbopen(%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, "servername set to %s", server); } if ((dbproc = calloc(1, sizeof(DBPROCESS))) == NULL) { dbperror(NULL, SYBEMEM, errno); return NULL; } dbproc->msdblib = msdblib; dbproc->dbopts = init_dboptions(); if (dbproc->dbopts == NULL) { free(dbproc); return NULL; } dbproc->dboptcmd = NULL; dbproc->avail_flag = TRUE; dbproc->command_state = DBCMDNONE; tds_set_server(login->tds_login, server); if ((dbproc->tds_socket = tds_alloc_socket(dblib_get_tds_ctx(), 512)) == NULL ){ dbperror(NULL, SYBEMEM, 0); 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'; 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 &= ~0x02; /* we're not an ODBC driver */ tds_fix_connection(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); if (tds_connect_and_login(dbproc->tds_socket, connection) != TDS_SUCCEED) { tds_free_connection(connection); dbclose(dbproc); return NULL; } tds_free_connection(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); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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[]) { tdsdump_log(TDS_DBG_FUNC, "dbcmd(%p, %s)\n", dbproc, cmdstring); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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); } } if (dbproc->dbbufsz == 0) { dbproc->dbbuf = malloc(strlen(cmdstring) + 1); if (dbproc->dbbuf == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } strcpy((char *) dbproc->dbbuf, cmdstring); dbproc->dbbufsz = (int)strlen(cmdstring) + 1; } else { void *p; size_t newsz = strlen(cmdstring) + dbproc->dbbufsz; if ((p = realloc(dbproc->dbbuf, newsz)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } dbproc->dbbuf = (unsigned char *) p; strcat((char *) dbproc->dbbuf, cmdstring); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 * \todo \a name should be quoted. * \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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_NULP(name, "dbuse", 2, FAIL); if (!dbproc->tds_socket) return FAIL; /* quote name */ query = malloc(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_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); } if (dbproc->bcpinfo) free(dbproc->bcpinfo->tablename); 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); return; } /** * \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->parent; 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); } static const char * prdbresults_state(int retcode) { static char unknown[24]; 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(unknown, "oops: %u ??", retcode); } return unknown; } 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 TDS_SUCCEED: return "TDS_SUCCEED"; case TDS_FAIL: return "TDS_FAIL"; case TDS_NO_MORE_RESULTS: return "TDS_NO_MORE_RESULTS"; case TDS_CANCELLED: return "TDS_CANCELLED"; default: sprintf(unknown, "oops: %u ??", retcode); } return unknown; } static const char * prresult_type(int result_type) { static char unknown[24]; 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(unknown, "oops: %u ??", result_type); } return unknown; } /** * \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); tdsdump_log(TDS_DBG_FUNC, "dbresults returning %d (%s)\n", erc, prdbretcode(erc)); return erc; } static RETCODE _dbresults(DBPROCESS * dbproc) { RETCODE retcode = FAIL; TDSSOCKET *tds; int result_type = 0, done_flags; tdsdump_log(TDS_DBG_FUNC, "dbresults(%p)\n", dbproc); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); tds = dbproc->tds_socket; tdsdump_log(TDS_DBG_FUNC, "dbresults: dbresults_state is %d (%s)\n", dbproc->dbresults_state, prdbresults_state(dbproc->dbresults_state)); 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 (;;) { 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), prresult_type(result_type)); switch (retcode) { case TDS_SUCCEED: 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)); /* 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; 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; case TDS_CANCELLED: case TDS_FAIL: dbproc->dbresults_state = _DB_RES_INIT; return FAIL; break; default: tdsdump_log(TDS_DBG_FUNC, "dbresults() does not recognize return code from process_result_tokens\n"); assert(0); 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); CHECK_PARAMETER(dbproc, SYBENULL, 0); colinfo = dbcolptr(dbproc, column); if (!colinfo) return NULL; assert(colinfo->column_name[colinfo->column_namelen] == 0); return 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_PARAMETER(bindval, SYBENBVP, FAIL); switch (bindtype) { case DATETIMEBIND: case DECIMALBIND: case FLT8BIND: case INTBIND: case MONEYBIND: case NUMERICBIND: case REALBIND: case SMALLBIND: case SMALLDATETIMEBIND: case SMALLMONEYBIND: case TINYBIND: case BIGINTBIND: 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 = ((TDS_VARBINARY*) bindval)->len; break; case VARYCHARBIND: bindlen = ((TDS_VARCHAR*) bindval)->len; break; #if 0 case SENSITIVITYBIND: case BOUNDARYBIND: #endif default: dbperror(dbproc, SYBEBTYP, 0); return FAIL; } if ((pval = malloc(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(). */ RETCODE 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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(). */ RETCODE dbnextrow(DBPROCESS * dbproc) { TDSRESULTINFO *resinfo; TDSSOCKET *tds; RETCODE result = FAIL; TDS_INT res_type; TDS_INT computeid; int idx; /* row buffer index. Unless DBUFFER is on, idx will always be 0. */ tdsdump_log(TDS_DBG_FUNC, "dbnextrow(%p)\n", dbproc); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); tds = dbproc->tds_socket; if (IS_TDSDEAD(tds)) { dbperror(dbproc, SYBEDDNE, 0); return FAIL; } resinfo = tds->res_info; tdsdump_log(TDS_DBG_FUNC, "dbnextrow() dbresults_state = %d (%s)\n", dbproc->dbresults_state, prdbresults_state(dbproc->dbresults_state)); 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 { const int mask = TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE; buffer_save_row(dbproc); /* Get the row from the TDS stream. */ switch (tds_process_tokens(tds, &res_type, NULL, mask)) { case TDS_SUCCEED: 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; } 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 (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)); } return result; } /* dbnextrow() */ static int _db_get_server_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 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: return SYBNUMERIC; break; case DECIMALBIND: return SYBDECIMAL; break; default: return -1; break; } } /** * \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(DBPROCESS * dbproc, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen) { CONV_RESULT dres; DBINT ret; int i; int len; DBNUMERIC *num; tdsdump_log(TDS_DBG_FUNC, "dbconvert(%p, %s, %p, %d, %s, %p, %d)\n", dbproc, tds_prdatatype(srctype), src, srclen, tds_prdatatype(desttype), dest, destlen); /* dbproc and src can be NULLs */ CHECK_PARAMETER(dest, SYBEACNV, -1); if (0 == destlen) return 0; if (src == NULL || srclen == 0) { int bind = dbbindtype(desttype); int size = tds_get_size_by_type(desttype); if (SYBCHAR == desttype) { if (destlen > 0) { size = destlen; bind = CHARBIND; } else { size = 1; bind = NTBSTRINGBIND; } } 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); /* FIXME what happen if client do not reset values ??? */ /* FIXME act differently for ms and sybase */ if (is_numeric_type(desttype)) { num = (DBNUMERIC *) dest; /* num->scale is unsigned */ if (num->precision <= 0 || num->precision > MAXPRECISION || num->scale > num->precision) { dres.n.precision = 18; dres.n.scale = 0; } else { dres.n.precision = num->precision; dres.n.scale = num->scale; } /* oft times we are asked to convert a data type to itself */ } else if (srctype == desttype) { ret = -2; /* to make sure we always set it */ tdsdump_log(TDS_DBG_INFO1, "dbconvert() 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 SYBUNIQUE: ret = tds_get_size_by_type(desttype); 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() 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() called tds_convert returned %d\n", len); switch (len) { case TDS_CONVERT_NOAVAIL: dbperror(dbproc, SYBERDCN, 0); return -1; break; case TDS_CONVERT_SYNTAX: dbperror(dbproc, SYBECSYN, 0); return -1; break; case TDS_CONVERT_NOMEM: dbperror(dbproc, SYBEMEM, ENOMEM); return -1; break; case TDS_CONVERT_OVERFLOW: dbperror(dbproc, SYBECOFL, 0); return -1; break; case TDS_CONVERT_FAIL: dbperror(dbproc, SYBECINTERNAL, 0); return -1; break; default: if (len < 0) { /* logic error: should be captured above */ dbperror(dbproc, SYBECINTERNAL, 0); return -1; } break; } 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); free(dres.ib); if (len < destlen) memset(dest + len, 0, destlen - len); ret = len; } break; case SYBINT1: memcpy(dest, &(dres.ti), 1); ret = 1; break; case SYBINT2: memcpy(dest, &(dres.si), 2); ret = 2; break; case SYBINT4: memcpy(dest, &(dres.i), 4); ret = 4; break; case SYBINT8: memcpy(dest, &(dres.bi), 8); ret = 8; break; case SYBFLT8: memcpy(dest, &(dres.f), 8); ret = 8; break; case SYBREAL: memcpy(dest, &(dres.r), 4); ret = 4; break; case SYBBIT: case SYBBITN: memcpy(dest, &(dres.ti), 1); ret = 1; break; case SYBMONEY: memcpy(dest, &(dres.m), sizeof(TDS_MONEY)); ret = sizeof(TDS_MONEY); break; case SYBMONEY4: memcpy(dest, &(dres.m4), sizeof(TDS_MONEY4)); ret = sizeof(TDS_MONEY4); break; case SYBDATETIME: memcpy(dest, &(dres.dt), sizeof(TDS_DATETIME)); ret = sizeof(TDS_DATETIME); break; case SYBDATETIME4: memcpy(dest, &(dres.dt4), sizeof(TDS_DATETIME4)); ret = sizeof(TDS_DATETIME4); break; case SYBNUMERIC: case SYBDECIMAL: memcpy(dest, &(dres.n), sizeof(TDS_NUMERIC)); ret = sizeof(TDS_NUMERIC); break; case SYBUNIQUE: memcpy(dest, &(dres.u), sizeof(TDS_UNIQUE)); ret = sizeof(TDS_UNIQUE); break; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: tdsdump_log(TDS_DBG_INFO1, "dbconvert() outputting %d bytes character data destlen = %d \n", len, destlen); if (destlen < -2) destlen = 0; /* failure condition */ switch (destlen) { case 0: ret = FAIL; 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(): unrecognized desttype %d \n", desttype); ret = -1; break; } return (ret); } /** * \ingroup dblib_core * \brief cf. dbconvert(), 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(), dberrhandle(), dbsetnull(), dbsetversion(), dbwillconvert(). */ DBINT dbconvert_ps(DBPROCESS * dbproc, int srctype, BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen, DBTYPEINFO * typeinfo) { DBNUMERIC *s; DBNUMERIC *d; tdsdump_log(TDS_DBG_FUNC, "dbconvert_ps(%p)\n", dbproc); /* dbproc can be NULL*/ if (is_numeric_type(desttype)) { if (typeinfo == NULL) { if (is_numeric_type(srctype)) { s = (DBNUMERIC *) src; d = (DBNUMERIC *) dest; d->precision = s->precision; d->scale = s->scale; } else { d = (DBNUMERIC *) dest; d->precision = 18; d->scale = 0; } } else { d = (DBNUMERIC *) dest; d->precision = typeinfo->precision; d->scale = typeinfo->scale; } } return dbconvert(dbproc, srctype, src, srclen, desttype, dest, destlen); } /** * \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; int srctype = -1; int desttype = -1; tdsdump_log(TDS_DBG_FUNC, "dbbind(%p, %d, %d, %d, %p)\n", dbproc, column, vartype, varlen, varaddr); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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); if (-1 == (desttype = _db_get_server_type(vartype))) { 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. For conversions from a fix-length type to a character type (e.g. INT to VARCHAR), the value * returned is the number of bytes needed hold the output. * \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); } /** * \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); CHECK_PARAMETER(dbproc, SYBENULL, 0); 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); CHECK_PARAMETER(dbproc, SYBENULL, 0); 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); CHECK_PARAMETER(dbproc, SYBENULL, 0); 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); CHECK_PARAMETER(dbproc, SYBENULL, FAIL); colinfo = dbcolptr(dbproc, column); if (!colinfo) return FAIL; CHECK_NULP(pdbcol, "dbcolinfo", 5, FAIL); if (type == CI_REGULAR) { tds_strlcpy(pdbcol->Name, dbcolname(dbproc, column), sizeof(pdbcol->Name)); tds_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]; tds_strlcpy(pdbcol->Name, colinfo->column_name, sizeof(pdbcol->Name)); tds_strlcpy(pdbcol->ActualName, 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) pdbcol->VarLength = TRUE; switch (colinfo->column_type) { case SYBNVARCHAR: case SYBVARBINARY: case SYBVARCHAR: case SYBBITN: case SYBDATETIMN: case SYBDECIMAL: case SYBFLTN: case SYBINTN: case SYBMONEYN: case SYBNUMERIC: case SYBIMAGE: case SYBNTEXT: case SYBTEXT: pdbcol->VarLength = TRUE; break; default: break; } 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); CHECK_PARAMETER(dbproc, SYBENULL, 0); colinfo = dbcolptr(dbproc, column); if (!colinfo) return NULL; return colinfo->table_column_name ? colinfo->table_column_name : colinfo->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); CHECK_PARAMETER(dbproc, SYBENULL, -1); colinfo = dbcolptr(dbproc, column); if (!colinfo) return -1; return colinfo->column_size; } /* 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); CHECK_PARAMETER(dbproc, SYBENULL, FALSE); 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); CHECK_PARAMETER(dbproc, SYBENULL, -1); 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) { TDSCOLUMN *colinfo; const static BYTE empty[1] = { 0 }; tdsdump_log(TDS_DBG_FUNC, "dbdata(%p, %d)\n", dbproc, column); CHECK_PARAMETER(dbproc, SYBENULL, 0); colinfo = dbcolptr(dbproc, column); if (!colinfo) return NULL; if (colinfo->column_cur_size < 0) return NULL; if (is_blob_col(colinfo)) { BYTE *res = (BYTE *) ((TDSBLOB *) colinfo->column_data)->textvalue; if (!res) return (BYTE *) empty; return res; } return (BYTE *) colinfo->column_data; } /** * \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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); tds = dbproc->tds_socket; tds_send_cancel(dbproc->tds_socket); tds_process_cancel(dbproc->tds_socket); 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 = colinfo->column_namelen; 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; int desttype, srctype; DBINT len; tdsdump_log(TDS_DBG_FUNC, "dbspr1row(%p, %s, %d)\n", dbproc, buffer, buf_len); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 { desttype = _db_get_server_type(STRINGBIND); srctype = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); if (srctype == SYBDATETIME || srctype == SYBDATETIME4) { memset(&when, 0, sizeof(when)); tds_datecrack(srctype, dbdata(dbproc, col + 1), &when); len = (int)tds_strftime(buffer, buf_len, "%b %d %Y %I:%M%p", &when); } 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 = colinfo->column_namelen; 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; DBINT 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); tds = dbproc->tds_socket; while ((status = dbnextrow(dbproc)) != NO_MORE_ROWS) { if (status == FAIL) { return FAIL; } if (status == REG_ROW) { resinfo = tds->res_info; if (col_printlens == NULL) { if ((col_printlens = calloc(resinfo->num_cols, sizeof(TDS_SMALLINT))) == 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 = _db_get_server_type(STRINGBIND); srctype = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); if (srctype == SYBDATETIME || srctype == SYBDATETIME4) { memset(&when, 0, sizeof(when)); tds_datecrack(srctype, dbdata(dbproc, col + 1), &when); len = (int)tds_strftime(dest, sizeof(dest), STD_DATETIME_FMT, &when); } 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 = colinfo->column_namelen; 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 = _db_get_server_type(STRINGBIND); srctype = dbalttype(dbproc, computeid, col); if (srctype == SYBDATETIME || srctype == SYBDATETIME4) { memset(&when, 0, sizeof(when)); tds_datecrack(srctype, dbadata(dbproc, computeid, col), &when); len = (int)tds_strftime(dest, sizeof(dest), STD_DATETIME_FMT, &when); } 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 = colinfo->column_namelen; 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; } /* * src/tds/convert.c::tds_willconvert() returns same information. * Available to user via dbwillconvert(). */ static int _get_printable_size(TDSCOLUMN * colinfo) { switch (colinfo->column_type) { case SYBINTN: switch (colinfo->column_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 colinfo->column_size; case SYBFLT8: case SYBREAL: return 11; /* FIX ME -- we do not track precision */ case SYBMONEY: case SYBMONEY4: return 12; case SYBDATETIME: case SYBDATETIME4: case SYBDATETIMN: return 26; case SYBUNIQUE: return 36; case SYBBIT: case SYBBITN: 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 = colinfo->column_namelen; 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, %s, %d)\n", dbproc, buffer, buf_len); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 = colinfo->column_namelen; padlen = (collen > namlen ? collen : namlen) - namlen; if (buf_len < namlen) { return FAIL; } strncpy(buffer, colinfo->column_name, namlen); buffer += 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 = colinfo->column_namelen; padlen = (collen > namlen ? collen : namlen) - namlen; printf("%*.*s", colinfo->column_namelen, colinfo->column_namelen, 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 = colinfo->column_namelen; 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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->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); 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 = calloc(maxprocs, sizeof(TDSSOCKET *)); 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; 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]) 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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; case SYBDATETIMN: if (colinfo->column_size == 8) return SYBDATETIME; else if (colinfo->column_size == 4) return SYBDATETIME4; break; case SYBMONEYN: if (colinfo->column_size == 4) return SYBMONEY4; else if (colinfo->column_size == 8) return SYBMONEY; break; case SYBFLTN: if (colinfo->column_size == 8) return SYBFLT8; else if (colinfo->column_size == 4) return SYBREAL; break; case SYBINTN: if (colinfo->column_size == 8) return SYBINT8; else if (colinfo->column_size == 4) return SYBINT4; else if (colinfo->column_size == 2) return SYBINT2; else if (colinfo->column_size == 1) return SYBINT1; break; default: return colinfo->column_type; } return -1; /* something went wrong */ } /** * \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) { int srctype = -1; int desttype = -1; 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 = _db_get_server_type(vartype); tdsdump_log(TDS_DBG_INFO1, "dbaltbind() srctype = %d desttype = %d \n", srctype, desttype); if (!dbwillconvert(srctype, _db_get_server_type(vartype))) { 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; tdsdump_log(TDS_DBG_FUNC, "dbsetopt(%p, %d, %s, %d)\n", dbproc, option, char_param, int_param); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 */ break; 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; 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; assert(param_info->columns[retnum - 1]->column_name[param_info->columns[retnum - 1]->column_namelen] == 0); return param_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) { TDSCOLUMN *column; 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; column = param_info->columns[retnum - 1]; /* FIXME blob are stored is different way */ return (BYTE *) column->column_data; } /** * \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; tdsdump_log(TDS_DBG_FUNC, "dbsqlok(%p)\n", dbproc); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 (;;) { int 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_CANCELLED: case TDS_FAIL: return FAIL; break; case TDS_SUCCEED: 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)); #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; } } 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 = 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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(). */ RETCODE dbdatecmp(DBPROCESS * dbproc, DBDATETIME * d1, DBDATETIME * d2) { tdsdump_log(TDS_DBG_FUNC, "dbdatecmp(%p, %p, %p)\n", dbproc, d1, d2); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_NULP(d1, "dbdatecmp", 2, FAIL); CHECK_NULP(d2, "dbdatecmp", 3, FAIL); 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; } /** * \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 * output, DBDATETIME * datetime) { #if MSDBLIB const int msdblib = 1; #else const int msdblib = 0; #endif TDSDATEREC dr; struct tds_sybase_dbdaterec *di = (struct tds_sybase_dbdaterec*) output; tdsdump_log(TDS_DBG_FUNC, "dbdatecrack(%p, %p, %p)\n", dbproc, output, datetime); CHECK_NULP(output, "dbdatecrack", 2, FAIL); CHECK_PARAMETER(datetime, SYBENDTP, FAIL); tds_datecrack(SYBDATETIME, datetime, &dr); 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->datemsecond = dr.millisecond; /* Revert to compiled-in default if dbproc can't be used to find the runtime override. */ if (dbproc ? dbproc->msdblib : msdblib) { ++di->quarter; ++di->datemonth; ++di->datedweek; } return SUCCEED; } #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) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "dbspid(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBESPID, -1); tds = dbproc->tds_socket; if (IS_TDSDEAD(tds)) return -1; return tds->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_80: 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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) { int rc; TDS_INT result_type; tdsdump_log(TDS_DBG_FUNC, "dbcanquery(%p)\n", dbproc); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 (rc == TDS_FAIL) return FAIL; 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 * \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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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; 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_NULP(pdbcol, "dbtablecolinfo", 3, FAIL); colinfo = dbcolptr(dbproc, column); if (!colinfo) return FAIL; tds_strlcpy(pdbcol->Name, colinfo->column_name, sizeof(pdbcol->Name)); tds_strlcpy(pdbcol->ActualName, 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) pdbcol->VarLength = TRUE; switch (colinfo->column_type) { case SYBNVARCHAR: case SYBVARBINARY: case SYBVARCHAR: case SYBBITN: case SYBDATETIMN: case SYBDECIMAL: case SYBFLTN: case SYBINTN: case SYBMONEYN: case SYBNUMERIC: case SYBIMAGE: case SYBNTEXT: case SYBTEXT: pdbcol->VarLength = TRUE; break; default: break; } 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; } /** * \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); CHECK_PARAMETER(dbproc, SYBENULL, 0); colinfo = dbcolptr(dbproc, column); if (!colinfo || !is_blob_col(colinfo)) return NULL; blob = (TDSBLOB *) colinfo->column_data; 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); CHECK_PARAMETER(dbproc, SYBENULL, 0); colinfo = dbcolptr(dbproc, column); if (!colinfo || !is_blob_col(colinfo)) return NULL; blob = (TDSBLOB *) colinfo->column_data; 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 int 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_writetext_start(dbproc->tds_socket, objname, textptr_string, timestamp_string, (log == TRUE), size) != TDS_SUCCEED) 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_FAIL: return -1; case TDS_SUCCEED: if (result_type == TDS_ROW_RESULT || result_type == TDS_COMPUTE_RESULT) break; case TDS_NO_MORE_RESULTS: return NO_MORE_ROWS; } } /* 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_writetext_continue(dbproc->tds_socket, text, size) != TDS_SUCCEED) 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->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; 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 rcsid_var; } #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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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; int rc; TDS_INT result_type; char timestr[256]; tdsdump_log(TDS_DBG_FUNC, "dbsqlsend(%p)\n", dbproc); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 (rc != TDS_SUCCEED) { 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_SUCCEED); 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_submit_query(dbproc->tds_socket, (char *) dbproc->dbbuf) != TDS_SUCCEED) { 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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)dbproc->tds_socket->s; } /** \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)dbproc->tds_socket->s; } 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(). */ int dbstrbuild(DBPROCESS * dbproc, char *charbuf, int bufsize, char *text, char *formats, ...) { va_list ap; int 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 rc == TDS_SUCCEED ? 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; } static char * tds_prdatatype(TDS_SERVER_TYPE datatype_token) { switch (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"; default: break; } return "(unknown)"; } #if 1 static void copy_data_to_host_var(DBPROCESS * dbproc, int srctype, const BYTE * src, DBINT srclen, int desttype, 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; 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, ); /* 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 (is_numeric_type(desttype)) { DBNUMERIC *num = (DBNUMERIC *) dest; /* num->scale is unsigned */ if (num->precision <= 0 || num->precision > MAXPRECISION || num->scale > num->precision) { 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, null 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 null 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 null 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 SYBUNIQUE: ret = tds_get_size_by_type(desttype); 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); switch (len) { case TDS_CONVERT_NOAVAIL: dbperror(dbproc, SYBERDCN, 0); return; break; case TDS_CONVERT_SYNTAX: dbperror(dbproc, SYBECSYN, 0); return; break; case TDS_CONVERT_NOMEM: dbperror(dbproc, SYBEMEM, ENOMEM); return; break; case TDS_CONVERT_OVERFLOW: dbperror(dbproc, SYBECOFL, 0); return; break; case TDS_CONVERT_FAIL: return; break; default: if (len < 0) { return; } break; } 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: memcpy(dest, &(dres.ti), 1); break; case SYBINT2: memcpy(dest, &(dres.si), 2); break; case SYBINT4: memcpy(dest, &(dres.i), 4); break; case SYBINT8: memcpy(dest, &(dres.bi), 8); break; case SYBFLT8: memcpy(dest, &(dres.f), 8); break; case SYBREAL: memcpy(dest, &(dres.r), 4); break; case SYBBIT: case SYBBITN: memcpy(dest, &(dres.ti), 1); break; case SYBMONEY: memcpy(dest, &(dres.m), sizeof(TDS_MONEY)); break; case SYBMONEY4: memcpy(dest, &(dres.m4), sizeof(TDS_MONEY4)); break; case SYBDATETIME: memcpy(dest, &(dres.dt), sizeof(TDS_DATETIME)); break; case SYBDATETIME4: memcpy(dest, &(dres.dt4), sizeof(TDS_DATETIME4)); break; case SYBNUMERIC: case SYBDECIMAL: memcpy(dest, &(dres.n), sizeof(TDS_NUMERIC)); break; case SYBUNIQUE: memcpy(dest, &(dres.u), sizeof(TDS_UNIQUE)); 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; 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" } }; /** \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; char *os_msgtext = strerror(errnum), *rc_name = "logic error"; 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. */ char * ptext = dblib_error_messages[i].msgtext; 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 = calloc(1, 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_FAIL == rc) { free(buffer); break; } constructed_message.msgtext = buffer; msg = &constructed_message; } break; } } tdsdump_log(TDS_DBG_FUNC, "%d: \"%s\"\n", msgno, msg->msgtext); /* call the error handler */ rc = (*_dblib_err_handler)(dbproc, msg->severity, msgno, errnum, msg->msgtext, 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, "\"%s\", client returns %d (%s)\n", msg->msgtext, rc, rc_name); /* we're done with the dynamic string now. */ if (msg == &constructed_message) { TDS_ZERO_FREE(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_name, "%d", rc); 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-0.91/src/dblib/dbutil.c100644 001750 000144 00000017504 11623070341 0012073/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include #include #include #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: dbutil.c,v 1.47.2.3 2011/06/09 13:02:49 freddy77 Exp $"); /* * test include consistency * I don't think all compiler are able to compile this code... if not comment it */ #if ENABLE_EXTRA_CHECKS #if defined(__GNUC__) && __GNUC__ >= 2 #define COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] __attribute__ ((unused)) #else #define COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] #endif /* TODO test SYBxxx consistency */ #define TEST_ATTRIBUTE(t,sa,fa,sb,fb) \ COMPILE_CHECK(t,sizeof(((sa*)0)->fa) == sizeof(((sb*)0)->fb) && (TDS_INTPTR)(&((sa*)0)->fa) == (TDS_INTPTR)(&((sb*)0)->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->parent)? (DBPROCESS *) tds->parent : 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, msg->msgno, DBNOERR, (char *) message, NULL); } return TDS_SUCCEED; } /** \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->parent)? (DBPROCESS *) tds->parent : 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 && DBDEAD(dbproc)) ); /* a non-process can't be a dead process */ 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; } } freetds-0.91/src/dblib/rpc.c100664 001750 000144 00000033405 11247132563 0011403/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: rpc.c,v 1.70 2009/09/01 05:47:31 freddy77 Exp $"); 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; int dbrpcrecompile = 0; tdsdump_log(TDS_DBG_FUNC, "dbrpcinit(%p, %s, %d)\n", dbproc, rpcname, options); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 = (DBREMOTE_PROC *) calloc(1, sizeof(DBREMOTE_PROC))) == 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 type, DBINT maxlen, DBINT datalen, BYTE * value) { char *name = NULL; DBREMOTE_PROC *rpc; DBREMOTE_PROC_PARAM **pparam; DBREMOTE_PROC_PARAM *param; tdsdump_log(TDS_DBG_FUNC, "dbrpcparam(%p, %s, 0x%x, %d, %d, %d, %p)\n", dbproc, paramname, status, type, maxlen, datalen, value); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_PARAMETER(dbproc->rpc, SYBERPCS, FAIL); /* 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 most 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 */ /* allocate */ param = (DBREMOTE_PROC_PARAM *) malloc(sizeof(DBREMOTE_PROC_PARAM)); 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 */ ; for (pparam = &rpc->param_list; *pparam != NULL; pparam = &(*pparam)->next); /* 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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) { int 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); tds_free_param_results(pparam_info); if (erc == TDS_FAIL) { 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 = malloc(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 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; int 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) { tds_strlcpy(pcol->column_name, p->name, sizeof(pcol->column_name)); pcol->column_namelen = (int)strlen(pcol->column_name); } tds_set_param_type(tds, 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; } } 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-0.91/src/dblib/bcp.c100644 001750 000144 00000230044 11623070341 0011350/* 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. */ #if HAVE_CONFIG_H #include #endif #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 #ifdef DMALLOC #include #endif #define HOST_COL_CONV_ERROR 1 #define HOST_COL_NULL_ERROR 2 #ifndef MAX #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) #endif TDS_RCSID(var, "$Id: bcp.c,v 1.197.2.8 2011/06/07 08:52:29 freddy77 Exp $"); #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 void _bcp_null_error(TDSBCPINFO *bcpinfo, int index, int offset); static int _bcp_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset); static int _bcp_no_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset); static int rtrim(char *, int); static offset_type _bcp_measure_terminated_field(FILE * hostfile, BYTE * terminator, int term_len); static RETCODE _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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_NULP(tblname, "bcp_init", 2, FAIL); /* Free previously allocated storage in dbproc & initialise flags, etc. */ _bcp_free_storage(dbproc); /* * Validate other parameters */ if (dbproc->tds_socket->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)) { /* 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); } /* Allocate storage */ dbproc->bcpinfo = calloc(1, sizeof(TDSBCPINFO)); if (dbproc->bcpinfo == NULL) goto memory_error; if ((dbproc->bcpinfo->tablename = strdup(tblname)) == NULL) goto memory_error; dbproc->bcpinfo->direction = direction; dbproc->bcpinfo->xfer_init = 0; dbproc->bcpinfo->var_cols = 0; dbproc->bcpinfo->bind_count = 0; if (tds_bcp_init(dbproc->tds_socket, dbproc->bcpinfo) == TDS_FAIL) { /* 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 = calloc(1, sizeof(BCP_HOSTFILEINFO)); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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]; DBPERROR_RETURN(varlen == 0 && !bcpcol->column_nullable, SYBEBCNN); /* non-nullable column cannot receive a NULL */ 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 = calloc(host_colcount, sizeof(BCP_HOSTCOLINFO *)); 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] = calloc(1, sizeof(BCP_HOSTCOLINFO)); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 (table_colnum <= 0 && host_type == 0) { dbperror(dbproc, SYBEBCPCTYP, 0); return FAIL; } if (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 = malloc(host_termlen)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } memcpy(terminator, host_term, host_termlen); } hostcol->host_column = host_colnum; hostcol->datatype = host_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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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 * \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", NULL }; tdsdump_log(TDS_DBG_FUNC, "bcp_options(%p, %d, %p, %d)\n", dbproc, option, value, valuelen); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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); } /** * \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; int i; TDSSOCKET *tds; TDSRESULTINFO *resinfo; TDSCOLUMN *curcol = NULL; BCP_HOSTCOLINFO *hostcol; BYTE *src; int srctype; int srclen; int buflen; int destlen; int plen; TDS_INT result_type; TDS_TINYINT ti; TDS_SMALLINT si; TDS_INT li; TDSDATEREC when; int row_of_query; int rows_written; char *bcpdatefmt; int 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_submit_query(tds, dbproc->bcpinfo->tablename) == TDS_FAIL) { return FAIL; } } else { /* TODO quote if needed */ if (tds_submit_queryf(tds, "select * from %s", dbproc->bcpinfo->tablename) == TDS_FAIL) { return FAIL; } } tdsret = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS); if (tdsret == TDS_FAIL || tdsret == TDS_CANCELLED) { 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; /* * Before we start retrieving the data, go through the defined * host file columns. If the host file column is related to a * table column, then allocate some space sufficient to hold * the resulting data (converted to whatever host file format) */ 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 (hostcol->datatype == 0) hostcol->datatype = curcol->column_type; /* work out how much space to allocate for output data */ /* TODO use a function for fixed types */ switch (hostcol->datatype) { case SYBINT1: buflen = destlen = 1; break; case SYBINT2: buflen = destlen = 2; break; case SYBINT4: buflen = destlen = 4; break; case SYBINT8: buflen = destlen = 8; break; case SYBREAL: buflen = destlen = 4; break; case SYBFLT8: buflen = destlen = 8; break; case SYBDATETIME: buflen = destlen = 8; break; case SYBDATETIME4: buflen = destlen = 4; break; case SYBBIT: buflen = destlen = 1; break; case SYBBITN: buflen = destlen = 1; break; case SYBMONEY: buflen = destlen = 8; break; case SYBMONEY4: buflen = destlen = 4; break; case SYBCHAR: case SYBVARCHAR: switch (curcol->column_type) { case SYBVARCHAR: buflen = curcol->column_size + 1; destlen = -1; break; case SYBCHAR: case SYBTEXT: /* FIXME column_size ?? if 2gb ?? */ buflen = curcol->column_size + 1; destlen = -2; break; case SYBINT1: buflen = 4 + 1; /* 255 */ destlen = -1; break; case SYBINT2: buflen = 6 + 1; /* -32768 */ destlen = -1; break; case SYBINT4: buflen = 11 + 1; /* -2147483648 */ destlen = -1; break; case SYBINT8: buflen = 20 + 1; /* -9223372036854775808 */ destlen = -1; break; case SYBNUMERIC: case SYBDECIMAL: buflen = 40 + 1; /* 10 to the 38 */ destlen = -1; break; case SYBFLT8: buflen = 40 + 1; /* 10 to the 38 */ destlen = -1; break; case SYBDATETIME: case SYBDATETIME4: buflen = 255 + 1; destlen = -1; break; default: buflen = 255 + 1; destlen = -1; break; } break; default: buflen = destlen = 255; } hostcol->bcp_column_data = tds_alloc_bcp_column_data(buflen); hostcol->bcp_column_data->datalen = destlen; } /* * 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); return FAIL; } /* 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_SUCCEED) { 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)) { /* Go through the hostfile columns, finding those that relate to database columns. */ for (i = 0; i < dbproc->hostfileinfo->host_colcount; i++) { size_t written = 0; 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]; src = curcol->column_data; if (is_blob_col(curcol)) { src = (BYTE *) ((TDSBLOB *) src)->textvalue; } srctype = tds_get_conversion_type(curcol->column_type, curcol->column_size); if (curcol->column_cur_size < 0) { srclen = 0; hostcol->bcp_column_data->is_null = 1; } else { if (is_numeric_type(curcol->column_type)) srclen = sizeof(TDS_NUMERIC); else srclen = curcol->column_cur_size; hostcol->bcp_column_data->is_null = 0; } if (hostcol->bcp_column_data->is_null) { buflen = 0; } else { /* * if we are converting datetime to string, need to override any * date time formats already established */ if ((srctype == SYBDATETIME || srctype == SYBDATETIME4) && (hostcol->datatype == SYBCHAR || hostcol->datatype == SYBVARCHAR)) { tds_datecrack(srctype, src, &when); buflen = (int)tds_strftime((TDS_CHAR *)hostcol->bcp_column_data->data, 256, bcpdatefmt, &when); } else { /* * 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. */ /* TODO check for text !!! */ buflen = dbconvert(dbproc, srctype, src, srclen, hostcol->datatype, hostcol->bcp_column_data->data, hostcol->bcp_column_data->datalen); /* * Special case: When outputting database varchar data * (either varchar or nullable char) dbconvert 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 (( curcol->column_type == SYBVARCHAR || (curcol->column_type == SYBCHAR && curcol->column_nullable) ) && srclen > 0 && buflen == 0) { strcpy ((char *)hostcol->bcp_column_data->data, " "); buflen = 1; } } } /* The prefix */ if ((plen = hostcol->prefix_len) == -1) { if (is_blob_type(hostcol->datatype)) plen = 4; else if (!(is_fixed_type(hostcol->datatype))) plen = 2; else if (curcol->column_nullable) plen = 1; else plen = 0; /* cache */ hostcol->prefix_len = plen; } switch (plen) { case 0: break; case 1: ti = buflen; written = fwrite(&ti, sizeof(ti), 1, hostfile); break; case 2: si = buflen; written = fwrite(&si, sizeof(si), 1, hostfile); break; case 4: li = buflen; written = fwrite(&li, sizeof(li), 1, hostfile); break; } if( plen != 0 && written != 1 ) { fclose(hostfile); dbperror(dbproc, SYBEBCWE, errno); return FAIL; } /* The data */ if (hostcol->column_len != -1) { buflen = buflen > hostcol->column_len ? hostcol->column_len : buflen; } if (buflen > 0) { written = fwrite(hostcol->bcp_column_data->data, buflen, 1, hostfile); if (written < 1) { fclose(hostfile); dbperror(dbproc, SYBEBCWE, errno); return FAIL; } } /* The terminator */ if (hostcol->terminator && hostcol->term_len > 0) { written = fwrite(hostcol->terminator, hostcol->term_len, 1, hostfile); if (written < 1) { fclose(hostfile); dbperror(dbproc, SYBEBCWE, errno); return FAIL; } } } rows_written++; } } if (fclose(hostfile) != 0) { dbperror(dbproc, SYBEBCUC, errno); return (FAIL); } 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); return (FAIL); } *rows_copied = rows_written; return SUCCEED; } static RETCODE _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); } /** * \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 RETCODE _bcp_read_hostfile(DBPROCESS * dbproc, FILE * hostfile, int *row_error) { TDSCOLUMN *bcpcol = NULL; BCP_HOSTCOLINFO *hostcol; TDS_TINYINT ti; TDS_SMALLINT si; TDS_INT li; TDS_INT 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++) { 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. * FIXME I think tab_colnum can be out of range - freddy77 */ if (hostcol->tab_colnum) { 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) { int len = bcpcol->column_varint_size; hostcol->prefix_len = len == 5 ? 4 : len; } /* 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); } /* * 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 */ int file_len; size_t col_bytes_left; offset_type file_bytes_left, len; iconv_t cd; len = _bcp_measure_terminated_field(hostfile, hostcol->terminator, hostcol->term_len); if (len > 0x7fffffffl || len < 0) { *row_error = TRUE; tdsdump_log(TDS_DBG_FUNC, "_bcp_measure_terminated_field returned -1!\n"); dbperror(dbproc, SYBEBCOR, 0); return (FAIL); } collen = (int)len; if (collen == 0) data_is_null = 1; tdsdump_log(TDS_DBG_FUNC, "_bcp_measure_terminated_field returned %d\n", collen); /* * Allocate a column buffer guaranteed to be big enough hold the post-iconv data. */ file_len = collen; if (bcpcol->char_conv) { TDSICONV *char_conv = bcpcol->char_conv; collen *= char_conv->server_charset.max_bytes_per_char; collen += char_conv->client_charset.min_bytes_per_char - 1; collen /= char_conv->client_charset.min_bytes_per_char; cd = char_conv->to_wire; tdsdump_log(TDS_DBG_FUNC, "Adjusted collen is %d.\n", collen); } else { cd = (iconv_t) - 1; } coldata = calloc(1, 1 + collen); if (coldata == NULL) { *row_error = TRUE; tdsdump_log(TDS_DBG_FUNC, "calloc returned NULL pointer!\n"); dbperror(dbproc, SYBEMEM, errno); return (FAIL); } /* * Read and convert the data */ col_bytes_left = collen; /* TODO make tds_iconv_fread handle terminator directly to avoid fseek in _bcp_measure_terminated_field */ file_bytes_left = tds_iconv_fread(cd, hostfile, file_len, hostcol->term_len, coldata, &col_bytes_left); collen -= (int)col_bytes_left; /* tdsdump_log(TDS_DBG_FUNC, "collen is %d after tds_iconv_fread()\n", collen); */ if (file_bytes_left != 0) { tdsdump_log(TDS_DBG_FUNC, "col %d: %ld of %d bytes unread\nfile_bytes_left != 0!\n", (i+1), (long)file_bytes_left, collen); *row_error = TRUE; free(coldata); dbperror(dbproc, SYBEBCOR, 0); return FAIL; } /* * 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 */ #if 0 bcpcol = dbproc->bcpinfo->bindinfo->columns[hostcol->tab_colnum - 1]; if (collen == 0 || bcpcol->column_nullable) { if (collen != 0) { /* A fixed length type */ TDS_TINYINT len; if (fread(&len, sizeof(len), 1, hostfile) != 1) { if (i != 0) dbperror(dbproc, SYBEBCRE, errno); return (FAIL); } if (len < 0) dbperror(dbproc, SYBEBCNL, errno); /* TODO 255 for NULL ?? check it, perhaps 0 */ collen = len == 255 ? -1 : len; } else { TDS_SMALLINT len; if (fread(&len, sizeof(len), 1, hostfile) != 1) { if (i != 0) dbperror(dbproc, SYBEBCRE, errno); return (FAIL); } if (len < 0) dbperror(dbproc, SYBEBCNL, errno); collen = len; } /* TODO if collen < -1 error */ if (collen <= -1) { collen = 0; data_is_null = 1; } tdsdump_log(TDS_DBG_FUNC, "Length read from hostfile: collen is now %d, data_is_null is %d\n", collen, data_is_null); } #endif coldata = (TDS_CHAR *) calloc(1, 1 + collen); if (coldata == NULL) { *row_error = TRUE; dbperror(dbproc, SYBEMEM, errno); return (FAIL); } 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); } } } /* * If we read no bytes and we're at end of file AND this is the first column, * then we've stumbled across the finish line. Tell the caller we failed to read * anything but encountered no error. */ if (i == 0 && collen == 0 && feof(hostfile)) { free(coldata); tdsdump_log(TDS_DBG_FUNC, "Normal end-of-file reached while loading bcp data file.\n"); return NO_MORE_ROWS; } /* * 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 (i == 370 - 1) { char buf[32]; memset(buf, '\0', sizeof(buf)); memcpy(buf, coldata, collen); tdsdump_log(TDS_DBG_FUNC, "column 370 is '%s', converts to %f\n", buf, atof(buf)); } if (hostcol->tab_colnum) { if (data_is_null) { bcpcol->bcp_column_data->is_null = 1; bcpcol->bcp_column_data->datalen = 0; } else { bcpcol->bcp_column_data->is_null = 0; desttype = tds_get_conversion_type(bcpcol->column_type, bcpcol->column_size); /* special hack for text columns */ if (bcpcol->column_size == 4096 && collen > bcpcol->column_size) { /* "4096" might not matter */ BYTE *oldbuffer = bcpcol->bcp_column_data->data; switch (desttype) { case SYBTEXT: case SYBNTEXT: case SYBIMAGE: case SYBVARBINARY: case XSYBVARBINARY: case SYBLONGBINARY: /* Reallocate enough space for the data from the file. */ bcpcol->column_size = 8 + collen; /* room to breathe */ bcpcol->bcp_column_data->data = (BYTE *) realloc(bcpcol->bcp_column_data->data, bcpcol->column_size); if (!bcpcol->bcp_column_data->data) { dbperror(dbproc, SYBEMEM, errno); free(oldbuffer); free(coldata); return FAIL; } break; default: break; } } /* end special hack for text columns */ /* * FIXME bcpcol->bcp_column_data->data && bcpcol->column_size ?? * It seems a buffer overflow waiting... */ bcpcol->bcp_column_data->datalen = dbconvert(dbproc, hostcol->datatype, (const BYTE *) coldata, collen, desttype, bcpcol->bcp_column_data->data, bcpcol->column_size); if (bcpcol->bcp_column_data->datalen == -1) { hostcol->column_error = HOST_COL_CONV_ERROR; *row_error = 1; /* FIXME possible integer overflow if off_t is 64bit and long int 32bit */ tdsdump_log(TDS_DBG_FUNC, "_bcp_read_hostfile failed to convert %d bytes at offset 0x%lx in the data file.\n", collen, (unsigned long int) ftello(hostfile) - collen); } /* trim trailing blanks from character data */ if (desttype == SYBCHAR || desttype == SYBVARCHAR) { bcpcol->bcp_column_data->datalen = rtrim((char *) bcpcol->bcp_column_data->data, bcpcol->bcp_column_data->datalen); } } 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); } } } } free(coldata); } return MORE_ROWS; } /* * Look for the next terminator in a host data file, and return the data size. * \return size of field, excluding the terminator. * \remarks The current offset will be unchanged. If an error was encountered, the returned size will be -1. * The caller should check for that possibility, but the appropriate message should already have been emitted. * The caller can then use tds_iconv_fread() to read-and-convert the file's data * into host format, or, if we're not dealing with a character column, just fread(3). */ /** * \ingroup dblib_bcp_internal * \brief * * \param hostfile * \param terminator * \param term_len * * \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 offset_type _bcp_measure_terminated_field(FILE * hostfile, BYTE * terminator, int term_len) { char *sample; int errnum; int sample_size, bytes_read = 0; offset_type size; const offset_type initial_offset = ftello(hostfile); tdsdump_log(TDS_DBG_FUNC, "_bcp_measure_terminated_field(%p, %p, %d)\n", hostfile, terminator, term_len); if ((sample = malloc(term_len)) == NULL) { dbperror(NULL, SYBEMEM, errno); return -1; } for (sample_size = 1; (bytes_read = (int)fread(sample, sample_size, 1, hostfile)) != 0;) { bytes_read *= sample_size; /* * Check for terminator. */ /* * TODO use memchr for performance, * optimize this strange loop - freddy77 */ if (*sample == *terminator) { if (sample_size == term_len) { /* * If we read a whole terminator, compare the whole sequence and, if found, go home. */ if (memcmp(sample, terminator, term_len) == 0) { free(sample); size = ftello(hostfile) - initial_offset; if (size < 0 || 0 != fseeko(hostfile, initial_offset, SEEK_SET)) { /* FIXME emit message */ return -1; } return size - term_len; } /* * If we tried to read a terminator and found something else, then we read a * terminator's worth of data. Back up N-1 bytes, and revert to byte-at-a-time testing. */ if (sample_size > 1) { sample_size--; if (0 != fseeko(hostfile, -sample_size, SEEK_CUR)) { /* FIXME emit message */ return -1; } } sample_size = 1; continue; } else { /* * Found start of terminator, but haven't read a full terminator's length yet. * Back up, read a whole terminator, and try again. */ assert(bytes_read == 1); ungetc(*sample, hostfile); sample_size = term_len; continue; } assert(0); /* should not arrive here */ } } free(sample); /* * To get here, we ran out of memory, or encountered an error (or EOF) with the file. * EOF is a surprise, because if we read a complete field with its terminator, * we would have returned without attempting to read past end of file. */ if (feof(hostfile)) { errnum = errno; if (initial_offset == ftello(hostfile)) { return 0; } else { /* a cheat: we don't have dbproc, so pass zero */ dbperror(0, SYBEBEOF, errnum); } } else if (ferror(hostfile)) { dbperror(0, SYBEBCRE, errno); } return -1; } /** * \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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_bcp_start_copy_in(tds, dbproc->bcpinfo) == TDS_FAIL) { dbperror(dbproc, SYBEBULKINSERT, 0); return FAIL; } dbproc->bcpinfo->xfer_init = 1; } dbproc->bcpinfo->parent = dbproc; return tds_bcp_send_record(dbproc->tds_socket, dbproc->bcpinfo, _bcp_get_col_data, _bcp_null_error, 0); } /** * \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; RETCODE 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_bcp_start_copy_in(tds, dbproc->bcpinfo) == TDS_FAIL) { 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 = malloc(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_bcp_send_record(dbproc->tds_socket, dbproc->bcpinfo, _bcp_no_get_col_data, _bcp_null_error, 0) == TDS_SUCCEED) { rows_written_so_far++; if (dbproc->hostfileinfo->batch > 0 && rows_written_so_far == dbproc->hostfileinfo->batch) { if (tds_bcp_done(tds, &rows_written_so_far) != TDS_SUCCEED) { 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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; FILE *ffile; char buffer[1024]; float lf_version = 0.0; int li_numcols = 0; int colinfo_count = 0; struct fflist { struct fflist *nextptr; BCP_HOSTCOLINFO colinfo; }; struct fflist *topptr = NULL; struct fflist *curptr = NULL; tdsdump_log(TDS_DBG_FUNC, "bcp_readfmt(%p, %s)\n", dbproc, filename? filename:"NULL"); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_NULP(filename, "bcp_readfmt", 2, FAIL); if ((ffile = fopen(filename, "r")) == NULL) { dbperror(dbproc, SYBEBUOF, 0); return (FAIL); } if ((_bcp_fgets(buffer, sizeof(buffer), ffile)) != NULL) { lf_version = (float)atof(buffer); } else if (ferror(ffile)) { dbperror(dbproc, SYBEBRFF, errno); return FAIL; } if ((_bcp_fgets(buffer, sizeof(buffer), ffile)) != NULL) { li_numcols = atoi(buffer); } else if (ferror(ffile)) { dbperror(dbproc, SYBEBRFF, errno); return FAIL; } /* FIXME fix memory leak, if this function returns FAIL... */ while ((_bcp_fgets(buffer, sizeof(buffer), ffile)) != NULL) { if (topptr == NULL) { /* first time */ if ((curptr = malloc(sizeof(struct fflist))) == NULL) { dbperror(dbproc, SYBEMEM, errno); return (FAIL); } topptr = curptr; } else { if ((curptr->nextptr = malloc(sizeof(struct fflist))) == NULL) { dbperror(dbproc, SYBEMEM, errno); return (FAIL); } curptr = curptr->nextptr; } curptr->nextptr = NULL; if (_bcp_readfmt_colinfo(dbproc, buffer, &(curptr->colinfo))) colinfo_count++; else return (FAIL); } if (ferror(ffile)) { dbperror(dbproc, SYBEBRFF, errno); return FAIL; } if (fclose(ffile) != 0) { dbperror(dbproc, SYBEBUCF, 0); return (FAIL); } if (colinfo_count != li_numcols) return (FAIL); if (bcp_columns(dbproc, li_numcols) == FAIL) { return (FAIL); } for (curptr = topptr; curptr->nextptr != NULL; curptr = curptr->nextptr) { hostcol = &(curptr->colinfo); if (bcp_colfmt(dbproc, hostcol->host_column, hostcol->datatype, hostcol->prefix_len, hostcol->column_len, hostcol->terminator, hostcol->term_len, hostcol->tab_colnum) == FAIL) { return (FAIL); } } hostcol = &(curptr->colinfo); if (bcp_colfmt(dbproc, hostcol->host_column, hostcol->datatype, hostcol->prefix_len, hostcol->column_len, hostcol->terminator, hostcol->term_len, hostcol->tab_colnum) == FAIL) { return (FAIL); } return (SUCCEED); } /** * \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, "SYBDATETIME") == 0) ci->datatype = SYBDATETIME; else if (strcmp(tok, "SYBDATETIME4") == 0) ci->datatype = SYBDATETIME4; 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); if ((ci->terminator = malloc(i)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FALSE; } memcpy(ci->terminator, term, i); ci->term_len = 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, -1); if (tds_bcp_done(dbproc->tds_socket, &rows_copied) != TDS_SUCCEED) 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_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); if (!(dbproc->bcpinfo)) return -1; CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); if (tds_bcp_done(dbproc->tds_socket, &rows_copied) != TDS_SUCCEED) 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 vartype, int table_column) { 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(vartype), table_column); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); 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; TDS_ZERO_FREE(colinfo->bcp_terminator); colinfo->bcp_term_len = 0; if((colinfo->bcp_terminator = malloc(termlen)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } memcpy(colinfo->bcp_terminator, terminator, termlen); colinfo->bcp_term_len = termlen; return SUCCEED; } static void _bcp_null_error(TDSBCPINFO *bcpinfo, int index, int offset) { DBPROCESS *dbproc = (DBPROCESS *) bcpinfo->parent; dbperror(dbproc, SYBEBCNN, 0); } /** * \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_SUCCEED or TDS_FAIL. * \sa _bcp_add_fixed_columns, _bcp_add_variable_columns, _bcp_send_bcp_record */ static int _bcp_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset) { TDS_TINYINT ti; TDS_SMALLINT si; TDS_INT li; TDS_INT desttype; int collen, coltype; int data_is_null; int bytes_read; int converted_data_size; BYTE *dataptr; DBPROCESS *dbproc = (DBPROCESS *) bcpinfo->parent; tdsdump_log(TDS_DBG_FUNC, "_bcp_get_col_data(%p, %p)\n", bcpinfo, bindcol); CHECK_DBPROC(); DBPERROR_RETURN(IS_TDSDEAD(dbproc->tds_socket), SYBEDDNE); CHECK_NULP(bindcol, "_bcp_get_col_data", 2, TDS_FAIL); dataptr = (BYTE *) bindcol->column_varaddr; data_is_null = 0; 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: memcpy(&ti, dataptr, 1); dataptr += 1; collen = ti; break; case 2: memcpy(&si, dataptr, 2); dataptr += 2; collen = si; break; case 4: memcpy(&li, dataptr, 4); dataptr += 4; collen = li; break; } if (collen == 0) data_is_null = 1; } /* if (Max) column length specified take that into consideration. */ if (!data_is_null && bindcol->column_bindlen >= 0) { if (bindcol->column_bindlen == 0) data_is_null = 1; else { 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 : 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) data_is_null = 1; } if (data_is_null) { bindcol->bcp_column_data->datalen = 0; bindcol->bcp_column_data->is_null = 1; } else { if ((converted_data_size = dbconvert(dbproc, coltype, (BYTE *) dataptr, collen, desttype, bindcol->bcp_column_data->data, bindcol->column_size)) == -1) { return TDS_FAIL; } bindcol->bcp_column_data->datalen = converted_data_size; bindcol->bcp_column_data->is_null = 0; assert(converted_data_size > 0); } return TDS_SUCCEED; } static int _bcp_no_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset) { return TDS_SUCCEED; } /** * 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_free_bcp_column_data(dbproc->hostfileinfo->host_columns[i]->bcp_column_data); 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); } if (dbproc->bcpinfo) { TDS_ZERO_FREE(dbproc->bcpinfo->tablename); TDS_ZERO_FREE(dbproc->bcpinfo->insert_stmt); tds_free_results(dbproc->bcpinfo->bindinfo); dbproc->bcpinfo->bindinfo = NULL; TDS_ZERO_FREE(dbproc->bcpinfo); } } freetds-0.91/src/dblib/xact.c100664 001750 000144 00000004737 11162032706 0011556/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include #include #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: xact.c,v 1.14 2009/03/24 01:22:14 jklowden Exp $"); #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-0.91/src/dblib/dbopen.c100664 001750 000144 00000002635 11372020767 0012070/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #ifdef DMALLOC #include #endif #ifdef dbopen #undef dbopen #endif TDS_RCSID(var, "$Id: dbopen.c,v 1.14 2010/05/10 15:10:47 freddy77 Exp $"); /** * 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) { #if MSDBLIB return tdsdbopen(login, server, 1); #else return tdsdbopen(login, server, 0); #endif } freetds-0.91/src/dblib/buffering.h100664 001750 000144 00000032064 11504613453 0012571typedef 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 int 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, ii, idx = -1; BUFFER_CHECK(buf); if (buf->tail == 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). */ for (ii=0, i = buf->tail; i != buf->head || ii == 0; i = buffer_idx_increment(buf, i)) { if( buffer_idx2row(buf, i) == row_number) { idx = i; break; } assert(ii++ < buf->capacity); /* prevent infinite loop */ } return idx; } /** * 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; int srctype, desttype; 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++) { DBINT srclen; TDSCOLUMN *curcol = row->resinfo->columns[i]; if (row->sizes) curcol->column_cur_size = row->sizes[i]; if (curcol->column_nullbind) { if (curcol->column_cur_size < 0) { *(DBINT *)(curcol->column_nullbind) = -1; } else { *(DBINT *)(curcol->column_nullbind) = 0; } } if (!curcol->column_varaddr) continue; if (row->row_data) src = &row->row_data[curcol->column_data - row->resinfo->current_row]; else src = curcol->column_data; srclen = curcol->column_cur_size; if (is_blob_col(curcol)) src = (BYTE *) ((TDSBLOB *) src)->textvalue; desttype = _db_get_server_type(curcol->column_bindtype); srctype = tds_get_conversion_type(curcol->column_type, curcol->column_size); if (srclen <= 0) { if (srclen == 0 || !curcol->column_nullbind) dbgetnull(dbproc, curcol->column_bindtype, curcol->column_bindlen, (BYTE *) curcol->column_varaddr); } else { copy_data_to_host_var(dbproc, srctype, src, srclen, desttype, (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 = (DBLIB_BUFFER_ROW *) calloc(buf->capacity, sizeof(DBLIB_BUFFER_ROW)); 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_INT *) calloc(resinfo->num_cols, sizeof(TDS_INT)); 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 int 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-0.91/src/dblib/db-lib.vcproj100775 001750 000144 00000017342 11326010000 0013011 freetds-0.91/src/dblib/unittests/README100664 001750 000144 00000001327 10167316132 0013367The 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-0.91/src/dblib/unittests/Makefile.am100664 001750 000144 00000006234 11424754547 0014562# $Id: Makefile.am,v 1.50 2010/07/31 08:05:59 freddy77 Exp $ 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) check_PROGRAMS = $(TESTS) SQL_DIST = bcp.sql dbmorecmds.sql done_handling.sql rpc.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 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 AM_CPPFLAGS = -DFREETDS_SRCDIR=\"$(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 $(LIBICONV) @NETWORK_LIBS@ EXTRA_DIST = t0016.in t0017.in t0017.in.be data.bin $(EXTRA_DIST_WIN32) $(SQL_DIST) CLEANFILES = tdsdump.out t0013.out t0014.out t0016.out \ t0016.err t0017.err t0017.out if HAVE_PERL_SOURCES dblib.dsw: $(top_srcdir)/win32/build_dsw.pl Makefile rm -rf $@ dblib.mak vc6 perl $(top_srcdir)/win32/build_dsw.pl $@ $(TESTS) vc6: dblib.dsw clean-local: rm -rf vc6 EXTRA_DIST_WIN32 = vc6 dblib.dsw dblib.mak endif $(SQL_DIST): ln -s $(srcdir)/$@ . freetds-0.91/src/dblib/unittests/Makefile.in100664 001750 000144 00000102444 11623070617 0014561# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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_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_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_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) 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(bcp_SOURCES) $(dbmorecmds_SOURCES) \ $(done_handling_SOURCES) $(hang_SOURCES) $(null_SOURCES) \ $(null2_SOURCES) $(numeric_SOURCES) $(rpc_SOURCES) \ $(setnull_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) $(dbmorecmds_SOURCES) \ $(done_handling_SOURCES) $(hang_SOURCES) $(null_SOURCES) \ $(null2_SOURCES) $(numeric_SOURCES) $(rpc_SOURCES) \ $(setnull_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) ETAGS = etags CTAGS = ctags am__tty_colors = \ red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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 $(LIBICONV) @NETWORK_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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.50 2010/07/31 08:05:59 freddy77 Exp $ 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) check_PROGRAMS = $(TESTS) SQL_DIST = bcp.sql dbmorecmds.sql done_handling.sql rpc.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 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 AM_CPPFLAGS = -DFREETDS_SRCDIR=\"$(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 $(EXTRA_DIST_WIN32) $(SQL_DIST) CLEANFILES = tdsdump.out t0013.out t0014.out t0016.out \ t0016.err t0017.err t0017.out @HAVE_PERL_SOURCES_TRUE@EXTRA_DIST_WIN32 = vc6 dblib.dsw dblib.mak 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/dblib/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/dblib/unittests/Makefile .PRECIOUS: 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) @rm -f bcp$(EXEEXT) $(LINK) $(bcp_OBJECTS) $(bcp_LDADD) $(LIBS) dbmorecmds$(EXEEXT): $(dbmorecmds_OBJECTS) $(dbmorecmds_DEPENDENCIES) @rm -f dbmorecmds$(EXEEXT) $(LINK) $(dbmorecmds_OBJECTS) $(dbmorecmds_LDADD) $(LIBS) done_handling$(EXEEXT): $(done_handling_OBJECTS) $(done_handling_DEPENDENCIES) @rm -f done_handling$(EXEEXT) $(LINK) $(done_handling_OBJECTS) $(done_handling_LDADD) $(LIBS) hang$(EXEEXT): $(hang_OBJECTS) $(hang_DEPENDENCIES) @rm -f hang$(EXEEXT) $(LINK) $(hang_OBJECTS) $(hang_LDADD) $(LIBS) null$(EXEEXT): $(null_OBJECTS) $(null_DEPENDENCIES) @rm -f null$(EXEEXT) $(LINK) $(null_OBJECTS) $(null_LDADD) $(LIBS) null2$(EXEEXT): $(null2_OBJECTS) $(null2_DEPENDENCIES) @rm -f null2$(EXEEXT) $(LINK) $(null2_OBJECTS) $(null2_LDADD) $(LIBS) numeric$(EXEEXT): $(numeric_OBJECTS) $(numeric_DEPENDENCIES) @rm -f numeric$(EXEEXT) $(LINK) $(numeric_OBJECTS) $(numeric_LDADD) $(LIBS) rpc$(EXEEXT): $(rpc_OBJECTS) $(rpc_DEPENDENCIES) @rm -f rpc$(EXEEXT) $(LINK) $(rpc_OBJECTS) $(rpc_LDADD) $(LIBS) setnull$(EXEEXT): $(setnull_OBJECTS) $(setnull_DEPENDENCIES) @rm -f setnull$(EXEEXT) $(LINK) $(setnull_OBJECTS) $(setnull_LDADD) $(LIBS) t0001$(EXEEXT): $(t0001_OBJECTS) $(t0001_DEPENDENCIES) @rm -f t0001$(EXEEXT) $(LINK) $(t0001_OBJECTS) $(t0001_LDADD) $(LIBS) t0002$(EXEEXT): $(t0002_OBJECTS) $(t0002_DEPENDENCIES) @rm -f t0002$(EXEEXT) $(LINK) $(t0002_OBJECTS) $(t0002_LDADD) $(LIBS) t0003$(EXEEXT): $(t0003_OBJECTS) $(t0003_DEPENDENCIES) @rm -f t0003$(EXEEXT) $(LINK) $(t0003_OBJECTS) $(t0003_LDADD) $(LIBS) t0004$(EXEEXT): $(t0004_OBJECTS) $(t0004_DEPENDENCIES) @rm -f t0004$(EXEEXT) $(LINK) $(t0004_OBJECTS) $(t0004_LDADD) $(LIBS) t0005$(EXEEXT): $(t0005_OBJECTS) $(t0005_DEPENDENCIES) @rm -f t0005$(EXEEXT) $(LINK) $(t0005_OBJECTS) $(t0005_LDADD) $(LIBS) t0006$(EXEEXT): $(t0006_OBJECTS) $(t0006_DEPENDENCIES) @rm -f t0006$(EXEEXT) $(LINK) $(t0006_OBJECTS) $(t0006_LDADD) $(LIBS) t0007$(EXEEXT): $(t0007_OBJECTS) $(t0007_DEPENDENCIES) @rm -f t0007$(EXEEXT) $(LINK) $(t0007_OBJECTS) $(t0007_LDADD) $(LIBS) t0008$(EXEEXT): $(t0008_OBJECTS) $(t0008_DEPENDENCIES) @rm -f t0008$(EXEEXT) $(LINK) $(t0008_OBJECTS) $(t0008_LDADD) $(LIBS) t0009$(EXEEXT): $(t0009_OBJECTS) $(t0009_DEPENDENCIES) @rm -f t0009$(EXEEXT) $(LINK) $(t0009_OBJECTS) $(t0009_LDADD) $(LIBS) t0011$(EXEEXT): $(t0011_OBJECTS) $(t0011_DEPENDENCIES) @rm -f t0011$(EXEEXT) $(LINK) $(t0011_OBJECTS) $(t0011_LDADD) $(LIBS) t0012$(EXEEXT): $(t0012_OBJECTS) $(t0012_DEPENDENCIES) @rm -f t0012$(EXEEXT) $(LINK) $(t0012_OBJECTS) $(t0012_LDADD) $(LIBS) t0013$(EXEEXT): $(t0013_OBJECTS) $(t0013_DEPENDENCIES) @rm -f t0013$(EXEEXT) $(LINK) $(t0013_OBJECTS) $(t0013_LDADD) $(LIBS) t0014$(EXEEXT): $(t0014_OBJECTS) $(t0014_DEPENDENCIES) @rm -f t0014$(EXEEXT) $(LINK) $(t0014_OBJECTS) $(t0014_LDADD) $(LIBS) t0015$(EXEEXT): $(t0015_OBJECTS) $(t0015_DEPENDENCIES) @rm -f t0015$(EXEEXT) $(LINK) $(t0015_OBJECTS) $(t0015_LDADD) $(LIBS) t0016$(EXEEXT): $(t0016_OBJECTS) $(t0016_DEPENDENCIES) @rm -f t0016$(EXEEXT) $(LINK) $(t0016_OBJECTS) $(t0016_LDADD) $(LIBS) t0017$(EXEEXT): $(t0017_OBJECTS) $(t0017_DEPENDENCIES) @rm -f t0017$(EXEEXT) $(LINK) $(t0017_OBJECTS) $(t0017_LDADD) $(LIBS) t0018$(EXEEXT): $(t0018_OBJECTS) $(t0018_DEPENDENCIES) @rm -f t0018$(EXEEXT) $(LINK) $(t0018_OBJECTS) $(t0018_LDADD) $(LIBS) t0019$(EXEEXT): $(t0019_OBJECTS) $(t0019_DEPENDENCIES) @rm -f t0019$(EXEEXT) $(LINK) $(t0019_OBJECTS) $(t0019_LDADD) $(LIBS) t0020$(EXEEXT): $(t0020_OBJECTS) $(t0020_DEPENDENCIES) @rm -f t0020$(EXEEXT) $(LINK) $(t0020_OBJECTS) $(t0020_LDADD) $(LIBS) t0021$(EXEEXT): $(t0021_OBJECTS) $(t0021_DEPENDENCIES) @rm -f t0021$(EXEEXT) $(LINK) $(t0021_OBJECTS) $(t0021_LDADD) $(LIBS) t0022$(EXEEXT): $(t0022_OBJECTS) $(t0022_DEPENDENCIES) @rm -f t0022$(EXEEXT) $(LINK) $(t0022_OBJECTS) $(t0022_LDADD) $(LIBS) t0023$(EXEEXT): $(t0023_OBJECTS) $(t0023_DEPENDENCIES) @rm -f t0023$(EXEEXT) $(LINK) $(t0023_OBJECTS) $(t0023_LDADD) $(LIBS) text_buffer$(EXEEXT): $(text_buffer_OBJECTS) $(text_buffer_DEPENDENCIES) @rm -f text_buffer$(EXEEXT) $(LINK) $(text_buffer_OBJECTS) $(text_buffer_LDADD) $(LIBS) thread$(EXEEXT): $(thread_OBJECTS) $(thread_DEPENDENCIES) @rm -f thread$(EXEEXT) $(LINK) $(thread_OBJECTS) $(thread_LDADD) $(LIBS) timeout$(EXEEXT): $(timeout_OBJECTS) $(timeout_DEPENDENCIES) @rm -f timeout$(EXEEXT) $(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)/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)/rpc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setnull.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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ echo "$$grn$$dashes"; \ else \ echo "$$red$$dashes"; \ fi; \ echo "$$banner"; \ test -z "$$skipped" || echo "$$skipped"; \ test -z "$$report" || echo "$$report"; \ echo "$$dashes$$std"; \ test "$$failed" -eq 0; \ else :; fi 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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." @HAVE_PERL_SOURCES_FALSE@clean-local: clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \ 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 all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool clean-local \ ctags 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 uninstall uninstall-am @HAVE_PERL_SOURCES_TRUE@dblib.dsw: $(top_srcdir)/win32/build_dsw.pl Makefile @HAVE_PERL_SOURCES_TRUE@ rm -rf $@ dblib.mak vc6 @HAVE_PERL_SOURCES_TRUE@ perl $(top_srcdir)/win32/build_dsw.pl $@ $(TESTS) @HAVE_PERL_SOURCES_TRUE@vc6: dblib.dsw @HAVE_PERL_SOURCES_TRUE@clean-local: @HAVE_PERL_SOURCES_TRUE@ rm -rf vc6 $(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-0.91/src/dblib/unittests/bcp.c100664 001750 000144 00000016117 11152006120 0013406/* * 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 software_version[] = "$Id: bcp.c,v 1.18 2009/02/27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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); add_bread_crumb(); dbsqlexec(dbproc); add_bread_crumb(); while ((rc=dbresults(dbproc)) == SUCCEED) { /* nop */ } if (rc != NO_MORE_RESULTS) return 1; add_bread_crumb(); fprintf(stdout, "Creating %s.%s..%s\n", SERVER, DATABASE, name); sql_cmd(dbproc); sql_cmd(dbproc); if (dbsqlexec(dbproc) == FAIL) { add_bread_crumb(); 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]); add_bread_crumb(); dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); 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); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); add_bread_crumb(); 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"); add_bread_crumb(); #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); add_bread_crumb(); sql_cmd(dbproc); add_bread_crumb(); dbsqlexec(dbproc); add_bread_crumb(); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } add_bread_crumb(); dbexit(); add_bread_crumb(); failed = 0; fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/bcp.h100664 001750 000144 00000006711 11122674700 0013426static 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-0.91/src/dblib/unittests/common.c100664 001750 000144 00000026253 11507145473 0014157#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 */ #if HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #if HAVE_SYS_RESOURCE_H #include #endif /* HAVE_SYS_RESOURCE_H */ #include "replacements.h" static char software_version[] = "$Id: common.c,v 1.42 2010/12/30 18:11:07 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; typedef struct _tag_memcheck_t { int item_number; unsigned int special; struct _tag_memcheck_t *next; } memcheck_t; static memcheck_t *breadcrumbs = NULL; static int num_breadcrumbs = 0; static const unsigned int BREADCRUMB = 0xABCD7890; #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) { size_t 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 = tds_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 <= 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; } void check_crumbs(void) { int i; memcheck_t *ptr = breadcrumbs; i = num_breadcrumbs; while (ptr != NULL) { if (ptr->special != BREADCRUMB || ptr->item_number != i) { fprintf(stderr, "Somebody overwrote one of the bread crumbs!!!\n"); abort(); } i--; ptr = ptr->next; } } void add_bread_crumb(void) { memcheck_t *tmp; check_crumbs(); tmp = (memcheck_t *) calloc(sizeof(memcheck_t), 1); if (tmp == NULL) { fprintf(stderr, "Out of memory"); abort(); exit(1); } num_breadcrumbs++; tmp->item_number = num_breadcrumbs; tmp->special = BREADCRUMB; tmp->next = breadcrumbs; breadcrumbs = tmp; } void free_bread_crumb(void) { memcheck_t *tmp, *ptr = breadcrumbs; check_crumbs(); while (ptr) { tmp = ptr->next; free(ptr); ptr = tmp; } num_breadcrumbs = 0; } int syb_msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { char var_value[31]; int i; char *c; 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 ) ; */ if (msgtext != NULL && (c = strchr(msgtext, '\'')) != NULL) { i = 0; for (++c; i <= 30 && *c != '\0' && *c != '\''; ++c) var_value[i++] = *c; var_value[i] = '\0'; } 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-0.91/src/dblib/unittests/common.h100664 001750 000144 00000004434 11247132563 0014156 #ifndef COMMON_h #define COMMON_h static char rcsid_common_h[] = "$Id: common.h,v 1.20 2009/09/01 05:47:31 freddy77 Exp $"; static void *no_unused_common_h_warn[] = { rcsid_common_h, no_unused_common_h_warn }; #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #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 #if !defined(FREETDS_SRCDIR) #define FREETDS_SRCDIR "../../../.." #endif #if !defined(EXIT_FAILURE) #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 #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); void check_crumbs(void); void add_bread_crumb(void); void free_bread_crumb(void); 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); #define int2ptr(i) ((void*)(((char*)0)+(i))) #define ptr2int(p) ((int)(((char*)(p))-((char*)0))) #endif freetds-0.91/src/dblib/unittests/dbmorecmds.c100664 001750 000144 00000005430 11152006120 0014755/* * Purpose: Test behaviour of dbmorecmds() * Functions: dbmorecmds */ #include "common.h" static char software_version[] = "$Id: dbmorecmds.c,v 1.15 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) { 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); fprintf(stdout, "after bread crumb\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); add_bread_crumb(); fprintf(stdout, "After second bread crumb\n"); 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); } add_bread_crumb(); dbloginfree(login); add_bread_crumb(); fprintf(stdout, "After dbuse [%s]\n", DATABASE); add_bread_crumb(); 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); add_bread_crumb(); nresults = 0; if (dbresults(dbproc) == SUCCEED) { do { while (dbnextrow(dbproc) != NO_MORE_ROWS); nresults++; } while (dbmorecmds(dbproc) == SUCCEED); } /* dbmorecmds should return success 0 times for select 1 */ if (nresults != 1) { add_bread_crumb(); 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); nresults++; } } while (dbmorecmds(dbproc) == SUCCEED); /* dbmorecmds should return success 2 times for select 2 */ if (nresults != 2) { /* two results sets plus a return code */ add_bread_crumb(); failed = 1; fprintf(stdout, "nresults was %d; was expecting nresults = 2.\n", nresults); exit(1); } /* end of test processing */ add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/done_handling.c100664 001750 000144 00000014021 11446325137 0015445#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-0.91/src/dblib/unittests/hang.c100664 001750 000144 00000005517 11113101425 0013562/* * Purpose: Test for dbsqlexec on closed connection */ #include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 */ static char software_version[] = "$Id: hang.c,v 1.3 2008/11/25 22:58:29 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; char *UNITTEST; #if HAVE_FSTAT && defined(S_IFSOCK) static int end_socket = -1; static int shutdown_last_socket(void) { int max_socket = -1, i; int sockets[2]; for (i = 3; i < 1024; ++i) { struct stat file_stat; if (fstat(i, &file_stat)) continue; if ((file_stat.st_mode & S_IFSOCK) == S_IFSOCK) max_socket = i; } 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 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_last_socket()) { 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-0.91/src/dblib/unittests/null.c100664 001750 000144 00000007745 11461506600 0013636/* * 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-0.91/src/dblib/unittests/null2.c100664 001750 000144 00000007647 11461506600 0013721/* * Purpose: Test NULL behavior using dbbind */ #include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ static char software_version[] = "$Id: null2.c,v 1.8 2010/10/26 08:12:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 binded */ 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-0.91/src/dblib/unittests/numeric.c100664 001750 000144 00000007003 11247435145 0014320#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("res %d\n", ret); if (ret == SUCCEED) return; fprintf(stderr, "error: %s\n", msg); exit(1); } static void test(int bind_type) { LOGINREC *login; DBPROCESS *dbproc; DBNUMERIC *num = NULL, *num2 = NULL; RETCODE ret; int i; sql_rewind(); login = dblogin(); DBSETLUSER(login, USER); DBSETLPWD(login, PASSWORD); DBSETLAPP(login, "numeric"); dbsetmaxprocs(25); DBSETLHOST(login, SERVER); dbproc = dbopen(login, SERVER); 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)); num->scale = 5; num->precision = 16; dbconvert(dbproc, SYBVARCHAR, (const BYTE *) "123.45", -1, SYBDECIMAL, (BYTE *) num, sizeof(*num)); 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)); num2->precision = 20; num2->scale = 10; dbconvert(dbproc, SYBVARCHAR, (const BYTE *) "246.9", -1, SYBDECIMAL, (BYTE *) num2, sizeof(*num2)); 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 = num2->precision; num->scale = num2->scale; dbbind(dbproc, 1, bind_type, 0, (BYTE *) num); while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS) { if (row_code == REG_ROW) { if (memcmp(num, num2, sizeof(*num)) != 0) { fprintf(stderr, "Failed. Output results does not match\n"); dump_addr(stderr, "numeric: ", num, sizeof(*num)); dump_addr(stderr, "numeric2:", 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); } int main(int argc, char **argv) { read_login_info(argc, argv); dbinit(); test(DECIMALBIND); test(NUMERICBIND); dbexit(); printf("Succeed\n"); return 0; } freetds-0.91/src/dblib/unittests/rpc.c100664 001750 000144 00000026563 11370700437 0013452/* * Purpose: Test remote procedure calls * Functions: dbretdata dbretlen dbretname dbretstatus dbrettype dbrpcinit dbrpcparam dbrpcsend */ #include "common.h" static char software_version[] = "$Id: rpc.c,v 1.39 2010/05/07 02:55:27 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int 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 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" ", @nv nvarchar(20) = N'hello'\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" "select name from sysobjects where 0=1\n" "select distinct convert(varchar(30), name) as 'type' from systypes \n" "where name in ('int', 'char', 'text') \n" "select @nrows = @@rowcount \n" "select distinct @nv as '@nv', convert(varchar(30), name) as name from sysobjects where type = 'S' \n" "return 42 \n" "END \n"; static RETCODE init_proc(DBPROCESS * dbproc, const char *name) { RETCODE ret = FAIL; if (name[0] != '#') { fprintf(stdout, "Dropping procedure %s\n", name); add_bread_crumb(); sql_cmd(dbproc); add_bread_crumb(); dbsqlexec(dbproc); add_bread_crumb(); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } add_bread_crumb(); } fprintf(stdout, "Creating procedure %s\n", name); sql_cmd(dbproc); if ((ret = dbsqlexec(dbproc)) == FAIL) { add_bread_crumb(); 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; } int ignore_msg_handler(DBPROCESS * dbproc, DBINT msgno, int state, int severity, char *text, char *server, char *proc, int line) { dbsetuserdata(dbproc, (BYTE*) &msgno); /* printf("(ignoring message %d)\n", msgno); */ return syb_msg_handler(dbproc, msgno, state, severity, text, server, proc, line); } /* * 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 ingnore_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); 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]; int param_data2, param_data3; 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 } , { "@nrows", DBRPCRETURN, SYBINT4, -1, -1, (BYTE *) ¶m_data3 } , { "@c", 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; char teststr[1024]; 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; static const char dashes30[] = "------------------------------"; static const char *dashes5 = dashes30 + (sizeof(dashes30) - 5), *dashes15 = dashes30 + (sizeof(dashes30) - 15); RETCODE erc, row_code; set_malloc_options(); memset(&save_param, 0, sizeof(save_param)); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); add_bread_crumb(); dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "#t0022"); dberrhandle(ignore_err_handler); DBSETLPACKET(login, -1); dberrhandle(syb_err_handler); fprintf(stdout, "About to open %s.%s\n", SERVER, DATABASE); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); add_bread_crumb(); dberrhandle(ignore_err_handler); dbmsghandle(ignore_msg_handler); printf("trying to create a temporary stored procedure\n"); if (FAIL == init_proc(dbproc, proc_name)) { 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; pb < bindings + sizeof(bindings)/sizeof(bindings[0]); pb++) { printf("executing dbrpcparam for %s\n", pb->name); 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_data3 = 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); } add_bread_crumb(); /* 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 { add_bread_crumb(); 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) < 4) { /* dbnumrets missed something */ fprintf(stderr, "Expected 4 output parameters.\n"); exit(1); } printf("retrieving output parameters...\n"); printf("%-5s %-15s %5s %6s %-30s\n", "param", "name", "type", "length", "data"); printf("%-5s %-15s %5s %5s- %-30s\n", dashes5, dashes15, dashes5, dashes5, dashes30); for (i = 1; i <= dbnumrets(dbproc); i++) { add_bread_crumb(); retname = dbretname(dbproc, i); rettype = dbrettype(dbproc, i); retlen = dbretlen(dbproc, i); dbconvert(dbproc, rettype, dbretdata(dbproc, i), retlen, SYBVARCHAR, (BYTE*) teststr, -1); printf("%-5d %-15s %5d %6d %-30s\n", i, retname, rettype, retlen, teststr); add_bread_crumb(); save_retparam(&save_param, retname, teststr, rettype, retlen); } /* * Test the last parameter for expected outcome */ if ((save_param.name == NULL) || strcmp(save_param.name, bindings[3].name)) { fprintf(stderr, "Expected retname to be '%s', got ", bindings[3].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(42 != return_status) { fprintf(stderr, "Expected status to be 42.\n"); exit(1); } printf("Good: Got 4 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); add_bread_crumb(); fprintf(stdout, "Dropping procedure\n"); add_bread_crumb(); sql_cmd(dbproc); add_bread_crumb(); dbsqlexec(dbproc); add_bread_crumb(); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); free(save_param.name); free(save_param.value); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/setnull.c100664 001750 000144 00000010154 11113101425 0014324/* * Purpose: dbnull behavior */ #include "common.h" #include "replacements.h" static char software_version[] = "$Id: setnull.c,v 1.9 2008/11/25 22:58:29 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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, tds_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, tds_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-0.91/src/dblib/unittests/t0001.c100664 001750 000144 00000007540 11152006120 0013406/* * 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" static char software_version[] = "$Id: t0001.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) { 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon as \"%s\"\n", USER); add_bread_crumb(); 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); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (!dbproc) { fprintf(stderr, "Unable to connect to %s\n", SERVER); return 1; } add_bread_crumb(); dbloginfree(login); add_bread_crumb(); fprintf(stdout, "Using database \"%s\"\n", DATABASE); if (strlen(DATABASE)) { erc = dbuse(dbproc, DATABASE); assert(erc == SUCCEED); } add_bread_crumb(); #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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); failed = 1; fprintf(stderr, "error: expected a result set, none returned.\n"); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 1, INTBIND, -1, (BYTE *) & testint)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } add_bread_crumb(); add_bread_crumb(); for (i = 0; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); add_bread_crumb(); 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); } add_bread_crumb(); 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); } add_bread_crumb(); if (dbnextrow(dbproc) != NO_MORE_ROWS) { failed = 1; fprintf(stderr, "Was expecting no more rows\n"); exit(1); } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0001.sql100664 001750 000144 00000005034 11141421123 0013761create 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-0.91/src/dblib/unittests/t0002.c100664 001750 000144 00000014667 11174033232 0013427/* * 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 static char software_version[] = "$Id: t0002.c,v 1.25 2009/04/23 09:36:26 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0002"); fprintf(stdout, "About to open %s..%s\n", SERVER, DATABASE); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); fprintf(stdout, "Setting row buffer to 10 rows\n"); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "10"); #else dbsetopt(dbproc, DBBUFFER, "10", 0); #endif add_bread_crumb(); add_bread_crumb(); sql_cmd(dbproc); /* drop table if exists */ add_bread_crumb(); dbsqlexec(dbproc); add_bread_crumb(); 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; } add_bread_crumb(); 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); add_bread_crumb(); for (iresults=1; iresults <= 2; iresults++ ) { fprintf(stdout, "fetching resultset %i\n", iresults); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); 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; add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is [%s]\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); /* 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++; add_bread_crumb(); 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; add_bread_crumb(); 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); add_bread_crumb(); 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); add_bread_crumb(); 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); add_bread_crumb(); 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); add_bread_crumb(); assert(rc == NO_MORE_ROWS); /* only 10 (not 11) rows buffered */ rc = dbgetrow(dbproc, 46); add_bread_crumb(); 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); add_bread_crumb(); assert(rc == REG_ROW); verify(47, testint, teststr); /* fetch row from database, should be 47 */ rc = dbnextrow(dbproc); add_bread_crumb(); 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 */ add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0003.c100664 001750 000144 00000006166 11152006120 0013413/* * Purpose: Test buffering * Functions: dbclrbuf dbgetrow dbsetopt */ #include "common.h" static char software_version[] = "$Id: t0003.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; 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0003"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "100"); #else dbsetopt(dbproc, DBBUFFER, "100", 0); #endif add_bread_crumb(); 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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { failed = 1; add_bread_crumb(); fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); add_bread_crumb(); for (i = 1; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); add_bread_crumb(); if (i % 100 == 0) { dbclrbuf(dbproc, 100); } add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } add_bread_crumb(); 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); } add_bread_crumb(); 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); } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0004.c100664 001750 000144 00000007152 11357311264 0013427/* * Purpose: Test retrieving data and attempting to initiate a new query with results pending * Functions: dbnextrow dbresults dbsqlexec dbgetchar */ #include "common.h" #include static char software_version[] = "$Id: t0004.c,v 1.21 2010/04/08 08:24:20 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]); add_bread_crumb(); dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0004"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); add_bread_crumb(); 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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); add_bread_crumb(); for (i = 1; i <= 24; i++) { char expected[1024]; sprintf(expected, "row %04d", i); add_bread_crumb(); if (i % 5 == 0) { dbclrbuf(dbproc, 5); } testint = -1; strcpy(teststr, "bogus"); add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } add_bread_crumb(); 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; } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0005.c100664 001750 000144 00000016430 11152006120 0013410/* * Purpose: Test data retrieval accuracy and cancelling results * Functions: dbbind dbcancel dbcmd dbcolname dbnextrow dbnumcols dbresults dbsqlexec */ #include "common.h" static char software_version[] = "$Id: t0005.c,v 1.26 2009/02/27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]); add_bread_crumb(); dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0005"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); add_bread_crumb(); 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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); add_bread_crumb(); for (i = 1; i < 5; i++) { char expected[1024]; sprintf(expected, "row %04d", i); add_bread_crumb(); testint = -1; strcpy(teststr, "bogus"); add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } add_bread_crumb(); 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; } add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); add_bread_crumb(); for (i = 1; i < 5; i++) { char expected[1024]; sprintf(expected, "row %04d", i); add_bread_crumb(); testint = -1; strcpy(teststr, "bogus"); add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } add_bread_crumb(); 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"); add_bread_crumb(); sql_cmd(dbproc); add_bread_crumb(); dbsqlexec(dbproc); add_bread_crumb(); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } add_bread_crumb(); fprintf(stdout, "creating proc\n"); sql_cmd(dbproc); if (dbsqlexec(dbproc) == FAIL) { add_bread_crumb(); 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) { add_bread_crumb(); fprintf(stderr, "%s:%d: failed to call procedure\n", __FILE__, __LINE__); failed = 1; } if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); for (i = 1; i < 6; i++) { char expected[1024]; sprintf(expected, "row %04d", i); add_bread_crumb(); testint = -1; strcpy(teststr, "bogus"); add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } add_bread_crumb(); 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); } add_bread_crumb(); 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; } add_bread_crumb(); dbcancel(dbproc); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0006.c100664 001750 000144 00000007323 11152006120 0013412/* * 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 software_version[] = "$Id: t0006.c,v 1.19 2009/02/27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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); add_bread_crumb(); 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0006"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "5000"); #else dbsetopt(dbproc, DBBUFFER, "5000", 0); #endif add_bread_crumb(); 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; } add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "%s:%d: Was expecting a result set.", __FILE__, __LINE__); failed = 1; exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); get_results(dbproc, 1); add_bread_crumb(); testint = -1; strcpy(teststr, "bogus"); fprintf(stdout, "second select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); add_bread_crumb(); if ((rc = dbresults(dbproc)) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "%s:%d: Was expecting a result set. (rc=%d)\n", __FILE__, __LINE__, rc); failed = 1; } if (!failed) { add_bread_crumb(); add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); get_results(dbproc, 25); } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0007.c100664 001750 000144 00000011655 11507152520 0013430/* * Purpose: Test binding strings and ints, attempt 2nd query with results pending. * Functions: dbbind dbcmd dbnextrow dbopen dbresults dbsqlexec */ #include "common.h" static char software_version[] = "$Id: t0007.c,v 1.23 2010/12/30 18:54:08 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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; } add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); return 0; } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is named \"%s\"\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } 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]); add_bread_crumb(); dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0007"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); add_bread_crumb(); create_tables(dbproc, 10); if (!start_query(dbproc)) { fprintf(stderr, "%s:%d: start_query failed\n", __FILE__, __LINE__); failed = 1; } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); add_bread_crumb(); for (i = 1; i <= 2; i++) { char expected[1024]; sprintf(expected, "row %07d", i); add_bread_crumb(); if (i % 5 == 0) { dbclrbuf(dbproc, 5); } testint = -1; strcpy(teststr, "bogus"); add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); abort(); } add_bread_crumb(); 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; } add_bread_crumb(); 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(); } testint = *((DBINT*) testvbin.array); 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); } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0008.c100664 001750 000144 00000007174 11173631630 0013435/* * Purpose: Test buffering. As of April 2005, jkl believes this test is broken. * Functions: dbclrbuf dbsetopt */ #include "common.h" static char software_version[] = "$Id: t0008.c,v 1.19 2009/04/22 15:11:20 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0008"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "25"); #else dbsetopt(dbproc, DBBUFFER, "25", 0); #endif add_bread_crumb(); 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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); add_bread_crumb(); for (i = 1; i <= rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); add_bread_crumb(); if (i % 25 == 0) { dbclrbuf(dbproc, 25); } add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "dblib failed for %s, dbnextrow1\n", __FILE__); add_bread_crumb(); dbexit(); add_bread_crumb(); free_bread_crumb(); return 1; } add_bread_crumb(); 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__); add_bread_crumb(); dbexit(); add_bread_crumb(); free_bread_crumb(); return 1; } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s (last_read: %d)\n", __FILE__, ((last_read != rows_to_add)? "failed!" : "OK"), (int) last_read); free_bread_crumb(); return (last_read == rows_to_add) ? 0 : 1; } freetds-0.91/src/dblib/unittests/t0009.c100664 001750 000144 00000005562 11152006120 0013420/* * 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" static char software_version[] = "$Id: t0009.c,v 1.17 2009/02/27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0009"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "100"); #else dbsetopt(dbproc, DBBUFFER, "100", 0); #endif add_bread_crumb(); 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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, -1, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); add_bread_crumb(); 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); } add_bread_crumb(); dbexit(); add_bread_crumb(); printf("dblib passed for %s\n", __FILE__); free_bread_crumb(); return 0; } freetds-0.91/src/dblib/unittests/t0011.c100664 001750 000144 00000005650 11152006120 0013407/* * 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-0.91/src/dblib/unittests/t0012.c100664 001750 000144 00000005466 11152006120 0013415/* * Purpose: Test datetime conversion as well as dbdata() & dbdatlen() * Functions: dbcmd dbdata dbdatecrack dbdatlen dbnextrow dbresults dbsqlexec */ #include "common.h" static char software_version[] = "$Id: t0012.c,v 1.24 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; char datestring[256]; DBDATEREC dateinfo; DBDATETIME mydatetime; 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 */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } dbsqlexec(dbproc); dbresults(dbproc); while (dbnextrow(dbproc) != NO_MORE_ROWS) { /* 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 */ #ifdef MSDBLIB printf("\tYear = %d.\n", dateinfo.year); printf("\tMonth = %d.\n", dateinfo.month); printf("\tDay of month = %d.\n", dateinfo.day); printf("\tDay of year = %d.\n", dateinfo.dayofyear); printf("\tDay of week = %d.\n", dateinfo.weekday); printf("\tHour = %d.\n", dateinfo.hour); printf("\tMinute = %d.\n", dateinfo.minute); printf("\tSecond = %d.\n", dateinfo.second); printf("\tMillisecond = %d.\n", dateinfo.millisecond); #else 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); #endif } dbclose(dbproc); dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/vc6/numeric.dsp100664 001750 000144 00000010703 11623073525 0015361# Microsoft Developer Studio Project File - Name="numeric" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=numeric - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "numeric.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "numeric.mak" CFG="numeric - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "numeric - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "numeric - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "numeric - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "numeric - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "numeric - Win32 Release" # Name "numeric - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\numeric.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0002.dsp100664 001750 000144 00000010653 11623073524 0014467# Microsoft Developer Studio Project File - Name="t0002" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0002 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0002.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0002.mak" CFG="t0002 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0002 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0002 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0002 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0002 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0002 - Win32 Release" # Name "t0002 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0002.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0003.dsp100664 001750 000144 00000010653 11623073524 0014470# Microsoft Developer Studio Project File - Name="t0003" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0003 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0003.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0003.mak" CFG="t0003 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0003 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0003 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0003 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0003 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0003 - Win32 Release" # Name "t0003 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0003.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0004.dsp100664 001750 000144 00000010653 11623073524 0014471# Microsoft Developer Studio Project File - Name="t0004" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0004 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0004.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0004.mak" CFG="t0004 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0004 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0004 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0004 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0004 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0004 - Win32 Release" # Name "t0004 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0004.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0005.dsp100664 001750 000144 00000010653 11623073524 0014472# Microsoft Developer Studio Project File - Name="t0005" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0005 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0005.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0005.mak" CFG="t0005 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0005 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0005 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0005 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0005 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0005 - Win32 Release" # Name "t0005 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0005.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0006.dsp100664 001750 000144 00000010653 11623073524 0014473# Microsoft Developer Studio Project File - Name="t0006" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0006 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0006.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0006.mak" CFG="t0006 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0006 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0006 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0006 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0006 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0006 - Win32 Release" # Name "t0006 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0006.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0007.dsp100664 001750 000144 00000010653 11623073524 0014474# Microsoft Developer Studio Project File - Name="t0007" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0007 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0007.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0007.mak" CFG="t0007 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0007 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0007 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0007 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0007 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0007 - Win32 Release" # Name "t0007 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0007.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0008.dsp100664 001750 000144 00000010653 11623073524 0014475# Microsoft Developer Studio Project File - Name="t0008" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0008 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0008.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0008.mak" CFG="t0008 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0008 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0008 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0008 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0008 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0008 - Win32 Release" # Name "t0008 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0008.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0009.dsp100664 001750 000144 00000010653 11623073524 0014476# Microsoft Developer Studio Project File - Name="t0009" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0009 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0009.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0009.mak" CFG="t0009 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0009 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0009 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0009 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0009 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0009 - Win32 Release" # Name "t0009 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0009.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0011.dsp100664 001750 000144 00000010653 11623073524 0014467# Microsoft Developer Studio Project File - Name="t0011" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0011 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0011.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0011.mak" CFG="t0011 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0011 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0011 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0011 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0011 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0011 - Win32 Release" # Name "t0011 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0011.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0012.dsp100664 001750 000144 00000010653 11623073524 0014470# Microsoft Developer Studio Project File - Name="t0012" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0012 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0012.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0012.mak" CFG="t0012 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0012 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0012 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0012 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0012 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0012 - Win32 Release" # Name "t0012 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0012.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0013.dsp100664 001750 000144 00000010653 11623073524 0014471# Microsoft Developer Studio Project File - Name="t0013" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0013 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0013.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0013.mak" CFG="t0013 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0013 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0013 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0013 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0013 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0013 - Win32 Release" # Name "t0013 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0013.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0014.dsp100664 001750 000144 00000010653 11623073524 0014472# Microsoft Developer Studio Project File - Name="t0014" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0014 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0014.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0014.mak" CFG="t0014 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0014 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0014 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0014 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0014 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0014 - Win32 Release" # Name "t0014 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0014.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0015.dsp100664 001750 000144 00000010653 11623073524 0014473# Microsoft Developer Studio Project File - Name="t0015" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0015 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0015.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0015.mak" CFG="t0015 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0015 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0015 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0015 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0015 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0015 - Win32 Release" # Name "t0015 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0015.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0016.dsp100664 001750 000144 00000010653 11623073524 0014474# Microsoft Developer Studio Project File - Name="t0016" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0016 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0016.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0016.mak" CFG="t0016 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0016 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0016 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0016 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0016 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0016 - Win32 Release" # Name "t0016 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0016.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0017.dsp100664 001750 000144 00000010653 11623073524 0014475# Microsoft Developer Studio Project File - Name="t0017" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0017 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0017.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0017.mak" CFG="t0017 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0017 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0017 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0017 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0017 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0017 - Win32 Release" # Name "t0017 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0017.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0018.dsp100664 001750 000144 00000010653 11623073524 0014476# Microsoft Developer Studio Project File - Name="t0018" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0018 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0018.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0018.mak" CFG="t0018 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0018 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0018 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0018 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0018 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0018 - Win32 Release" # Name "t0018 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0018.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0019.dsp100664 001750 000144 00000010653 11623073524 0014477# Microsoft Developer Studio Project File - Name="t0019" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0019 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0019.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0019.mak" CFG="t0019 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0019 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0019 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0019 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0019 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0019 - Win32 Release" # Name "t0019 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0019.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0020.dsp100664 001750 000144 00000010653 11623073524 0014467# Microsoft Developer Studio Project File - Name="t0020" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0020 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0020.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0020.mak" CFG="t0020 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0020 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0020 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0020 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0020 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0020 - Win32 Release" # Name "t0020 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0020.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0021.dsp100664 001750 000144 00000010653 11623073524 0014470# Microsoft Developer Studio Project File - Name="t0021" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0021 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0021.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0021.mak" CFG="t0021 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0021 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0021 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0021 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0021 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0021 - Win32 Release" # Name "t0021 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0021.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0022.dsp100664 001750 000144 00000010653 11623073524 0014471# Microsoft Developer Studio Project File - Name="t0022" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0022 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0022.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0022.mak" CFG="t0022 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0022 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0022 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0022 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0022 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0022 - Win32 Release" # Name "t0022 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0022.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0023.dsp100664 001750 000144 00000010653 11623073524 0014472# Microsoft Developer Studio Project File - Name="t0023" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0023 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0023.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0023.mak" CFG="t0023 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0023 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0023 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0023 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0023 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0023 - Win32 Release" # Name "t0023 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0023.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/rpc.dsp100664 001750 000144 00000010623 11623073524 0014503# Microsoft Developer Studio Project File - Name="rpc" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=rpc - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "rpc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "rpc.mak" CFG="rpc - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "rpc - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "rpc - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "rpc - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "rpc - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "rpc - Win32 Release" # Name "rpc - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\rpc.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/dbmorecmds.dsp100664 001750 000144 00000010747 11623073524 0016045# Microsoft Developer Studio Project File - Name="dbmorecmds" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=dbmorecmds - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "dbmorecmds.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "dbmorecmds.mak" CFG="dbmorecmds - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "dbmorecmds - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "dbmorecmds - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "dbmorecmds - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "dbmorecmds - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "dbmorecmds - Win32 Release" # Name "dbmorecmds - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\dbmorecmds.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/bcp.dsp100664 001750 000144 00000010623 11623073524 0014463# Microsoft Developer Studio Project File - Name="bcp" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=bcp - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "bcp.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "bcp.mak" CFG="bcp - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "bcp - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "bcp - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "bcp - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "bcp - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "bcp - Win32 Release" # Name "bcp - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\bcp.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/thread.dsp100664 001750 000144 00000010667 11623073524 0015176# Microsoft Developer Studio Project File - Name="thread" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=thread - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "thread.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "thread.mak" CFG="thread - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "thread - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "thread - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "thread - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "thread - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "thread - Win32 Release" # Name "thread - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\thread.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/text_buffer.dsp100664 001750 000144 00000010763 11623073524 0016241# Microsoft Developer Studio Project File - Name="text_buffer" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=text_buffer - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "text_buffer.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "text_buffer.mak" CFG="text_buffer - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "text_buffer - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "text_buffer - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "text_buffer - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "text_buffer - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "text_buffer - Win32 Release" # Name "text_buffer - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\text_buffer.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/done_handling.dsp100664 001750 000144 00000011013 11623073524 0016502# Microsoft Developer Studio Project File - Name="done_handling" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=done_handling - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "done_handling.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "done_handling.mak" CFG="done_handling - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "done_handling - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "done_handling - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "done_handling - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "done_handling - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "done_handling - Win32 Release" # Name "done_handling - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\done_handling.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/timeout.dsp100664 001750 000144 00000010703 11623073524 0015404# Microsoft Developer Studio Project File - Name="timeout" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=timeout - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "timeout.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "timeout.mak" CFG="timeout - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "timeout - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "timeout - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "timeout - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "timeout - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "timeout - Win32 Release" # Name "timeout - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\timeout.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/hang.dsp100664 001750 000144 00000010637 11623073524 0014641# Microsoft Developer Studio Project File - Name="hang" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=hang - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "hang.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "hang.mak" CFG="hang - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "hang - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "hang - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "hang - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "hang - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "hang - Win32 Release" # Name "hang - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\hang.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/null.dsp100664 001750 000144 00000010637 11623073524 0014676# Microsoft Developer Studio Project File - Name="null" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=null - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "null.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "null.mak" CFG="null - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "null - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "null - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "null - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "null - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "null - Win32 Release" # Name "null - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\null.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/null2.dsp100664 001750 000144 00000010653 11623073525 0014757# Microsoft Developer Studio Project File - Name="null2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=null2 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "null2.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "null2.mak" CFG="null2 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "null2 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "null2 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "null2 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "null2 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "null2 - Win32 Release" # Name "null2 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\null2.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/setnull.dsp100664 001750 000144 00000010703 11623073525 0015405# Microsoft Developer Studio Project File - Name="setnull" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=setnull - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "setnull.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "setnull.mak" CFG="setnull - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "setnull - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "setnull - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "setnull - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "setnull - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "setnull - Win32 Release" # Name "setnull - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\setnull.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/vc6/t0001.dsp100664 001750 000144 00000010653 11623073524 0014466# Microsoft Developer Studio Project File - Name="t0001" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0001 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0001.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0001.mak" CFG="t0001 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0001 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0001 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0001 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0001 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0001 - Win32 Release" # Name "t0001 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0001.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/dblib/unittests/t0013.c100664 001750 000144 00000015147 11507145473 0013436/* * Purpose: Test sending and receiving TEXT datatype * Functions: dbmoretext dbreadtext dbtxptr dbtxtimestamp dbwritetext */ #include "common.h" static char software_version[] = "$Id: t0013.c,v 1.31 2010/12/30 18:11:07 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define BLOB_BLOCK_SIZE 4096 int failed = 0; #if !defined(FREETDS_SRCDIR) #define FREETDS_SRCDIR "../../../.." #endif #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; BOOL readFirstImage; 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 = malloc(isiz); assert(blob); fread((void *) blob, isiz, 1, fp); fclose(fp); drop_table(); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } atexit(drop_table); 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); assert(0 < textPtr); /* * 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; readFirstImage = FALSE; while ((result = dbreadtext(dbproc, rbuf, BLOB_BLOCK_SIZE)) != NO_MORE_ROWS) { if (result == 0) { /* this indicates end of row */ readFirstImage = TRUE; } else { 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(); #if 1 dbclose(dbproc); #else if (SUCCEED != dbclose(dbproc)){ fprintf(stdout, "dbclose failed"); abort(); } #endif dbproc = 0; 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-0.91/src/dblib/unittests/t0014.c100664 001750 000144 00000014060 11507145473 0013430/* * Purpose: Test sending and receiving TEXT datatype * Functions: dbbind dbmoretext dbreadtext dbtxptr dbtxtimestamp dbwritetext */ #include "common.h" static char software_version[] = "$Id: t0014.c,v 1.32 2010/12/30 18:11:07 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #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; BOOL readFirstImage; 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); fread((void *) blob, isiz, 1, fp); 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); /* * 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); } } } 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; readFirstImage = FALSE; while ((result = dbreadtext(blobproc, rbuf, BLOB_BLOCK_SIZE)) != NO_MORE_ROWS) { if (result == 0) { /* this indicates end of row */ readFirstImage = TRUE; } else { 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-0.91/src/dblib/unittests/t0015.c100664 001750 000144 00000007401 11152006120 0013407/* * Purpose: Test binding and retrieving strings and ints, and cancelling results * Functions: dbbind dbcancel dbnextrow dbnumcols dbresults dbsqlexec */ #include "common.h" static char software_version[] = "$Id: t0015.c,v 1.20 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) { 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0015"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); 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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } add_bread_crumb(); add_bread_crumb(); 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) { add_bread_crumb(); failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } add_bread_crumb(); for (i = 26; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } add_bread_crumb(); 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); } add_bread_crumb(); if (dbnextrow(dbproc) != NO_MORE_ROWS) { failed = 1; fprintf(stderr, "Was expecting no more rows\n"); exit(1); } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0016.c100664 001750 000144 00000011511 11152006120 0013405/* * Purpose: Test bcp in and out, and specifically bcp_colfmt() * Functions: bcp_colfmt bcp_columns bcp_exec bcp_init */ #include "common.h" #include static char software_version[] = "$Id: t0016.c,v 1.30 2009/02/27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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.in" #define TABLE_NAME "#dblib0016" int main(int argc, char *argv[]) { LOGINREC *login; DBPROCESS *dbproc; int i; RETCODE ret; const char *out_file = "t0016.out"; const char *in_file = FREETDS_SRCDIR "/" INFILE_NAME; const char *err_file = "t0016.err"; DBINT rows_copied; int num_cols = 0; FILE *input_file, *output_file; #if 1 struct stat sb; if (0 != stat(in_file, &sb)) { in_file = INFILE_NAME; if (0 != stat(in_file, &sb)) { perror("could not open " INFILE_NAME); exit(1); } } #endif 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"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) { dbuse(dbproc, DATABASE); } dbloginfree(login); printf("After logon\n"); printf("Creating table '%s'\n", TABLE_NAME); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } /* 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 != 2) 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 != 2) failure("bcp_exec failed\n"); printf("%d rows copied out\n", rows_copied); dbclose(dbproc); dbexit(); /* check input and output should be the same */ input_file = fopen(in_file, "r"); output_file = fopen(out_file, "r"); if (!failed && input_file != NULL && output_file != NULL) { char line1[128]; char line2[128]; char *p1, *p2; int line = 1; for (;; ++line) { p1 = fgets(line1, sizeof(line1), input_file); p2 = fgets(line2, sizeof(line2), output_file); /* EOF or error of one */ if (!!p1 != !!p2) { failure("error reading a file or EOF of a file\n"); break; } /* EOF or error of both */ if (!p1) { if (feof(input_file) && feof(output_file)) break; failure("error reading a file\n"); break; } if (strcmp(line1, line2) != 0) { failure("File different at line %d\n" " input: %s" " output: %s", line, line1, line2); } } if (!failed) printf("Input and output files are equal\n"); } else { if (!failed) failure("error opening files\n"); } if (input_file) fclose(input_file); if (output_file) fclose(output_file); printf("dblib %s on %s\n", (failed ? "failed!" : "okay"), __FILE__); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0017.c100664 001750 000144 00000011475 11152006120 0013417/* * 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-0.91/src/dblib/unittests/t0018.c100664 001750 000144 00000010226 11152006120 0013411/* * Purpose: Test behaviour of DBCOUNT() for updates and inserts * Functions: DBCOUNT dbbind dbnextrow dbnumcols dbopen dbresults dbsqlexec */ #include "common.h" static char software_version[] = "$Id: t0018.c,v 1.21 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) { 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0018"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); 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); add_bread_crumb(); fprintf(stdout, "Checking for an empty result set.\n"); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); failed = 1; fprintf(stdout, "Was expecting a result set.\n"); exit(1); } add_bread_crumb(); if(DBROWS(dbproc) != FAIL) { add_bread_crumb(); failed = 1; fprintf(stdout, "Was expecting no rows to be available.\n"); exit(1); } add_bread_crumb(); fprintf(stdout, "Checking for a result set with content.\n"); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } add_bread_crumb(); add_bread_crumb(); for (i = 0; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); add_bread_crumb(); if (REG_ROW != dbnextrow(dbproc)) { failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } add_bread_crumb(); 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); } add_bread_crumb(); 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); add_bread_crumb(); 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)); } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0019.c100664 001750 000144 00000006340 10552754515 0013441/* * Purpose: Test Some conversion, check trimming error and results * Functions: dbconvert dberrhandle dbmsghandle dbinit dbexit */ #include "common.h" #include static char software_version[] = "$Id: t0019.c,v 1.13 2007/01/15 19:43:09 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 || len == FAIL) { 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"); dbexit(); if (!failure) printf("All tests passed!\n"); return failure; } freetds-0.91/src/dblib/unittests/t0020.c100664 001750 000144 00000004565 11152006120 0013413/* * Purpose: Test for proper return code from dbsqlexec() * Functions: db_name dbcmd dberrhandle dbmsghandle dbnextrow dbopen dbresults dbsqlexec */ #include "common.h" static char software_version[] = "$Id: t0020.c,v 1.18 2009/02/27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0020"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); 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); } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0021.c100664 001750 000144 00000003173 11160442215 0013416/* * 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-0.91/src/dblib/unittests/t0022.c100664 001750 000144 00000014277 11244772137 0013442/* * Purpose: Test retrieving output parameters and return status * Functions: DBTDS dbnumrets dbresults dbretdata dbretlen dbretname dbrettype dbsqlexec */ #include "common.h" #include static char software_version[] = "$Id: t0022.c,v 1.29 2009/08/25 14:25:35 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]); add_bread_crumb(); dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0022"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); fprintf(stdout, "Dropping proc\n"); add_bread_crumb(); sql_cmd(dbproc); add_bread_crumb(); dbsqlexec(dbproc); add_bread_crumb(); 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); add_bread_crumb(); fprintf(stdout, "creating proc\n"); sql_cmd(dbproc); if (dbsqlexec(dbproc) == FAIL) { add_bread_crumb(); 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); add_bread_crumb(); while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { if (erc == FAIL) { add_bread_crumb(); 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); } add_bread_crumb(); #if defined(DBTDS_7_0) && defined(DBTDS_7_1) && defined(DBTDS_7_2) if ((dbnumrets(dbproc) == 0) && ((DBTDS(dbproc) == DBTDS_7_0) || (DBTDS(dbproc) == DBTDS_7_1) || (DBTDS(dbproc) == DBTDS_7_2))) { 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(); free_bread_crumb(); exit(0); } #endif for (i = 1; i <= dbnumrets(dbproc); i++) { add_bread_crumb(); 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); add_bread_crumb(); } 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"); add_bread_crumb(); sql_cmd(dbproc); add_bread_crumb(); dbsqlexec(dbproc); add_bread_crumb(); 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 */ add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0023.c100664 001750 000144 00000011233 11152006120 0013404/* * Purpose: Test retrieving compute rows * Functions: dbaltbind dbaltcolid dbaltop dbalttype dbnumalts */ #include "common.h" #include static char software_version[] = "$Id: t0023.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; 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0023"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); 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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); failed = 1; fprintf(stdout, "Was expecting a result set.\n"); exit(1); } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); 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(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) rowchar)) { failed = 1; fprintf(stderr, "Had problem with bind col2\n"); abort(); } add_bread_crumb(); if (SUCCEED != dbbind(dbproc, 3, STRINGBIND, 0, (BYTE *) rowdate)) { failed = 1; fprintf(stderr, "Had problem with bind col3\n"); abort(); } add_bread_crumb(); 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(); } add_bread_crumb(); 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(); } add_bread_crumb(); 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); } } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/text_buffer.c100664 001750 000144 00000006773 11152006120 0015166/* * Purpose: Test to see if row buffering and blobs works correctly. * Functions: dbbind dbnextrow dbopen dbresults dbsqlexec dbgetrow */ #include "common.h" static char software_version[] = "$Id: text_buffer.c,v 1.6 2009/02/27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]); add_bread_crumb(); /* Fortify_EnterScope(); */ dbinit(); add_bread_crumb(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "text_buffer"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); add_bread_crumb(); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "100"); #else dbsetopt(dbproc, DBBUFFER, "100", 0); #endif add_bread_crumb(); 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); add_bread_crumb(); if (dbresults(dbproc) != SUCCEED) { add_bread_crumb(); fprintf(stdout, "Was expecting a result set."); return 1; } add_bread_crumb(); for (i = 1; i <= dbnumcols(dbproc); i++) { add_bread_crumb(); printf("col %d is %s\n", i, dbcolname(dbproc, i)); add_bread_crumb(); } add_bread_crumb(); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); add_bread_crumb(); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); add_bread_crumb(); add_bread_crumb(); 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; } add_bread_crumb(); dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (0 ? "failed!" : "OK")); free_bread_crumb(); return 0; } freetds-0.91/src/dblib/unittests/thread.c100664 001750 000144 00000011560 11113101425 0014107/* * Purpose: Test dblib thread safety */ #include "common.h" #ifdef TDS_HAVE_PTHREAD_MUTEX #include #include static char software_version[] = "$Id: thread.c,v 1.13 2008/11/25 22:58:29 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static pthread_mutex_t mutex = PTHREAD_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) { pthread_mutex_lock(&mutex); result = 1; pthread_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 void * thread_test(void * 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); pthread_mutex_lock(&mutex); ++thread_count; pthread_mutex_unlock(&mutex); printf("thread %2d waiting for all threads to start\n", num+1); pthread_mutex_lock(&mutex); while (thread_count < NUM_THREAD) { pthread_mutex_unlock(&mutex); sleep(1); pthread_mutex_lock(&mutex); } pthread_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; pthread_t 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 = pthread_create(&th[i], NULL, 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 */ sleep(1); } for (i = 0; i < NUM_THREAD; ++i) { pthread_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-0.91/src/dblib/unittests/timeout.c100664 001750 000144 00000014224 11172370015 0014336/* * Purpose: Test handling of timeouts with an error handler * Functions: dberrhandle, dbsetlogintime, dbsettime * \todo We test returning INT_CANCEL for a login timeout. We don't test it for a query_timeout. */ #include "common.h" #include static char software_version[] = "$Id: timeout.c,v 1.8 2009/04/18 15:21:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int ntimeouts = 0, ncancels = 0; const int max_timeouts = 3, timeout_seconds = 3; int start_time; int timeout_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); int chkintr(DBPROCESS * dbproc); int hndlintr(DBPROCESS * dbproc); #if !defined(SYBETIME) #define SYBETIME SQLETIME #define INT_TIMEOUT INT_CANCEL dbsetinterrupt(DBPROCESS *dbproc, void* hand, void* p) {} #endif 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; } int chkintr(DBPROCESS * dbproc) { printf("in chkintr, %ld seconds elapsed\n", (long int) (time(NULL) - start_time)); return FALSE; } int hndlintr(DBPROCESS * dbproc) { printf("in hndlintr, %ld seconds elapsed\n", (long int) (time(NULL) - start_time)); return INT_CONTINUE; } int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; int i,r, failed = 0; RETCODE erc, row_code; int num_resultset = 0; char teststr[1024]; /* * Connect to server */ set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); add_bread_crumb(); dbinit(); add_bread_crumb(); dberrhandle(timeout_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); add_bread_crumb(); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "#t0022"); fprintf(stdout, "About to open %s.%s\n", SERVER, DATABASE); add_bread_crumb(); /* * 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); add_bread_crumb(); dbloginfree(login); add_bread_crumb(); /* send something that will take awhile to execute */ printf ("using %d %d-second query timeouts\n", max_timeouts, timeout_seconds); if (FAIL == dbsettime(timeout_seconds)) { fprintf(stderr, "Failed: dbsettime\n"); exit(1); } 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); 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); } add_bread_crumb(); /* retrieve outputs per usual */ r = 0; for (i=0; (erc = dbresults(dbproc)) != NO_MORE_RESULTS; i++) { int nrows, ncols, empty_resultset; switch (erc) { case SUCCEED: if (DBROWS(dbproc) == FAIL){ r++; continue; } assert(DBROWS(dbproc) == SUCCEED); printf("dbrows() returned SUCCEED, processing rows\n"); ncols = dbnumcols(dbproc); empty_resultset = 1; ++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) { empty_resultset = 0; 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"); } 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 */ dbexit(); add_bread_crumb(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_bread_crumb(); return failed ? 1 : 0; } freetds-0.91/src/dblib/unittests/t0016.in100664 001750 000144 00000000224 11623070341 00136011 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-0.91/src/dblib/unittests/t0017.in100664 001750 000144 00000000116 07534065362 0013617"3DEprova di testo questo testo dovrebbe andare a finire in un campo textfreetds-0.91/src/dblib/unittests/t0017.in.be100664 001750 000144 00000000116 10473535723 0014203D3"Eprova di testo questo testo dovrebbe andare a finire in un campo textfreetds-0.91/src/dblib/unittests/data.bin100664 001750 000144 00000164644 07534060062 0014130ELFdÕ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-0.91/src/dblib/unittests/dblib.dsw100664 001750 000144 00000015240 11623073525 0014305Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "t0001"=.\vc6\t0001.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0002"=.\vc6\t0002.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0003"=.\vc6\t0003.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0004"=.\vc6\t0004.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0005"=.\vc6\t0005.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0006"=.\vc6\t0006.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0007"=.\vc6\t0007.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0008"=.\vc6\t0008.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0009"=.\vc6\t0009.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0011"=.\vc6\t0011.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0012"=.\vc6\t0012.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0013"=.\vc6\t0013.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0014"=.\vc6\t0014.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0015"=.\vc6\t0015.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0016"=.\vc6\t0016.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0017"=.\vc6\t0017.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0018"=.\vc6\t0018.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0019"=.\vc6\t0019.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0020"=.\vc6\t0020.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0021"=.\vc6\t0021.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0022"=.\vc6\t0022.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0023"=.\vc6\t0023.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "rpc"=.\vc6\rpc.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "dbmorecmds"=.\vc6\dbmorecmds.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "bcp"=.\vc6\bcp.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "thread"=.\vc6\thread.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "text_buffer"=.\vc6\text_buffer.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "done_handling"=.\vc6\done_handling.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "timeout"=.\vc6\timeout.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "hang"=.\vc6\hang.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "null"=.\vc6\null.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "null2"=.\vc6\null2.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "setnull"=.\vc6\setnull.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "numeric"=.\vc6\numeric.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### freetds-0.91/src/dblib/unittests/dblib.mak100664 001750 000144 00000022706 11623073525 0014265!IF "$(OS)" == "Windows_NT" NULL= !ELSE NULL=nul !ENDIF OUTDIR=.\Release INTDIR=.\Release ALL : \ "$(OUTDIR)\t0001.exe" \ "$(OUTDIR)\t0002.exe" \ "$(OUTDIR)\t0003.exe" \ "$(OUTDIR)\t0004.exe" \ "$(OUTDIR)\t0005.exe" \ "$(OUTDIR)\t0006.exe" \ "$(OUTDIR)\t0007.exe" \ "$(OUTDIR)\t0008.exe" \ "$(OUTDIR)\t0009.exe" \ "$(OUTDIR)\t0011.exe" \ "$(OUTDIR)\t0012.exe" \ "$(OUTDIR)\t0013.exe" \ "$(OUTDIR)\t0014.exe" \ "$(OUTDIR)\t0015.exe" \ "$(OUTDIR)\t0016.exe" \ "$(OUTDIR)\t0017.exe" \ "$(OUTDIR)\t0018.exe" \ "$(OUTDIR)\t0019.exe" \ "$(OUTDIR)\t0020.exe" \ "$(OUTDIR)\t0021.exe" \ "$(OUTDIR)\t0022.exe" \ "$(OUTDIR)\t0023.exe" \ "$(OUTDIR)\rpc.exe" \ "$(OUTDIR)\dbmorecmds.exe" \ "$(OUTDIR)\bcp.exe" \ "$(OUTDIR)\thread.exe" \ "$(OUTDIR)\text_buffer.exe" \ "$(OUTDIR)\done_handling.exe" \ "$(OUTDIR)\timeout.exe" \ "$(OUTDIR)\hang.exe" \ "$(OUTDIR)\null.exe" \ "$(OUTDIR)\null2.exe" \ "$(OUTDIR)\setnull.exe" \ "$(OUTDIR)\numeric.exe" CLEAN : -@erase "$(INTDIR)*.obj" -@erase "$(OUTDIR)*.exe" "$(OUTDIR)" : if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" CPP=cl.exe CPP_PROJ=/nologo /MD /W3 /O2 /Ob2 /I "./" /D WIN32 /D NDEBUG /D _CONSOLE /D _MBCS /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c .c{$(INTDIR)}.obj:: $(CPP) $(CPP_PROJ) $< LINK32=link.exe LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib advapi32.lib ws2_32.lib odbc32.lib ntwdblib.lib /nologo /subsystem:console /incremental:no /machine:I386 "$(OUTDIR)\t0001.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0001.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0001.obj" /pdb:"$(OUTDIR)\t0001.pdb" /out:"$(OUTDIR)\t0001.exe" "$(OUTDIR)\t0002.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0002.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0002.obj" /pdb:"$(OUTDIR)\t0002.pdb" /out:"$(OUTDIR)\t0002.exe" "$(OUTDIR)\t0003.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0003.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0003.obj" /pdb:"$(OUTDIR)\t0003.pdb" /out:"$(OUTDIR)\t0003.exe" "$(OUTDIR)\t0004.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0004.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0004.obj" /pdb:"$(OUTDIR)\t0004.pdb" /out:"$(OUTDIR)\t0004.exe" "$(OUTDIR)\t0005.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0005.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0005.obj" /pdb:"$(OUTDIR)\t0005.pdb" /out:"$(OUTDIR)\t0005.exe" "$(OUTDIR)\t0006.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0006.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0006.obj" /pdb:"$(OUTDIR)\t0006.pdb" /out:"$(OUTDIR)\t0006.exe" "$(OUTDIR)\t0007.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0007.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0007.obj" /pdb:"$(OUTDIR)\t0007.pdb" /out:"$(OUTDIR)\t0007.exe" "$(OUTDIR)\t0008.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0008.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0008.obj" /pdb:"$(OUTDIR)\t0008.pdb" /out:"$(OUTDIR)\t0008.exe" "$(OUTDIR)\t0009.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0009.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0009.obj" /pdb:"$(OUTDIR)\t0009.pdb" /out:"$(OUTDIR)\t0009.exe" "$(OUTDIR)\t0011.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0011.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0011.obj" /pdb:"$(OUTDIR)\t0011.pdb" /out:"$(OUTDIR)\t0011.exe" "$(OUTDIR)\t0012.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0012.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0012.obj" /pdb:"$(OUTDIR)\t0012.pdb" /out:"$(OUTDIR)\t0012.exe" "$(OUTDIR)\t0013.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0013.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0013.obj" /pdb:"$(OUTDIR)\t0013.pdb" /out:"$(OUTDIR)\t0013.exe" "$(OUTDIR)\t0014.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0014.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0014.obj" /pdb:"$(OUTDIR)\t0014.pdb" /out:"$(OUTDIR)\t0014.exe" "$(OUTDIR)\t0015.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0015.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0015.obj" /pdb:"$(OUTDIR)\t0015.pdb" /out:"$(OUTDIR)\t0015.exe" "$(OUTDIR)\t0016.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0016.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0016.obj" /pdb:"$(OUTDIR)\t0016.pdb" /out:"$(OUTDIR)\t0016.exe" "$(OUTDIR)\t0017.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0017.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0017.obj" /pdb:"$(OUTDIR)\t0017.pdb" /out:"$(OUTDIR)\t0017.exe" "$(OUTDIR)\t0018.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0018.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0018.obj" /pdb:"$(OUTDIR)\t0018.pdb" /out:"$(OUTDIR)\t0018.exe" "$(OUTDIR)\t0019.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0019.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0019.obj" /pdb:"$(OUTDIR)\t0019.pdb" /out:"$(OUTDIR)\t0019.exe" "$(OUTDIR)\t0020.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0020.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0020.obj" /pdb:"$(OUTDIR)\t0020.pdb" /out:"$(OUTDIR)\t0020.exe" "$(OUTDIR)\t0021.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0021.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0021.obj" /pdb:"$(OUTDIR)\t0021.pdb" /out:"$(OUTDIR)\t0021.exe" "$(OUTDIR)\t0022.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0022.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0022.obj" /pdb:"$(OUTDIR)\t0022.pdb" /out:"$(OUTDIR)\t0022.exe" "$(OUTDIR)\t0023.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0023.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0023.obj" /pdb:"$(OUTDIR)\t0023.pdb" /out:"$(OUTDIR)\t0023.exe" "$(OUTDIR)\rpc.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\rpc.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\rpc.obj" /pdb:"$(OUTDIR)\rpc.pdb" /out:"$(OUTDIR)\rpc.exe" "$(OUTDIR)\dbmorecmds.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\dbmorecmds.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\dbmorecmds.obj" /pdb:"$(OUTDIR)\dbmorecmds.pdb" /out:"$(OUTDIR)\dbmorecmds.exe" "$(OUTDIR)\bcp.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\bcp.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\bcp.obj" /pdb:"$(OUTDIR)\bcp.pdb" /out:"$(OUTDIR)\bcp.exe" "$(OUTDIR)\thread.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\thread.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\thread.obj" /pdb:"$(OUTDIR)\thread.pdb" /out:"$(OUTDIR)\thread.exe" "$(OUTDIR)\text_buffer.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\text_buffer.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\text_buffer.obj" /pdb:"$(OUTDIR)\text_buffer.pdb" /out:"$(OUTDIR)\text_buffer.exe" "$(OUTDIR)\done_handling.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\done_handling.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\done_handling.obj" /pdb:"$(OUTDIR)\done_handling.pdb" /out:"$(OUTDIR)\done_handling.exe" "$(OUTDIR)\timeout.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\timeout.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\timeout.obj" /pdb:"$(OUTDIR)\timeout.pdb" /out:"$(OUTDIR)\timeout.exe" "$(OUTDIR)\hang.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\hang.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\hang.obj" /pdb:"$(OUTDIR)\hang.pdb" /out:"$(OUTDIR)\hang.exe" "$(OUTDIR)\null.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\null.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\null.obj" /pdb:"$(OUTDIR)\null.pdb" /out:"$(OUTDIR)\null.exe" "$(OUTDIR)\null2.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\null2.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\null2.obj" /pdb:"$(OUTDIR)\null2.pdb" /out:"$(OUTDIR)\null2.exe" "$(OUTDIR)\setnull.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\setnull.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\setnull.obj" /pdb:"$(OUTDIR)\setnull.pdb" /out:"$(OUTDIR)\setnull.exe" "$(OUTDIR)\numeric.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\numeric.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\numeric.obj" /pdb:"$(OUTDIR)\numeric.pdb" /out:"$(OUTDIR)\numeric.exe" CHECK : "$(OUTDIR)\t0001.exe" "$(OUTDIR)\t0002.exe" "$(OUTDIR)\t0003.exe" "$(OUTDIR)\t0004.exe" "$(OUTDIR)\t0005.exe" "$(OUTDIR)\t0006.exe" "$(OUTDIR)\t0007.exe" "$(OUTDIR)\t0008.exe" "$(OUTDIR)\t0009.exe" "$(OUTDIR)\t0011.exe" "$(OUTDIR)\t0012.exe" "$(OUTDIR)\t0013.exe" "$(OUTDIR)\t0014.exe" "$(OUTDIR)\t0015.exe" "$(OUTDIR)\t0016.exe" "$(OUTDIR)\t0017.exe" "$(OUTDIR)\t0018.exe" "$(OUTDIR)\t0019.exe" "$(OUTDIR)\t0020.exe" "$(OUTDIR)\t0021.exe" "$(OUTDIR)\t0022.exe" "$(OUTDIR)\t0023.exe" "$(OUTDIR)\rpc.exe" "$(OUTDIR)\dbmorecmds.exe" "$(OUTDIR)\bcp.exe" "$(OUTDIR)\thread.exe" "$(OUTDIR)\text_buffer.exe" "$(OUTDIR)\done_handling.exe" "$(OUTDIR)\timeout.exe" "$(OUTDIR)\hang.exe" "$(OUTDIR)\null.exe" "$(OUTDIR)\null2.exe" "$(OUTDIR)\setnull.exe" "$(OUTDIR)\numeric.exe" freetds-0.91/src/dblib/unittests/bcp.sql100664 001750 000144 00000007476 11141421123 0013775if 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 ) 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-0.91/src/dblib/unittests/dbmorecmds.sql100664 001750 000144 00000001243 11141421123 0015332create 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 compute count(name) go freetds-0.91/src/dblib/unittests/done_handling.sql100664 001750 000144 00000001413 11141421123 0016003create 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-0.91/src/dblib/unittests/rpc.sql100664 001750 000144 00000004452 11422517551 0014021CREATE PROCEDURE #t0022 @null_input varchar(30) OUTPUT , @first_type varchar(30) OUTPUT , @nullout int OUTPUT , @nrows int OUTPUT , @c 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 is not NULL begin select 'error: should be NULL' as status, @c as '@c' return -42 end else begin print 'Good: @c 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 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 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 '@null_input is NULL, as expected' end if @c is not NULL begin select 'error: should be NULL' as status, @c as '@c' return -42 end else begin print 'Good: @c 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 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-0.91/src/dblib/unittests/t0002.sql100664 001750 000144 00000005212 11141421123 0013760if 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-0.91/src/dblib/unittests/t0003.sql100664 001750 000144 00000004700 11141421123 0013762create 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-0.91/src/dblib/unittests/t0004.sql100664 001750 000144 00000005313 11141421123 0013764create 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-0.91/src/dblib/unittests/t0005.sql100664 001750 000144 00000005766 11141421123 0014001create 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-0.91/src/dblib/unittests/t0006.sql100664 001750 000144 00000005057 11141421123 0013773create 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-0.91/src/dblib/unittests/t0007.sql100664 001750 000144 00000001437 11507152520 0014002create 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-0.91/src/dblib/unittests/t0009.sql100664 001750 000144 00000000303 11141421123 0013763create 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-0.91/src/dblib/unittests/t0011.sql100664 001750 000144 00000001102 11141421123 0013752drop 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-0.91/src/dblib/unittests/t0012.sql100664 001750 000144 00000000317 11141421123 0013762create 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 freetds-0.91/src/dblib/unittests/t0013.sql100664 001750 000144 00000000665 11201754566 0014012if 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-0.91/src/dblib/unittests/t0014.sql100664 001750 000144 00000000676 11141421123 0013774if 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-0.91/src/dblib/unittests/t0015.sql100664 001750 000144 00000005044 11141421123 0013767create 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-0.91/src/dblib/unittests/t0016.sql100644 001750 000144 00000000337 11623070341 0013775create 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 freetds-0.91/src/dblib/unittests/t0017.sql100664 001750 000144 00000000726 11141421123 0013773create 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-0.91/src/dblib/unittests/t0018.sql100664 001750 000144 00000005066 11141421123 0013776create 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-0.91/src/dblib/unittests/t0020.sql100664 001750 000144 00000000144 11141421123 0013757/* request an invalid column from a non-existent table */ select dsjfkl dsjf go select db_name() go freetds-0.91/src/dblib/unittests/t0022.sql100664 001750 000144 00000000531 11141421123 0013761if 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-0.91/src/dblib/unittests/t0023.sql100664 001750 000144 00000001030 11141421123 0013755create 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-0.91/src/dblib/unittests/text_buffer.sql100664 001750 000144 00000000246 11141421123 0015532create 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-0.91/src/dblib/unittests/timeout.sql100664 001750 000144 00000000133 11141421123 0014676select getdate() as 'begintime' waitfor delay '00:00:30' select getdate() as 'endtime' go freetds-0.91/src/dblib/unittests/numeric.sql100664 001750 000144 00000000337 11247132563 0014676IF OBJECT_ID('testDecimal') IS NOT NULL DROP PROC testDecimal go CREATE PROCEDURE testDecimal @idecimal NUMERIC(20,10) AS BEGIN SELECT @idecimal*2 END go IF OBJECT_ID('testDecimal') IS NOT NULL DROP PROC testDecimal go freetds-0.91/src/odbc/Makefile.am100664 001750 000144 00000002520 11424513320 0012323# $Id: Makefile.am,v 1.50 2010/07/30 09:09:36 freddy77 Exp $ SUBDIRS = unittests AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) lib_LTLIBRARIES = libtdsodbc.la ##EXTRA_LTLIBRARIES = libtdsodbc.la if MINGW32 MINGW_SOURCES = ../../win32/winlogin.c ../../win32/winsetup.c ../../win32/initnet.c else MINGW_SOURCES = endif libtdsodbc_la_SOURCES= odbc.c connectparams.c convert_tds2sql.c \ descriptor.c prepare_query.c odbc_util.c \ native.c sql2tds.c error.c odbc_checks.c sqlwchar.c sqlwparams.h $(MINGW_SOURCES) if MINGW32 libtdsodbc_la_LIBADD= ../../win32/setup.res ../tds/libtds.la ../replacements/libreplacements.la $(ODBCINSTLIB) \ $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) libtdsodbc_la_LDFLAGS = -Wl,--kill-at -Wl,--enable-stdcall-fixup -Wl,-s -Wl,$(top_srcdir)/win32/FreeTDS.def -Wl,../../win32/setup.res $(FREETDS_SYMBOLIC) .rc.res: $(RC) -i $< -I $(top_builddir)/win32 --input-format=rc -o $@ -O coff else libtdsodbc_la_LIBADD= ../tds/libtds.la ../replacements/libreplacements.la $(ODBCINSTLIB) $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) if MACOSX SYMBOLS = else SYMBOLS = -export-symbols-regex '^(SQL|ODBCINST).*' endif # -module is needed by Darwin (Mac OS X) libtdsodbc_la_LDFLAGS = $(SYMBOLS) $(FREETDS_SYMBOLIC) $(FREETDS_ODBC_MODULE) endif ## Need blank statement to avoid compiling odbc.c odbc: $(EXTRA_LTLIBRARIES) @echo '' freetds-0.91/src/odbc/Makefile.in100664 001750 000144 00000072525 11623070617 0012360# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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/odbc DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = @MINGW32_FALSE@libtdsodbc_la_DEPENDENCIES = ../tds/libtds.la \ @MINGW32_FALSE@ ../replacements/libreplacements.la \ @MINGW32_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @MINGW32_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) @MINGW32_TRUE@libtdsodbc_la_DEPENDENCIES = ../../win32/setup.res \ @MINGW32_TRUE@ ../tds/libtds.la \ @MINGW32_TRUE@ ../replacements/libreplacements.la \ @MINGW32_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @MINGW32_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__libtdsodbc_la_SOURCES_DIST = odbc.c connectparams.c \ convert_tds2sql.c descriptor.c prepare_query.c odbc_util.c \ native.c sql2tds.c error.c odbc_checks.c sqlwchar.c \ sqlwparams.h ../../win32/winlogin.c ../../win32/winsetup.c \ ../../win32/initnet.c @MINGW32_TRUE@am__objects_1 = winlogin.lo winsetup.lo initnet.lo am_libtdsodbc_la_OBJECTS = odbc.lo connectparams.lo convert_tds2sql.lo \ descriptor.lo prepare_query.lo odbc_util.lo native.lo \ sql2tds.lo error.lo odbc_checks.lo sqlwchar.lo \ $(am__objects_1) libtdsodbc_la_OBJECTS = $(am_libtdsodbc_la_OBJECTS) libtdsodbc_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libtdsodbc_la_LDFLAGS) $(LDFLAGS) -o $@ 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtdsodbc_la_SOURCES) DIST_SOURCES = $(am__libtdsodbc_la_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-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 uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) 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@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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.50 2010/07/30 09:09:36 freddy77 Exp $ SUBDIRS = unittests AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) lib_LTLIBRARIES = libtdsodbc.la @MINGW32_FALSE@MINGW_SOURCES = @MINGW32_TRUE@MINGW_SOURCES = ../../win32/winlogin.c ../../win32/winsetup.c ../../win32/initnet.c libtdsodbc_la_SOURCES = odbc.c connectparams.c convert_tds2sql.c \ descriptor.c prepare_query.c odbc_util.c \ native.c sql2tds.c error.c odbc_checks.c sqlwchar.c sqlwparams.h $(MINGW_SOURCES) @MINGW32_FALSE@libtdsodbc_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(ODBCINSTLIB) $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) @MINGW32_TRUE@libtdsodbc_la_LIBADD = ../../win32/setup.res ../tds/libtds.la ../replacements/libreplacements.la $(ODBCINSTLIB) \ @MINGW32_TRUE@ $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) # -module is needed by Darwin (Mac OS X) @MINGW32_FALSE@libtdsodbc_la_LDFLAGS = $(SYMBOLS) $(FREETDS_SYMBOLIC) $(FREETDS_ODBC_MODULE) @MINGW32_TRUE@libtdsodbc_la_LDFLAGS = -Wl,--kill-at -Wl,--enable-stdcall-fixup -Wl,-s -Wl,$(top_srcdir)/win32/FreeTDS.def -Wl,../../win32/setup.res $(FREETDS_SYMBOLIC) @MACOSX_FALSE@@MINGW32_FALSE@SYMBOLS = -export-symbols-regex '^(SQL|ODBCINST).*' @MACOSX_TRUE@@MINGW32_FALSE@SYMBOLS = all: 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 .PRECIOUS: 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) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @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 " $(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)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtdsodbc.la: $(libtdsodbc_la_OBJECTS) $(libtdsodbc_la_DEPENDENCIES) $(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)/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)/initnet.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_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)/winsetup.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< winlogin.lo: ../../win32/winlogin.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT winlogin.lo -MD -MP -MF $(DEPDIR)/winlogin.Tpo -c -o winlogin.lo `test -f '../../win32/winlogin.c' || echo '$(srcdir)/'`../../win32/winlogin.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/winlogin.Tpo $(DEPDIR)/winlogin.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../win32/winlogin.c' object='winlogin.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o winlogin.lo `test -f '../../win32/winlogin.c' || echo '$(srcdir)/'`../../win32/winlogin.c winsetup.lo: ../../win32/winsetup.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT winsetup.lo -MD -MP -MF $(DEPDIR)/winsetup.Tpo -c -o winsetup.lo `test -f '../../win32/winsetup.c' || echo '$(srcdir)/'`../../win32/winsetup.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/winsetup.Tpo $(DEPDIR)/winsetup.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../win32/winsetup.c' object='winsetup.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o winsetup.lo `test -f '../../win32/winsetup.c' || echo '$(srcdir)/'`../../win32/winsetup.c initnet.lo: ../../win32/initnet.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT initnet.lo -MD -MP -MF $(DEPDIR)/initnet.Tpo -c -o initnet.lo `test -f '../../win32/initnet.c' || echo '$(srcdir)/'`../../win32/initnet.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/initnet.Tpo $(DEPDIR)/initnet.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../win32/initnet.c' object='initnet.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o initnet.lo `test -f '../../win32/initnet.c' || echo '$(srcdir)/'`../../win32/initnet.c 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. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; 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" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) 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; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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 \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \ 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-recursive uninstall uninstall-am \ uninstall-libLTLIBRARIES @MINGW32_TRUE@.rc.res: @MINGW32_TRUE@ $(RC) -i $< -I $(top_builddir)/win32 --input-format=rc -o $@ -O coff odbc: $(EXTRA_LTLIBRARIES) @echo '' # 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-0.91/src/odbc/odbc.c100644 001750 000144 00000640403 11557650317 0011367/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001 Brian Bruns * Copyright (C) 2002-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. */ /* * PROGRAMMER NAME CONTACT *============================================================== * BSB Brian Bruns camber@ais.org * PAH Peter Harvey pharvey@codebydesign.com * SMURPH Steve Murphree smurph@smcomp.com * *************************************************************** * DATE PROGRAMMER CHANGE *============================================================== * Original. * 03.FEB.02 PAH Started adding use of SQLGetPrivateProfileString(). * 04.FEB.02 PAH Fixed small error preventing SQLBindParameter from being called */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "tdsodbc.h" #include "tdsiconv.h" #include "tdsstring.h" #include "tdsconvert.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: odbc.c,v 1.556.2.2 2011/04/28 14:50:41 freddy77 Exp $"); 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); static SQLRETURN _SQLGetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength); 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); static int odbc_process_tokens(TDS_STMT * stmt, unsigned flag); static int odbc_lock_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 CHECK_HDBC if ( SQL_NULL_HDBC == hdbc || !IS_HDBC(hdbc) ) return SQL_INVALID_HANDLE; #define CHECK_HSTMT if ( SQL_NULL_HSTMT == hstmt || !IS_HSTMT(hstmt) ) return SQL_INVALID_HANDLE; #define CHECK_HENV if ( SQL_NULL_HENV == henv || !IS_HENV(henv) ) return SQL_INVALID_HANDLE; #define CHECK_HDESC if ( SQL_NULL_HDESC == hdesc || !IS_HDESC(hdesc) ) return SQL_INVALID_HANDLE; #define INIT_HSTMT \ TDS_STMT *stmt = (TDS_STMT*)hstmt; \ CHECK_HSTMT; \ CHECK_STMT_EXTRA(stmt); \ odbc_errs_reset(&stmt->errs); \ #define INIT_HDBC \ TDS_DBC *dbc = (TDS_DBC*)hdbc; \ CHECK_HDBC; \ CHECK_DBC_EXTRA(dbc); \ odbc_errs_reset(&dbc->errs); \ #define INIT_HENV \ TDS_ENV *env = (TDS_ENV*)henv; \ CHECK_HENV; \ CHECK_ENV_EXTRA(env); \ odbc_errs_reset(&env->errs); \ #define INIT_HDESC \ TDS_DESC *desc = (TDS_DESC*)hdesc; \ CHECK_HDESC; \ CHECK_DESC_EXTRA(desc); \ odbc_errs_reset(&desc->errs); \ #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 char * odbc_prret(SQLRETURN ret, char *unknown) { 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, sizeof(unknown), "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) 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->dbc->tds_socket != NULL && (resinfo = stmt->dbc->tds_socket->current_results) != NULL) { if (colpos <= resinfo->num_cols) { /* no overflow possible, name is always shorter */ strcpy(resinfo->columns[colpos - 1]->column_name, name); resinfo->columns[colpos - 1]->column_namelen = strlen(name); if (resinfo->columns[colpos - 1]->table_column_name) TDS_ZERO_FREE(resinfo->columns[colpos - 1]->table_column_name); } } #endif if (colpos > 0 && colpos <= stmt->ird->header.sql_desc_count) { --colpos; tds_dstr_copy(&stmt->ird->records[colpos].sql_desc_label, name); tds_dstr_copy(&stmt->ird->records[colpos].sql_desc_name, name); } } /* spinellia@acm.org : copied shamelessly from change_database */ static SQLRETURN change_autocommit(TDS_DBC * dbc, int state) { TDSSOCKET *tds = dbc->tds_socket; char query[80]; /* * We may not be connected yet and dbc->tds_socket * may not initialized. */ if (tds) { /* * mssql: SET IMPLICIT_TRANSACTION ON * sybase: SET CHAINED ON */ /* implicit transactions are on if autocommit is off :-| */ if (TDS_IS_MSSQL(tds)) sprintf(query, "SET IMPLICIT_TRANSACTIONS %s", (state == SQL_AUTOCOMMIT_ON) ? "OFF" : "ON"); else { /* Sybase, do not use SET CHAINED but emulate for compatility */ if (state == SQL_AUTOCOMMIT_ON) strcpy(query, "WHILE @@TRANCOUNT > 0 COMMIT"); else strcpy(query, "BEGIN TRANSACTION"); } tdsdump_log(TDS_DBG_INFO1, "change_autocommit: 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_submit_query(tds, query) != TDS_SUCCEED) { odbc_errs_add(&dbc->errs, "HY000", "Could not change transaction status"); ODBC_RETURN(dbc, SQL_ERROR); } if (tds_process_simple_query(tds) != TDS_SUCCEED) { odbc_errs_add(&dbc->errs, "HY000", "Could not change transaction status"); ODBC_RETURN(dbc, 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 = (char *) malloc(6 + tds_quote_id(tds, NULL, database, database_len)); if (!query) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, 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_submit_query(tds, query) != TDS_SUCCEED) { free(query); odbc_errs_add(&dbc->errs, "HY000", "Could not change database"); ODBC_RETURN(dbc, SQL_ERROR); } free(query); if (tds_process_simple_query(tds) != TDS_SUCCEED) { odbc_errs_add(&dbc->errs, "HY000", "Could not change database"); ODBC_RETURN(dbc, SQL_ERROR); } } else { tds_dstr_copyn(&dbc->attr.current_catalog, database, database_len); } 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); ODBC_RETURN(dbc, 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); ODBC_RETURN(dbc, SQL_ERROR); } tds->query_timeout = dbc->default_query_timeout; sprintf(query, "SET TRANSACTION ISOLATION LEVEL %s", level); if (tds_submit_query(tds, query) != TDS_SUCCEED) ODBC_RETURN(dbc, SQL_ERROR); if (tds_process_simple_query(tds) != TDS_SUCCEED) ODBC_RETURN(dbc, SQL_ERROR); return SQL_SUCCESS; } static void odbc_env_change(TDSSOCKET * tds, int type, char *oldval, char *newval) { TDS_DBC *dbc; if (tds == NULL) { return; } dbc = (TDS_DBC *) tds->parent; 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, TDSCONNECTION * connection) { 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) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } dbc->tds_socket->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_connection(connection); connection->connect_timeout = dbc->attr.connection_timeout; #ifdef ENABLE_ODBC_WIDE /* force utf-8 in order to support wide characters */ tds_dstr_dup(&dbc->original_charset, &connection->client_charset); tds_dstr_copy(&connection->client_charset, "UTF-8"); #endif if (tds_connect_and_login(dbc->tds_socket, connection) != TDS_SUCCEED) { tds_free_socket(dbc->tds_socket); dbc->tds_socket = NULL; odbc_errs_add(&dbc->errs, "08001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } #ifdef ENABLE_ODBC_WIDE dbc->mb_conv = tds_iconv_get(dbc->tds_socket, 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)) dbc->cursor_support = 1; if (dbc->attr.txn_isolation != SQL_TXN_READ_COMMITTED) if (change_txn(dbc, dbc->attr.txn_isolation) != SQL_SUCCESS) ODBC_RETURN_(dbc); if (dbc->attr.autocommit != SQL_AUTOCOMMIT_ON) if (!SQL_SUCCEEDED(change_autocommit(dbc, dbc->attr.autocommit))) ODBC_RETURN_(dbc); /* this overwrite any error arrived (wanted behavior, Sybase return error for conversion errors) */ ODBC_RETURN(dbc, SQL_SUCCESS); } 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)) { 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->dbc->tds_socket; int in_row = 0; if (tds_submit_prepare(tds, stmt->prepared_query, NULL, &stmt->dyn, stmt->params) == TDS_FAIL) ODBC_RETURN(stmt, 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_SUCCEED: 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->dbc->current_statement == stmt) stmt->dbc->current_statement = NULL; if (stmt->errs.lastrc == SQL_ERROR && !stmt->dyn->emulated) { TDSDYNAMIC *dyn = stmt->dyn; stmt->dyn = NULL; tds_free_dynamic(tds, dyn); } stmt->need_reprepare = 0; ODBC_RETURN_(stmt); } #define FUNC NAME(SQLDriverConnect) (P(SQLHDBC,hdbc), P(SQLHWND,hwnd), PCHARIN(ConnStrIn,SQLSMALLINT), \ PCHAROUT(ConnStrOut,SQLSMALLINT), P(SQLUSMALLINT,fDriverCompletion) WIDE) #include "sqlwparams.h" { TDSCONNECTION *connection; TDS_PARSED_PARAM params[ODBC_PARAM_SIZE]; DSTR conn_str; INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLDriverConnect(%p, %p, %s, %d, %p, %d, %p, %d)\n", hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion); #ifdef TDS_NO_DM /* Check string length */ if (!IS_VALID_LEN(cbConnStrIn) || cbConnStrIn == 0) { odbc_errs_add(&dbc->errs, "HY090", NULL); ODBC_RETURN(dbc, SQL_ERROR); } /* 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_RETURN(dbc, SQL_ERROR); } #endif tds_dstr_init(&conn_str); if (!odbc_dstr_copy(dbc, &conn_str, cbConnStrIn, szConnStrIn)) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } connection = tds_alloc_connection(dbc->env->tds_ctx->locale); if (!connection) { tds_dstr_free(&conn_str); odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } if (!tds_dstr_isempty(&dbc->attr.current_catalog)) tds_dstr_dup(&connection->database, &dbc->attr.current_catalog); /* 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), connection, params)) { tds_dstr_free(&conn_str); ODBC_RETURN(dbc, SQL_ERROR); } 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(&connection->server_name))) { #ifdef _WIN32 char *out = NULL; /* prompt for login information */ if (!get_login_info(hwnd, connection)) { tds_free_connection(connection); odbc_errs_add(&dbc->errs, "08001", "User canceled login"); ODBC_RETURN(dbc, SQL_ERROR); } if (tds_dstr_isempty(&connection->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(&connection->user_name); params[ODBC_PARAM_UID].len = tds_dstr_len(&connection->user_name); params[ODBC_PARAM_PWD].p = tds_dstr_cstr(&connection->password); params[ODBC_PARAM_PWD].len = tds_dstr_len(&connection->password); params[ODBC_PARAM_Trusted_Connection].p = NULL; } if (!odbc_build_connect_string(&dbc->errs, params, &out)) ODBC_RETURN(dbc, SQL_ERROR); 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(&connection->server_name)) { tds_free_connection(connection); odbc_errs_add(&dbc->errs, "IM007", "Could not find Servername or server parameter"); ODBC_RETURN(dbc, SQL_ERROR); } if (odbc_connect(dbc, connection) != SQL_SUCCESS) { tds_free_connection(connection); ODBC_RETURN_(dbc); } tds_free_connection(connection); ODBC_RETURN_(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); INIT_HDBC; odbc_errs_add(&dbc->errs, "HYC00", "SQLBrowseConnect: function not implemented"); ODBC_RETURN(dbc, SQL_ERROR); } #endif #define FUNC NAME(SQLColumnPrivileges) (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), \ PCHARIN(TableName,SQLSMALLINT), PCHARIN(ColumnName,SQLSMALLINT) WIDE) #include "sqlwparams.h" { int retcode; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLColumnPrivileges(%p, %p, %d, %p, %d, %p, %d, %p, %d)\n", hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName); 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_RETURN_(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); INIT_HSTMT; odbc_errs_add(&stmt->errs, "HYC00", "SQLDescribeParam: function not implemented"); ODBC_RETURN(stmt, SQL_ERROR); } #endif SQLRETURN 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; INIT_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_RETURN(stmt, SQL_ERROR); } /* 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_RETURN(stmt, ret); } #define FUNC NAME(SQLForeignKeys) (P(SQLHSTMT,hstmt), PCHARIN(PkCatalogName,SQLSMALLINT),\ PCHARIN(PkSchemaName,SQLSMALLINT), PCHARIN(PkTableName,SQLSMALLINT),\ PCHARIN(FkCatalogName,SQLSMALLINT), PCHARIN(FkSchemaName,SQLSMALLINT),\ PCHARIN(FkTableName,SQLSMALLINT) WIDE) #include "sqlwparams.h" { int retcode; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLForeignKeys(%p, %p, %d, %p, %d, %p, %d, %p, %d, %p, %d, %p, %d)\n", hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName, szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName, szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName); 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_RETURN_(stmt); } static int odbc_lock_statement(TDS_STMT* stmt) { TDSSOCKET *tds = stmt->dbc->tds_socket; /* FIXME quite bad... two thread can lock the same TDSSOCKET */ if (stmt->dbc->current_statement != NULL && stmt->dbc->current_statement != stmt) { if (!tds || tds->state != TDS_IDLE) { odbc_errs_add(&stmt->errs, "24000", NULL); return 0; } } if (tds) tds->query_timeout = (stmt->attr.query_timeout != DEFAULT_QUERY_TIMEOUT) ? stmt->attr.query_timeout : stmt->dbc->default_query_timeout; stmt->dbc->current_statement = stmt; stmt->cancel_sent = 0; return 1; } SQLRETURN ODBC_API SQLMoreResults(SQLHSTMT hstmt) { TDSSOCKET *tds; TDS_INT result_type; int tdsret; int in_row = 0; SQLUSMALLINT param_status; int token_flags; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLMoreResults(%p)\n", hstmt); tds = stmt->dbc->tds_socket; /* We already read all results... */ /* TODO cursor */ if (stmt->dbc->current_statement != stmt) ODBC_RETURN(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 (stmt->dbc->current_statement == stmt) stmt->dbc->current_statement = NULL; #if 1 /* !UNIXODBC */ tds_free_all_results(tds); #endif odbc_populate_ird(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_RETURN(stmt, SQL_NO_DATA); } ODBC_RETURN_(stmt); case TDS_CMD_FAIL: ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); 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_RETURN_(stmt); case NOT_IN_ROW: /* this should never happen, protocol error */ ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); 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_RETURN_(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); ODBC_RETURN(stmt, SQL_ERROR); case TDS_FAIL: ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); } 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_RETURN_(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_RETURN_(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_RETURN_(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_RETURN(stmt, SQL_ERROR); } #define FUNC NAME(SQLNativeSql) (P(SQLHDBC,hdbc), PCHARIN(SqlStrIn,SQLINTEGER),\ PCHAROUT(SqlStr,SQLINTEGER) WIDE) #include "sqlwparams.h" { SQLRETURN ret = SQL_SUCCESS; DSTR query; INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLNativeSql(%p, %s, %d, %p, %d, %p)\n", hdbc, szSqlStrIn, (int)cbSqlStrIn, szSqlStr, (int)cbSqlStrMax, pcbSqlStr); tds_dstr_init(&query); #ifdef TDS_NO_DM if (!szSqlStrIn || !IS_VALID_LEN(cbSqlStrIn)) { odbc_errs_add(&dbc->errs, "HY009", NULL); ODBC_RETURN(dbc, SQL_ERROR); } #endif if (!odbc_dstr_copy(dbc, &query, cbSqlStrIn, szSqlStrIn)) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } /* TODO support not null terminated in native_sql */ native_sql(dbc, tds_dstr_buf(&query)); ret = odbc_set_string(dbc, szSqlStr, cbSqlStrMax, pcbSqlStr, tds_dstr_cstr(&query), -1); tds_dstr_free(&query); ODBC_RETURN(dbc, ret); } SQLRETURN ODBC_API SQLNumParams(SQLHSTMT hstmt, SQLSMALLINT FAR * pcpar) { INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLNumParams(%p, %p)\n", hstmt, pcpar); *pcpar = stmt->param_count; ODBC_RETURN_(stmt); } SQLRETURN 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); if (res != SQL_SUCCESS) return res; return _SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) (TDS_INTPTR) crow, 0); } #define FUNC NAME(SQLPrimaryKeys) (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT),\ PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT) WIDE) #include "sqlwparams.h" { int retcode; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLPrimaryKeys(%p, %p, %d, %p, %d, %p, %d)\n", hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName); 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_RETURN_(stmt); } #define FUNC NAME(SQLProcedureColumns) (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT),\ PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(ProcName,SQLSMALLINT), PCHARIN(ColumnName,SQLSMALLINT) WIDE) #include "sqlwparams.h" { int retcode; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLProcedureColumns(%p, %p, %d, %p, %d, %p, %d, %p, %d)\n", hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szProcName, cbProcName, szColumnName, cbColumnName); 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_RETURN_(stmt); } #define FUNC NAME(SQLProcedures) (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT),\ PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(ProcName,SQLSMALLINT) WIDE) #include "sqlwparams.h" { int retcode; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLProcedures(%p, %p, %d, %p, %d, %p, %d)\n", hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szProcName, cbProcName); 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_RETURN_(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))) { tds_free_param_results(params); odbc_errs_add(&stmt->errs, "HY001", NULL); return NULL; } params = temp_params; curcol = params->columns[params->num_cols - 1]; tds_strlcpy(curcol->column_name, tds_dstr_cstr(&drec_ird->sql_desc_name), sizeof(curcol->column_name)); curcol->column_namelen = strlen(curcol->column_name); /* TODO use all infos... */ tds_strlcpy(curcol->table_name, tds_dstr_cstr(&drec_ird->sql_desc_base_table_name), sizeof(curcol->table_name)); curcol->table_namelen = strlen(curcol->table_name); switch (odbc_sql2tds(stmt, drec_ird, &stmt->ard->records[n], curcol, 1, stmt->ard, n_row)) { case SQL_NEED_DATA: odbc_errs_add(&stmt->errs, "HY001", NULL); case SQL_ERROR: tds_free_param_results(params); return NULL; } } return params; } SQLRETURN ODBC_API SQLSetPos(SQLHSTMT hstmt, SQLSETPOSIROW irow, SQLUSMALLINT fOption, SQLUSMALLINT fLock) { int ret; TDSSOCKET *tds; TDS_CURSOR_OPERATION op; TDSPARAMINFO *params = NULL; INIT_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_RETURN(stmt, SQL_ERROR); } /* TODO handle irow == 0 (all rows) */ if (!stmt->cursor) { odbc_errs_add(&stmt->errs, "HY109", NULL); ODBC_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); 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_RETURN(stmt, SQL_ERROR); } break; case SQL_DELETE: op = TDS_CURSOR_DELETE; break; case SQL_ADD: op = TDS_CURSOR_INSERT; break; } tds = stmt->dbc->tds_socket; if (!odbc_lock_statement(stmt)) { tds_free_param_results(params); ODBC_RETURN_(stmt); } if (tds_cursor_update(tds, stmt->cursor, op, irow, params) != TDS_SUCCEED) { tds_free_param_results(params); ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); } tds_free_param_results(params); params = NULL; ret = tds_process_simple_query(tds); stmt->dbc->current_statement = NULL; if (ret != TDS_SUCCEED) { ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); } ODBC_RETURN_(stmt); } #define FUNC NAME(SQLTablePrivileges) (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT),\ PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT) WIDE) #include "sqlwparams.h" { int retcode; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLTablePrivileges(%p, %p, %d, %p, %d, %p, %d)\n", hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName); 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_RETURN_(stmt); } #if (ODBCVER >= 0x0300) SQLRETURN ODBC_API SQLSetEnvAttr(SQLHENV henv, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER StringLength) { SQLINTEGER i_val = (SQLINTEGER) (TDS_INTPTR) Value; INIT_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); ODBC_RETURN(env, SQL_ERROR); break; case SQL_ATTR_ODBC_VERSION: switch (i_val) { case SQL_OV_ODBC3: case SQL_OV_ODBC2: break; default: odbc_errs_add(&env->errs, "HY024", NULL); ODBC_RETURN(env, SQL_ERROR); } env->attr.odbc_version = i_val; ODBC_RETURN_(env); break; case SQL_ATTR_OUTPUT_NTS: env->attr.output_nts = i_val; /* TODO - Make this really work */ env->attr.output_nts = SQL_TRUE; ODBC_RETURN_(env); break; } odbc_errs_add(&env->errs, "HY092", NULL); ODBC_RETURN(env, SQL_ERROR); } SQLRETURN ODBC_API SQLGetEnvAttr(SQLHENV henv, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { size_t size; void *src; INIT_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_RETURN(env, SQL_ERROR); break; } if (StringLength) { *StringLength = size; } memcpy(Value, src, size); ODBC_RETURN_(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; INIT_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_RETURN(stmt, SQL_ERROR); } /* Check max buffer length */ if (cbValueMax < 0) { odbc_errs_add(&stmt->errs, "HY090", NULL); ODBC_RETURN(stmt, SQL_ERROR); } #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_RETURN(stmt, SQL_ERROR); } if (ibScale < 0 || ibScale > cbColDef) { odbc_errs_add(&stmt->errs, "HY104", "Invalid scale value"); ODBC_RETURN(stmt, SQL_ERROR); } } /* Check parameter number */ if (ipar <= 0 || ipar > 4000) { odbc_errs_add(&stmt->errs, "07009", NULL); ODBC_RETURN(stmt, SQL_ERROR); } /* 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_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } if (is_numeric) { drec->sql_desc_precision = cbColDef; drec->sql_desc_scale = ibScale; } else { drec->sql_desc_length = cbColDef; } ODBC_RETURN_(stmt); } SQLRETURN 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_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_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; } /* TODO HY092 error */ return SQL_ERROR; } #endif static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc) { TDS_DBC *dbc; INIT_HENV; tdsdump_log(TDS_DBG_FUNC, "_SQLAllocConnect(%p, %p)\n", henv, phdbc); dbc = (TDS_DBC *) calloc(1, sizeof(TDS_DBC)); if (!dbc) { odbc_errs_add(&env->errs, "HY001", NULL); ODBC_RETURN(env, SQL_ERROR); } dbc->htype = SQL_HANDLE_DBC; dbc->env = env; tds_dstr_init(&dbc->server); 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 dbc->attr.translate_option = 0; dbc->attr.txn_isolation = SQL_TXN_READ_COMMITTED; *phdbc = (SQLHDBC) dbc; ODBC_RETURN_(env); } SQLRETURN 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_ENV *) calloc(1, sizeof(TDS_ENV)); 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"); *phenv = (SQLHENV) env; return SQL_SUCCESS; } SQLRETURN 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; INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLAllocDesc(%p, %p)\n", hdbc, phdesc); for (i = 0; i < TDS_MAX_APP_DESC; ++i) { 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); ODBC_RETURN(dbc, SQL_ERROR); } dbc->uad[i] = desc; *phdesc = (SQLHDESC) desc; ODBC_RETURN_(dbc); } } odbc_errs_add(&dbc->errs, "HY014", NULL); ODBC_RETURN(dbc, SQL_ERROR); } static SQLRETURN _SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT FAR * phstmt) { TDS_STMT *stmt; char *pstr; INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLAllocStmt(%p, %p)\n", hdbc, phstmt); stmt = (TDS_STMT *) calloc(1, sizeof(TDS_STMT)); if (!stmt) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } tds_dstr_init(&stmt->cursor_name); 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_RETURN(dbc, SQL_ERROR); } /* 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_RETURN(dbc, SQL_ERROR); } /* 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; 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; *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); ODBC_RETURN_(dbc); } SQLRETURN 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_API SQLBindCol(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgbValue, SQLLEN cbValueMax, SQLLEN FAR * pcbValue) { SQLRETURN rc = SQL_SUCCESS; TDS_DESC *ard; struct _drecord *drec; SQLSMALLINT orig_ard_size; INIT_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); rc = SQL_ERROR; } break; } #endif if (icol <= 0 || icol > 4000) { odbc_errs_add(&stmt->errs, "07009", NULL); rc = SQL_ERROR; } if (rc != SQL_SUCCESS) { ODBC_RETURN(stmt, rc); } 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_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } 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_RETURN_(stmt); } SQLRETURN 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 */ INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLCancel(%p)\n", hstmt); tds = stmt->dbc->tds_socket; if (!tds) { odbc_errs_add(&stmt->errs, "HY010", NULL); ODBC_RETURN(stmt, SQL_ERROR); } /* FIXME test current statement */ stmt->cancel_sent = 1; if (tds_send_cancel(tds) == TDS_FAIL) { ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); } if (tds_process_cancel(tds) == TDS_FAIL) { ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); } /* only if we processed cancel reset statement */ if (stmt->dbc->current_statement && stmt->dbc->current_statement == stmt && tds->state == TDS_IDLE) stmt->dbc->current_statement = NULL; ODBC_RETURN_(stmt); } #define FUNC NAME(SQLConnect) (P(SQLHDBC,hdbc), PCHARIN(DSN,SQLSMALLINT), PCHARIN(UID,SQLSMALLINT), \ PCHARIN(AuthStr,SQLSMALLINT) WIDE) #include "sqlwparams.h" { SQLRETURN result; TDSCONNECTION *connection; INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLConnect(%p, %p, %d, %p, %d, %p, %d)\n", hdbc, szDSN, cbDSN, szUID, cbUID, szAuthStr, cbAuthStr); #ifdef TDS_NO_DM if (szDSN && !IS_VALID_LEN(cbDSN)) { odbc_errs_add(&dbc->errs, "HY090", "Invalid DSN buffer length"); ODBC_RETURN(dbc, SQL_ERROR); } if (szUID && !IS_VALID_LEN(cbUID)) { odbc_errs_add(&dbc->errs, "HY090", "Invalid UID buffer length"); ODBC_RETURN(dbc, SQL_ERROR); } if (szAuthStr && !IS_VALID_LEN(cbAuthStr)) { odbc_errs_add(&dbc->errs, "HY090", "Invalid PWD buffer length"); ODBC_RETURN(dbc, SQL_ERROR); } #endif connection = tds_alloc_connection(dbc->env->tds_ctx->locale); if (!connection) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } /* data source name */ if (odbc_get_string_size(cbDSN, szDSN _wide)) odbc_dstr_copy(dbc, &dbc->dsn, cbDSN, szDSN); else tds_dstr_copy(&dbc->dsn, "DEFAULT"); if (!odbc_get_dsn_info(&dbc->errs, tds_dstr_cstr(&dbc->dsn), connection)) { tds_free_connection(connection); ODBC_RETURN(dbc, SQL_ERROR); } if (!tds_dstr_isempty(&dbc->attr.current_catalog)) tds_dstr_dup(&connection->database, &dbc->attr.current_catalog); /* * 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, &connection->user_name, cbUID, szUID)) { tds_free_connection(connection); odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } } /* password */ if (szAuthStr && !tds_dstr_isempty(&connection->user_name)) { if (!odbc_dstr_copy(dbc, &connection->password, cbAuthStr, szAuthStr)) { tds_free_connection(connection); odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } } /* DO IT */ if ((result = odbc_connect(dbc, connection)) != SQL_SUCCESS) { tds_free_connection(connection); ODBC_RETURN_(dbc); } tds_free_connection(connection); ODBC_RETURN_(dbc); } #define FUNC NAME(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) #include "sqlwparams.h" { TDS_DESC *ird; struct _drecord *drec; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLDescribeCol(%p, %d, %p, %d, %p, %p, %p, %p, %p)\n", hstmt, icol, szColName, cbColNameMax, pcbColName, pfSqlType, pcbColDef, pibScale, pfNullable); ird = stmt->ird; IRD_UPDATE(ird, &stmt->errs, ODBC_RETURN(stmt, SQL_ERROR)); if (icol <= 0 || icol > ird->header.sql_desc_count) { odbc_errs_add(&stmt->errs, "07009", "Column out of range"); ODBC_RETURN(stmt, SQL_ERROR); } /* check name length */ if (cbColNameMax < 0) { odbc_errs_add(&stmt->errs, "HY090", NULL); ODBC_RETURN(stmt, SQL_ERROR); } drec = &ird->records[icol - 1]; /* cbColNameMax can be 0 (to retrieve name length) */ if (szColName && cbColNameMax) { SQLRETURN result; /* 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 (result == SQL_SUCCESS_WITH_INFO) { odbc_errs_add(&stmt->errs, "01004", NULL); stmt->errs.lastrc = SQL_SUCCESS_WITH_INFO; } } 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) { if (drec->sql_desc_type == SQL_NUMERIC || drec->sql_desc_type == SQL_DECIMAL || drec->sql_desc_type == SQL_DATETIME || drec->sql_desc_type == SQL_FLOAT) { *pibScale = drec->sql_desc_scale; } else { /* TODO test setting desc directly, SQLDescribeCol return just descriptor data ?? */ *pibScale = 0; } } if (pfNullable) { *pfNullable = drec->sql_desc_nullable; } ODBC_RETURN_(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; INIT_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_RETURN(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_RETURN(stmt, SQL_SUCCESS); break; } if (!ird->header.sql_desc_count) { odbc_errs_add(&stmt->errs, "07005", NULL); ODBC_RETURN(stmt, SQL_ERROR); } if (icol <= 0 || icol > ird->header.sql_desc_count) { odbc_errs_add(&stmt->errs, "07009", "Column out of range"); ODBC_RETURN(stmt, SQL_ERROR); } 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_TIMESTAMP) 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_TIMESTAMP || drec->sql_desc_concise_type == SQL_FLOAT) 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_RETURN(stmt, SQL_ERROR); break; } if (result == SQL_SUCCESS_WITH_INFO) odbc_errs_add(&stmt->errs, "01004", NULL); ODBC_RETURN(stmt, result); #undef COUT #undef SOUT #undef IOUT } SQLRETURN 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_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_API SQLDisconnect(SQLHDBC hdbc) { int i; INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLDisconnect(%p)\n", hdbc); /* free all associated statements */ while (dbc->stmt_list) _SQLFreeStmt(dbc->stmt_list, SQL_DROP, 1); /* 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_free_socket(dbc->tds_socket); dbc->tds_socket = NULL; dbc->cursor_support = 0; ODBC_RETURN_(dbc); } static int odbc_errmsg_handler(const TDSCONTEXT * ctx, TDSSOCKET * tds, TDSMESSAGE * msg) { struct _sql_errors *errs = NULL; TDS_DBC *dbc = 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 && (dbc = (TDS_DBC *) tds->parent) && dbc->current_statement) { TDS_STMT *stmt = dbc->current_statement; /* cancel sent, handling interrupt */ if (tds->in_cancel && stmt->cancel_sent) { stmt->cancel_sent = 0; tdsdump_log(TDS_DBG_INFO1, "returning from timeout\n"); return TDS_INT_TIMEOUT; } if (!tds->in_cancel) odbc_errs_add(&stmt->errs, "HYT00", "Timeout expired"); stmt->errs.lastrc = SQL_ERROR; /* attent indefinitely cancel */ /* stmt->dbc->tds_socket->query_timeout = 0; */ } else if (dbc) { odbc_errs_add(&dbc->errs, "HYT00", "Timeout expired"); dbc->errs.lastrc = SQL_ERROR; tds_close_socket(tds); tdsdump_log(TDS_DBG_INFO1, "returning cancel from timeout\n"); return TDS_INT_CANCEL; } if (tds->in_cancel) { tds_close_socket(tds); tdsdump_log(TDS_DBG_INFO1, "returning cancel from timeout\n"); return TDS_INT_CANCEL; } tdsdump_log(TDS_DBG_INFO1, "returning from timeout\n"); return TDS_INT_TIMEOUT; } if (tds && tds->parent) { dbc = (TDS_DBC *) tds->parent; errs = &dbc->errs; if (dbc->current_statement) errs = &dbc->current_statement->errs; /* set server info if not setted in dbc */ if (msg->server && tds_dstr_isempty(&dbc->server)) tds_dstr_copy(&dbc->server, msg->server); } 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); /* 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_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; INIT_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_RETURN(desc, SQL_ERROR); } if (nRecordNumber > desc->header.sql_desc_count || nRecordNumber <= 0) { odbc_errs_add(&desc->errs, "07009", NULL); ODBC_RETURN(desc, SQL_ERROR); } 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_RETURN(desc, SQL_ERROR); } } else { if (concise_type != nType) { odbc_errs_add(&desc->errs, "HY021", NULL); ODBC_RETURN(desc, SQL_ERROR); } 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_RETURN_(desc); } #define FUNC NAME(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) #include "sqlwparams.h" { struct _drecord *drec = NULL; SQLRETURN rc = SQL_SUCCESS; INIT_HDESC; tdsdump_log(TDS_DBG_FUNC, "SQLGetDescRec(%p, %d, %p, %d, %p, %p, %p, %p, %p, %p, %p)\n", hdesc, RecordNumber, szName, cbNameMax, pcbName, Type, SubType, Length, Precision, Scale, Nullable); if (RecordNumber <= 0) { odbc_errs_add(&desc->errs, "07009", NULL); ODBC_RETURN(desc, SQL_ERROR); } IRD_UPDATE(desc, &desc->errs, ODBC_RETURN(desc, SQL_ERROR)); if (RecordNumber > desc->header.sql_desc_count) ODBC_RETURN(desc, SQL_NO_DATA); if (desc->type == DESC_IRD && !desc->header.sql_desc_count) { odbc_errs_add(&desc->errs, "HY007", NULL); ODBC_RETURN(desc, SQL_ERROR); } 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_RETURN(desc, rc); } #define FUNC NAME(SQLGetDescField) (P(SQLHDESC,hdesc), P(SQLSMALLINT,icol), P(SQLSMALLINT,fDescType), P(SQLPOINTER,Value), \ P(SQLINTEGER,BufferLength), P(SQLINTEGER *,StringLength) WIDE) #include "sqlwparams.h" { struct _drecord *drec; SQLRETURN result = SQL_SUCCESS; INIT_HDESC; tdsdump_log(TDS_DBG_FUNC, "SQLGetDescField(%p, %d, %d, %p, %d, %p)\n", hdesc, icol, fDescType, Value, (int)BufferLength, StringLength); #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_RETURN_(desc); break; case SQL_DESC_ARRAY_SIZE: IOUT(SQLULEN, desc->header.sql_desc_array_size); ODBC_RETURN_(desc); break; case SQL_DESC_ARRAY_STATUS_PTR: IOUT(SQLUSMALLINT *, desc->header.sql_desc_array_status_ptr); ODBC_RETURN_(desc); break; case SQL_DESC_BIND_OFFSET_PTR: IOUT(SQLLEN *, desc->header.sql_desc_bind_offset_ptr); ODBC_RETURN_(desc); break; case SQL_DESC_BIND_TYPE: IOUT(SQLINTEGER, desc->header.sql_desc_bind_type); ODBC_RETURN_(desc); break; case SQL_DESC_COUNT: IRD_UPDATE(desc, &desc->errs, ODBC_RETURN(desc, SQL_ERROR)); IOUT(SQLSMALLINT, desc->header.sql_desc_count); ODBC_RETURN_(desc); break; case SQL_DESC_ROWS_PROCESSED_PTR: IOUT(SQLULEN *, desc->header.sql_desc_rows_processed_ptr); ODBC_RETURN_(desc); break; } IRD_UPDATE(desc, &desc->errs, ODBC_RETURN(desc, SQL_ERROR)); if (!desc->header.sql_desc_count) { odbc_errs_add(&desc->errs, "07005", NULL); ODBC_RETURN(desc, SQL_ERROR); } if (icol < 1) { odbc_errs_add(&desc->errs, "07009", "Column out of range"); ODBC_RETURN(desc, SQL_ERROR); } if (icol > desc->header.sql_desc_count) ODBC_RETURN(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_RETURN(desc, SQL_ERROR); break; } if (result == SQL_SUCCESS_WITH_INFO) odbc_errs_add(&desc->errs, "01004", NULL); ODBC_RETURN(desc, result); #undef COUT #undef SOUT #undef IOUT } #define FUNC NAME(SQLSetDescField) (P(SQLHDESC,hdesc), P(SQLSMALLINT,icol), P(SQLSMALLINT,fDescType), \ P(SQLPOINTER,Value), P(SQLINTEGER,BufferLength) WIDE) #include "sqlwparams.h" { struct _drecord *drec; SQLRETURN result = SQL_SUCCESS; INIT_HDESC; tdsdump_log(TDS_DBG_FUNC, "SQLSetDescField(%p, %d, %d, %p, %d)\n", hdesc, icol, fDescType, Value, (int)BufferLength); #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_RETURN(desc, SQL_ERROR); } /* dont check column index for these */ switch (fDescType) { case SQL_DESC_ALLOC_TYPE: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); ODBC_RETURN(desc, SQL_ERROR); break; case SQL_DESC_ARRAY_SIZE: IIN(SQLULEN, desc->header.sql_desc_array_size); ODBC_RETURN_(desc); break; case SQL_DESC_ARRAY_STATUS_PTR: PIN(SQLUSMALLINT *, desc->header.sql_desc_array_status_ptr); ODBC_RETURN_(desc); break; case SQL_DESC_ROWS_PROCESSED_PTR: PIN(SQLULEN *, desc->header.sql_desc_rows_processed_ptr); ODBC_RETURN_(desc); break; case SQL_DESC_BIND_TYPE: IIN(SQLINTEGER, desc->header.sql_desc_bind_type); ODBC_RETURN_(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_RETURN(desc, SQL_ERROR); } result = desc_alloc_records(desc, n); if (result == SQL_ERROR) odbc_errs_add(&desc->errs, "HY001", NULL); ODBC_RETURN(desc, result); } break; } if (!desc->header.sql_desc_count) { odbc_errs_add(&desc->errs, "07005", NULL); ODBC_RETURN(desc, SQL_ERROR); } if (icol <= 0 || icol > desc->header.sql_desc_count) { odbc_errs_add(&desc->errs, "07009", "Column out of range"); ODBC_RETURN(desc, SQL_ERROR); } 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, 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_RETURN(desc, SQL_ERROR); break; } #undef IIN ODBC_RETURN(desc, result); } SQLRETURN ODBC_API SQLCopyDesc(SQLHDESC hdesc, SQLHDESC htarget) { TDS_DESC *target; INIT_HDESC; tdsdump_log(TDS_DBG_FUNC, "SQLCopyDesc(%p, %p)\n", hdesc, htarget); if (SQL_NULL_HDESC == htarget || !IS_HDESC(htarget)) return SQL_INVALID_HANDLE; target = (TDS_DESC *) htarget; CHECK_DESC_EXTRA(target); /* do not write on IRD */ if (target->type == DESC_IRD) { odbc_errs_add(&target->errs, "HY016", NULL); ODBC_RETURN(target, SQL_ERROR); } IRD_UPDATE(desc, &desc->errs, ODBC_RETURN(target, SQL_ERROR)); ODBC_RETURN(target, desc_copy(target, desc)); } #if ENABLE_EXTRA_CHECKS static void odbc_ird_check(TDS_STMT * stmt) { TDS_DESC *ird = stmt->ird; TDSRESULTINFO *res_info = NULL; int cols = 0, i; if (!stmt->dbc->tds_socket) return; if (stmt->dbc->tds_socket->current_results) { res_info = stmt->dbc->tds_socket->current_results; cols = res_info->num_cols; } if (stmt->cursor != NULL || stmt->dbc->current_statement != stmt) 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(tds_dstr_len(&drec->sql_desc_label) == col->column_namelen); assert(memcmp(tds_dstr_cstr(&drec->sql_desc_label), col->column_name, col->column_namelen) == 0); } } #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->dbc->tds_socket || !(res_info = stmt->dbc->tds_socket->current_results)) 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) { odbc_errs_add(&stmt->errs, "HY001", NULL); return SQL_ERROR; } for (i = 0; i < num_cols; i++) { int type; drec = &ird->records[i]; col = res_info->columns[i]; type = tds_get_conversion_type(col->column_type, col->column_size); drec->sql_desc_auto_unique_value = col->column_identity ? SQL_TRUE : SQL_FALSE; /* TODO SQL_FALSE ?? */ drec->sql_desc_case_sensitive = SQL_TRUE; /* TODO test error ?? */ odbc_set_concise_sql_type(odbc_server_to_sql_type(col->on_server.column_type, col->on_server.column_size), drec, 0); /* * 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! */ drec->sql_desc_display_size = odbc_sql_to_displaysize(drec->sql_desc_concise_type, col); drec->sql_desc_fixed_prec_scale = (col->column_prec && col->column_scale) ? SQL_TRUE : SQL_FALSE; if (!tds_dstr_copyn(&drec->sql_desc_label, col->column_name, col->column_namelen)) return SQL_ERROR; odbc_set_sql_type_info(col, drec, stmt->dbc->env->attr.odbc_version); if (!col->table_column_name) { if (!tds_dstr_copyn(&drec->sql_desc_name, col->column_name, col->column_namelen)) return SQL_ERROR; } else { if (!tds_dstr_copy(&drec->sql_desc_name, col->table_column_name)) return SQL_ERROR; if (!tds_dstr_copy(&drec->sql_desc_base_column_name, col->table_column_name)) return SQL_ERROR; } /* extract sql_desc_(catalog/schema/base_table)_name */ /* TODO extract them dinamically (when needed) ? */ /* TODO store in libTDS in different way (separately) ? */ if (col->table_namelen) { struct { const char *start; const char *end; } partials[4]; const char *p; char buf[256]; int i; p = col->table_name; for (i = 0; i < 4; ++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 (*p != '.') break; ++p; } odbc_unquote(buf, sizeof(buf), partials[i].start, partials[i].end); tds_dstr_copy(&drec->sql_desc_base_table_name, buf); --i; if (i >= 0) { odbc_unquote(buf, sizeof(buf), partials[i].start, partials[i].end); tds_dstr_copy(&drec->sql_desc_schema_name, buf); } --i; if (i >= 0) { odbc_unquote(buf, sizeof(buf), partials[i].start, partials[i].end); tds_dstr_copy(&drec->sql_desc_catalog_name, buf); } } 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; if (drec->sql_desc_concise_type == SQL_NUMERIC) drec->sql_desc_num_prec_radix = 10; else drec->sql_desc_num_prec_radix = 0; drec->sql_desc_octet_length_ptr = NULL; switch (type) { case SYBDATETIME: drec->sql_desc_precision = 3; drec->sql_desc_scale = 3; break; case SYBMONEY: drec->sql_desc_precision = 19; drec->sql_desc_scale = 4; break; case SYBMONEY4: drec->sql_desc_precision = 10; drec->sql_desc_scale = 4; break; default: drec->sql_desc_precision = col->column_prec; drec->sql_desc_scale = col->column_scale; break; } /* 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; /* TODO perhaps TINYINY and BIT.. */ drec->sql_desc_unsigned = SQL_FALSE; drec->sql_desc_updatable = col->column_writeable && !col->column_identity ? SQL_TRUE : SQL_FALSE; } return (SQL_SUCCESS); } static int odbc_cursor_execute(TDS_STMT * stmt) { TDSSOCKET *tds = stmt->dbc->tds_socket; int send = 0, i, 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); if (stmt->cursor) { tds_release_cursor(tds, stmt->cursor); stmt->cursor = NULL; } if (stmt->query) cursor = tds_alloc_cursor(tds, tds_dstr_cstr(&stmt->cursor_name), tds_dstr_len(&stmt->cursor_name), stmt->query, strlen(stmt->query)); else cursor = tds_alloc_cursor(tds, tds_dstr_cstr(&stmt->cursor_name), tds_dstr_len(&stmt->cursor_name), stmt->prepared_query, strlen(stmt->prepared_query)); if (!cursor) { stmt->dbc->current_statement = NULL; 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 = 4; break; case SQL_CURSOR_STATIC: i = 8; break; case SQL_CURSOR_KEYSET_DRIVEN: i = 1; break; case SQL_CURSOR_DYNAMIC: i = 2; break; } cursor->type = i; switch (stmt->attr.concurrency) { default: case SQL_CONCUR_READ_ONLY: i = 1; break; case SQL_CONCUR_LOCK: i = 2; break; case SQL_CONCUR_ROWVER: i = 4; break; case SQL_CONCUR_VALUES: i = 8; break; } cursor->concurrency = 0x2000 | i; ret = tds_cursor_declare(tds, cursor, params, &send); if (ret != TDS_SUCCEED) return ret; ret = tds_cursor_open(tds, cursor, params, &send); if (ret != TDS_SUCCEED) 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 (ret == TDS_SUCCEED && IS_TDS7_PLUS(tds) && !tds_dstr_isempty(&stmt->cursor_name)) { ret = odbc_process_tokens(stmt, TDS_RETURN_MSG|TDS_RETURN_DONE|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE); stmt->row_count = tds->rows_affected; stmt->dbc->current_statement = NULL; 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_SUCCEED; } if (!cursor->cursor_id) { stmt->cursor = NULL; tds_cursor_dealloc(tds, cursor); } } return ret; } static SQLRETURN _SQLExecute(TDS_STMT * stmt) { int ret; TDSSOCKET *tds = stmt->dbc->tds_socket; TDS_INT result_type; TDS_INT done = 0; int in_row = 0; SQLUSMALLINT param_status; int found_info = 0, found_error = 0; tdsdump_log(TDS_DBG_FUNC, "_SQLExecute(%p)\n", stmt); stmt->row = 0; tdsdump_log(TDS_DBG_FUNC, "_SQLExecute() starting with state %d\n", tds->state); /* check parameters are all OK */ if (stmt->params && stmt->param_num <= stmt->param_count) /* TODO what error ?? */ return SQL_ERROR; 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; } if (!odbc_lock_statement(stmt)) 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 = stmt->query; char *end, tmp; if (!name) name = stmt->prepared_query; end = name; if (*end == '[') end = (char *) tds_skip_quoted(end); else while (!isspace((unsigned char) *++end) && *end); stmt->prepared_pos = end; tmp = *end; *end = 0; ret = tds_submit_rpc(tds, name, stmt->params); *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->query) { /* not prepared query */ /* TODO cursor change way of calling */ /* SQLExecDirect */ if (stmt->num_param_rows <= 1) { if (!stmt->params) { ret = tds_submit_query(tds, stmt->query); } else { ret = tds_submit_execdirect(tds, stmt->query, stmt->params); } } else { /* pack multiple submit using language */ TDSMULTIPLE multiple; ret = tds_multiple_init(tds, &multiple, TDS_MULTIPLE_QUERY); for (stmt->curr_param_row = 0; ret == TDS_SUCCEED; ) { /* submit a query */ ret = tds_multiple_query(tds, &multiple, 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 (ret == TDS_SUCCEED) ret = tds_multiple_done(tds, &multiple); } } else if (stmt->num_param_rows <= 1 && IS_TDS71_PLUS(tds) && (!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 = tds8_submit_prepexec(tds, stmt->prepared_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))) { /* 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, tds8) */ if (tds_submit_prepare(tds, stmt->prepared_query, NULL, &stmt->dyn, stmt->params) == TDS_FAIL) { /* TODO ?? tds_free_param_results(params); */ ODBC_RETURN(stmt, SQL_ERROR); } if (tds_process_simple_query(tds) != TDS_SUCCEED) { dyn = stmt->dyn; stmt->dyn = NULL; tds_free_dynamic(tds, dyn); /* TODO ?? tds_free_param_results(params); */ ODBC_RETURN(stmt, 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); for (stmt->curr_param_row = 0; ret == TDS_SUCCEED; ) { 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 (ret == TDS_SUCCEED) ret = tds_multiple_done(tds, &multiple); } } if (ret != TDS_SUCCEED) ODBC_RETURN(stmt, 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: 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 && stmt->ipd->header.sql_desc_array_status_ptr) stmt->ipd->header.sql_desc_array_status_ptr[stmt->curr_param_row] = param_status; if (stmt->curr_param_row + 1 >= stmt->num_param_rows) { done = 1; break; } if (stmt->errs.lastrc == SQL_SUCCESS_WITH_INFO) found_info = 1; if (stmt->errs.lastrc == SQL_ERROR) found_error = 1; stmt->errs.lastrc = SQL_SUCCESS; param_status = SQL_PARAM_SUCCESS; ++stmt->curr_param_row; 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 (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; } odbc_populate_ird(stmt); switch (result_type) { case TDS_CMD_DONE: if (stmt->dbc->current_statement == stmt) stmt->dbc->current_statement = NULL; 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_RETURN(stmt, SQL_ERROR); } ODBC_RETURN_(stmt); } #define FUNC NAME(SQLExecDirect) (P(SQLHSTMT,hstmt), PCHARIN(SqlStr,SQLINTEGER) WIDE) #include "sqlwparams.h" { SQLRETURN res; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLExecDirect(%p, %p, %d)\n", hstmt, szSqlStr, (int)cbSqlStr); if (SQL_SUCCESS != odbc_set_stmt_query(stmt, szSqlStr, cbSqlStr _wide)) { odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_RETURN(stmt, SQL_ERROR); } /* count placeholders */ /* note: szSqlStr can be no-null terminated, so first we set query and then count placeholders */ stmt->param_count = tds_count_placeholders(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_RETURN(stmt, SQL_ERROR); } res = start_parse_prepared_query(stmt, 1); if (SQL_SUCCESS != res) ODBC_RETURN(stmt, res); return _SQLExecute(stmt); } SQLRETURN ODBC_API SQLExecute(SQLHSTMT hstmt) { ODBC_PRRET_BUF; SQLRETURN res; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLExecute(%p)\n", hstmt); if (!stmt->prepared_query) { /* TODO error report, only without DM ?? */ tdsdump_log(TDS_DBG_FUNC, "SQLExecute returns SQL_ERROR (not prepared)\n"); ODBC_RETURN(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_RETURN(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)); return res; } static int odbc_process_tokens(TDS_STMT * stmt, unsigned flag) { TDS_INT result_type; int done_flags; TDSSOCKET * tds = stmt->dbc->tds_socket; flag |= TDS_RETURN_DONE | TDS_RETURN_PROC; for (;;) { int 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_NO_MORE_RESULTS: return TDS_CMD_DONE; case TDS_CANCELLED: odbc_errs_add(&stmt->errs, "HY008", NULL); case TDS_FAIL: 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->internal_sp_called == TDS_SP_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->dbc->tds_socket; 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); } break; case SYBINT4: { TDS_INT *data = (TDS_INT *) colinfo->column_data; *data = odbc_swap_datetime_sql_type(*data); } 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; TDSCONTEXT *context; 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->dbc->tds_socket; 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); ODBC_RETURN(stmt, 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; 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); ODBC_RETURN(stmt, 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_cursor_fetch(tds, cursor, fetch_type, FetchOffset) != TDS_SUCCEED) { /* TODO what kind of error ?? */ ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, 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 (stmt->dbc->current_statement != stmt || stmt->row_status == NOT_IN_ROW) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } IRD_CHECK; if (stmt->ird->header.sql_desc_count <= 0) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } context = stmt->dbc->env->tds_ctx; 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(stmt->dbc->tds_socket, &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_RETURN(stmt, 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(stmt->dbc->tds_socket, &result_type, NULL, TDS_TOKEN_TRAILING); stmt->dbc->current_statement = NULL; } 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_API SQLFetch(SQLHSTMT hstmt) { SQLRETURN ret; struct { SQLULEN array_size; SQLULEN *rows_processed_ptr; SQLUSMALLINT *array_status_ptr; } keep; INIT_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_RETURN(stmt, ret); } #if (ODBCVER >= 0x0300) SQLRETURN ODBC_API SQLFetchScroll(SQLHSTMT hstmt, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset) { INIT_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_RETURN(stmt, SQL_ERROR); } ODBC_RETURN(stmt, _SQLFetch(stmt, FetchOrientation, FetchOffset)); } #endif #if (ODBCVER >= 0x0300) SQLRETURN 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; INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLFreeConnect(%p)\n", hdbc); /* TODO if connected return error */ tds_free_socket(dbc->tds_socket); /* 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); #ifdef ENABLE_ODBC_WIDE tds_dstr_free(&dbc->original_charset); #endif tds_dstr_free(&dbc->server); 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); free(dbc); return SQL_SUCCESS; } SQLRETURN ODBC_API SQLFreeConnect(SQLHDBC hdbc) { tdsdump_log(TDS_DBG_INFO2, "SQLFreeConnect(%p)\n", hdbc); return _SQLFreeConnect(hdbc); } #endif static SQLRETURN _SQLFreeEnv(SQLHENV henv) { INIT_HENV; tdsdump_log(TDS_DBG_FUNC, "_SQLFreeEnv(%p)\n", henv); odbc_errs_reset(&env->errs); tds_free_context(env->tds_ctx); free(env); return SQL_SUCCESS; } SQLRETURN 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; INIT_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_RETURN(stmt, SQL_ERROR); } /* 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->dbc->tds_socket; /* * 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 && stmt->dbc->current_statement == stmt) { if (tds_send_cancel(tds) == TDS_SUCCEED) tds_process_cancel(tds); } /* free cursor */ retcode = odbc_free_cursor(stmt); if (!force && retcode != SQL_SUCCESS) return 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) return retcode; /* detatch from list */ 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; free(stmt->query); free(stmt->prepared_query); tds_free_param_results(stmt->params); odbc_errs_reset(&stmt->errs); if (stmt->dbc->current_statement == stmt) stmt->dbc->current_statement = NULL; tds_dstr_free(&stmt->cursor_name); desc_free(stmt->ird); desc_free(stmt->ipd); desc_free(stmt->orig_ard); desc_free(stmt->orig_apd); free(stmt); /* NOTE we freed stmt, do not use ODBC_RETURN */ return SQL_SUCCESS; } ODBC_RETURN_(stmt); } SQLRETURN 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_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) { INIT_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_RETURN(desc, SQL_ERROR); } 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 */ 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; } for (i = 0; i < TDS_MAX_APP_DESC; ++i) { if (dbc->uad[i] == desc) { dbc->uad[i] = NULL; desc_free(desc); break; } } } return SQL_SUCCESS; } static SQLRETURN _SQLGetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { void *src; size_t size; INIT_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->dbc->tds_socket, 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; /* TODO SQL_COLUMN_SEARCHABLE, although ODBC2 */ default: odbc_errs_add(&stmt->errs, "HY092", NULL); ODBC_RETURN(stmt, SQL_ERROR); } memcpy(Value, src, size); if (StringLength) *StringLength = size; ODBC_RETURN_(stmt); } #if (ODBCVER >= 0x0300) SQLRETURN 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); } #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); } #endif #endif SQLRETURN 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); } SQLRETURN ODBC_API SQLNumResultCols(SQLHSTMT hstmt, SQLSMALLINT FAR * pccol) { INIT_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_RETURN(stmt, SQL_ERROR); } #endif IRD_UPDATE(stmt->ird, &stmt->errs, ODBC_RETURN(stmt, SQL_ERROR)); *pccol = stmt->ird->header.sql_desc_count; ODBC_RETURN_(stmt); } #define FUNC NAME(SQLPrepare) (P(SQLHSTMT,hstmt), PCHARIN(SqlStr,SQLINTEGER) WIDE) #include "sqlwparams.h" { SQLRETURN retcode; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLPrepare(%p, %s, %d)\n", hstmt, szSqlStr, (int)cbSqlStr); /* try to free dynamic associated */ retcode = odbc_free_dynamic(stmt); if (retcode != SQL_SUCCESS) return retcode; if (SQL_SUCCESS != odbc_set_stmt_prepared_query(stmt, szSqlStr, cbSqlStr _wide)) ODBC_RETURN(stmt, SQL_ERROR); /* count parameters */ stmt->param_count = tds_count_placeholders(stmt->prepared_query); /* trasform to native (one time, not for every SQLExecute) */ if (SQL_SUCCESS != prepare_call(stmt)) ODBC_RETURN(stmt, SQL_ERROR); /* TODO needed ?? */ if (stmt->dyn) { tds_free_dynamic(stmt->dbc->tds_socket, stmt->dyn); stmt->dyn = NULL; } /* 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)) { TDSSOCKET *tds = stmt->dbc->tds_socket; 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(tds)) { stmt->need_reprepare = 1; ODBC_RETURN_(stmt); } tdsdump_log(TDS_DBG_INFO1, "Creating prepared statement\n"); if (!odbc_lock_statement(stmt)) ODBC_RETURN_(stmt); return odbc_prepare(stmt); } ODBC_RETURN_(stmt); } SQLRETURN _SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow) { TDSSOCKET *tds; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "_SQLRowCount(%p, %p)\n", hstmt, pcrow); tds = stmt->dbc->tds_socket; if (stmt->row_status == NOT_IN_ROW) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } *pcrow = -1; if (stmt->row_count != TDS_NO_COUNT) *pcrow = stmt->row_count; ODBC_RETURN_(stmt); } SQLRETURN 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; } #define FUNC NAME(SQLSetCursorName) (P(SQLHSTMT,hstmt), PCHARIN(Cursor,SQLSMALLINT) WIDE) #include "sqlwparams.h" { INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLSetCursorName(%p, %p, %d)\n", hstmt, szCursor, cbCursor); /* cursor already present, we cannot set name */ if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } if (!odbc_dstr_copy(stmt->dbc, &stmt->cursor_name, cbCursor, szCursor)) { odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_RETURN(stmt, SQL_ERROR); } ODBC_RETURN_(stmt); } #define FUNC NAME(SQLGetCursorName) (P(SQLHSTMT,hstmt), PCHAROUT(Cursor,SQLSMALLINT) WIDE) #include "sqlwparams.h" { SQLRETURN rc; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLGetCursorName(%p, %p, %d, %p)\n", hstmt, szCursor, cbCursorMax, pcbCursor); 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_RETURN(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) { const char *query; TDSSOCKET *tds = dbc->tds_socket; tdsdump_log(TDS_DBG_INFO1, "change_transaction(0x%p,%d)\n", dbc, state); if (dbc->attr.autocommit == SQL_AUTOCOMMIT_ON || TDS_IS_MSSQL(tds)) query = state ? "IF @@TRANCOUNT > 0 COMMIT" : "IF @@TRANCOUNT > 0 ROLLBACK"; else query = state ? "IF @@TRANCOUNT > 0 COMMIT BEGIN TRANSACTION" : "IF @@TRANCOUNT > 0 ROLLBACK BEGIN TRANSACTION"; /* 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_process_simple_query(tds) == TDS_FAIL) return SQL_ERROR; } /* TODO better idle check, not thread safe */ if (tds->state == TDS_IDLE) tds->query_timeout = dbc->default_query_timeout; if (tds_submit_query(tds, query) != TDS_SUCCEED) { odbc_errs_add(&dbc->errs, "HY000", "Could not perform COMMIT or ROLLBACK"); return SQL_ERROR; } if (tds_process_simple_query(tds) != TDS_SUCCEED) 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! */ INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLTransact(%p, %p, %d)\n", henv, hdbc, fType); ODBC_RETURN(dbc, change_transaction(dbc, op)); } SQLRETURN 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_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_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 ] * */ #define FUNC NAME(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) #include "sqlwparams.h" { int retcode; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLColumns(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n", hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName); 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_RETURN_(stmt); } #define FUNC NAME(SQLGetConnectAttr) (P(SQLHDBC,hdbc), P(SQLINTEGER,Attribute), P(SQLPOINTER,Value), P(SQLINTEGER,BufferLength),\ P(SQLINTEGER *,StringLength) WIDE) #include "sqlwparams.h" { const char *p = NULL; SQLRETURN rc; INIT_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; ODBC_RETURN_(dbc); 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; ODBC_RETURN_(dbc); break; #endif case SQL_ATTR_CONNECTION_TIMEOUT: *((SQLUINTEGER *) Value) = dbc->attr.connection_timeout; ODBC_RETURN_(dbc); break; case SQL_ATTR_ACCESS_MODE: *((SQLUINTEGER *) Value) = dbc->attr.access_mode; ODBC_RETURN_(dbc); 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; ODBC_RETURN_(dbc); break; case SQL_ATTR_ODBC_CURSORS: *((SQLUINTEGER *) Value) = dbc->attr.odbc_cursors; ODBC_RETURN_(dbc); break; case SQL_ATTR_PACKET_SIZE: *((SQLUINTEGER *) Value) = dbc->attr.packet_size; ODBC_RETURN_(dbc); break; case SQL_ATTR_QUIET_MODE: *((SQLHWND *) Value) = dbc->attr.quite_mode; ODBC_RETURN_(dbc); break; #ifdef TDS_NO_DM case SQL_ATTR_TRACE: *((SQLUINTEGER *) Value) = dbc->attr.trace; ODBC_RETURN_(dbc); 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; ODBC_RETURN_(dbc); break; case SQL_ATTR_TRANSLATE_LIB: case SQL_ATTR_TRANSLATE_OPTION: odbc_errs_add(&dbc->errs, "HYC00", NULL); ODBC_RETURN(dbc, SQL_ERROR); break; default: odbc_errs_add(&dbc->errs, "HY092", NULL); ODBC_RETURN(dbc, SQL_ERROR); break; } assert(p); rc = odbc_set_string_oct(dbc, Value, BufferLength, StringLength, p, -1); ODBC_RETURN(dbc, rc); } SQLRETURN 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_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; TDSSOCKET *tds; TDSCONTEXT *context; SQLLEN dummy_cb; INIT_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_RETURN(stmt, SQL_ERROR); } /* read data from TDS only if current statement */ if ((stmt->cursor == NULL && stmt->dbc->current_statement != stmt) || stmt->row_status == PRE_NORMAL_ROW || stmt->row_status == NOT_IN_ROW) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } IRD_CHECK; if (!pcbValue) pcbValue = &dummy_cb; tds = stmt->dbc->tds_socket; context = stmt->dbc->env->tds_ctx; resinfo = stmt->cursor ? stmt->cursor->res_info : tds->current_results; if (!resinfo) { odbc_errs_add(&stmt->errs, "HY010", NULL); ODBC_RETURN(stmt, SQL_ERROR); } if (icol <= 0 || icol > resinfo->num_cols) { odbc_errs_add(&stmt->errs, "07009", "Column out of range"); ODBC_RETURN(stmt, SQL_ERROR); } 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_RETURN(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_RETURN(stmt, SQL_ERROR); } 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_RETURN(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_RETURN(stmt, SQL_SUCCESS_WITH_INFO); } } 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_RETURN(stmt, SQL_ERROR); } } } ODBC_RETURN_(stmt); } SQLRETURN ODBC_API SQLGetFunctions(SQLHDBC hdbc, SQLUSMALLINT fFunction, SQLUSMALLINT FAR * pfExists) { int i; INIT_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_ ODBC_RETURN(dbc, SQL_SUCCESS); #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_ ODBC_RETURN(dbc, SQL_SUCCESS); 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; ODBC_RETURN(dbc, SQL_SUCCESS); default: *pfExists = SQL_FALSE; ODBC_RETURN(dbc, SQL_SUCCESS); break; } ODBC_RETURN(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->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->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: /* TODO check ##.##.#### format */ p = VERSION; 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 = tds_dstr_cstr(&dbc->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; 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_API SQLGetInfo(SQLHDBC hdbc, SQLUSMALLINT fInfoType, SQLPOINTER rgbInfoValue, SQLSMALLINT cbInfoValueMax, SQLSMALLINT FAR * pcbInfoValue) { INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLGetInfo(%p, %d, %p, %d, %p)\n", hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue); ODBC_RETURN(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) { INIT_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLGetInfoW(%p, %d, %p, %d, %p)\n", hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue); ODBC_RETURN(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; TDSCOLUMN *colinfo; 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) { char *p; colinfo = resinfo->columns[icol]; /* upper case */ /* TODO procedure */ for (p = colinfo->column_name; p < (colinfo->column_name + colinfo->column_namelen); ++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)); } } static SQLSMALLINT odbc_swap_datetime_sql_type(SQLSMALLINT sql_type) { switch (sql_type) { case SQL_TYPE_TIMESTAMP: sql_type = SQL_TIMESTAMP; break; case SQL_TIMESTAMP: sql_type = SQL_TYPE_TIMESTAMP; break; case SQL_TYPE_DATE: sql_type = SQL_DATE; break; case SQL_DATE: sql_type = SQL_TYPE_DATE; break; case SQL_TYPE_TIME: sql_type = SQL_TIME; break; case SQL_TIME: sql_type = SQL_TYPE_TIME; break; } return sql_type; } SQLRETURN 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[] = "EXEC sp_datatype_info %d"; char sql[sizeof(sql_templ) + 30]; int odbc3; INIT_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); /* 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)); stmt->special_row = ODBC_SPECIAL_GETTYPEINFO; } else { sprintf(sql, sql_templ, fSqlType); strcat(sql, ",3"); } } else { /* FIXME MS ODBC translate SQL_TIMESTAMP to SQL_TYPE_TIMESTAMP even for ODBC 2 apps */ sprintf(sql, sql_templ, fSqlType); } if (SQL_SUCCESS != odbc_set_stmt_query(stmt, (ODBC_CHAR*) sql, strlen(sql) _wide0)) ODBC_RETURN(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_RETURN(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_SUCCEED: 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_RETURN(stmt, res); } static SQLRETURN _SQLParamData(SQLHSTMT hstmt, SQLPOINTER FAR * prgbValue) { INIT_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_RETURN(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_RETURN(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_RETURN(stmt, SQL_NEED_DATA); case SQL_SUCCESS: return _SQLExecute(stmt); } ODBC_RETURN(stmt, res); } odbc_errs_add(&stmt->errs, "HY010", NULL); ODBC_RETURN(stmt, SQL_ERROR); } SQLRETURN 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_API SQLPutData(SQLHSTMT hstmt, SQLPOINTER rgbValue, SQLLEN cbValue) { ODBC_PRRET_BUF; INIT_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLPutData(%p, %p, %i)\n", hstmt, rgbValue, (int)cbValue); if (stmt->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_RETURN(stmt, ret); } odbc_errs_add(&stmt->errs, "HY010", NULL); tdsdump_log(TDS_DBG_FUNC, "SQLPutData returns SQL_ERROR (function sequence error)\n"); ODBC_RETURN(stmt, SQL_ERROR); } #define FUNC NAME(SQLSetConnectAttr) (P(SQLHDBC,hdbc), P(SQLINTEGER,Attribute), P(SQLPOINTER,ValuePtr), P(SQLINTEGER,StringLength) WIDE) #include "sqlwparams.h" { SQLULEN u_value = (SQLULEN) (TDS_INTPTR) ValuePtr; INIT_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 */ ODBC_RETURN(dbc, change_autocommit(dbc, u_value)); break; case SQL_ATTR_CONNECTION_TIMEOUT: dbc->attr.connection_timeout = u_value; ODBC_RETURN_(dbc); break; case SQL_ATTR_ACCESS_MODE: dbc->attr.access_mode = u_value; ODBC_RETURN_(dbc); break; case SQL_ATTR_CURRENT_CATALOG: if (!IS_VALID_LEN(StringLength)) { odbc_errs_add(&dbc->errs, "HY090", NULL); ODBC_RETURN(dbc, SQL_ERROR); } { DSTR s; SQLRETURN ret; tds_dstr_init(&s); if (!odbc_dstr_copy_oct(dbc, &s, StringLength, ValuePtr)) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } ret = change_database(dbc, tds_dstr_cstr(&s), tds_dstr_len(&s)); tds_dstr_free(&s); ODBC_RETURN(dbc, ret); } break; case SQL_ATTR_CURSOR_TYPE: if (dbc->cursor_support) { dbc->attr.cursor_type = u_value; ODBC_RETURN_(dbc); } break; case SQL_ATTR_LOGIN_TIMEOUT: dbc->attr.login_timeout = u_value; ODBC_RETURN_(dbc); break; case SQL_ATTR_ODBC_CURSORS: /* TODO cursors */ dbc->attr.odbc_cursors = u_value; ODBC_RETURN_(dbc); break; case SQL_ATTR_PACKET_SIZE: dbc->attr.packet_size = u_value; ODBC_RETURN_(dbc); break; case SQL_ATTR_QUIET_MODE: dbc->attr.quite_mode = (SQLHWND) (TDS_INTPTR) ValuePtr; ODBC_RETURN_(dbc); break; #ifdef TDS_NO_DM case SQL_ATTR_TRACE: dbc->attr.trace = u_value; ODBC_RETURN_(dbc); break; case SQL_ATTR_TRACEFILE: if (!IS_VALID_LEN(StringLength)) { odbc_errs_add(&dbc->errs, "HY090", NULL); ODBC_RETURN(dbc, SQL_ERROR); } if (odbc_dstr_copy(dbc, &dbc->attr.tracefile, StringLength, (ODBC_CHAR *) ValuePtr)) ODBC_RETURN_(dbc); else { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN(dbc, SQL_ERROR); } 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; } ODBC_RETURN_(dbc); break; case SQL_ATTR_TRANSLATE_LIB: case SQL_ATTR_TRANSLATE_OPTION: odbc_errs_add(&dbc->errs, "HYC00", NULL); ODBC_RETURN(dbc, SQL_ERROR); break; } odbc_errs_add(&dbc->errs, "HY092", NULL); ODBC_RETURN(dbc, SQL_ERROR); } SQLRETURN ODBC_API SQLSetConnectOption(SQLHDBC hdbc, SQLUSMALLINT fOption, SQLULEN vParam) { tdsdump_log(TDS_DBG_FUNC, "SQLSetConnectOption(%p, %d, %u)\n", hdbc, fOption, (unsigned)vParam); return _SQLSetConnectAttr(hdbc, (SQLINTEGER) fOption, (SQLPOINTER) 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); return _SQLSetConnectAttr(hdbc, (SQLINTEGER) fOption, (SQLPOINTER) vParam, SQL_NTS, 1); } #endif static SQLRETURN _SQLSetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength) { SQLULEN ui = (SQLULEN) (TDS_INTPTR) ValuePtr; SQLUSMALLINT *usip = (SQLUSMALLINT *) ValuePtr; SQLLEN *lp = (SQLLEN *) ValuePtr; SQLULEN *ulp = (SQLULEN *) ValuePtr; INIT_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); ODBC_RETURN(stmt, SQL_ERROR); } /* 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); ODBC_RETURN(stmt, SQL_ERROR); } 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); ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); } if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } 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); ODBC_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } 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); ODBC_RETURN(stmt, SQL_ERROR); } 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); ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); } if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } 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); ODBC_RETURN(stmt, SQL_ERROR); } 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); ODBC_RETURN(stmt, SQL_ERROR); 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); ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); } 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); ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); } 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); ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); } 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); ODBC_RETURN(stmt, SQL_ERROR); 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); ODBC_RETURN(stmt, SQL_ERROR); } if (stmt->attr.simulate_cursor != ui) { odbc_errs_add(&stmt->errs, "01S02", NULL); ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); } stmt->attr.simulate_cursor = ui; break; case SQL_ATTR_USE_BOOKMARKS: if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } 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); ODBC_RETURN(stmt, SQL_ERROR); } stmt->sql_rowset_size = ui; break; default: odbc_errs_add(&stmt->errs, "HY092", NULL); ODBC_RETURN(stmt, SQL_ERROR); } ODBC_RETURN_(stmt); } #if (ODBCVER >= 0x0300) SQLRETURN 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); } #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); } #endif #endif SQLRETURN ODBC_API SQLSetStmtOption(SQLHSTMT hstmt, SQLUSMALLINT fOption, SQLULEN vParam) { tdsdump_log(TDS_DBG_FUNC, "SQLSetStmtOption(%p, %u, %u)\n", hstmt, fOption, (unsigned)vParam); return _SQLSetStmtAttr(hstmt, (SQLINTEGER) fOption, (SQLPOINTER) vParam, SQL_NTS); } #define FUNC NAME(SQLSpecialColumns) (P(SQLHSTMT,hstmt), P(SQLUSMALLINT,fColType), PCHARIN(CatalogName,SQLSMALLINT), \ PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT), \ P(SQLUSMALLINT,fScope), P(SQLUSMALLINT,fNullable) WIDE) #include "sqlwparams.h" { int retcode; char nullable, scope, col_type; INIT_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_RETURN(stmt, SQL_ERROR); } /* 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_RETURN(stmt, SQL_ERROR); } /* Check nullable */ if (fNullable != SQL_NO_NULLS && fNullable != SQL_NULLABLE) { odbc_errs_add(&stmt->errs, "HY099", NULL); ODBC_RETURN(stmt, SQL_ERROR); } if (!odbc_get_string_size(cbTableName, szTableName _wide)) { odbc_errs_add(&stmt->errs, "HY009", "SQLSpecialColumns: The table name parameter is required"); ODBC_RETURN(stmt, SQL_ERROR); } switch (fScope) { case SQL_SCOPE_CURROW: case SQL_SCOPE_TRANSACTION: case SQL_SCOPE_SESSION: break; default: odbc_errs_add(&stmt->errs, "HY098", NULL); ODBC_RETURN(stmt, SQL_ERROR); } #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_RETURN_(stmt); } #define FUNC NAME(SQLStatistics) (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT),\ PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT), P(SQLUSMALLINT,fUnique), \ P(SQLUSMALLINT,fAccuracy) WIDE) #include "sqlwparams.h" { int retcode; char unique, accuracy; INIT_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_RETURN(stmt, SQL_ERROR); } /* check our uniqueness value */ if (fUnique != SQL_INDEX_UNIQUE && fUnique != SQL_INDEX_ALL) { odbc_errs_add(&stmt->errs, "HY100", NULL); ODBC_RETURN(stmt, SQL_ERROR); } /* check our accuracy value */ if (fAccuracy != SQL_QUICK && fAccuracy != SQL_ENSURE) { odbc_errs_add(&stmt->errs, "HY101", NULL); ODBC_RETURN(stmt, SQL_ERROR); } if (!odbc_get_string_size(cbTableName, szTableName _wide)) { odbc_errs_add(&stmt->errs, "HY009", NULL); ODBC_RETURN(stmt, SQL_ERROR); } #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_RETURN_(stmt); } #define FUNC NAME(SQLTables) (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), \ PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT), PCHARIN(TableType,SQLSMALLINT) WIDE) #include "sqlwparams.h" { int retcode; const char *proc = NULL; int wildcards; TDSSOCKET *tds; DSTR schema_name, catalog_name, table_type; INIT_HSTMT; tds_dstr_init(&schema_name); tds_dstr_init(&catalog_name); tds_dstr_init(&table_type); 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_type, cbTableType, szTableType)) { tds_dstr_free(&schema_name); tds_dstr_free(&catalog_name); tds_dstr_free(&table_type); odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_RETURN(stmt, SQL_ERROR); } /* 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->product_version >= TDS_MS_VER(8,0,0)) { proc = "sp_tableswc"; if (tds_dstr_isempty(&schema_name)) tds_dstr_copy(&schema_name, "%"); } /* * 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 = 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 = (char *) malloc(tds_dstr_len(&table_type) + elements * 2 + 3); if (!type) { odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_RETURN(stmt, SQL_ERROR); } p = tds_dstr_cstr(&table_type); dst = type; for (;;) { const char *begin = p; p = 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; tds_dstr_set(&table_type, type); } } /* 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 @table_name='', @table_owner='', @table_qualifier='%' ", 0); } else { retcode = odbc_stat_execute(stmt _wide, proc, 4, "P@table_name", szTableName, cbTableName, "!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_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_RETURN_(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); if (!type || (type == 'O' && dbc->attr.metadata_id == SQL_FALSE)) return tds_quote_string(dbc->tds_socket, dest, s, 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; } } /* limit string/id lengths */ if (len > 384) len = 384; 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; *dst++ = '\''; for (; --len >= 0; prev = *s++) { switch (*s) { case '\'': *dst++ = '\''; break; 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++ = *s; } *dst++ = '\''; return dst - dest; } #define ODBC_MAX_STAT_PARAM 8 static SQLRETURN odbc_stat_execute(TDS_STMT * stmt _WIDE, const char *begin, int nparams, ...) { struct param { DSTR value; char *name; char type; } params[ODBC_MAX_STAT_PARAM]; int i, len, param_qualifier = -1; char *proc, *p; int retcode; va_list marker; assert(nparams < ODBC_MAX_STAT_PARAM); /* read all params and calc len required */ va_start(marker, nparams); len = strlen(begin) + 3; for (i = 0; i < nparams; ++i) { int param_len, convert = 1; DSTR *out; p = va_arg(marker, char *); if (*p == '!') { convert = 0; ++p; } switch (*p) { case 'V': /* ODBC version */ len += strlen(p) + 3; case 'O': /* ordinary arguments */ case 'P': /* pattern value arguments */ params[i].type = *p++; break; default: params[i].type = 0; /* ordinary type */ break; } params[i].name = p; p = va_arg(marker, char *); param_len = va_arg(marker, int); tds_dstr_init(¶ms[i].value); #ifdef ENABLE_ODBC_WIDE if (!convert) out = tds_dstr_copyn(¶ms[i].value, p, param_len); else out = odbc_dstr_copy(stmt->dbc, ¶ms[i].value, param_len, (ODBC_CHAR *) p); #else out = odbc_dstr_copy(stmt->dbc, ¶ms[i].value, param_len, (ODBC_CHAR *) p); #endif if (!out) { while (--i >= 0) tds_dstr_free(¶ms[i].value); odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_RETURN(stmt, SQL_ERROR); } if (!tds_dstr_isempty(¶ms[i].value)) { len += strlen(params[i].name) + odbc_quote_metadata(stmt->dbc, params[i].type, NULL, ¶ms[i].value) + 3; if (begin[0] == '.' && strstr(params[i].name, "qualifier")) { len += tds_quote_id(stmt->dbc->tds_socket, NULL, tds_dstr_cstr(¶ms[param_qualifier].value), tds_dstr_len(¶ms[param_qualifier].value)); param_qualifier = i; } } } va_end(marker); /* allocate space for string */ if (!(proc = (char *) malloc(len))) { for (i = 0; i < nparams; ++i) tds_dstr_free(¶ms[i].value); odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_RETURN(stmt, SQL_ERROR); } /* build string */ p = proc; if (param_qualifier >= 0) p += tds_quote_id(stmt->dbc->tds_socket, p, tds_dstr_cstr(¶ms[param_qualifier].value), tds_dstr_len(¶ms[param_qualifier].value)); strcpy(p, begin); p += strlen(begin); *p++ = ' '; for (i = 0; i < nparams; ++i) { if (tds_dstr_isempty(¶ms[i].value) && params[i].type != 'V') continue; if (params[i].name[0]) { strcpy(p, params[i].name); p += strlen(params[i].name); *p++ = '='; } if (params[i].type != 'V') p += odbc_quote_metadata(stmt->dbc, params[i].type, p, ¶ms[i].value); else *p++ = (stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) ? '3': '2'; *p++ = ','; tds_dstr_free(¶ms[i].value); } *--p = '\0'; assert(p - proc + 1 <= len); /* set it */ /* FIXME is neither mb or wide, is always utf encoded !!! */ retcode = odbc_set_stmt_query(stmt, (ODBC_CHAR *) proc, p - proc _wide0); free(proc); if (retcode != SQL_SUCCESS) ODBC_RETURN(stmt, retcode); /* execute it */ retcode = _SQLExecute(stmt); if (SQL_SUCCEEDED(retcode)) odbc_upper_column_names(stmt); ODBC_RETURN(stmt, retcode); } static SQLRETURN odbc_free_dynamic(TDS_STMT * stmt) { TDSSOCKET *tds = stmt->dbc->tds_socket; if (stmt->dyn) { if (!tds_needs_unprepare(tds, stmt->dyn)) { tds_free_dynamic(tds, stmt->dyn); stmt->dyn = NULL; } else if (tds_submit_unprepare(tds, stmt->dyn) == TDS_SUCCEED) { if (tds_process_simple_query(tds) != TDS_SUCCEED) ODBC_RETURN(stmt, SQL_ERROR); tds_free_dynamic(tds, stmt->dyn); stmt->dyn = NULL; } else { /* TODO if fail add to odbc to free later, when we are in idle */ ODBC_RETURN(stmt, SQL_ERROR); } } return SQL_SUCCESS; } static SQLRETURN odbc_free_cursor(TDS_STMT * stmt) { TDSCURSOR *cursor = stmt->cursor; TDSSOCKET *tds = stmt->dbc->tds_socket; if (cursor && tds) { int error = 1; cursor->status.dealloc = TDS_CURSOR_STATE_REQUESTED; /* TODO if fail add to odbc to free later, when we are in idle */ if (tds_cursor_close(tds, cursor) == TDS_SUCCEED) { if (tds_process_simple_query(tds) == TDS_SUCCEED) error = 0; /* TODO check error */ tds_cursor_dealloc(tds, cursor); stmt->cursor = NULL; } if (error) ODBC_RETURN(stmt, SQL_ERROR); } return SQL_SUCCESS; } SQLRETURN ODBC_API SQLSetScrollOptions(SQLHSTMT hstmt, SQLUSMALLINT fConcurrency, SQLLEN crowKeyset, SQLUSMALLINT crowRowset) { SQLUSMALLINT info; SQLUINTEGER value, check; SQLUINTEGER cursor_type; INIT_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_RETURN(stmt, SQL_ERROR); } if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } 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_RETURN(stmt, SQL_ERROR); } value = 0; _SQLGetInfo(stmt->dbc, info, &value, sizeof(value), NULL _wide0); if ((value & check) == 0) { odbc_errs_add(&stmt->errs, "HYC00", NULL); ODBC_RETURN(stmt, SQL_ERROR); } _SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) (TDS_INTPTR) cursor_type, 0); _SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) (TDS_INTPTR) fConcurrency, 0); _SQLSetStmtAttr(hstmt, SQL_ATTR_KEYSET_SIZE, (SQLPOINTER) (TDS_INTPTR) crowKeyset, 0); _SQLSetStmtAttr(hstmt, SQL_ROWSET_SIZE, (SQLPOINTER) (TDS_INTPTR) crowRowset, 0); ODBC_RETURN_(stmt); } freetds-0.91/src/odbc/connectparams.c100664 001750 000144 00000057143 11466266342 0013322/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "tdsodbc.h" #include "tdsstring.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: connectparams.c,v 1.88 2010/11/09 15:46:42 freddy77 Exp $"); #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, TDSCONNECTION * connection) { char ip[64]; char *p = (char *) strchr(server, '\\'); if (p) { if (!tds_dstr_copy(&connection->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) { connection->port = atoi(p+1); *p = 0; } } if (tds_lookup_host(server, ip) == TDS_SUCCEED) tds_dstr_copy(&connection->server_host_name, server); if (!tds_dstr_copy(&connection->ip_addr, ip)) { 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 connection where to store connection info * @return 1 if success 0 otherwhise */ int odbc_get_dsn_info(TDS_ERRS *errs, const char *DSN, TDSCONNECTION * connection) { char tmp[FILENAME_MAX]; int freetds_conf_less = 1; /* use old servername */ if (myGetPrivateProfileString(DSN, odbc_param_Servername, tmp) > 0) { freetds_conf_less = 0; tds_dstr_copy(&connection->server_name, tmp); tds_read_conf_file(connection, 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 */ tds_lookup_host(tmp, tmp); tds_dstr_copy(&connection->ip_addr, tmp); } if (myGetPrivateProfileString(DSN, odbc_param_Server, tmp) > 0) { tds_dstr_copy(&connection->server_name, tmp); if (!address_specified) { if (!parse_server(errs, tmp, connection)) return 0; } } } if (myGetPrivateProfileString(DSN, odbc_param_Port, tmp) > 0) tds_parse_conf_section(TDS_STR_PORT, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_TDS_Version, tmp) > 0) tds_parse_conf_section(TDS_STR_VERSION, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_Language, tmp) > 0) tds_parse_conf_section(TDS_STR_LANGUAGE, tmp, connection); if (tds_dstr_isempty(&connection->database) && myGetPrivateProfileString(DSN, odbc_param_Database, tmp) > 0) tds_dstr_copy(&connection->database, tmp); if (myGetPrivateProfileString(DSN, odbc_param_TextSize, tmp) > 0) tds_parse_conf_section(TDS_STR_TEXTSZ, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_PacketSize, tmp) > 0) tds_parse_conf_section(TDS_STR_BLKSZ, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_ClientCharset, tmp) > 0) tds_parse_conf_section(TDS_STR_CLCHARSET, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_DumpFile, tmp) > 0) tds_parse_conf_section(TDS_STR_DUMPFILE, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_DumpFileAppend, tmp) > 0) tds_parse_conf_section(TDS_STR_APPENDMODE, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_DebugFlags, tmp) > 0) tds_parse_conf_section(TDS_STR_DEBUGFLAGS, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_Encryption, tmp) > 0) tds_parse_conf_section(TDS_STR_ENCRYPTION, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_UseNTLMv2, tmp) > 0) tds_parse_conf_section(TDS_STR_USENTLMV2, tmp, connection); if (myGetPrivateProfileString(DSN, odbc_param_Trusted_Connection, tmp) > 0 && tds_config_boolean(tmp)) { tds_dstr_copy(&connection->user_name, ""); tds_dstr_copy(&connection->password, ""); } return 1; } /** * Parse connection string and fill connection according * @param connect_string connect string * @param connect_string_end connect string end (pointer to char past last) * @param connection 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, TDSCONNECTION * connection, TDS_PARSED_PARAM *parsed_params) { const char *p, *end; DSTR *dest_s, value; 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); tds_dstr_init(&value); 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 = &connection->server_name; /* not that safe cast but works -- freddy77 */ if (!parse_server(errs, (char *) tds_dstr_cstr(&value), connection)) { 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) { tds_dstr_dup(&connection->server_name, &value); tds_read_conf_file(connection, tds_dstr_cstr(&value)); 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), connection)) { tds_dstr_free(&value); return 0; } cfgs = CFG_DSN; p = connect_string; continue; } } else if (CHK_PARAM(Database)) { dest_s = &connection->database; } else if (CHK_PARAM(UID)) { dest_s = &connection->user_name; } else if (CHK_PARAM(PWD)) { dest_s = &connection->password; } else if (CHK_PARAM(APP)) { dest_s = &connection->app_name; } else if (CHK_PARAM(WSID)) { dest_s = &connection->client_host_name; } else if (CHK_PARAM(Language)) { tds_parse_conf_section(TDS_STR_LANGUAGE, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(Port)) { tds_parse_conf_section(TDS_STR_PORT, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(TDS_Version)) { tds_parse_conf_section(TDS_STR_VERSION, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(TextSize)) { tds_parse_conf_section(TDS_STR_TEXTSZ, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(PacketSize)) { tds_parse_conf_section(TDS_STR_BLKSZ, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(ClientCharset)) { tds_parse_conf_section(TDS_STR_CLCHARSET, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(DumpFile)) { tds_parse_conf_section(TDS_STR_DUMPFILE, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(DumpFileAppend)) { tds_parse_conf_section(TDS_STR_APPENDMODE, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(DebugFlags)) { tds_parse_conf_section(TDS_STR_DEBUGFLAGS, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(Encryption)) { tds_parse_conf_section(TDS_STR_ENCRYPTION, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(UseNTLMv2)) { tds_parse_conf_section(TDS_STR_USENTLMV2, tds_dstr_cstr(&value), connection); } else if (CHK_PARAM(Trusted_Connection)) { trusted = tds_config_boolean(tds_dstr_cstr(&value)); tdsdump_log(TDS_DBG_INFO1, "trusted %s -> %d\n", tds_dstr_cstr(&value), trusted); num_param = -1; /* TODO odbc_param_Address field */ } 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) { DSTR tmp = *dest_s; *dest_s = value; value = tmp; } 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_copy(&connection->user_name, ""); tds_dstr_copy(&connection->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 = (char*) malloc(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) { tds_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) { tds_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", 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; tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); tds_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)); tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); tds_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; tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); tds_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); tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); tds_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"); 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-0.91/src/odbc/convert_tds2sql.c100664 001750 000144 00000030731 11421506013 0013572/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "tdsodbc.h" #include "tdsconvert.h" #include "tdsiconv.h" #include "tdsstring.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: convert_tds2sql.c,v 1.72 2010/07/21 05:56:27 freddy77 Exp $"); #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, err, char_size; TDSSOCKET *tds = stmt->dbc->tds_socket; TDSICONV *conv = curcol->char_conv; if (!conv) conv = tds->char_convs[client2server_chardata]; if (desttype == SQL_C_WCHAR) { /* SQL_C_WCHAR, convert to wide encode */ conv = tds_iconv_get(tds, ODBC_WIDE_NAME, conv->server_charset.name); if (!conv) conv = tds_iconv_get(tds, ODBC_WIDE_NAME, "ISO-8859-1"); #ifdef ENABLE_ODBC_WIDE } else { conv = tds_iconv_get(tds, tds_dstr_cstr(&stmt->dbc->original_charset), conv->server_charset.name); if (!conv) conv = tds_iconv_get(tds, tds_dstr_cstr(&stmt->dbc->original_charset), "ISO-8859-1"); if (!conv) conv = tds_iconv_get(tds, "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; err = tds_iconv(tds, conv, to_client, &ib, &il, &ob, &ol); ol = ob - dest; /* bytes written */ if (curcol) 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->client_charset.min_bytes_per_char == conv->client_charset.max_bytes_per_char && conv->server_charset.min_bytes_per_char == conv->server_charset.max_bytes_per_char)) { ol += il * conv->client_charset.min_bytes_per_char / conv->server_charset.min_bytes_per_char; } 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; } 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_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 == TDS_FAIL) { 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 { ret = srclen; if (destlen > 0) { cplen = (destlen > srclen) ? srclen : destlen; assert(cplen >= 0); /* do not NULL terminate binary buffer */ memcpy(dest, src, cplen); if (curcol) curcol->column_text_sqlgetdatapos += cplen; } else { /* if destlen == 0 we return only length */ if (destlen != 0) { odbc_errs_add(&stmt->errs, "07006", NULL); return SQL_NULL_DATA; } } return ret; } } 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) && (srctype == SYBDATETIME || srctype == SYBDATETIME4)) { char buf[40]; TDSDATEREC when; memset(&when, 0, sizeof(when)); tds_datecrack(srctype, src, &when); tds_strftime(buf, sizeof(buf), srctype == SYBDATETIME ? "%Y-%m-%d %H:%M:%S.%z" : "%Y-%m-%d %H:%M:%S", &when); nRetVal = strlen(buf); memcpy(dest, buf, destlen < nRetVal ? destlen : nRetVal); } else { 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 SYBDATETIME * now decompose date into constituent parts... */ tds_datecrack(SYBDATETIME, &(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 SYBDATETIME * now decompose date into constituent parts... */ tds_datecrack(SYBDATETIME, &(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 SYBDATETIME * now decompose date into constituent parts... */ tds_datecrack(SYBDATETIME, &(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.millisecond * 1000000u; 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 case SQL_C_BINARY: /* type already handled */ assert(desttype != SQL_C_BINARY); default: break; } return ret; } freetds-0.91/src/odbc/descriptor.c100664 001750 000144 00000012160 11413330711 0012611/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "tdsodbc.h" #include "tdsstring.h" #ifdef DMALLOC #include #endif 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_DESC *) calloc(1, sizeof(TDS_DESC)); if (!desc) return NULL; /* set defualt 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, *drecs; 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 (desc->records) drecs = (struct _drecord *) realloc(desc->records, sizeof(struct _drecord) * (count + 0)); else drecs = (struct _drecord *) malloc(sizeof(struct _drecord) * (count + 0)); if (!drecs) return SQL_ERROR; desc->records = drecs; 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); 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-0.91/src/odbc/prepare_query.c100664 001750 000144 00000027535 11305570415 0013341/* 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "tdsodbc.h" #include "tdsconvert.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: prepare_query.c,v 1.79 2009/12/02 22:58:21 jklowden Exp $"); #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; for (;;) { TDSPARAMINFO *temp_params; TDSCOLUMN *curcol; TDS_SERVER_TYPE type; const char *start; while (TDS_ISSPACE(*++p)); 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(stmt->dbc->tds_socket)) { tds_set_param_type(stmt->dbc->tds_socket, curcol, SYBVOID); curcol->column_size = curcol->column_cur_size = 0; } else { /* TODO is there a better type ? */ tds_set_param_type(stmt->dbc->tds_socket, 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(stmt->dbc->tds_socket, 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 binded 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)); 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 (blob->textvalue) p = (TDS_CHAR *) realloc(blob->textvalue, len + curcol->column_cur_size); else { assert(curcol->column_cur_size == 0); p = (TDS_CHAR *) malloc(len); } if (!p) { odbc_errs_add(&stmt->errs, "HY001", NULL); /* Memory allocation error */ return SQL_ERROR; } blob->textvalue = p; 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, DataPtr, len): odbc_wchar2hex(p, len / 2u, 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-0.91/src/odbc/odbc_util.c100664 001750 000144 00000110551 11426244216 0012412/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "tdsodbc.h" #include "tdsiconv.h" #include "tdsstring.h" #include "tdsconvert.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: odbc_util.c,v 1.124 2010/08/04 11:01:34 freddy77 Exp $"); /** * \ingroup odbc_api * \defgroup odbc_util ODBC utility * Functions called within \c ODBC driver. */ /** * \addtogroup odbc_util * @{ */ #ifdef ENABLE_ODBC_WIDE static char *odbc_iso2utf(const char *s, int len); static char *odbc_mb2utf(TDS_DBC *dbc, const char *s, int len); static char *odbc_wide2utf(const SQLWCHAR *s, int len); #endif static char * odbc_strndup(const char *s, int len) { char *out = (char*) malloc(len+1); if (!out) return NULL; memcpy(out, s, len); out[len] = 0; return out; } static int odbc_set_stmt(TDS_STMT * stmt, char **dest, const ODBC_CHAR *sql, int sql_len _WIDE) { char *p; assert(dest == &stmt->prepared_query || dest == &stmt->query); 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->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 (stmt->prepared_query) TDS_ZERO_FREE(stmt->prepared_query); if (stmt->query) TDS_ZERO_FREE(stmt->query); #ifdef ENABLE_ODBC_WIDE *dest = p = wide ? odbc_wide2utf(sql->wide, sql_len) : odbc_mb2utf(stmt->dbc, sql->mb, sql_len); #else *dest = p = odbc_strndup((const char*) sql, sql_len); #endif if (!p) return SQL_ERROR; return SQL_SUCCESS; } int odbc_set_stmt_query(TDS_STMT * stmt, const ODBC_CHAR *sql, int sql_len _WIDE) { return odbc_set_stmt(stmt, &stmt->query, sql, sql_len _wide); } int odbc_set_stmt_prepared_query(TDS_STMT * stmt, const ODBC_CHAR *sql, int sql_len _WIDE) { return odbc_set_stmt(stmt, &stmt->prepared_query, sql, sql_len _wide); } int odbc_get_string_size(int size, 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 size; } /* SQL_NULL_DATA or any other strange value */ return 0; } #ifdef ENABLE_ODBC_WIDE static char * odbc_iso2utf(const char *s, int len) { int i, o_len = len + 1; char *out, *p; assert(s && len >= 0); for (i = 0; i < len; ++i) if ((s[i] & 0x80) != 0) ++o_len; out = (char *) malloc(o_len); if (!out) return NULL; 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; } } *p = 0; assert(p+1-out <= o_len); return out; } static char * odbc_wide2utf(const SQLWCHAR *s, int len) { 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(len >= 0 && (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 } out = (char *) malloc(o_len); if (!out) return NULL; for (p = out; len > 0; --len) { SQLWCHAR u = *s++; if ((u & MASK(7)) == 0) { *p++ = 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); } *p = 0; assert(p+1-out <= o_len); return out; } static char * odbc_mb2utf(TDS_DBC *dbc, const char *s, 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(s, len); if (char_conv->flags == TDS_ENCODING_MEMCPY) return odbc_strndup(s, len); il = len; /* allocate needed buffer (+1 is to exclude 0 case) */ ol = il * char_conv->server_charset.max_bytes_per_char / char_conv->client_charset.min_bytes_per_char + 1; assert(ol > 0); buf = (char *) malloc(ol); if (!buf) return NULL; 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) { free(buf); return NULL; } *ob = 0; return buf; } #endif #ifdef ENABLE_ODBC_WIDE DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, int size, ODBC_CHAR * str, int flag) { int wide = flag&1; int len = odbc_get_string_size((flag&0x21) == 0x21 && size >= 0 ? size/SIZEOF_SQLWCHAR : size, str, wide); char *buf; if (wide) buf = odbc_wide2utf(str->wide, len); else buf = odbc_mb2utf(dbc, str->mb, len); if (!buf) return NULL; return tds_dstr_set(s, buf); } #else DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, int size, 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); #ifdef ENABLE_ODBC_WIDE if ((flag & 1) != 0) { /* wide characters */ const unsigned char *p = (const unsigned char*) s; SQLWCHAR *dest = (SQLWCHAR*) buffer; if (cbBuffer < 0) cbBuffer = 0; 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); 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; assert(cbBuffer >= 0); #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); /* 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 */ 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 (tds_iconv(dbc->tds_socket, char_conv, to_client, &ib, &il, &ob, &ol) == (size_t)-1) 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) result = SQL_ERROR; if (out_len < cbBuffer) { int max_copy = out_len - cbBuffer; if (max_copy > sizeof(discard) - ol) max_copy = sizeof(discard) - ol; memcpy(((char *) buffer) + out_len, discard, max_copy); } out_len += sizeof(discard) - 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->dbc->tds_socket; /* 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 = 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, (void *) 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->dbc->tds_socket; 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 = 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, (void *) 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 } } /** * Convert type from database to ODBC */ SQLSMALLINT odbc_server_to_sql_type(int col_type, int col_size) { /* FIXME finish */ switch ((TDS_SERVER_TYPE) col_type) { case XSYBCHAR: case SYBCHAR: return SQL_CHAR; case XSYBVARCHAR: case SYBVARCHAR: return SQL_VARCHAR; case SYBTEXT: return SQL_LONGVARCHAR; case XSYBNCHAR: return SQL_WCHAR; /* TODO really sure ?? SYBNVARCHAR sybase only ?? */ case SYBNVARCHAR: case XSYBNVARCHAR: return SQL_WVARCHAR; case SYBNTEXT: return SQL_WLONGVARCHAR; case SYBBIT: case SYBBITN: return SQL_BIT; #if (ODBCVER >= 0x0300) case SYB5INT8: case SYBINT8: /* TODO return numeric for odbc2 and convert bigint to numeric */ return SQL_BIGINT; #endif case SYBINT4: return SQL_INTEGER; case SYBINT2: return SQL_SMALLINT; case SYBINT1: return SQL_TINYINT; case SYBINTN: switch (col_size) { case 1: return SQL_TINYINT; case 2: return SQL_SMALLINT; case 4: return SQL_INTEGER; #if (ODBCVER >= 0x0300) case 8: return SQL_BIGINT; #endif } break; case SYBREAL: return SQL_REAL; case SYBFLT8: return SQL_DOUBLE; case SYBFLTN: switch (col_size) { case 4: return SQL_REAL; case 8: return SQL_DOUBLE; } break; case SYBMONEY: case SYBMONEY4: case SYBMONEYN: return SQL_DECIMAL; case SYBDATETIME: case SYBDATETIME4: case SYBDATETIMN: #if (ODBCVER >= 0x0300) return SQL_TYPE_TIMESTAMP; #else return SQL_TIMESTAMP; #endif case XSYBBINARY: case SYBBINARY: return SQL_BINARY; case SYBLONGBINARY: case SYBIMAGE: return SQL_LONGVARBINARY; case XSYBVARBINARY: case SYBVARBINARY: return SQL_VARBINARY; case SYBNUMERIC: case SYBDECIMAL: return SQL_NUMERIC; #if (ODBCVER >= 0x0300) case SYBUNIQUE: #ifdef SQL_GUID return SQL_GUID; #else return SQL_CHAR; #endif case SYBVARIANT: break; #endif case SYBMSXML: return SQL_CHAR; /* * TODO what should I do with these types ?? * return other types can cause additional problems */ case SYBVOID: case SYBSINT1: case SYBUINT2: case SYBUINT4: case SYBUINT8: case SYBUINT1: case SYBDATE: case SYBDATEN: case SYBINTERVAL: case SYBTIME: case SYBTIMEN: case SYBUINTN: case SYBUNITEXT: case SYBXML: case SYBMSUDT: break; } return SQL_UNKNOWN_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 even if server do not support it */ int 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_SBIGINT: case SQL_C_UBIGINT: return SYBINT8; #ifdef SQL_C_GUID case SQL_C_GUID: return SYBUNIQUE; #endif #endif case SQL_C_LONG: case SQL_C_SLONG: case SQL_C_ULONG: return SYBINT4; case SQL_C_SHORT: case SQL_C_SSHORT: case SQL_C_USHORT: return SYBINT2; case SQL_C_TINYINT: case SQL_C_STINYINT: 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 SYBDATETIME; /* 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_FAIL; } void odbc_set_sql_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { #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) drec->sql_desc_octet_length = drec->sql_desc_length = col->on_server.column_size; switch (tds_get_conversion_type(col->column_type, col->column_size)) { case XSYBCHAR: case SYBCHAR: if (col->on_server.column_type == XSYBNCHAR) SET_INFO2("nchar", "'", "'", col->on_server.column_size / 2); SET_INFO("char", "'", "'"); case XSYBVARCHAR: case SYBVARCHAR: if (col->on_server.column_type == SYBNVARCHAR || col->on_server.column_type == XSYBNVARCHAR) SET_INFO2("nvarchar", "'", "'", col->on_server.column_size / 2); SET_INFO("varchar", "'", "'"); case SYBTEXT: if (col->on_server.column_type == SYBNTEXT) SET_INFO2("ntext", "'", "'", col->on_server.column_size / 2); SET_INFO("text", "'", "'"); case SYBBIT: case SYBBITN: SET_INFO2("bit", "", "", 1); #if (ODBCVER >= 0x0300) case SYBINT8: /* TODO return numeric for odbc2 and convert bigint to numeric */ SET_INFO2("bigint", "", "", 19); #endif case SYBINT4: SET_INFO2("int", "", "", 10); case SYBINT2: SET_INFO2("smallint", "", "", 5); case SYBINT1: SET_INFO2("tinyint", "", "", 3); case SYBREAL: SET_INFO2("real", "", "", odbc_ver == SQL_OV_ODBC3 ? 24 : 7); case SYBFLT8: SET_INFO2("float", "", "", odbc_ver == SQL_OV_ODBC3 ? 53 : 15); case SYBMONEY: drec->sql_desc_octet_length = 21; SET_INFO2("money", "$", "", 19); case SYBMONEY4: drec->sql_desc_octet_length = 12; SET_INFO2("money", "$", "", 10); case SYBDATETIME: drec->sql_desc_octet_length = sizeof(TIMESTAMP_STRUCT); SET_INFO2("datetime", "'", "'", 23); case SYBDATETIME4: drec->sql_desc_octet_length = sizeof(TIMESTAMP_STRUCT); SET_INFO2("datetime", "'", "'", 16); case SYBBINARY: /* handle TIMESTAMP using usertype */ if (col->column_usertype == 80) SET_INFO("timestamp", "0x", ""); SET_INFO("binary", "0x", ""); case SYBIMAGE: SET_INFO("image", "0x", ""); case SYBVARBINARY: SET_INFO("varbinary", "0x", ""); case SYBNUMERIC: drec->sql_desc_octet_length = col->column_prec + 2; SET_INFO2("numeric", "", "", col->column_prec); case SYBDECIMAL: drec->sql_desc_octet_length = col->column_prec + 2; SET_INFO2("decimal", "", "", col->column_prec); case SYBINTN: case SYBDATETIMN: case SYBFLTN: case SYBMONEYN: assert(0); case SYBVOID: case SYBNTEXT: case SYBNVARCHAR: case XSYBNVARCHAR: case XSYBNCHAR: break; #if (ODBCVER >= 0x0300) case SYBUNIQUE: /* FIXME for Sybase ?? */ SET_INFO2("uniqueidentifier", "'", "'", 36); case SYBVARIANT: SET_INFO("sql_variant", "", ""); break; #endif case SYBMSXML: SET_INFO("xml", "'", "'"); } SET_INFO("", "", ""); #undef SET_INFO #undef SET_INFO2 } SQLINTEGER odbc_sql_to_displaysize(int sqltype, TDSCOLUMN *col) { SQLINTEGER size = 0; switch (sqltype) { case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: size = col->on_server.column_size; break; /* FIXME sure ?? *2 or not ?? */ case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: size = col->on_server.column_size / 2; break; case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: size = col->column_size * 2; break; case SQL_BIGINT: size = 20; break; case SQL_INTEGER: size = 11; /* -1000000000 */ break; case SQL_SMALLINT: size = 6; /* -10000 */ break; case SQL_BIT: size = 1; break; case SQL_TINYINT: size = 3; /* 255 */ break; case SQL_DECIMAL: case SQL_NUMERIC: /* TODO check money format returned by propretary ODBC, scale == 4 but we use 2 digits */ if (col->column_type == SYBMONEY || (col->column_type == SYBMONEYN && col->column_size == 8)) size = 21; else if (col->column_type == SYBMONEY4 || (col->column_type == SYBMONEYN && col->column_size == 4)) size = 12; else size = col->column_prec + 2; break; case SQL_DATE: case SQL_TYPE_DATE: /* FIXME check always yyyy-mm-dd ?? */ size = 19; break; case SQL_TIME: case SQL_TYPE_TIME: /* FIXME check always hh:mm:ss[.fff] */ size = 19; break; case SQL_TYPE_TIMESTAMP: case SQL_TIMESTAMP: /* TODO dependent on precision (decimal second digits) */ /* we always format using yyyy-mm-dd hh:mm:ss[.fff], see convert_tds2sql.c */ size = 19; if (col->column_type == SYBDATETIME || (col->column_type == SYBDATETIMN && col->column_size == 8)) size = 23; break; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: /* TODO check REAL/FLOAT format */ if (col->column_type == SYBREAL || (col->column_type == SYBFLTN && col->column_size == 4)) size = 14; else size = 24; /* FIXME -- what should the correct size be? */ break; #ifdef SQL_GUID case SQL_GUID: size = 36; break; #endif default: /* FIXME TODO finish, should support ALL types (interval, binary) */ size = 40; tdsdump_log(TDS_DBG_INFO1, "odbc_sql_to_displaysize: unknown sql type %d\n", (int) sqltype); break; } return size; } 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; } } int odbc_sql_to_server_type(TDSSOCKET * tds, int sql_type) { switch (sql_type) { case SQL_WCHAR: if (IS_TDS7_PLUS(tds)) return XSYBNCHAR; case SQL_CHAR: return SYBCHAR; case SQL_WVARCHAR: if (IS_TDS7_PLUS(tds)) return XSYBNVARCHAR; case SQL_VARCHAR: return SYBVARCHAR; case SQL_WLONGVARCHAR: if (IS_TDS7_PLUS(tds)) return SYBNTEXT; 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(tds)) return SYBUNIQUE; return 0; #endif case SQL_BIT: if (IS_TDS7_PLUS(tds)) return SYBBITN; return SYBBIT; case SQL_TINYINT: return SYBINT1; case SQL_SMALLINT: return SYBINT2; case SQL_INTEGER: return SYBINT4; case SQL_BIGINT: 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: case SQL_TYPE_TIME: case SQL_TYPE_TIMESTAMP: return SYBDATETIME; case SQL_BINARY: return SYBBINARY; case SQL_VARBINARY: return SYBVARBINARY; case SQL_LONGVARBINARY: return SYBIMAGE; /* TODO interval types */ default: return 0; } } /** Returns the version of the RDBMS in the ODBC format */ void odbc_rdbms_version(TDSSOCKET * tds, char *pversion_string) { sprintf(pversion_string, "%.02d.%.02d.%.04d", (int) ((tds->product_version & 0x7F000000) >> 24), (int) ((tds->product_version & 0x00FF0000) >> 16), (int) (tds->product_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; if (type == SQL_C_DEFAULT) type = odbc_sql_to_c_type_default(drec_ixd->sql_desc_concise_type); type = odbc_c_to_server_type(type); /* FIXME check what happen to DATE/TIME types */ size = tds_get_size_by_type(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_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_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-0.91/src/odbc/native.c100664 001750 000144 00000021767 10407770157 0011754/* 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. */ #if HAVE_CONFIG_H #include #endif #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 "tdsodbc.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: native.c,v 1.29 2006/03/21 12:24:15 freddy77 Exp $"); #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, char *buf) { char *d, *s; int nest_syntax = 0; /* list of bit, used as stack, is call ? FIXME limites size... */ unsigned long is_calls = 0; int server_scalar; assert(dbc && buf); server_scalar = TDS_IS_MSSQL(dbc->tds_socket) && dbc->tds_socket->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) { /* 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)); 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)); if (*pcall == '=') { while (TDS_ISSPACE(*++pcall)); } 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++; } } *d = '\0'; 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") < (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; } SQLRETURN prepare_call(struct _hstmt * stmt) { const char *s, *p, *param_start; char *buf; SQLRETURN rc; TDS_SERVER_TYPE type; if (stmt->prepared_query) buf = stmt->prepared_query; else if (stmt->query) buf = stmt->query; else return SQL_ERROR; if ((rc = to_native(stmt->dbc, stmt, buf)) != 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; 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; if (*s == '[') { /* FIXME handle [dbo].[name] and [master]..[name] syntax */ s = (char *) tds_skip_quoted(s); } else { /* FIXME: stop at other characters ??? */ while (*s && !TDS_ISSPACE(*s)) ++s; } param_start = s; --s; /* trick, now s point to no blank */ for (;;) { while (TDS_ISSPACE(*++s)); 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)); if (!*s) break; if (*s != ',') { stmt->prepared_query_is_func = 0; return SQL_SUCCESS; } } stmt->prepared_query_is_rpc = 1; /* remove unneeded exec */ memmove(buf, p, strlen(p) + 1); stmt->prepared_pos = buf + (param_start - p); return SQL_SUCCESS; } /* TODO handle output parameter and not terminated string */ SQLRETURN native_sql(struct _hdbc * dbc, char *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-0.91/src/odbc/sql2tds.c100664 001750 000144 00000034345 11507147510 0012047/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #include "tdsodbc.h" #include "tdsconvert.h" #include "tdsiconv.h" #include "tdsstring.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: sql2tds.c,v 1.86 2010/12/30 18:28:24 freddy77 Exp $"); static TDS_INT convert_datetime2server(int bindtype, const void *src, TDS_DATETIME * dt) { struct tm src_tm; int tm_ms; 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; 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_ms = 0; 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_ms = 0; 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_ms = src_timestamp->fraction / 1000000lu; break; default: return TDS_FAIL; } /* TODO code copied from convert.c, function */ i = (src_tm.tm_mon - 13) / 12; dt->dtdays = 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; dt_time = (src_tm.tm_hour * 60 + src_tm.tm_min) * 60 + src_tm.tm_sec; dt->dttime = dt_time * 300 + (tm_ms * 3 + 5) / 10; return sizeof(TDS_DATETIME); } static char* odbc_wstr2str(TDS_STMT * stmt, const char *src, int* len) { int srclen = (*len) / sizeof(SQLWCHAR); char *out = (char *) malloc(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++ = *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; int dest_type, src_type, sql_src_type, res; CONV_RESULT ores; TDSBLOB *blob; char *src, *converted_src; unsigned char *dest; int len; TDS_DATETIME dt; 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(dbc->tds_socket, drec_ipd->sql_desc_concise_type); if (dest_type == TDS_FAIL) { 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); /* TODO what happen for unicode types ?? */ if (is_char_type(dest_type) && sql_src_type == SQL_C_WCHAR) { TDSSOCKET *tds = dbc->tds_socket; TDSICONV *conv = tds->char_convs[is_unicode_type(dest_type) ? client2ucs2 : client2server_chardata]; tds_set_param_type(tds, curcol, dest_type); curcol->char_conv = tds_iconv_get(tds, ODBC_WIDE_NAME, conv->server_charset.name); memcpy(curcol->column_collation, tds->collation, sizeof(tds->collation)); } else { #ifdef ENABLE_ODBC_WIDE TDSSOCKET *tds = dbc->tds_socket; TDSICONV *conv = tds->char_convs[is_unicode_type(dest_type) ? client2ucs2 : client2server_chardata]; tds_set_param_type(tds, curcol, dest_type); /* use binary format for binary to char */ if (is_char_type(dest_type)) curcol->char_conv = sql_src_type == SQL_C_BINARY ? NULL : tds_iconv_get(tds, tds_dstr_cstr(&dbc->original_charset), conv->server_charset.name); #else tds_set_param_type(dbc->tds_socket, curcol, dest_type); /* use binary format for binary to char */ if (sql_src_type == SQL_C_BINARY && is_char_type(dest_type)) 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(dbc->tds_socket, 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 == TDS_FAIL) { 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 = 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: case SQL_DATA_AT_EXEC: odbc_errs_add(&stmt->errs, "07S01", NULL); /* Invalid use of default parameter */ return SQL_ERROR; break; 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; } } switch (dest_type) { case SYBCHAR: case SYBVARCHAR: case XSYBCHAR: case XSYBVARCHAR: case XSYBNVARCHAR: case XSYBNCHAR: case SYBNVARCHAR: case SYBNTEXT: case SYBTEXT: if (!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)) { TDSBLOB *blob = (TDSBLOB *) calloc(1, sizeof(TDSBLOB)); 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 SYBDATETIME: convert_datetime2server(drec_apd->sql_desc_concise_type, src, &dt); src = (char *) &dt; 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: 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-0.91/src/odbc/error.c100664 001750 000144 00000053264 11474002372 0011604/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "tdsodbc.h" #include "odbcss.h" #include "tdsstring.h" #include "replacements.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: error.c,v 1.66 2010/11/26 19:05:30 freddy77 Exp $"); 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 = -1; for (current = settled; current < errs->num_errors; current++) { 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; } if (best == -1) best = current; /* 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)) { tds_strlcpy(dest_state, pmap->v2, 6); return; } ++pmap; } /* return the original if a v2 state is not found */ tds_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) { struct _sql_error *p; int n; assert(sqlstate); if (!errs) return; n = errs->num_errors; if (errs->errs) p = (struct _sql_error *) realloc(errs->errs, sizeof(struct _sql_error) * (n + 1)); else p = (struct _sql_error *) malloc(sizeof(struct _sql_error)); if (!p) return; errs->errs = p; memset(&errs->errs[n], 0, sizeof(struct _sql_error)); errs->errs[n].native = 0; tds_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; 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) { struct _sql_error *p; int n = errs->num_errors; if (errs->errs) p = (struct _sql_error *) realloc(errs->errs, sizeof(struct _sql_error) * (n + 1)); else p = (struct _sql_error *) malloc(sizeof(struct _sql_error)); if (!p) return; errs->errs = p; memset(&errs->errs[n], 0, sizeof(struct _sql_error)); errs->errs[n].native = native; if (sqlstate) tds_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"); } #define FUNC NAME(SQLGetDiagRec) (P(SQLSMALLINT,handleType), P(SQLHANDLE,handle), P(SQLSMALLINT,numRecord), PCHAR(szSqlState),\ P(SQLINTEGER FAR *,pfNativeError), PCHAROUT(ErrorMsg,SQLSMALLINT) WIDE) #include "sqlwparams.h" { 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; tdsdump_log(TDS_DBG_FUNC, "SQLGetDiagRec(%d, %p, %d, %p, %p, %p, %d, %p)\n", handleType, handle, numRecord, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg); 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; } #define FUNC NAME(SQLError) (P(SQLHENV,henv), P(SQLHDBC,hdbc), P(SQLHSTMT,hstmt), PCHAR(szSqlState), P(SQLINTEGER FAR *,pfNativeError),\ PCHAROUT(ErrorMsg,SQLSMALLINT) WIDE) #include "sqlwparams.h" { SQLRETURN result; SQLSMALLINT type; SQLHANDLE handle; tdsdump_log(TDS_DBG_FUNC, "SQLError(%p, %p, %p, %p, %p, %p, %d, %p)\n", henv, hdbc, hstmt, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg); 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; } #define FUNC NAME(SQLGetDiagField) (P(SQLSMALLINT,handleType), P(SQLHANDLE,handle), P(SQLSMALLINT,numRecord),\ P(SQLSMALLINT,diagIdentifier), P(SQLPOINTER,buffer), P(SQLSMALLINT,cbBuffer), P(SQLSMALLINT FAR *,pcbBuffer) WIDE) #include "sqlwparams.h" { 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]; tdsdump_log(TDS_DBG_FUNC, "SQLGetDiagField(%d, %p, %d, %d, %p, %d, %p)\n", handleType, handle, numRecord, diagIdentifier, buffer, cbBuffer, pcbBuffer); 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 = 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->spid > 0) cplen = sprintf(tmp, "%d", dbc->tds_socket->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 = ""; switch (handleType) { case SQL_HANDLE_ENV: break; case SQL_HANDLE_DBC: msg = tds_dstr_cstr(&dbc->server); break; case SQL_HANDLE_STMT: msg = tds_dstr_cstr(&stmt->dbc->server); /* * if dbc->server is not initialized, init it * from the errs structure */ if (!msg[0] && errs->errs[numRecord].server) { tds_dstr_copy(&stmt->dbc->server, errs->errs[numRecord].server); msg = errs->errs[numRecord].server; } break; } result = odbc_set_string_oct(dbc, buffer, cbBuffer, pcbBuffer, 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; } freetds-0.91/src/odbc/odbc_checks.c100664 001750 000144 00000007674 11052274657 0012717/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "tdsodbc.h" #include "tdsstring.h" #ifdef DMALLOC #include #endif TDS_RCSID(var, "$Id: odbc_checks.c,v 1.21 2008/08/18 13:31:27 freddy77 Exp $"); #if ENABLE_EXTRA_CHECKS void odbc_check_env_extra(TDS_ENV * env) { assert(env && env->htype == SQL_HANDLE_ENV); } 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) { char *query = stmt->prepared_query ? stmt->prepared_query : 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); /* unbinded 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-0.91/src/odbc/sqlwchar.c100664 001750 000144 00000002275 11100303542 0012260/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include "tdsodbc.h" TDS_RCSID(var, "$Id: sqlwchar.c,v 1.2 2008/10/24 08:29:22 freddy77 Exp $"); #if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T size_t sqlwcslen(const SQLWCHAR * s) { const SQLWCHAR *p = s; while (*p) ++p; return p - s; } #endif freetds-0.91/src/odbc/sqlwparams.h100664 001750 000144 00000003636 11474002372 0012650//#define FUNC NAME(SQLTest) (P(SQLSMALLINT, x), PCHAR(y) WIDE) #ifdef ENABLE_ODBC_WIDE #undef NAME #undef WIDE #undef P #undef PCHAR #undef PCHARIN #undef PCHAROUT #define NAME(a) _ ## a #define WIDE , int wide #define P(a,b) a b #define PCHAR(a) ODBC_CHAR* a #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) static SQLRETURN FUNC; #undef NAME #undef WIDE #undef PCHAR #define NAME(a) a #define WIDE #define PCHAR(a) SQLCHAR* a SQLRETURN ODBC_PUBLIC ODBC_API FUNC { #undef NAME #undef WIDE #undef P #undef PCHAR #define NAME(a) _ ## a #define WIDE ,0 #define P(a,b) b #define PCHAR(a) (ODBC_CHAR*) a return FUNC; } #undef NAME #undef WIDE #undef P #undef PCHAR #define NAME(a) a ## W #define WIDE #define P(a,b) a b #define PCHAR(a) SQLWCHAR * a SQLRETURN ODBC_PUBLIC ODBC_API FUNC { #undef NAME #undef WIDE #undef P #undef PCHAR #define NAME(a) _ ## a #define WIDE ,1 #define P(a,b) b #define PCHAR(a) (ODBC_CHAR*) a return FUNC; } #undef WIDE #undef P #undef PCHAR #define WIDE , int wide #define P(a,b) a b #define PCHAR(a) ODBC_CHAR* a static SQLRETURN FUNC #else #undef NAME #undef WIDE #undef P #undef PCHAR #undef PCHARIN #undef PCHAROUT #define NAME(a) _ ## a #define WIDE #define P(a,b) a b #define PCHAR(a) SQLCHAR* a #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) static SQLRETURN FUNC; #undef NAME #undef WIDE #undef P #undef PCHAR #define NAME(a) a #define WIDE #define P(a,b) a b #define PCHAR(a) SQLCHAR* a SQLRETURN ODBC_API FUNC { #undef NAME #undef WIDE #undef P #undef PCHAR #define NAME(a) _ ## a #define WIDE #define P(a,b) b #define PCHAR(a) a return FUNC; } #undef NAME #undef WIDE #undef P #undef PCHAR #define NAME(a) _ ## a #define WIDE #define P(a,b) a b #define PCHAR(a) SQLCHAR* a static SQLRETURN FUNC #endif #undef FUNC freetds-0.91/src/odbc/unittests/Makefile.am100664 001750 000144 00000012026 11507146343 0014400# $Id: Makefile.am,v 1.85 2010/12/30 18:18:11 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) 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 connect_SOURCES = connect.c common.c common.h connect_LDFLAGS = $(ODBCINSTLIB) 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 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 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 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 AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 AM_LDFLAGS = -no-fast-install else AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs endif LIBS = $(ODBCLIB) $(ODBCNODMLIB) @NETWORK_LIBS@ DISTCLEANFILES = odbc.ini odbcinst.ini EXTRA_DIST = describecol.in attributes.in $(EXTRA_DIST_WIN32) if HAVE_PERL_SOURCES odbc.dsw: $(top_srcdir)/win32/build_dsw.pl Makefile rm -rf $@ odbc.mak vc6 perl $(top_srcdir)/win32/build_dsw.pl $@ $(TESTS) vc6: odbc.dsw clean-local: rm -rf vc6 EXTRA_DIST_WIN32 = vc6 odbc.dsw odbc.mak endif freetds-0.91/src/odbc/unittests/Makefile.in100664 001750 000144 00000140605 11623070620 0014407# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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/odbc/unittests DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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_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_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_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) --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) 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) describecol_OBJECTS = $(am_describecol_OBJECTS) describecol_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) 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_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_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_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.$(OBJEXT) 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) 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(array_SOURCES) $(array_out_SOURCES) $(attributes_SOURCES) \ $(binary_test_SOURCES) $(blob1_SOURCES) $(cancel_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) \ $(earlybind_SOURCES) $(error_SOURCES) $(freeclose_SOURCES) \ $(funccall_SOURCES) $(genparams_SOURCES) $(getdata_SOURCES) \ $(hidden_SOURCES) $(insert_speed_SOURCES) \ $(lang_error_SOURCES) $(moreandcount_SOURCES) \ $(norowset_SOURCES) $(paramcore_SOURCES) $(params_SOURCES) \ $(peter_SOURCES) $(prepare_results_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_out_SOURCES) \ $(attributes_SOURCES) $(binary_test_SOURCES) $(blob1_SOURCES) \ $(cancel_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) $(earlybind_SOURCES) \ $(error_SOURCES) $(freeclose_SOURCES) $(funccall_SOURCES) \ $(genparams_SOURCES) $(getdata_SOURCES) $(hidden_SOURCES) \ $(insert_speed_SOURCES) $(lang_error_SOURCES) \ $(moreandcount_SOURCES) $(norowset_SOURCES) \ $(paramcore_SOURCES) $(params_SOURCES) $(peter_SOURCES) \ $(prepare_results_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) ETAGS = etags CTAGS = ctags am__tty_colors = \ red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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) @NETWORK_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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.85 2010/12/30 18:18:11 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) 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 connect_SOURCES = connect.c common.c common.h connect_LDFLAGS = $(ODBCINSTLIB) 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 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 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 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 AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" @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 = describecol.in attributes.in $(EXTRA_DIST_WIN32) @HAVE_PERL_SOURCES_TRUE@EXTRA_DIST_WIN32 = vc6 odbc.dsw odbc.mak 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/odbc/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/odbc/unittests/Makefile .PRECIOUS: 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) @rm -f array$(EXEEXT) $(LINK) $(array_OBJECTS) $(array_LDADD) $(LIBS) array_out$(EXEEXT): $(array_out_OBJECTS) $(array_out_DEPENDENCIES) @rm -f array_out$(EXEEXT) $(LINK) $(array_out_OBJECTS) $(array_out_LDADD) $(LIBS) attributes$(EXEEXT): $(attributes_OBJECTS) $(attributes_DEPENDENCIES) @rm -f attributes$(EXEEXT) $(LINK) $(attributes_OBJECTS) $(attributes_LDADD) $(LIBS) binary_test$(EXEEXT): $(binary_test_OBJECTS) $(binary_test_DEPENDENCIES) @rm -f binary_test$(EXEEXT) $(LINK) $(binary_test_OBJECTS) $(binary_test_LDADD) $(LIBS) blob1$(EXEEXT): $(blob1_OBJECTS) $(blob1_DEPENDENCIES) @rm -f blob1$(EXEEXT) $(LINK) $(blob1_OBJECTS) $(blob1_LDADD) $(LIBS) cancel$(EXEEXT): $(cancel_OBJECTS) $(cancel_DEPENDENCIES) @rm -f cancel$(EXEEXT) $(LINK) $(cancel_OBJECTS) $(cancel_LDADD) $(LIBS) compute$(EXEEXT): $(compute_OBJECTS) $(compute_DEPENDENCIES) @rm -f compute$(EXEEXT) $(LINK) $(compute_OBJECTS) $(compute_LDADD) $(LIBS) connect$(EXEEXT): $(connect_OBJECTS) $(connect_DEPENDENCIES) @rm -f connect$(EXEEXT) $(connect_LINK) $(connect_OBJECTS) $(connect_LDADD) $(LIBS) connect2$(EXEEXT): $(connect2_OBJECTS) $(connect2_DEPENDENCIES) @rm -f connect2$(EXEEXT) $(LINK) $(connect2_OBJECTS) $(connect2_LDADD) $(LIBS) const_params$(EXEEXT): $(const_params_OBJECTS) $(const_params_DEPENDENCIES) @rm -f const_params$(EXEEXT) $(LINK) $(const_params_OBJECTS) $(const_params_LDADD) $(LIBS) convert_error$(EXEEXT): $(convert_error_OBJECTS) $(convert_error_DEPENDENCIES) @rm -f convert_error$(EXEEXT) $(LINK) $(convert_error_OBJECTS) $(convert_error_LDADD) $(LIBS) copydesc$(EXEEXT): $(copydesc_OBJECTS) $(copydesc_DEPENDENCIES) @rm -f copydesc$(EXEEXT) $(LINK) $(copydesc_OBJECTS) $(copydesc_LDADD) $(LIBS) cursor1$(EXEEXT): $(cursor1_OBJECTS) $(cursor1_DEPENDENCIES) @rm -f cursor1$(EXEEXT) $(LINK) $(cursor1_OBJECTS) $(cursor1_LDADD) $(LIBS) cursor2$(EXEEXT): $(cursor2_OBJECTS) $(cursor2_DEPENDENCIES) @rm -f cursor2$(EXEEXT) $(LINK) $(cursor2_OBJECTS) $(cursor2_LDADD) $(LIBS) cursor3$(EXEEXT): $(cursor3_OBJECTS) $(cursor3_DEPENDENCIES) @rm -f cursor3$(EXEEXT) $(LINK) $(cursor3_OBJECTS) $(cursor3_LDADD) $(LIBS) cursor4$(EXEEXT): $(cursor4_OBJECTS) $(cursor4_DEPENDENCIES) @rm -f cursor4$(EXEEXT) $(LINK) $(cursor4_OBJECTS) $(cursor4_LDADD) $(LIBS) cursor5$(EXEEXT): $(cursor5_OBJECTS) $(cursor5_DEPENDENCIES) @rm -f cursor5$(EXEEXT) $(LINK) $(cursor5_OBJECTS) $(cursor5_LDADD) $(LIBS) cursor6$(EXEEXT): $(cursor6_OBJECTS) $(cursor6_DEPENDENCIES) @rm -f cursor6$(EXEEXT) $(LINK) $(cursor6_OBJECTS) $(cursor6_LDADD) $(LIBS) cursor7$(EXEEXT): $(cursor7_OBJECTS) $(cursor7_DEPENDENCIES) @rm -f cursor7$(EXEEXT) $(LINK) $(cursor7_OBJECTS) $(cursor7_LDADD) $(LIBS) data$(EXEEXT): $(data_OBJECTS) $(data_DEPENDENCIES) @rm -f data$(EXEEXT) $(LINK) $(data_OBJECTS) $(data_LDADD) $(LIBS) date$(EXEEXT): $(date_OBJECTS) $(date_DEPENDENCIES) @rm -f date$(EXEEXT) $(LINK) $(date_OBJECTS) $(date_LDADD) $(LIBS) descrec$(EXEEXT): $(descrec_OBJECTS) $(descrec_DEPENDENCIES) @rm -f descrec$(EXEEXT) $(LINK) $(descrec_OBJECTS) $(descrec_LDADD) $(LIBS) describecol$(EXEEXT): $(describecol_OBJECTS) $(describecol_DEPENDENCIES) @rm -f describecol$(EXEEXT) $(LINK) $(describecol_OBJECTS) $(describecol_LDADD) $(LIBS) earlybind$(EXEEXT): $(earlybind_OBJECTS) $(earlybind_DEPENDENCIES) @rm -f earlybind$(EXEEXT) $(LINK) $(earlybind_OBJECTS) $(earlybind_LDADD) $(LIBS) error$(EXEEXT): $(error_OBJECTS) $(error_DEPENDENCIES) @rm -f error$(EXEEXT) $(LINK) $(error_OBJECTS) $(error_LDADD) $(LIBS) freeclose$(EXEEXT): $(freeclose_OBJECTS) $(freeclose_DEPENDENCIES) @rm -f freeclose$(EXEEXT) $(LINK) $(freeclose_OBJECTS) $(freeclose_LDADD) $(LIBS) funccall$(EXEEXT): $(funccall_OBJECTS) $(funccall_DEPENDENCIES) @rm -f funccall$(EXEEXT) $(LINK) $(funccall_OBJECTS) $(funccall_LDADD) $(LIBS) genparams$(EXEEXT): $(genparams_OBJECTS) $(genparams_DEPENDENCIES) @rm -f genparams$(EXEEXT) $(LINK) $(genparams_OBJECTS) $(genparams_LDADD) $(LIBS) getdata$(EXEEXT): $(getdata_OBJECTS) $(getdata_DEPENDENCIES) @rm -f getdata$(EXEEXT) $(LINK) $(getdata_OBJECTS) $(getdata_LDADD) $(LIBS) hidden$(EXEEXT): $(hidden_OBJECTS) $(hidden_DEPENDENCIES) @rm -f hidden$(EXEEXT) $(LINK) $(hidden_OBJECTS) $(hidden_LDADD) $(LIBS) insert_speed$(EXEEXT): $(insert_speed_OBJECTS) $(insert_speed_DEPENDENCIES) @rm -f insert_speed$(EXEEXT) $(LINK) $(insert_speed_OBJECTS) $(insert_speed_LDADD) $(LIBS) lang_error$(EXEEXT): $(lang_error_OBJECTS) $(lang_error_DEPENDENCIES) @rm -f lang_error$(EXEEXT) $(LINK) $(lang_error_OBJECTS) $(lang_error_LDADD) $(LIBS) moreandcount$(EXEEXT): $(moreandcount_OBJECTS) $(moreandcount_DEPENDENCIES) @rm -f moreandcount$(EXEEXT) $(LINK) $(moreandcount_OBJECTS) $(moreandcount_LDADD) $(LIBS) norowset$(EXEEXT): $(norowset_OBJECTS) $(norowset_DEPENDENCIES) @rm -f norowset$(EXEEXT) $(LINK) $(norowset_OBJECTS) $(norowset_LDADD) $(LIBS) paramcore$(EXEEXT): $(paramcore_OBJECTS) $(paramcore_DEPENDENCIES) @rm -f paramcore$(EXEEXT) $(LINK) $(paramcore_OBJECTS) $(paramcore_LDADD) $(LIBS) params$(EXEEXT): $(params_OBJECTS) $(params_DEPENDENCIES) @rm -f params$(EXEEXT) $(LINK) $(params_OBJECTS) $(params_LDADD) $(LIBS) peter$(EXEEXT): $(peter_OBJECTS) $(peter_DEPENDENCIES) @rm -f peter$(EXEEXT) $(LINK) $(peter_OBJECTS) $(peter_LDADD) $(LIBS) prepare_results$(EXEEXT): $(prepare_results_OBJECTS) $(prepare_results_DEPENDENCIES) @rm -f prepare_results$(EXEEXT) $(LINK) $(prepare_results_OBJECTS) $(prepare_results_LDADD) $(LIBS) prepclose$(EXEEXT): $(prepclose_OBJECTS) $(prepclose_DEPENDENCIES) @rm -f prepclose$(EXEEXT) $(LINK) $(prepclose_OBJECTS) $(prepclose_LDADD) $(LIBS) preperror$(EXEEXT): $(preperror_OBJECTS) $(preperror_DEPENDENCIES) @rm -f preperror$(EXEEXT) $(LINK) $(preperror_OBJECTS) $(preperror_LDADD) $(LIBS) print$(EXEEXT): $(print_OBJECTS) $(print_DEPENDENCIES) @rm -f print$(EXEEXT) $(LINK) $(print_OBJECTS) $(print_LDADD) $(LIBS) putdata$(EXEEXT): $(putdata_OBJECTS) $(putdata_DEPENDENCIES) @rm -f putdata$(EXEEXT) $(LINK) $(putdata_OBJECTS) $(putdata_LDADD) $(LIBS) raiserror$(EXEEXT): $(raiserror_OBJECTS) $(raiserror_DEPENDENCIES) @rm -f raiserror$(EXEEXT) $(LINK) $(raiserror_OBJECTS) $(raiserror_LDADD) $(LIBS) rebindpar$(EXEEXT): $(rebindpar_OBJECTS) $(rebindpar_DEPENDENCIES) @rm -f rebindpar$(EXEEXT) $(LINK) $(rebindpar_OBJECTS) $(rebindpar_LDADD) $(LIBS) rowset$(EXEEXT): $(rowset_OBJECTS) $(rowset_DEPENDENCIES) @rm -f rowset$(EXEEXT) $(LINK) $(rowset_OBJECTS) $(rowset_LDADD) $(LIBS) rpc$(EXEEXT): $(rpc_OBJECTS) $(rpc_DEPENDENCIES) @rm -f rpc$(EXEEXT) $(LINK) $(rpc_OBJECTS) $(rpc_LDADD) $(LIBS) scroll$(EXEEXT): $(scroll_OBJECTS) $(scroll_DEPENDENCIES) @rm -f scroll$(EXEEXT) $(LINK) $(scroll_OBJECTS) $(scroll_LDADD) $(LIBS) stats$(EXEEXT): $(stats_OBJECTS) $(stats_DEPENDENCIES) @rm -f stats$(EXEEXT) $(LINK) $(stats_OBJECTS) $(stats_LDADD) $(LIBS) t0001$(EXEEXT): $(t0001_OBJECTS) $(t0001_DEPENDENCIES) @rm -f t0001$(EXEEXT) $(LINK) $(t0001_OBJECTS) $(t0001_LDADD) $(LIBS) t0002$(EXEEXT): $(t0002_OBJECTS) $(t0002_DEPENDENCIES) @rm -f t0002$(EXEEXT) $(LINK) $(t0002_OBJECTS) $(t0002_LDADD) $(LIBS) t0003$(EXEEXT): $(t0003_OBJECTS) $(t0003_DEPENDENCIES) @rm -f t0003$(EXEEXT) $(LINK) $(t0003_OBJECTS) $(t0003_LDADD) $(LIBS) t0004$(EXEEXT): $(t0004_OBJECTS) $(t0004_DEPENDENCIES) @rm -f t0004$(EXEEXT) $(LINK) $(t0004_OBJECTS) $(t0004_LDADD) $(LIBS) tables$(EXEEXT): $(tables_OBJECTS) $(tables_DEPENDENCIES) @rm -f tables$(EXEEXT) $(LINK) $(tables_OBJECTS) $(tables_LDADD) $(LIBS) test64$(EXEEXT): $(test64_OBJECTS) $(test64_DEPENDENCIES) @rm -f test64$(EXEEXT) $(LINK) $(test64_OBJECTS) $(test64_LDADD) $(LIBS) testodbc$(EXEEXT): $(testodbc_OBJECTS) $(testodbc_DEPENDENCIES) @rm -f testodbc$(EXEEXT) $(LINK) $(testodbc_OBJECTS) $(testodbc_LDADD) $(LIBS) timeout$(EXEEXT): $(timeout_OBJECTS) $(timeout_DEPENDENCIES) @rm -f timeout$(EXEEXT) $(LINK) $(timeout_OBJECTS) $(timeout_LDADD) $(LIBS) timeout2$(EXEEXT): $(timeout2_OBJECTS) $(timeout2_DEPENDENCIES) @rm -f timeout2$(EXEEXT) $(LINK) $(timeout2_OBJECTS) $(timeout2_LDADD) $(LIBS) timeout3$(EXEEXT): $(timeout3_OBJECTS) $(timeout3_DEPENDENCIES) @rm -f timeout3$(EXEEXT) $(LINK) $(timeout3_OBJECTS) $(timeout3_LDADD) $(LIBS) timeout4$(EXEEXT): $(timeout4_OBJECTS) $(timeout4_DEPENDENCIES) @rm -f timeout4$(EXEEXT) $(LINK) $(timeout4_OBJECTS) $(timeout4_LDADD) $(LIBS) transaction$(EXEEXT): $(transaction_OBJECTS) $(transaction_DEPENDENCIES) @rm -f transaction$(EXEEXT) $(LINK) $(transaction_OBJECTS) $(transaction_LDADD) $(LIBS) transaction2$(EXEEXT): $(transaction2_OBJECTS) $(transaction2_DEPENDENCIES) @rm -f transaction2$(EXEEXT) $(LINK) $(transaction2_OBJECTS) $(transaction2_LDADD) $(LIBS) type$(EXEEXT): $(type_OBJECTS) $(type_DEPENDENCIES) @rm -f type$(EXEEXT) $(LINK) $(type_OBJECTS) $(type_LDADD) $(LIBS) typeinfo$(EXEEXT): $(typeinfo_OBJECTS) $(typeinfo_DEPENDENCIES) @rm -f typeinfo$(EXEEXT) $(LINK) $(typeinfo_OBJECTS) $(typeinfo_LDADD) $(LIBS) utf8$(EXEEXT): $(utf8_OBJECTS) $(utf8_DEPENDENCIES) @rm -f utf8$(EXEEXT) $(LINK) $(utf8_OBJECTS) $(utf8_LDADD) $(LIBS) utf8_2$(EXEEXT): $(utf8_2_OBJECTS) $(utf8_2_DEPENDENCIES) @rm -f utf8_2$(EXEEXT) $(LINK) $(utf8_2_OBJECTS) $(utf8_2_LDADD) $(LIBS) warning$(EXEEXT): $(warning_OBJECTS) $(warning_DEPENDENCIES) @rm -f warning$(EXEEXT) $(LINK) $(warning_OBJECTS) $(warning_LDADD) $(LIBS) wchar$(EXEEXT): $(wchar_OBJECTS) $(wchar_DEPENDENCIES) @rm -f wchar$(EXEEXT) $(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_out.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/attributes.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)/cancel.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)/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)/moreandcount.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norowset.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)/peter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prepare_results.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.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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ echo "$$grn$$dashes"; \ else \ echo "$$red$$dashes"; \ fi; \ echo "$$banner"; \ test -z "$$skipped" || echo "$$skipped"; \ test -z "$$report" || echo "$$report"; \ echo "$$dashes$$std"; \ test "$$failed" -eq 0; \ else :; fi 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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." @HAVE_PERL_SOURCES_FALSE@clean-local: clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \ 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 all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool clean-local \ ctags 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 uninstall uninstall-am @HAVE_PERL_SOURCES_TRUE@odbc.dsw: $(top_srcdir)/win32/build_dsw.pl Makefile @HAVE_PERL_SOURCES_TRUE@ rm -rf $@ odbc.mak vc6 @HAVE_PERL_SOURCES_TRUE@ perl $(top_srcdir)/win32/build_dsw.pl $@ $(TESTS) @HAVE_PERL_SOURCES_TRUE@vc6: odbc.dsw @HAVE_PERL_SOURCES_TRUE@clean-local: @HAVE_PERL_SOURCES_TRUE@ rm -rf vc6 # 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-0.91/src/odbc/unittests/array.c100664 001750 000144 00000010702 11414321740 0013616#include "common.h" #include /* Test using array binding */ static char software_version[] = "$Id: array.c,v 1.16 2010/07/05 09:20:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static const char *test_query = NULL; static void * xmalloc(size_t s) { void *p = malloc(s); if (!p) { fprintf(stderr, "Out of memory\n"); exit(1); } return p; } #define XMALLOC_N(t, n) (t*) xmalloc(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); SQLULEN processed; RETCODE ret; char status[20]; int failure = 0; 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 * 132; sprintf((char *) descs[i], "data %d", i * 7); id_lens[i] = 0; desc_lens[i] = SQL_NTS; } if (!prepare) { ret = SQLExecDirect(odbc_stmt, (SQLCHAR *) test_query, SQL_NTS); } else { SQLPrepare(odbc_stmt, (SQLCHAR *) test_query, SQL_NTS); ret = SQLExecute(odbc_stmt); } if (ret != expected) { char buf[256]; sprintf(buf, "Invalid result: got %d exptected %d processed %d", ret, expected, (int) processed); ODBC_REPORT_ERROR(buf); } for (i = 0; i < ARRAY_SIZE; i++) SQLMoreResults(odbc_stmt); if (processed > ARRAY_SIZE) { char buf[256]; sprintf(buf, "Invalid processed number: %d", (int) processed); ODBC_REPORT_ERROR(buf); } for (i = 0; i < processed; ++i) { switch (statuses[i]) { case SQL_PARAM_SUCCESS: case SQL_PARAM_SUCCESS_WITH_INFO: status[i] = 'V'; break; case SQL_PARAM_ERROR: status[i] = '!'; break; case SQL_PARAM_UNUSED: status[i] = ' '; break; case SQL_PARAM_DIAG_UNAVAILABLE: 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); failure = 1; } odbc_reset_statement(); free(ids); free(descs); free(id_lens); free(desc_lens); free(statuses); if (failure) { odbc_disconnect(); exit(1); } } int main(int argc, char *argv[]) { odbc_use_version3 = 1; odbc_connect(); if (odbc_db_is_microsoft()) { test_query = "INSERT INTO #tmp1 (id, value) VALUES (?, ?)"; query_test(0, SQL_ERROR, "VV!!!!!!!!"); /* FIXME test why is different and what should be correct result */ query_test(1, odbc_driver_is_freetds() ? SQL_ERROR : SQL_SUCCESS_WITH_INFO, "VV!!!!!!!!"); test_query = "INSERT INTO #tmp1 (id) VALUES (?) UPDATE #tmp1 SET value = ?"; query_test(0, SQL_SUCCESS_WITH_INFO, "VVVV!V!V!V"); /* FIXME test why is different and what should be correct result */ query_test(1, odbc_driver_is_freetds() ? SQL_ERROR : SQL_SUCCESS_WITH_INFO, "VV!!!!!!!!"); /* with result, see how SQLMoreResult work */ test_query = "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"); #ifdef ENABLE_DEVELOPING query_test(1, SQL_SUCCESS, "VVVVVVVVVV"); #endif } else { /* Sybase test for conversions before executing */ test_query = "INSERT INTO #tmp1 (id, value) VALUES (?/8, ?)"; query_test(0, SQL_SUCCESS, "VVVVVVVVVV"); } /* TODO record binding, array fetch, sqlputdata */ odbc_disconnect(); printf("Success!.\n"); return 0; } freetds-0.91/src/odbc/unittests/common.c100664 001750 000144 00000024651 11414321740 0014000#include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #ifndef _WIN32 #include "tds_sysdep_private.h" #else #define TDS_SDIR_SEPARATOR "\\" #endif static char software_version[] = "$Id: common.c,v 1.59 2010/07/05 09:20:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]; #ifndef _WIN32 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; } #endif /* 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 int odbc_read_login_info(void) { static const char *PWD = "../../../PWD"; FILE *in = NULL; char line[512]; char *s1, *s2; #ifndef _WIN32 char path[1024]; int len; #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); #ifndef _WIN32 /* find our driver */ if (!getcwd(path, sizeof(path))) 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 || strcmp(path + len - 10, "/unittests") != 0) return 0; path[len - 9] = 0; /* TODO this must be extended with all possible systems... */ if (!check_lib(path, ".libs/libtdsodbc.so") && !check_lib(path, ".libs/libtdsodbc.sl") && !check_lib(path, ".libs/libtdsodbc.dll") && !check_lib(path, ".libs/libtdsodbc.dylib") && !check_lib(path, "_libs/libtdsodbc.exe")) return 0; strcpy(odbc_driver, path); /* craft out odbc.ini, avoid to read wrong one */ in = fopen("odbc.ini", "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); } #endif return 0; } void odbc_report_error(const char *errmsg, int line, const char *file) { SQLSMALLINT handletype; SQLHANDLE handle; SQLRETURN ret; unsigned char sqlstate[6]; unsigned char msg[256]; 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, sizeof(msg), NULL); if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) fprintf(stderr, "SQL error %s -- %s\n", sqlstate, msg); odbc_disconnect(); exit(1); } static void ReportODBCError(const char *errmsg, SQLSMALLINT handletype, SQLHANDLE handle, SQLRETURN rc, int line, const char *file) { SQLRETURN ret; unsigned char sqlstate[6]; unsigned char msg[256]; 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, sizeof(msg), NULL); if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) fprintf(stderr, "SQL error %s -- %s\n", sqlstate, msg); odbc_disconnect(); exit(1); } int odbc_connect(void) { char command[512]; 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); if (odbc_set_conn_attr) (*odbc_set_conn_attr)(); CHKR(SQLConnect, (odbc_conn, (SQLCHAR *) odbc_server, SQL_NTS, (SQLCHAR *) odbc_user, SQL_NTS, (SQLCHAR *) odbc_password, SQL_NTS), "SI"); CHKAllocStmt(&odbc_stmt, "S"); sprintf(command, "use %s", odbc_database); printf("%s\n", command); CHKExecDirect((SQLCHAR *) command, SQL_NTS, "SI"); #ifndef TDS_NO_DM /* unixODBC seems to require it */ SQLMoreResults(odbc_stmt); #endif 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; } return 0; } SQLRETURN odbc_command_with_result(HSTMT stmt, const char *command) { printf("%s\n", command); return SQLExecDirect(stmt, (SQLCHAR *) command, SQL_NTS); } static int ms_db = -1; int odbc_db_is_microsoft(void) { char 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(buf, "microsoft") != NULL); } return ms_db; } static int freetds_driver = -1; int odbc_driver_is_freetds(void) { char 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(buf, "tds") != NULL); } return freetds_driver; } static char db_str_version[32]; const char *odbc_db_version(void) { SQLSMALLINT version_len; if (!db_str_version[0]) CHKR(SQLGetInfo, (odbc_conn, SQL_DBMS_VER, db_str_version, sizeof(db_str_version), &version_len), "S"); 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_check_cursor(void) { SQLRETURN retcode; retcode = SQLSetStmtAttr(odbc_stmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); if (retcode != SQL_SUCCESS) { char output[256]; unsigned char sqlstate[6]; CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, (SQLCHAR *) output, sizeof(output), NULL, "S"); sqlstate[5] = 0; if (strcmp((const char*) sqlstate, "01S02") == 0) { printf("Your connection seems to not support cursors, probably you are using wrong protocol version or Sybase\n"); odbc_disconnect(); exit(0); } ReportODBCError("SQLSetStmtAttr", SQL_HANDLE_STMT, odbc_stmt, retcode, __LINE__, __FILE__); } odbc_reset_statement(); } 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) { printf("%s\n", command); return odbc_check_res(file, line, SQLExecDirect(stmt, (SQLCHAR *) command, SQL_NTS), SQL_HANDLE_STMT, stmt, "odbc_command", res); } char odbc_err[512]; char odbc_sqlstate[6]; void odbc_read_error(void) { memset(odbc_err, 0, sizeof(odbc_err)); memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, (SQLCHAR *) odbc_sqlstate, NULL, (SQLCHAR *) odbc_err, sizeof(odbc_err), NULL, "SI"); 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; for (i = 0; i < n; ++i) { assert(src[i] < 256); dst[i] = src[i]; } return n; } freetds-0.91/src/odbc/unittests/common.h100664 001750 000144 00000016150 11437410512 0014001#ifdef _WIN32 #include #include #include #endif #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include static char rcsid_common_h[] = "$Id: common.h,v 1.35 2010/09/01 08:39:38 freddy77 Exp $"; static void *no_unused_common_h_warn[] = { rcsid_common_h, no_unused_common_h_warn }; #ifndef HAVE_SQLLEN #ifndef SQLULEN #define SQLULEN SQLUINTEGER #endif #ifndef SQLLEN #define SQLLEN SQLINTEGER #endif #endif 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); #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 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 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); #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 int odbc_to_sqlwchar(SQLWCHAR *dst, const char *src, int n); int odbc_from_sqlwchar(char *dst, const SQLWCHAR *src, int n); freetds-0.91/src/odbc/unittests/array_out.c100664 001750 000144 00000010535 11446325137 0014522#include "common.h" #include /* Test using array binding */ static char software_version[] = "$Id: array_out.c,v 1.17 2010/09/22 07:03:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 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 *) malloc(sizeof(SQLUINTEGER) * ARRAY_SIZE); descs = malloc(sizeof(SQLCHAR) * ARRAY_SIZE * desc_len); desc_lens = (SQLLEN *) malloc(sizeof(SQLLEN) * ARRAY_SIZE); id_lens = (SQLLEN *) malloc(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 *) malloc(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((SQLCHAR *) 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); } free(ids); if (!record_bind) { free(descs); free(id_lens); free(desc_lens); } } 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-0.91/src/odbc/unittests/attributes.c100664 001750 000144 00000021204 11414321740 0014665#include "common.h" #include /* * SQLSetStmtAttr */ static char software_version[] = "$Id: attributes.c,v 1.6 2010/07/05 09:20:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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) 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-0.91/src/odbc/unittests/binary_test.c100664 001750 000144 00000007127 11414321740 0015032/** * Summary: Freetds binary patch test. * Author: Gerhard Esterhuizen * Date: April 2003 */ #include "common.h" #include static char software_version[] = "$Id: binary_test.c,v 1.9 2010/07/05 09:20:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #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((SQLCHAR *) 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((SQLCHAR *) 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); 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."); 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-0.91/src/odbc/unittests/blob1.c100775 001750 000144 00000023453 11414365233 0013516/* Testing large objects */ /* Test from Sebastien Flaesch */ #include "common.h" #include #include static char software_version[] = "$Id: blob1.c,v 1.23 2010/07/05 14:22:19 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define NBYTES 10000 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"); // printf("out_len %u bufsize %u len2 %u\n", (unsigned) len, (unsigned) bufsize, (unsigned) len2); 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(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((SQLCHAR *) 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((SQLCHAR *) 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-0.91/src/odbc/unittests/cancel.c100664 001750 000144 00000006120 11414321740 0013724/* Testing SQLCancel() */ #include "common.h" /* TODO port to windows, use thread */ #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if defined(TDS_HAVE_PTHREAD_MUTEX) && HAVE_ALARM #include static char sqlstate[SQL_SQLSTATE_SIZE + 1]; static void getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) { SQLRETURN rcode = 0; SQLINTEGER naterror = 0; SQLCHAR msgtext[SQL_MAX_MESSAGE_LENGTH + 1]; SQLSMALLINT msgtextl = 0; msgtext[0] = 0; rcode = SQLGetDiagRec((SQLSMALLINT) sqlhdltype, (SQLHANDLE) sqlhandle, (SQLSMALLINT) 1, (SQLCHAR *) sqlstate, (SQLINTEGER *) & naterror, (SQLCHAR *) msgtext, (SQLSMALLINT) sizeof(msgtext), (SQLSMALLINT *) & msgtextl); sqlstate[sizeof(sqlstate)-1] = 0; fprintf(stderr, "Diagnostic info:\n"); fprintf(stderr, " SQL State: %s\n", sqlstate); fprintf(stderr, " SQL code : %d\n", (int) naterror); fprintf(stderr, " Message : %s\n", (char *) msgtext); } static void exit_forced(int s) { exit(1); } static void sigalrm_handler(int s) { printf(">>>> SQLCancel() ...\n"); CHKCancel("S"); printf(">>>> ... SQLCancel done\n"); alarm(4); signal(SIGALRM, exit_forced); } volatile int exit_thread; static void * wait_thread_proc(void * arg) { int n; sleep(4); printf(">>>> SQLCancel() ...\n"); CHKCancel("S"); printf(">>>> ... SQLCancel done\n"); for (n = 0; n < 4; ++n) { sleep(1); if (exit_thread) return NULL; } exit_forced(0); return NULL; } static void Test(int use_threads) { pthread_t wait_thread; 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 = pthread_create(&wait_thread, NULL, wait_thread_proc, NULL); if (err != 0) { perror("pthread_create"); exit(1); } } CHKExecDirect((SQLCHAR *) "WAITFOR DELAY '000:05:00'", SQL_NTS, "E"); exit_thread = 1; if (!use_threads) { alarm(0); } else { pthread_join(wait_thread, NULL); } getErrorInfo(SQL_HANDLE_STMT, odbc_stmt); if (strcmp(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 (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(); Test(0); Test(1); odbc_disconnect(); return 0; } #else int main(void) { printf("Not possible for this platform.\n"); return 0; } #endif freetds-0.91/src/odbc/unittests/compute.c100664 001750 000144 00000012156 11414321740 0014161#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 software_version[] = "$Id: compute.c,v 1.13 2010/07/05 09:20:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static char col1[256], col2[256]; static SQLLEN ind1, ind2; static int main_line; static void TestName(SQLSMALLINT index, const char *expected_name) { char name[128]; char buf[256]; SQLSMALLINT len, type; #define NAME_TEST \ do { \ if (strcmp(name, expected_name) != 0) \ { \ sprintf(buf, "line %d: wrong name in column %d expected '%s' got '%s'", \ main_line, index, expected_name, name); \ ODBC_REPORT_ERROR(buf); \ } \ } while(0) /* retrieve with SQLDescribeCol */ CHKDescribeCol(index, (SQLCHAR *) name, sizeof(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; } 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(); 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-0.91/src/odbc/unittests/connect.c100664 001750 000144 00000007030 11421036157 0014134#include "common.h" static char software_version[] = "$Id: connect.c,v 1.14 2010/07/19 11:52:15 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &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, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &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 */ 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, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &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); rc = CHKDriverConnect(NULL, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &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-0.91/src/odbc/unittests/connect2.c100664 001750 000144 00000005261 11414321740 0014217#include "common.h" /* * Test setting current "catalog" before and after connection using * either SQLConnect and SQLDriverConnect */ static char software_version[] = "$Id: connect2.c,v 1.8 2010/07/05 09:20:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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) { CHKR(SQLConnect, (odbc_conn, (SQLCHAR *) odbc_server, SQL_NTS, (SQLCHAR *) odbc_user, SQL_NTS, (SQLCHAR *) odbc_password, SQL_NTS), "SI"); } static void driver_connect(const char *conn_str) { char tmp[1024]; SQLSMALLINT len; CHKDriverConnect(NULL, (SQLCHAR *) conn_str, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT, "SI"); } static void check_dbname(const char *dbname) { SQLINTEGER len; char out[512]; len = sizeof(out); CHKGetConnectAttr(SQL_ATTR_CURRENT_CATALOG, (SQLPOINTER) out, sizeof(out), &len, "SI"); if (strcmp(out, dbname) != 0) { fprintf(stderr, "Current database (%s) is not %s\n", out, dbname); failed = 1; } } static void set_dbname(const char *dbname) { CHKSetConnectAttr(SQL_ATTR_CURRENT_CATALOG, (SQLPOINTER) dbname, strlen(dbname), "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-0.91/src/odbc/unittests/const_params.c100664 001750 000144 00000007016 11414321740 0015175#include "common.h" /* Test for {?=call store(?,123,'foo')} syntax and run */ static char software_version[] = "$Id: const_params.c,v 1.18 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[]) { 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((SQLCHAR *) "{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((SQLCHAR *) "{?=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((SQLCHAR *) "{?=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-0.91/src/odbc/unittests/convert_error.c100664 001750 000144 00000003175 11414321740 0015377/* * 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.11 2010/07/05 09:20:32 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; SQLFreeStmt(odbc_stmt, SQL_RESET_PARAMS); ++test_num; sprintf(sql, "insert into #test_output values (%s, %s)", bind1, bind2); CHKPrepare((SQLCHAR *) 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"); } 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-0.91/src/odbc/unittests/copydesc.c100664 001750 000144 00000001712 11414321740 0014312#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-0.91/src/odbc/unittests/cursor1.c100664 001750 000144 00000012512 11414321740 0014077#include "common.h" /* Test cursors */ static char software_version[] = "$Id: cursor1.c,v 1.20 2010/07/05 09:20:32 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 int mssql2005 = 0; static void CheckNoRow(const char *query) { SQLRETURN rc; rc = CHKExecDirect((SQLCHAR *) 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); } 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((SQLCHAR *) "C1", SQL_NTS, "S"); /* */ CHKExecDirect((SQLCHAR *) 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) { if (mssql2005) CHKSetPos(i, use_sql ? SQL_POSITION : SQL_DELETE, SQL_LOCK_NO_CHANGE, "SI"); else CHKSetPos(i, use_sql ? SQL_POSITION : SQL_DELETE, SQL_LOCK_NO_CHANGE, "S"); if (use_sql) { SWAP_STMT(stmt2); CHKPrepare((SQLCHAR *) "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 { unsigned char sqlstate[6]; unsigned char 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, sizeof(msg), NULL, "S"); if (strstr((char *) 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((SQLCHAR *) "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 */ CheckNoRow("IF (SELECT COUNT(*) FROM #test) <> 4 SELECT 1"); CheckNoRow("IF NOT EXISTS(SELECT * FROM #test WHERE i = 3 AND c = 'ccc') SELECT 1"); CheckNoRow("IF NOT EXISTS(SELECT * FROM #test WHERE i = 4 AND c = 'dddd') SELECT 1"); if (strstr(select_sql, "#a") == NULL || use_sql) { CheckNoRow("IF NOT EXISTS(SELECT * FROM #test WHERE i = 2 AND c = 'foo') SELECT 1"); CheckNoRow("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-0.91/src/odbc/unittests/cursor2.c100664 001750 000144 00000002450 11422052216 0014076#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.11 2010/07/22 14:24:14 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { unsigned char sqlstate[6]; unsigned char 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, sizeof(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-0.91/src/odbc/unittests/cursor3.c100664 001750 000144 00000006175 11414321740 0014111/* Tests 2 active statements */ #include "common.h" static char software_version[] = "$Id: cursor3.c,v 1.10 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) { 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((SQLCHAR *) "c1", SQL_NTS, "S"); odbc_stmt = stmt2; CHKSetCursorName((SQLCHAR *) "c2", SQL_NTS, "S"); odbc_stmt = stmt1; CHKPrepare((SQLCHAR *) "SELECT * FROM #t1 ORDER BY k", SQL_NTS, "S"); odbc_stmt = stmt2; CHKPrepare((SQLCHAR *) "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-0.91/src/odbc/unittests/cursor4.c100775 001750 000144 00000003223 11414321741 0014105/* 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* AIP Server Cursors ... */ #include "common.h" static char software_version[] = "$Id: cursor4.c,v 1.9 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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((SQLCHAR *) "c112", SQL_NTS, "S"); CHKPrepare((SQLCHAR *) "SELECT * FROM #t1 FOR UPDATE", SQL_NTS, "S"); exec_direct("BEGIN TRANSACTION"); CHKExecute("S"); CHKFetch("S"); exec_direct("UPDATE #t1 SET c = 'xxx' WHERE CURRENT OF c112"); CHKCloseCursor("SI"); exec_direct("COMMIT TRANSACTION"); CHKExecDirect((SQLCHAR *) "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-0.91/src/odbc/unittests/cursor5.c100775 001750 000144 00000003706 11414321741 0014114#include "common.h" static char software_version[] = "$Id: cursor5.c,v 1.10 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static SQLINTEGER v_int_3; static SQLLEN v_ind_3_1; static char v_char_3[21]; static SQLLEN v_ind_3_2; static void doFetch(int dir, int pos) { 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); } 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((SQLCHAR *) "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); doFetch(SQL_FETCH_PRIOR, 0); doFetch(SQL_FETCH_PRIOR, 0); doFetch(SQL_FETCH_PRIOR, 0); doFetch(SQL_FETCH_NEXT, 0); doFetch(SQL_FETCH_NEXT, 0); doFetch(SQL_FETCH_NEXT, 0); doFetch(SQL_FETCH_NEXT, 0); doFetch(SQL_FETCH_FIRST, 0); doFetch(SQL_FETCH_NEXT, 0); doFetch(SQL_FETCH_NEXT, 0); doFetch(SQL_FETCH_ABSOLUTE, 3); doFetch(SQL_FETCH_RELATIVE, -2); doFetch(SQL_FETCH_RELATIVE, -2); doFetch(SQL_FETCH_RELATIVE, 5); CHKCloseCursor("SI"); odbc_disconnect(); return 0; } freetds-0.91/src/odbc/unittests/cursor6.c100775 001750 000144 00000005415 11414321741 0014114#include "common.h" /* Test SQLFetchScroll with no binded columns */ static char software_version[] = "$Id: cursor6.c,v 1.6 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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]; SQLULEN 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((SQLCHAR *) "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 = 0xdeadbeef; data[1].i = 0xdeadbeef; if (normal_fetch) CHKFetch("S"); else CHKFetchScroll(SQL_FETCH_NEXT, 0, "S"); /* now check row numbers */ printf("num_row %d statuses[0] %d statuses[1] %d odbc3 %d\n", (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-0.91/src/odbc/unittests/cursor7.c100664 001750 000144 00000004715 11414321741 0014114#include "common.h" /* Test SQLFetchScroll with a non-unitary rowset, using bottom-up direction */ static char software_version[] = "$Id: cursor7.c,v 1.9 2010/07/05 09:20:33 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((SQLCHAR *) "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 /* Test various bind type */ /* * 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 char software_version[] = "$Id: data.c,v 1.38 2011/01/17 22:05:37 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int result = 0; static char sbuf[1024]; static int ignore_select_error = 0; static void Test(const char *type, const char *value_to_convert, SQLSMALLINT out_c_type, const char *expected) { unsigned char out_buf[256]; SQLLEN out_len = 0; SQL_NUMERIC_STRUCT *num; SQLWCHAR *wp; int i; 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(); return; } } else { odbc_command(sbuf); } ignore_select_error = 0; SQLBindCol(odbc_stmt, 1, out_c_type, out_buf, sizeof(out_buf), &out_len); CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); /* test results */ sbuf[0] = 0; switch (out_c_type) { case SQL_C_NUMERIC: num = (SQL_NUMERIC_STRUCT *) out_buf; sprintf(sbuf, "%d %d %d ", num->precision, num->scale, num->sign); i = SQL_MAX_NUMERIC_LEN; for (; i > 0 && !num->val[--i];); for (; i >= 0; --i) sprintf(strchr(sbuf, 0), "%02X", num->val[i]); break; case SQL_C_BINARY: assert(out_len >= 0); for (i = 0; i < out_len; ++i) sprintf(strchr(sbuf, 0), "%02X", (int) out_buf[i]); break; case SQL_C_CHAR: out_buf[sizeof(out_buf) - 1] = 0; sprintf(sbuf,"%u %s", (unsigned int) strlen((char *) out_buf), out_buf); break; case SQL_C_WCHAR: assert(out_len >=0 && (out_len % sizeof(SQLWCHAR)) == 0); sprintf(sbuf, "%u ", (unsigned int) (out_len / sizeof(SQLWCHAR))); wp = (SQLWCHAR*) out_buf; for (i = 0; i < out_len / sizeof(SQLWCHAR); ++i) if ((unsigned int) wp[i] < 256) sprintf(strchr(sbuf, 0), "%c", (char) wp[i]); else sprintf(strchr(sbuf, 0), "\\u%04x", (unsigned int) wp[i]); break; case SQL_C_LONG: assert(out_len == sizeof(SQLINTEGER)); sprintf(sbuf, "%ld", (long int) *((SQLINTEGER *) out_buf)); break; default: /* not supported */ assert(0); break; } if (strcmp(sbuf, expected) != 0) { fprintf(stderr, "Wrong result\n Got: %s\n Expected: %s\n", sbuf, expected); result = 1; } } int main(int argc, char *argv[]) { int big_endian = 1; odbc_connect(); if (((char *) &big_endian)[0] == 1) big_endian = 0; Test("NUMERIC(18,2)", "123", SQL_C_NUMERIC, "38 0 1 7B"); /* all binary results */ /* cases (2) */ Test("CHAR(7)", "pippo", SQL_C_BINARY, "706970706F2020"); Test("TEXT", "mickey", SQL_C_BINARY, "6D69636B6579"); Test("VARCHAR(20)", "foo", SQL_C_BINARY, "666F6F"); Test("BINARY(5)", "qwer", SQL_C_BINARY, "7177657200"); Test("IMAGE", "cricetone", SQL_C_BINARY, "6372696365746F6E65"); Test("VARBINARY(20)", "teo", SQL_C_BINARY, "74656F"); /* TODO only MS ?? */ if (odbc_db_is_microsoft()) Test("TIMESTAMP", "abcdefghi", SQL_C_BINARY, "6162636465666768"); Test("DATETIME", "2004-02-24 15:16:17", SQL_C_BINARY, big_endian ? "0000949700FBAA2C" : "979400002CAAFB00"); Test("SMALLDATETIME", "2004-02-24 15:16:17", SQL_C_BINARY, big_endian ? "94970394" : "97949403"); Test("BIT", "1", SQL_C_BINARY, "01"); Test("BIT", "0", SQL_C_BINARY, "00"); Test("TINYINT", "231", SQL_C_BINARY, "E7"); Test("SMALLINT", "4321", SQL_C_BINARY, big_endian ? "10E1" : "E110"); Test("INT", "1234567", SQL_C_BINARY, big_endian ? "0012D687" : "87D61200"); if ((odbc_db_is_microsoft() && odbc_db_version_int() >= 0x08000000u) || (!odbc_db_is_microsoft() && strncmp(odbc_db_version(), "15.00.", 6) >= 0)) { int old_result = result; Test("BIGINT", "123456789012345", SQL_C_BINARY, big_endian ? "00007048860DDF79" : "79DF0D8648700000"); if (result && strcmp(sbuf, "13000179DF0D86487000000000000000000000") == 0) { fprintf(stderr, "Ignore previous error. You should configure TDS 8.0 for this!!!\n"); if (!old_result) result = 0; } } Test("INT", "-123", SQL_C_CHAR, "4 -123"); Test("INT", "78654", SQL_C_WCHAR, "5 78654"); Test("VARCHAR(10)", " 51245 ", SQL_C_LONG, "51245"); Test("VARCHAR(20)", " 15.1245 ", SQL_C_NUMERIC, "38 0 1 0F"); Test("VARCHAR(20)", " 15 ", SQL_C_NUMERIC, "38 0 1 0F"); if (odbc_db_is_microsoft() && (strncmp(odbc_db_version(), "08.00.", 6) == 0 || strncmp(odbc_db_version(), "09.00.", 6) == 0)) { /* nvarchar without extended characters */ Test("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 (odbc_driver_is_freetds()) Test("NVARCHAR(20)", "0x830068006900f200", SQL_C_CHAR, "4 \x83hi\xf2"); Test("VARCHAR(20)", "test", SQL_C_WCHAR, "4 test"); /* nvarchar with extended characters */ Test("NVARCHAR(20)", "0x830068006900f200", SQL_C_WCHAR, "4 \x83hi\xf2"); Test("NVARCHAR(20)", "0xA406A5FB", SQL_C_WCHAR, "2 \\u06a4\\ufba5"); /* NVARCHAR -> SQL_C_LONG */ Test("NVARCHAR(20)", "-24785 ", SQL_C_LONG, "-24785"); } ignore_select_error = 1; Test("UNIVARCHAR(10)", "u&'\\06A4\\FBA5'", SQL_C_WCHAR, "2 \\u06a4\\ufba5"); /* case (1) */ Test("DECIMAL", "1234.5678", SQL_C_BINARY, "120001D3040000000000000000000000000000"); Test("NUMERIC", "8765.4321", SQL_C_BINARY, "1200013D220000000000000000000000000000"); Test("FLOAT", "1234.5678", SQL_C_BINARY, big_endian ? "40934A456D5CFAAD" : "ADFA5C6D454A9340"); Test("REAL", "8765.4321", SQL_C_BINARY, big_endian ? "4608F5BA" : "BAF50846"); Test("SMALLMONEY", "765.4321", SQL_C_BINARY, big_endian ? "0074CBB1" : "B1CB7400"); Test("MONEY", "4321234.5678", SQL_C_BINARY, big_endian ? "0000000A0FA8114E" : "0A0000004E11A80F"); /* behavior is different from MS ODBC */ if (odbc_db_is_microsoft()) { Test("NCHAR(7)", "donald", SQL_C_BINARY, "64006F006E0061006C0064002000"); Test("NTEXT", "duck", SQL_C_BINARY, "6400750063006B00"); Test("NVARCHAR(20)", "daffy", SQL_C_BINARY, "64006100660066007900"); } if (odbc_db_is_microsoft()) Test("UNIQUEIDENTIFIER", "0DDF3B64-E692-11D1-AB06-00AA00BDD685", SQL_C_BINARY, big_endian ? "0DDF3B64E69211D1AB0600AA00BDD685" : "643BDF0D92E6D111AB0600AA00BDD685"); /* case (4) */ Test("DATETIME", "2006-06-09 11:22:44", SQL_C_CHAR, "23 2006-06-09 11:22:44.000"); Test("SMALLDATETIME", "2006-06-12 22:37:21", SQL_C_CHAR, "19 2006-06-12 22:37:00"); Test("DATETIME", "2006-06-09 11:22:44", SQL_C_WCHAR, "23 2006-06-09 11:22:44.000"); Test("SMALLDATETIME", "2006-06-12 22:37:21", SQL_C_WCHAR, "19 2006-06-12 22:37:00"); if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x08000000u) { Test("SQL_VARIANT", "CAST('123' AS INT)", SQL_C_CHAR, "3 123"); Test("SQL_VARIANT", "CAST('hello' AS CHAR(6))", SQL_C_CHAR, "6 hello "); Test("SQL_VARIANT", "CAST('ciao' AS VARCHAR(10))", SQL_C_CHAR, "4 ciao"); Test("SQL_VARIANT", "CAST('foo' AS NVARCHAR(10))", SQL_C_CHAR, "3 foo"); Test("SQL_VARIANT", "CAST('Super' AS NCHAR(8))", SQL_C_CHAR, "8 Super "); Test("SQL_VARIANT", "CAST('321' AS VARBINARY(10))", SQL_C_CHAR, "6 333231"); /* for some reasons MS ODBC seems to convert -123.4 to -123.40000000000001 */ Test("SQL_VARIANT", "CAST('-123.5' AS FLOAT)", SQL_C_CHAR, "6 -123.5"); Test("SQL_VARIANT", "CAST('-123.4' AS NUMERIC(10,2))", SQL_C_CHAR, "7 -123.40"); Test("SQL_VARIANT", "CAST('0DDF3B64-E692-11D1-AB06-00AA00BDD685' AS UNIQUEIDENTIFIER)", SQL_C_CHAR, "36 0DDF3B64-E692-11D1-AB06-00AA00BDD685"); } if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x09000000u) { Test("VARCHAR(MAX)", "goodbye!", SQL_C_CHAR, "8 goodbye!"); Test("NVARCHAR(MAX)", "Micio mao", SQL_C_CHAR, "9 Micio mao"); Test("VARBINARY(MAX)", "ciao", SQL_C_BINARY, "6369616F"); Test("XML", "ciaohi", SQL_C_CHAR, "28 ciaohi"); /* XML with schema */ odbc_command("IF EXISTS(SELECT * FROM sys.xml_schema_collections WHERE [name] = 'test_schema') DROP XML SCHEMA COLLECTION test_schema"); odbc_command("CREATE XML SCHEMA COLLECTION test_schema AS ''"); Test("XML(test_schema)", "ciao", SQL_C_CHAR, "17 ciao"); odbc_command("DROP XML SCHEMA COLLECTION test_schema"); } if (!odbc_db_is_microsoft() && strncmp(odbc_db_version(), "15.00.", 6) >= 0) { /* FIXME sure ?? with date and time always ?? */ Test("DATE", "1923-12-02", SQL_C_CHAR, "23 1923-12-02 00:00:00.000"); Test("TIME", "12:23:45", SQL_C_CHAR, "23 1900-01-01 12:23:45.000"); } odbc_disconnect(); if (!result) printf("Done successfully!\n"); return result; } freetds-0.91/src/odbc/unittests/date.c100664 001750 000144 00000002263 11414321741 0013421#include "common.h" static char software_version[] = "$Id: date.c,v 1.13 2010/07/05 09:20:33 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, output, sizeof(output), 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-0.91/src/odbc/unittests/descrec.c100664 001750 000144 00000002177 11414321741 0014120/* test SQLGetDescRec */ #include "common.h" static char software_version[] = "$Id: descrec.c,v 1.2 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(void) { SQLHDESC Descriptor; SQLINTEGER ind; SQLCHAR 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, sizeof(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, sizeof(name), &si, NULL /*Type*/, NULL /*SubType*/, NULL /*Length*/, NULL/*Precision*/, NULL /*Scale*/, NULL /*Nullable*/, "No"); odbc_command("SELECT name FROM sysobjects"); CHKGetDescRec(1, name, sizeof(name), &si, NULL /*Type*/, NULL /*SubType*/, NULL /*Length*/, NULL/*Precision*/, NULL /*Scale*/, NULL /*Nullable*/, "S"); odbc_disconnect(); return 0; } freetds-0.91/src/odbc/unittests/describecol.c100664 001750 000144 00000021174 11426207361 0014770#include "common.h" #include /* * SQLDescribeCol test for precision * test what say SQLDescribeCol about precision using some type */ static char software_version[] = "$Id: describecol.c,v 1.19 2010/08/04 06:55:45 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 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), #undef TYPE { 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) #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, 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[128]; SQLSMALLINT len; ret = SQLColAttribute(odbc_stmt, 1, attr->value, buf, sizeof(buf), &len, NULL); if (!SQL_SUCCEEDED(ret)) fatal("Line %u: failure not expected\n", line_num); buf[sizeof(buf)-1] = 0; if (strcmp(buf, expected_value) != 0) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %s expected %s\n", 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)) fatal("Line %u: failure not expected\n", line_num); /* SQL_DESC_LENGTH is the same of SQLDescribeCol len */ if (attr->value == SQL_DESC_LENGTH) { SQLSMALLINT si; SQLULEN li; CHKDescribeCol(1, NULL, 0, NULL, &si, &li, &si, &si, "S"); if (i != li) fatal("Line %u: attr %s SQLDescribeCol len %ld != SQLColAttribute len %ld\n", line_num, attr->name, (long) li, (long) i); } if (i != lookup(expected_value, attr->lookup)) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %ld expected %s\n", line_num, attr->name, (long int) i, 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[128]; /* 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); break; case type_SMALLINT: si = 0xbeef; ret = SQLGetDescField(desc, 1, attr->value, (SQLPOINTER) & si, sizeof(SQLSMALLINT), &ind); i = si; break; case type_LEN: li = 0xdeadbeef; ret = SQLGetDescField(desc, 1, attr->value, (SQLPOINTER) & li, sizeof(SQLLEN), &ind); i = li; break; case type_CHARP: ret = SQLGetDescField(desc, 1, attr->value, buf, sizeof(buf), &ind); if (!SQL_SUCCEEDED(ret)) fatal("Line %u: failure not expected\n", line_num); if (strcmp(buf, expected_value) != 0) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %s expected %s\n", line_num, attr->name, buf, expected_value); } return; } if (!SQL_SUCCEEDED(ret)) fatal("Line %u: failure not expected\n", line_num); if (i != lookup(expected_value, attr->lookup)) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %ld expected %s\n", line_num, attr->name, (long int) i, 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[]) { #define TEST_FILE "describecol.in" const char *in_file = FREETDS_SRCDIR "/" TEST_FILE; FILE *f; char buf[256]; SQLINTEGER i; SQLLEN len; check_attr_t check_attr_p = check_attr_none; odbc_connect(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); f = fopen(in_file, "r"); if (!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); } } /* select type */ if (strcmp(cmd, "select") == 0) { const char *type = strtok(NULL, SEP); const char *value = strtok(NULL, SEP); char sql[sizeof(buf) + 40]; SQLMoreResults(odbc_stmt); odbc_reset_statement(); sprintf(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(strtok(NULL, SEP)); char *value = strtok(NULL, SEP); SQLHDESC desc; SQLRETURN ret; SQLINTEGER ind; if (!value) fatal("Line %u: value not defined\n", line_num); /* 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)) fatal("Line %u: failure not expected setting ARD attribute\n", line_num); check_attr_p = check_attr_ard; } /* test attribute */ if (strcmp(cmd, "attr") == 0) { const struct attribute *attr = lookup_attr(strtok(NULL, SEP)); char *expected = strtok(NULL, SEP); if (!expected) fatal("Line %u: value not defined\n", line_num); check_attr_p(attr, expected); } } fclose(f); odbc_disconnect(); printf("Done.\n"); return g_result; } freetds-0.91/src/odbc/unittests/earlybind.c100664 001750 000144 00000003076 11414321741 0014460#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-0.91/src/odbc/unittests/error.c100664 001750 000144 00000002640 11414321741 0013634#include "common.h" /* some tests on error reporting */ static char software_version[] = "$Id: error.c,v 1.11 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[]) { SQLRETURN RetCode; HSTMT stmt, tmp_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"); tmp_stmt = odbc_stmt; odbc_stmt = stmt; /* a statement is already active so you get error */ odbc_command2("SELECT * FROM sysobjects", "E"); odbc_read_error(); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-0.91/src/odbc/unittests/freeclose.c100664 001750 000144 00000024016 11437410512 0014453#include "common.h" /* TODO port to windows, use thread */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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_HAVE_PTHREAD_MUTEX) && HAVE_ALARM && HAVE_FSTAT && defined(S_IFSOCK)) || defined(_WIN32) #include #if HAVE_PTHREAD #include #endif #include "tds.h" static char software_version[] = "$Id: freeclose.c,v 1.14 2010/09/01 08:39:38 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* this crazy test test that we do not send too much prepare ... */ #ifndef _WIN32 static int find_last_socket(void) { int max_socket = -1, i; for (i = 3; i < 1024; ++i) { struct stat file_stat; if (fstat(i, &file_stat)) continue; if ((file_stat.st_mode & S_IFSOCK) == S_IFSOCK) max_socket = i; } return max_socket; } #else static TDS_SYS_SOCKET find_last_socket(void) { TDS_SYS_SOCKET max_socket = INVALID_SOCKET; int i; for (i = 4; i <= (4096*4); i += 4) { struct sockaddr addr; socklen_t addr_len; if (tds_getpeername((TDS_SYS_SOCKET) i, &addr, &addr_len)) continue; max_socket = (TDS_SYS_SOCKET) i; } return max_socket; } #endif static struct sockaddr remote_addr; static socklen_t remote_addr_len; static TDS_SYS_SOCKET fake_sock; #ifndef _WIN32 static pthread_t fake_thread; #define THREADAPI #define THREADRET void* #else static HANDLE fake_thread; #define THREADAPI WINAPI #define THREADRET DWORD #define pthread_join(th,fl) WaitForSingleObject(th,INFINITE) #define alarm(n) do { ; } while(0) #endif static THREADRET THREADAPI fake_thread_proc(void *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 = 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); #ifndef _WIN32 if (pthread_create(&fake_thread, NULL, fake_thread_proc, int2ptr(s)) != 0) { perror("pthread_create"); exit(1); } #else fake_thread = CreateThread(NULL, 0, fake_thread_proc, int2ptr(s), 0, NULL); if (!fake_thread) { fprintf(stderr, "CreateThread error %u\n", (unsigned) GetLastError()); exit(1); } #endif 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) { ++inserts; /* 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 THREADRET THREADAPI fake_thread_proc(void * arg) { TDS_SYS_SOCKET s = ptr2int(arg), server_sock; socklen_t len; char buf[128]; struct sockaddr_in sin; fd_set fds_read, fds_write, fds_error; int max_fd = 0; memset(&sin, 0, sizeof(sin)); len = sizeof(sin); alarm(30); if ((fake_sock = tds_accept(s, (struct sockaddr *) &sin, &len)) < 0) { perror("accept"); exit(1); } CLOSESOCKET(s); if (TDS_IS_SOCKET_INVALID(server_sock = socket(AF_INET, SOCK_STREAM, 0))) { perror("socket"); exit(1); } if (connect(server_sock, &remote_addr, remote_addr_len)) { perror("socket"); 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) ++round_trips; flow = sending; len = READSOCKET(fake_sock, buf, sizeof(buf)); if (len == 0) break; if (len < 0 && sock_errno != TDSSOCK_EINPROGRESS) break; count_insert(buf, len); write_all(server_sock, buf, len); } if (FD_ISSET(server_sock, &fds_read)) { if (flow != receiving) ++round_trips; flow = receiving; len = READSOCKET(server_sock, buf, sizeof(buf)); if (len == 0) break; if (len < 0 && sock_errno != TDSSOCK_EINPROGRESS) break; write_all(fake_sock, buf, len); } } CLOSESOCKET(fake_sock); CLOSESOCKET(server_sock); return (THREADRET) 0; } 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 odbc_connect(); last_socket = 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, &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 binded 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, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &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 */ round_trips = 0; inserts = 0; 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((SQLCHAR *) query, SQL_NTS, "SI"); printf("%u round trips %u inserts\n", round_trips, inserts); for (id = 0; id < num_inserts; id++) { sprintf(string, "This is a test (%d)", (int) id); CHKExecute("SI"); CHKFreeStmt(SQL_CLOSE, "S"); } printf("%u round trips %u inserts\n", round_trips, inserts); odbc_reset_statement(); if (inserts > 1 || round_trips > num_inserts * 2 + 6) { fprintf(stderr, "Too much round trips (%u) or insert (%u) !!!\n", round_trips, inserts); return 1; } printf("%u round trips %u inserts\n", round_trips, inserts); #ifdef ENABLE_DEVELOPING /* check for SQL_RESET_PARAMS */ round_trips = 0; inserts = 0; 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"); printf("%u round trips %u inserts\n", round_trips, inserts); 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"); } printf("%u round trips %u inserts\n", round_trips, inserts); odbc_reset_statement(); if (inserts > 1 || round_trips > num_inserts * 2 + 6) { fprintf(stderr, "Too much round trips (%u) or insert (%u) !!!\n", round_trips, inserts); return 1; } printf("%u round trips %u inserts\n", round_trips, inserts); #endif odbc_disconnect(); alarm(10); pthread_join(fake_thread, NULL); return 0; } #else int main(void) { printf("Not possible for this platform.\n"); return 0; } #endif freetds-0.91/src/odbc/unittests/funccall.c100664 001750 000144 00000011111 11414321741 0014263#include "common.h" /* Test for {?=call store(?)} syntax and run */ static char software_version[] = "$Id: funccall.c,v 1.18 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 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((SQLCHAR *) "{ \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); } /* 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((SQLCHAR *) "{?=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((SQLCHAR *) "{ \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; 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_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((SQLCHAR *) "{ ? = 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((SQLCHAR *) "{ 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(); printf("Done.\n"); return 0; } freetds-0.91/src/odbc/unittests/genparams.c100664 001750 000144 00000043035 11462505232 0014465#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 */ static char software_version[] = "$Id: genparams.c,v 1.47 2010/10/29 08:49:30 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #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 void 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; SQL_NUMERIC_STRUCT *num; int i; 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((SQLCHAR *) "{call spTestProc(?)}", SQL_NTS, "S"); } else { if (prepare_before) CHKPrepare((SQLCHAR *) "{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((SQLCHAR *) "{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 */ sbuf[0] = 0; switch (out_c_type) { case SQL_C_NUMERIC: num = (SQL_NUMERIC_STRUCT *) out_buf; sprintf(sbuf, "%d %d %d ", num->precision, num->scale, num->sign); i = SQL_MAX_NUMERIC_LEN; for (; i > 0 && !num->val[--i];); for (; i >= 0; --i) sprintf(strchr(sbuf, 0), "%02X", num->val[i]); break; case SQL_C_BINARY: assert(out_len >= 0); for (i = 0; i < out_len; ++i) sprintf(strchr(sbuf, 0), "%02X", (int) out_buf[i]); break; case SQL_C_CHAR: sprintf(sbuf, "%d %s", (int) out_len, out_buf); break; default: /* not supported */ assert(0); break; } if (strcmp(sbuf, expected) != 0) { fprintf(stderr, "Wrong result\n Got: %s\n Expected: %s\n", sbuf, expected); exit(1); } odbc_command("drop proc spTestProc"); } 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((SQLCHAR *) sbuf, SQL_NTS, "E"); else CHKExecDirect((SQLCHAR *) sbuf, SQL_NTS, "SNo"); } else { if (prepare_before) CHKPrepare((SQLCHAR *) 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((SQLCHAR *) 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"); } /* 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((SQLCHAR *) sbuf, SQL_NTS, "SNo"); } else { if (prepare_before) CHKPrepare((SQLCHAR *) 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((SQLCHAR *) 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 col LIKE ''"); else odbc_command("SELECT * FROM #tmp_insert WHERE col IS NULL"); CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); odbc_command("DROP TABLE #tmp_insert"); } static int big_endian = 1; 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"); /* 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, big_endian ? "0000949700FBAA2C" : "979400002CAAFB00"); TestOutput("SMALLDATETIME", "2004-02-24 15:16:17", SQL_C_BINARY, SQL_TIMESTAMP, big_endian ? "0000949700FB9640" : "979400004096FB00"); 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 */ TestOutput("VARCHAR(20)", "0xf8f9", SQL_C_CHAR, SQL_VARCHAR, "2 \xf8\xf9"); if ((odbc_db_is_microsoft() && odbc_db_version_int() >= 0x08000000u) || (!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(); 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-0.91/src/odbc/unittests/getdata.c100664 001750 000144 00000013214 11414321741 0014113#include "common.h" #include static char software_version[] = "$Id: getdata.c,v 1.18 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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); } int main(int argc, char *argv[]) { char buf[32]; SQLINTEGER int_buf; SQLLEN len; SQLRETURN rc; odbc_connect(); lc = 1; type = SQL_C_CHAR; for (;;) { /* TODO test with VARCHAR too */ odbc_command("SELECT CONVERT(TEXT,'Prova')"); CHKFetch("S"); /* these 2 tests test an old severe BUG in FreeTDS */ CHKGetData(1, type, buf, 0, NULL, "I"); CHKGetData(1, type, buf, 0, NULL, "I"); CHKGetData(1, type, buf, 3 * lc, NULL, "I"); if (mycmp(buf, "Pr") != 0) { printf("Wrong data result 1\n"); exit(1); } CHKGetData(1, type, buf, 16, NULL, "S"); if (mycmp(buf, "ova") != 0) { printf("Wrong data result 2 res = '%s'\n", buf); exit(1); } odbc_reset_statement(); /* test with varchar, not blob but variable */ odbc_command("SELECT CONVERT(VARCHAR(100), 'Other test')"); CHKFetch("S"); CHKGetData(1, type, buf, 7 * lc, NULL, "I"); if (mycmp(buf, "Other ") != 0) { printf("Wrong data result 1\n"); exit(1); } CHKGetData(1, type, buf, 20, NULL, "S"); if (mycmp(buf, "test") != 0) { printf("Wrong data result 2 res = '%s'\n", buf); exit(1); } odbc_reset_statement(); if (type != SQL_C_CHAR) break; type = SQL_C_WCHAR; lc = sizeof(SQLWCHAR); } /* 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 (;;) { 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(); 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-0.91/src/odbc/unittests/hidden.c100775 001750 000144 00000002556 11414321741 0013747/* Testing result column numbers having hidden columns */ /* Test from Sebastien Flaesch */ #include "common.h" static char software_version[] = "$Id: hidden.c,v 1.8 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) { 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((SQLCHAR *) "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-0.91/src/odbc/unittests/insert_speed.c100664 001750 000144 00000004053 11414321741 0015167#include "common.h" #include static char software_version[] = "$Id: insert_speed.c,v 1.9 2010/07/05 09:20:33 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((SQLCHAR *) "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((SQLCHAR *) "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-0.91/src/odbc/unittests/lang_error.c100664 001750 000144 00000000753 11414321741 0014640#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-0.91/src/odbc/unittests/moreandcount.c100664 001750 000144 00000004675 11414321741 0015213#include "common.h" /* Test for SQLMoreResults and SQLRowCount on batch */ static char software_version[] = "$Id: moreandcount.c,v 1.19 2010/07/05 09:20:33 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((SQLCHAR *) query, SQL_NTS, "S"); CHKExecute("S"); } else { /* execute a batch command select insert insert select and check rows */ CHKExecDirect((SQLCHAR *) 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 } 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-0.91/src/odbc/unittests/norowset.c100664 001750 000144 00000002001 11414321741 0014352#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-0.91/src/odbc/unittests/paramcore.c100664 001750 000144 00000003276 11414321741 0014462#include "common.h" /* * Try to make core dump using SQLBindParameter */ static char software_version[] = "$Id: paramcore.c,v 1.8 2010/07/05 09:20:33 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((SQLCHAR*) 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((SQLCHAR*) 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-0.91/src/odbc/unittests/params.c100664 001750 000144 00000004614 11414321741 0013771#include "common.h" /* Test for store procedure and params */ /* Test from Tom Rogers */ static char software_version[] = "$Id: params.c,v 1.12 2010/07/05 09:20:33 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((SQLCHAR *) 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((SQLCHAR *) 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(); 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-0.91/src/odbc/unittests/peter.c100664 001750 000144 00000002151 11462560022 0013617#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.1 2010/10/29 14:54:10 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((SQLCHAR*) "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-0.91/src/odbc/unittests/prepare_results.c100644 001750 000144 00000006625 11557650317 0015743#include "common.h" /* Test for data format returned from SQLPrepare */ static char software_version[] = "$Id: prepare_results.c,v 1.13.2.1 2011/04/24 18:26:02 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; char name[128]; /* test query returns column information */ CHKPrepare((SQLCHAR *) "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, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable, "S"); if (type != SQL_INTEGER || strcmp(name, "i") != 0) { fprintf(stderr, "wrong column 1 informations (type %d name '%s' size %d)\n", (int) type, name, (int) size); exit(1); } CHKDescribeCol(2, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable, "S"); if (type != SQL_CHAR || strcmp(name, "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, name, (int) size); exit(1); } CHKDescribeCol(3, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable, "S"); if (type != SQL_NUMERIC || strcmp(name, "n") != 0 || size != 34 || digits != 12) { fprintf(stderr, "wrong column 3 informations (type %d name '%s' size %d)\n", (int) type, name, (int) size); exit(1); } } 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((SQLCHAR *) "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((SQLCHAR *) "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((SQLCHAR *) "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-0.91/src/odbc/unittests/prepclose.c100664 001750 000144 00000004222 11414321741 0014475#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. */ static char software_version[] = "$Id: prepclose.c,v 1.7 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #if HAVE_FSTAT && defined(S_IFSOCK) static int close_last_socket(void) { int max_socket = -1, i; int sockets[2]; for (i = 3; i < 1024; ++i) { struct stat file_stat; if (fstat(i, &file_stat)) continue; if ((file_stat.st_mode & S_IFSOCK) == S_IFSOCK) max_socket = i; } 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]); close(sockets[1]); return 1; } static int Test(int direct) { char buf[256]; unsigned char sqlstate[6]; odbc_connect(); if (!close_last_socket()) { fprintf(stderr, "Error closing connection\n"); return 1; } /* force disconnection closing socket */ if (direct) { CHKExecDirect((SQLCHAR *) "SELECT 1", SQL_NTS, "E"); } else { SQLSMALLINT cols; /* use prepare, force dialog with server */ if (CHKPrepare((SQLCHAR *) "SELECT 1", SQL_NTS, "SE") == SQL_SUCCESS) CHKNumResultCols(&cols, "E"); } CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, (SQLCHAR *) buf, sizeof(buf), NULL, "SI"); sqlstate[5] = 0; printf("state=%s err=%s\n", (char*) sqlstate, 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"); return 0; } #endif freetds-0.91/src/odbc/unittests/preperror.c100664 001750 000144 00000002673 11414321741 0014531#include "common.h" /* test error on prepared statement, from Nathaniel Talbott test */ static char software_version[] = "$Id: preperror.c,v 1.9 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[]) { SQLLEN cbInString = SQL_NTS; char buf[256]; unsigned char sqlstate[6]; odbc_connect(); odbc_command("CREATE TABLE #urls ( recdate DATETIME ) "); /* test implicit conversion error */ CHKExecDirect((SQLCHAR *) "INSERT INTO #urls ( recdate ) VALUES ( '2003-10-1 10:11:1 0' )", SQL_NTS, "E"); /* test prepared implicit conversion error */ CHKPrepare((SQLCHAR *) "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, (SQLCHAR *) buf, sizeof(buf), NULL, "SI"); printf("err=%s\n", buf); /* assure initial state */ odbc_reset_statement(); /* try to prepare and execute a statement with error (from DBD::ODBC test) */ if (CHKPrepare((SQLCHAR *) "SELECT XXNOTCOLUMN FROM sysobjects", SQL_NTS, "SE") == SQL_SUCCESS) CHKExecute("E"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, (SQLCHAR *) buf, sizeof(buf), NULL, "SI"); printf("err=%s\n", buf); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-0.91/src/odbc/unittests/print.c100664 001750 000144 00000004206 11414321741 0013637#include "common.h" static char software_version[] = "$Id: print.c,v 1.24 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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) { if (tds_no_dm) { #if 0 ODBC_CHECK_COLS(-1); #endif ODBC_CHECK_ROWS(-2); } } else { 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-0.91/src/odbc/unittests/putdata.c100664 001750 000144 00000011144 11414321741 0014144#include "common.h" /* Test for SQLPutData */ static char software_version[] = "$Id: putdata.c,v 1.18 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 void CheckNoRow(const char *query) { SQLRETURN rc; rc = CHKExecDirect((SQLCHAR *) 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); } 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((SQLCHAR *) "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((SQLCHAR *) "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"); CheckNoRow(sql); odbc_command("DELETE FROM #putdata"); /* test len == 0 case from ML */ type = SQL_C_CHAR; for (;;) { CHKPrepare((SQLCHAR *) "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) { SQLPutData(odbc_stmt, "abc", 3); } else { SQLWCHAR buf[10]; SQLPutData(odbc_stmt, buf, to_sqlwchar(buf, "abc", 3)); } } } if (type != SQL_C_CHAR) break; type = SQL_C_WCHAR; odbc_reset_statement(); } /* check inserts ... */ CheckNoRow("IF EXISTS(SELECT * FROM #putdata WHERE c NOT LIKE 'abc') SELECT 1"); /* TODO test cancel inside SQLExecute */ odbc_disconnect(); printf("Done.\n"); return 0; } freetds-0.91/src/odbc/unittests/raiserror.c100664 001750 000144 00000015752 11414321741 0014523#include "common.h" /* test RAISERROR in a store procedure, from Tom Rogers tests */ /* TODO add support for Sybase */ static char software_version[] = "$Id: raiserror.c,v 1.25 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #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) { SQLCHAR SqlState[6]; SQLINTEGER NativeError; char 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, (SQLCHAR *) MessageText, sizeof(MessageText), &TextLength, "SI"); printf("Func=%s Result=%d DIAG REC 1: State=%s Error=%d: %s\n", func, (int) rc, SqlState, (int) NativeError, MessageText); if (strstr(MessageText, "An error occurred") == NULL) { fprintf(stderr, "Wrong error returned!\n"); fprintf(stderr, "Error returned: %s\n", MessageText); exit(1); } } #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, "Test") == 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, (SQLCHAR *) 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, "Test"); SQLBindParameter(odbc_stmt, 4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, OutString, OUTSTRING_LEN, &cbOutString); CHKExecute("S"); CheckData(""); CHKFetch("S"); CheckData("Here is the first row"); result = SQLFetch(odbc_stmt); if (odbc_use_version3) { SQLCHAR SqlState[6]; SQLINTEGER NativeError; char MessageText[1000]; SQLSMALLINT TextLength; SQLRETURN expected; if (result != SQL_NO_DATA) ODBC_REPORT_ERROR("SQLFetch should return NO DATA"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, SqlState, &NativeError, (SQLCHAR *) MessageText, sizeof(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 (odbc_use_version3 && !g_second_select && g_nocount) { CheckReturnCode(result, 0); ReturnCode = INVALID_RETURN; TestResult(result, level, "SQLMoreResults"); ReturnCode = 0; } else { TestResult(result, level, "SQLMoreResults"); } ODBC_CHECK_ROWS(-1); } else { TestResult(result, level, "SQLFetch"); } if (odbc_driver_is_freetds()) CheckData(""); if (!g_second_select) { ODBC_CHECK_ROWS(-1); 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) { CHKMoreResults("S"); result = SQL_SUCCESS; } CheckReturnCode(result, INVALID_RETURN); CheckData(""); 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(""); } 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-0.91/src/odbc/unittests/rebindpar.c100664 001750 000144 00000003325 11414321741 0014452#include "common.h" /* Test for executing SQLExecute and rebinding parameters */ static char software_version[] = "$Id: rebindpar.c,v 1.10 2010/07/05 09:20:33 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) { 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((SQLCHAR *) "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); } 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-0.91/src/odbc/unittests/rowset.c100664 001750 000144 00000003757 11414321741 0014040#include "common.h" static char software_version[] = "$Id: rowset.c,v 1.7 2010/07/05 09:20:33 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((SQLCHAR *) "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-0.91/src/odbc/unittests/rpc.c100664 001750 000144 00000016147 11414321741 0013276/* * Purpose: Test remote procedure calls * Functions: */ #include "common.h" #include static char software_version[] = "$Id: rpc.c,v 1.13 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 sysobjects where type = 'S' \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((SQLCHAR *) 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((SQLCHAR *) 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) malloc(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((SQLCHAR *) call_cmd, SQL_NTS, "S"); printf("executing SQLExecute\n"); CHKExecute("SI"); do { static const char dashes[] = "------------------------------"; int nrows; SQLSMALLINT icol, ncols; SQLCHAR name[256] = ""; 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, sizeof(name), &namelen, &type, &size, &scale, &nullable, "S"); printf("%-5d %-15s %5d %5ld %5d %8c\n", icol, name, type, (long int)size, scale, (nullable? 'Y' : 'N')); } printf("executing SQLFetch...\n"); printf("\t%-30s\n\t%s\n", 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; for (ipar = 0; ipar < sizeof(args)/sizeof(args[0]); ++ipar) if (args[ipar].BufferLength > 0) free(args[ipar].ParameterValuePtr); 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"); return 0; } freetds-0.91/src/odbc/unittests/scroll.c100664 001750 000144 00000006323 11414321741 0014003#include "common.h" /* Test cursors */ static char software_version[] = "$Id: scroll.c,v 1.10 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[]) { #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((SQLCHAR *) "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-0.91/src/odbc/unittests/stats.c100664 001750 000144 00000004502 11414321741 0013640#include "common.h" static char software_version[] = "$Id: stats.c,v 1.3 2010/07/05 09:20:33 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((SQLCHAR *) catalog, LEN(catalog), (SQLCHAR *) schema, LEN(schema), (SQLCHAR *) proc, LEN(proc), (SQLCHAR *) 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"); } 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((SQLCHAR *) catalog, LEN(catalog), (SQLCHAR *) schema, LEN(schema), (SQLCHAR *) table, LEN(table), (SQLCHAR *) 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"); } #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-0.91/src/odbc/unittests/t0001.c100664 001750 000144 00000002365 11414321741 0013253#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-0.91/src/odbc/unittests/t0002.c100664 001750 000144 00000002445 11414321741 0013253#include "common.h" static char software_version[] = "$Id: t0002.c,v 1.17 2010/07/05 09:20:33 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) int main(int argc, char *argv[]) { HSTMT old_odbc_stmt; 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) */ old_odbc_stmt = odbc_stmt; odbc_stmt = SQL_NULL_HSTMT; CHKAllocStmt(&odbc_stmt, "S"); odbc_command("select * from #odbctestdata where 0=1"); CHKFetch("No"); CHKCloseCursor("SI"); SWAP_STMT(old_odbc_stmt); odbc_command("select * from #odbctestdata"); SWAP_STMT(old_odbc_stmt); /* drop first statement .. data should not disappear */ CHKFreeStmt(SQL_DROP, "S"); odbc_stmt = old_odbc_stmt; CHKFetch("SI"); CHKFetch("No"); CHKCloseCursor("SI"); odbc_command("drop table #odbctestdata"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-0.91/src/odbc/unittests/t0003.c100664 001750 000144 00000002516 11414321741 0013253#include "common.h" /* Test for SQLMoreResults */ static char software_version[] = "$Id: t0003.c,v 1.20 2010/07/05 09:20:33 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((SQLCHAR *)"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((SQLCHAR *)"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"); } int main(int argc, char *argv[]) { odbc_connect(); DoTest(0); DoTest(1); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-0.91/src/odbc/unittests/t0004.c100664 001750 000144 00000001636 11414321741 0013256#include "common.h" /* Test for SQLMoreResults */ static char software_version[] = "$Id: t0004.c,v 1.18 2010/07/05 09:20:33 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((SQLCHAR *) "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"); } int main(int argc, char *argv[]) { odbc_connect(); Test(1); Test(0); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-0.91/src/odbc/unittests/tables.c100664 001750 000144 00000010534 11414321741 0013756#include "common.h" static char software_version[] = "$Id: tables.c,v 1.19 2010/07/05 09:20:33 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) { char name[128]; char buf[256]; SQLSMALLINT len, type; #define NAME_TEST \ do { \ if (strcmp(name, expected_name) != 0) \ { \ sprintf(buf, "wrong name in column %d expected '%s' got '%s'", index, expected_name, name); \ ODBC_REPORT_ERROR(buf); \ } \ } while(0) /* retrieve with SQLDescribeCol */ CHKDescribeCol(index, (SQLCHAR *) name, sizeof(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; } 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 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\n", type ? type : "", row_returned ? "with" : "without"); CHKTables((SQLCHAR *) catalog, LEN(catalog), (SQLCHAR *) schema, LEN(schema), (SQLCHAR *) table_buf, table_len, (SQLCHAR *) 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; } 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-0.91/src/odbc/unittests/test64.c100664 001750 000144 00000013135 11507146343 0013643/* test win64 consistency */ #include "common.h" static char software_version[] = "$Id: test64.c,v 1.11 2010/12/30 18:18:11 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* 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(int2ptr(0x01020304)); check_ipd_params(); set_ipd_params2(int2ptr(0xabcdef12)); check_ipd_params(); set_ipd_params3(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(int2ptr(0x01020304)); check_ird_params(); set_ird_params2(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(); // 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"); 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"); 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-0.91/src/odbc/unittests/testodbc.c100664 001750 000144 00000030740 11414321741 0014314/* * Code to test ODBC implementation. * - David Fraser, Abelon Systems 2003. */ /* * TODO * remove Northwind dependency */ #include "common.h" static char software_version[] = "$Id: testodbc.c,v 1.15 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #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) { SQLCHAR *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); queryString = (SQLCHAR *) "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); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd, "S"); CHKExecDirect((SQLCHAR *) "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; SQLCHAR *queryString; SQLLEN lenOrInd; SQLSMALLINT age; SQLCHAR 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 = (SQLCHAR *) "CREATE TABLE #pet (name VARCHAR(20), owner VARCHAR(20), " "species VARCHAR(20), sex CHAR(1), age INTEGER, " "guid UNIQUEIDENTIFIER DEFAULT NEWID() ); "; CHKExecDirect(queryString, SQL_NTS, "SNo"); odbc_command_with_result(odbc_stmt, "DROP PROC GetGUIDRows"); AB_PRINT(("Creating stored proc GetGUIDRows")); queryString = (SQLCHAR *) "CREATE PROCEDURE GetGUIDRows (@guidpar uniqueidentifier) AS \ SELECT name, guid FROM #pet WHERE guid = @guidpar"; CHKExecDirect(queryString, SQL_NTS, "SNo"); AB_PRINT(("Insert row 1")); queryString = (SQLCHAR *) "INSERT INTO #pet( name, owner, species, sex, age ) \ VALUES ( 'Fang', 'Mike', 'dog', 'm', 12 );"; CHKExecDirect(queryString, SQL_NTS, "S"); AB_PRINT(("Insert row 2")); /* * Ok - new row with explicit GUID, but parameterised age. */ queryString = (SQLCHAR *) "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(queryString, SQL_NTS, "S"); CHKFreeStmt(SQL_CLOSE, "S"); AB_PRINT(("Insert row 3")); /* * Ok - new row with parameterised GUID. */ queryString = (SQLCHAR *) "INSERT INTO #pet( name, owner, species, sex, age, guid ) \ VALUES ( 'Woof', 'Tom', 'cat', 'f', 2, ? );"; lenOrInd = SQL_NTS; strcpy((char *) (guid), "87654321-4321-4321-4321-123456789abc"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_GUID, 0, 0, guid, 0, &lenOrInd, "S"); CHKExecDirect(queryString, SQL_NTS, "S"); AB_PRINT(("Insert row 4")); /* * Ok - new row with parameterised GUID. */ queryString = (SQLCHAR *) "INSERT INTO #pet( name, owner, species, sex, age, guid ) \ VALUES ( 'Spike', 'Diane', 'pig', 'f', 4, ? );"; lenOrInd = SQL_NTS; strcpy((char *) (guid), "1234abcd-abcd-abcd-abcd-123456789abc"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 36, 0, guid, 0, &lenOrInd, "S"); CHKExecDirect(queryString, SQL_NTS, "S"); AB_PRINT(("Insert row 5")); /* * Ok - new row with parameterised GUID. */ queryString = (SQLCHAR *) "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((char *) (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, 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 = (SQLCHAR *) "SELECT name, guid FROM #pet"; CHKExecDirect(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 = (SQLCHAR *) "SELECT name, guid FROM #pet"; CHKExecDirect(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 = (SQLCHAR *) "{call GetGUIDRows(?)}"; lenOrInd = SQL_NTS; strcpy((char *) (guid), "87654321-4321-4321-4321-123456789abc"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_GUID, 0, 0, guid, 0, &lenOrInd, "S"); CHKExecDirect(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++; } 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-0.91/src/odbc/unittests/timeout.c100664 001750 000144 00000003652 11414321741 0014175#include "common.h" #include /* Test timeout of query */ static char software_version[] = "$Id: timeout.c,v 1.13 2010/07/05 09:20:33 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((SQLCHAR *) "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-0.91/src/odbc/unittests/timeout2.c100664 001750 000144 00000002472 11414321741 0014256#include "common.h" #ifdef HAVE_UNISTD_H #include #endif #include /* * 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 */ static char software_version[] = "$Id: timeout2.c,v 1.9 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #if defined(__MINGW32__) || defined(_WIN32) #define sleep(s) Sleep((s)*1000) #endif 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((SQLCHAR*) "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"); sleep(15); } SQLFreeStmt(odbc_stmt, SQL_CLOSE); SQLFreeStmt(odbc_stmt, SQL_UNBIND); SQLFreeStmt(odbc_stmt, SQL_RESET_PARAMS); SQLCloseCursor(odbc_stmt); } odbc_disconnect(); return 0; } freetds-0.91/src/odbc/unittests/timeout3.c100664 001750 000144 00000010703 11414321741 0014253#include "common.h" /* TODO port to windows, use thread */ #if defined(TDS_HAVE_PTHREAD_MUTEX) && HAVE_ALARM #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 */ #include #include "tds.h" /* test connection timeout */ static char software_version[] = "$Id: timeout3.c,v 1.12 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 pthread_t fake_thread; static TDS_SYS_SOCKET fake_sock; static void *fake_thread_proc(void * arg); 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 = pthread_create(&fake_thread, NULL, fake_thread_proc, int2ptr(s)); if (err != 0) { perror("pthread_create"); exit(1); } return 0; } static void * fake_thread_proc(void * arg) { TDS_SYS_SOCKET s = ptr2int(arg); socklen_t len; char buf[128]; struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); len = sizeof(sin); alarm(30); if (TDS_IS_SOCKET_INVALID(fake_sock = tds_accept(s, (struct sockaddr *) &sin, &len))) { perror("accept"); exit(1); } CLOSESOCKET(s); for (;;) { /* just read and discard */ len = READSOCKET(fake_sock, buf, sizeof(buf)); if (len == 0) break; if (len < 0 && sock_errno != TDSSOCK_EINPROGRESS) break; } return NULL; } int main(int argc, char *argv[]) { char tmp[2048]; char sqlstate[6]; SQLSMALLINT len; int port; time_t start_time, end_time; 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 binded at port %d\n", port); init_connect(); CHKSetConnectAttr(SQL_ATTR_CONNECTION_TIMEOUT, (SQLPOINTER) 10, sizeof(SQLINTEGER), "SI"); CHKSetConnectAttr(SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) 10, sizeof(SQLINTEGER), "SI"); /* this is expected to work with unixODBC */ printf("try to connect to our port just to check connection timeout\n"); sprintf(tmp, "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, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT, "E"); end_time = time(NULL); strcpy(sqlstate, "XXXXX"); tmp[0] = 0; CHKGetDiagRec(SQL_HANDLE_DBC, odbc_conn, 1, (SQLCHAR *) sqlstate, NULL, (SQLCHAR *) tmp, sizeof(tmp), NULL, "SI"); odbc_disconnect(); CLOSESOCKET(fake_sock); pthread_join(fake_thread, NULL); printf("Message: %s - %s\n", sqlstate, tmp); if (strcmp(sqlstate, "HYT00") || !strstr(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"); return 0; } #else /* !TDS_HAVE_PTHREAD_MUTEX */ int main(void) { printf("Not possible for this platform.\n"); return 0; } #endif freetds-0.91/src/odbc/unittests/timeout4.c100664 001750 000144 00000005574 11414321741 0014266#include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if TIME_WITH_SYS_TIME # if HAVE_SYS_TIME_H # include # endif # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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. */ static char software_version[] = "$Id: timeout4.c,v 1.6 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #if HAVE_FSTAT && defined(S_IFSOCK) static int end_socket = -1; static int shutdown_last_socket(void) { int max_socket = -1, i; int sockets[2]; for (i = 3; i < 1024; ++i) { struct stat file_stat; if (fstat(i, &file_stat)) continue; if ((file_stat.st_mode & S_IFSOCK) == S_IFSOCK) max_socket = i; } 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) { char buf[256]; char sqlstate[6]; time_t start_time, end_time; 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((SQLCHAR *) "SELECT 1", SQL_NTS, "E"); } else { SQLSMALLINT cols; /* force dialog with server */ if (CHKPrepare((SQLCHAR *) "SELECT 1", SQL_NTS, "SE") == SQL_SUCCESS) CHKNumResultCols(&cols, "E"); } end_time = time(NULL); alarm(0); strcpy(sqlstate, "XXXXX"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, (SQLCHAR *) sqlstate, NULL, (SQLCHAR *) buf, sizeof(buf), NULL, "SI"); sqlstate[5] = 0; printf("Message: %s - %s\n", sqlstate, buf); if (strcmp(sqlstate, "HYT00") || !strstr(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"); return 0; } #endif freetds-0.91/src/odbc/unittests/transaction.c100664 001750 000144 00000005607 11414321741 0015036#include "common.h" static char software_version[] = "$Id: transaction.c,v 1.17 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int Test(int discard_test) { SQLINTEGER out_buf; SQLLEN out_len; SQLLEN rows; int retcode = 0; char buf[512]; unsigned char 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, (SQLCHAR *)buf, sizeof(buf), NULL, "SI"); printf("err=%s\n", buf); CHKMoreResults("No"); cleanup: /* drop table */ odbc_command_with_result(odbc_stmt, "DROP PROCEDURE testinsert"); odbc_command_with_result(odbc_stmt, "DROP PROCEDURE testerror"); 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-0.91/src/odbc/unittests/transaction2.c100664 001750 000144 00000015747 11414321741 0015126#include "common.h" #include /* Test transaction types */ static char software_version[] = "$Id: transaction2.c,v 1.10 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void ReadErrorConn(void) { memset(odbc_err, 0, sizeof(odbc_err)); memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); CHKGetDiagRec(SQL_HANDLE_DBC, odbc_conn, 1, (SQLCHAR *) odbc_sqlstate, NULL, (SQLCHAR *) odbc_err, sizeof(odbc_err), NULL, "SI"); 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-0.91/src/odbc/unittests/type.c100664 001750 000144 00000013307 11414321741 0013466#include "common.h" #include static char software_version[] = "$Id: type.c,v 1.9 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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_C(SQL_C_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-0.91/src/odbc/unittests/typeinfo.c100664 001750 000144 00000013116 11507101727 0014343#include "common.h" static char software_version[] = "$Id: typeinfo.c,v 1.15 2010/12/30 13:06:31 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void TestName(int index, const char *expected_name) { char name[128]; char buf[256]; SQLSMALLINT len, type; #define NAME_TEST \ do { \ if (strcmp(name, expected_name) != 0) \ { \ sprintf(buf, "wrong name in column %d expected '%s' got '%s'", index, expected_name, name); \ ODBC_REPORT_ERROR(buf); \ } \ } while(0) /* retrieve with SQLDescribeCol */ CHKDescribeCol(index, (SQLCHAR *) name, sizeof(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; } 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. Inpute 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; odbc_use_version3 = version3; name_version3 = version3; odbc_connect(); printf("Using ODBC version %d\n", version3 ? 3 : 2); /* 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; 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); CHECK_TYPE(SQL_DATE, date_time_supported && !version3 ? SQL_DATE : SQL_UNKNOWN_TYPE); CHECK_TYPE(SQL_TIME, date_time_supported && !version3 ? SQL_TIME : SQL_UNKNOWN_TYPE); /* MS ODBC returns S1004 (HY004), TODO support it */ if (odbc_driver_is_freetds() || version3) { CHECK_TYPE(SQL_TYPE_DATE, date_time_supported && version3 ? SQL_TYPE_DATE : SQL_UNKNOWN_TYPE); CHECK_TYPE(SQL_TYPE_TIME, date_time_supported && version3 ? SQL_TYPE_TIME : SQL_UNKNOWN_TYPE); } /* TODO MS ODBC handle SQL_TIMESTAMP even for ODBC 3 */ if (odbc_driver_is_freetds()) CHECK_TYPE(SQL_TIMESTAMP, version3 ? SQL_UNKNOWN_TYPE : SQL_TIMESTAMP); else CHECK_TYPE(SQL_TIMESTAMP, version3 ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP); /* MS ODBC returns S1004 (HY004), TODO support it */ if (odbc_driver_is_freetds() || version3) { CHECK_TYPE(SQL_TYPE_TIMESTAMP, version3 ? SQL_TYPE_TIMESTAMP : SQL_UNKNOWN_TYPE); } /* 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"); if (odbc_db_is_microsoft()) CHKFetch("S"); CHKFetch("No"); CHKGetTypeInfo(SQL_BINARY, "SI"); } odbc_disconnect(); } int main(int argc, char *argv[]) { DoTest(0); DoTest(1); printf("Done.\n"); return 0; } freetds-0.91/src/odbc/unittests/utf8.c100775 001750 000144 00000010565 11414321741 0013401#include "common.h" /* test binding with UTF-8 encoding */ static char software_version[] = "$Id: utf8.c,v 1.12 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 void CheckNoRow(const char *query) { SQLRETURN rc; rc = CHKExecDirect((SQLCHAR *) 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); exit(1); } } while (CHKMoreResults("SNo") == SQL_SUCCESS); } /* 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((SQLCHAR *) 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; 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]); CheckNoRow(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, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT, "SI"); if (!odbc_driver_is_freetds()) { odbc_disconnect(); printf("Driver is not FreeTDS, exiting\n"); return 0; } if (!odbc_db_is_microsoft() || odbc_db_version_int() < 0x08000000u) { odbc_disconnect(); printf("Test for MSSQL only\n"); 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]); CheckNoRow(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; } freetds-0.91/src/odbc/unittests/utf8_2.c100775 001750 000144 00000004441 11414321741 0013616#include "common.h" /* test conversion of Hebrew characters (which have shift sequences) */ static char software_version[] = "$Id: utf8_2.c,v 1.9 2010/07/05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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[128]; 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, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT, "SI"); if (!odbc_driver_is_freetds()) { odbc_disconnect(); printf("Driver is not FreeTDS, exiting\n"); return 0; } if (!odbc_db_is_microsoft() || odbc_db_version_int() < 0x08000000u) { odbc_disconnect(); printf("Test for MSSQL only\n"); 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-0.91/src/odbc/unittests/warning.c100664 001750 000144 00000003645 11414321741 0014156#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.10 2010/07/05 09:20:33 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((SQLCHAR *) 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) { SQLCHAR output[256]; CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, NULL, NULL, output, sizeof(output), NULL, "SI"); printf("Message: %s\n", (char *) 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-0.91/src/odbc/unittests/wchar.c100664 001750 000144 00000001343 11414321741 0013606#include "common.h" /* test SQL_C_DEFAULT with NCHAR type */ static char software_version[] = "$Id: wchar.c,v 1.4 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[]) { 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(); if (strcmp(buf, "Pippo 123 ") != 0) { fprintf(stderr, "Wrong results '%s'\n", buf); failed = 1; } return failed ? 1 : 0; } freetds-0.91/src/odbc/unittests/describecol.in100664 001750 000144 00000027614 11426217440 0015160# test all types using ODBC 2 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 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 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 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 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 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_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 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 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 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 select sql_variant 'hello' #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_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 # some additional tests using ARD set DESC_CONCISE_TYPE SQL_NUMERIC set DESC_PRECISION 20 set DESC_SCALE 4 set DESC_CONCISE_TYPE SQL_INTEGER attr DESC_TYPE SQL_INTEGER attr DESC_LENGTH 0 attr DESC_PRECISION 0 attr DESC_SCALE 0 freetds-0.91/src/odbc/unittests/attributes.in100775 001750 000144 00000001002 10732226125 0015051# 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-0.91/src/odbc/unittests/vc6/test64.dsp100664 001750 000144 00000010667 11623073531 0014711# Microsoft Developer Studio Project File - Name="test64" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=test64 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "test64.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "test64.mak" CFG="test64 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "test64 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "test64 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "test64 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "test64 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "test64 - Win32 Release" # Name "test64 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\test64.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/t0002.dsp100664 001750 000144 00000010653 11623073530 0014317# Microsoft Developer Studio Project File - Name="t0002" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0002 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0002.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0002.mak" CFG="t0002 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0002 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0002 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0002 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0002 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0002 - Win32 Release" # Name "t0002 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0002.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/t0003.dsp100664 001750 000144 00000010653 11623073530 0014320# Microsoft Developer Studio Project File - Name="t0003" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0003 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0003.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0003.mak" CFG="t0003 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0003 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0003 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0003 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0003 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0003 - Win32 Release" # Name "t0003 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0003.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/t0004.dsp100664 001750 000144 00000010653 11623073530 0014321# Microsoft Developer Studio Project File - Name="t0004" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0004 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0004.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0004.mak" CFG="t0004 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0004 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0004 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0004 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0004 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0004 - Win32 Release" # Name "t0004 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0004.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/connect.dsp100664 001750 000144 00000010703 11623073530 0015177# Microsoft Developer Studio Project File - Name="connect" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=connect - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "connect.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "connect.mak" CFG="connect - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "connect - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "connect - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "connect - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "connect - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "connect - Win32 Release" # Name "connect - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\connect.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/print.dsp100664 001750 000144 00000010653 11623073530 0014706# Microsoft Developer Studio Project File - Name="print" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=print - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "print.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "print.mak" CFG="print - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "print - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "print - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "print - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "print - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "print - Win32 Release" # Name "print - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\print.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/date.dsp100664 001750 000144 00000010637 11623073530 0014471# Microsoft Developer Studio Project File - Name="date" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=date - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "date.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "date.mak" CFG="date - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "date - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "date - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "date - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "date - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "date - Win32 Release" # Name "date - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\date.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/norowset.dsp100664 001750 000144 00000010717 11623073530 0015433# Microsoft Developer Studio Project File - Name="norowset" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=norowset - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "norowset.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "norowset.mak" CFG="norowset - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "norowset - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "norowset - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "norowset - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "norowset - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "norowset - Win32 Release" # Name "norowset - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\norowset.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/funccall.dsp100664 001750 000144 00000010717 11623073530 0015342# Microsoft Developer Studio Project File - Name="funccall" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=funccall - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "funccall.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "funccall.mak" CFG="funccall - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "funccall - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "funccall - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "funccall - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "funccall - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "funccall - Win32 Release" # Name "funccall - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\funccall.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/lang_error.dsp100664 001750 000144 00000010747 11623073530 0015710# Microsoft Developer Studio Project File - Name="lang_error" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=lang_error - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "lang_error.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "lang_error.mak" CFG="lang_error - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "lang_error - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "lang_error - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "lang_error - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "lang_error - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "lang_error - Win32 Release" # Name "lang_error - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\lang_error.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/tables.dsp100664 001750 000144 00000010667 11623073530 0015031# Microsoft Developer Studio Project File - Name="tables" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=tables - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "tables.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "tables.mak" CFG="tables - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "tables - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "tables - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "tables - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "tables - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "tables - Win32 Release" # Name "tables - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\tables.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/binary_test.dsp100664 001750 000144 00000010763 11623073530 0016077# Microsoft Developer Studio Project File - Name="binary_test" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=binary_test - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "binary_test.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "binary_test.mak" CFG="binary_test - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "binary_test - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "binary_test - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "binary_test - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "binary_test - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "binary_test - Win32 Release" # Name "binary_test - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\binary_test.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/moreandcount.dsp100664 001750 000144 00000010777 11623073530 0016257# Microsoft Developer Studio Project File - Name="moreandcount" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=moreandcount - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "moreandcount.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "moreandcount.mak" CFG="moreandcount - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "moreandcount - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "moreandcount - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "moreandcount - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "moreandcount - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "moreandcount - Win32 Release" # Name "moreandcount - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\moreandcount.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/earlybind.dsp100664 001750 000144 00000010733 11623073530 0015522# Microsoft Developer Studio Project File - Name="earlybind" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=earlybind - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "earlybind.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "earlybind.mak" CFG="earlybind - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "earlybind - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "earlybind - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "earlybind - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "earlybind - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "earlybind - Win32 Release" # Name "earlybind - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\earlybind.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/putdata.dsp100664 001750 000144 00000010703 11623073530 0015210# Microsoft Developer Studio Project File - Name="putdata" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=putdata - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "putdata.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "putdata.mak" CFG="putdata - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "putdata - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "putdata - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "putdata - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "putdata - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "putdata - Win32 Release" # Name "putdata - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\putdata.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/params.dsp100664 001750 000144 00000010667 11623073530 0015042# Microsoft Developer Studio Project File - Name="params" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=params - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "params.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "params.mak" CFG="params - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "params - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "params - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "params - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "params - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "params - Win32 Release" # Name "params - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\params.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/raiserror.dsp100664 001750 000144 00000010733 11623073530 0015561# Microsoft Developer Studio Project File - Name="raiserror" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=raiserror - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "raiserror.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "raiserror.mak" CFG="raiserror - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "raiserror - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "raiserror - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "raiserror - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "raiserror - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "raiserror - Win32 Release" # Name "raiserror - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\raiserror.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/getdata.dsp100664 001750 000144 00000010703 11623073530 0015157# Microsoft Developer Studio Project File - Name="getdata" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=getdata - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "getdata.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "getdata.mak" CFG="getdata - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "getdata - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "getdata - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "getdata - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "getdata - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "getdata - Win32 Release" # Name "getdata - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\getdata.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/transaction.dsp100664 001750 000144 00000010763 11623073530 0016101# Microsoft Developer Studio Project File - Name="transaction" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=transaction - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "transaction.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "transaction.mak" CFG="transaction - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "transaction - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "transaction - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "transaction - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "transaction - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "transaction - Win32 Release" # Name "transaction - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\transaction.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/type.dsp100664 001750 000144 00000010637 11623073530 0014535# Microsoft Developer Studio Project File - Name="type" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=type - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "type.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "type.mak" CFG="type - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "type - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "type - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "type - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "type - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "type - Win32 Release" # Name "type - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\type.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/genparams.dsp100664 001750 000144 00000010733 11623073530 0015526# Microsoft Developer Studio Project File - Name="genparams" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=genparams - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "genparams.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "genparams.mak" CFG="genparams - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "genparams - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "genparams - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "genparams - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "genparams - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "genparams - Win32 Release" # Name "genparams - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\genparams.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/preperror.dsp100664 001750 000144 00000010733 11623073530 0015571# Microsoft Developer Studio Project File - Name="preperror" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=preperror - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "preperror.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "preperror.mak" CFG="preperror - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "preperror - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "preperror - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "preperror - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "preperror - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "preperror - Win32 Release" # Name "preperror - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\preperror.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/prepare_results.dsp100664 001750 000144 00000011043 11623073530 0016763# Microsoft Developer Studio Project File - Name="prepare_results" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=prepare_results - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "prepare_results.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "prepare_results.mak" CFG="prepare_results - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "prepare_results - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "prepare_results - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "prepare_results - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "prepare_results - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "prepare_results - Win32 Release" # Name "prepare_results - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\prepare_results.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/testodbc.dsp100664 001750 000144 00000010717 11623073530 0015362# Microsoft Developer Studio Project File - Name="testodbc" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=testodbc - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "testodbc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "testodbc.mak" CFG="testodbc - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "testodbc - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "testodbc - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "testodbc - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "testodbc - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "testodbc - Win32 Release" # Name "testodbc - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\testodbc.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/data.dsp100664 001750 000144 00000010637 11623073530 0014465# Microsoft Developer Studio Project File - Name="data" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=data - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "data.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "data.mak" CFG="data - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "data - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "data - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "data - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "data - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "data - Win32 Release" # Name "data - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\data.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/error.dsp100664 001750 000144 00000010653 11623073530 0014703# Microsoft Developer Studio Project File - Name="error" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=error - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "error.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "error.mak" CFG="error - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "error - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "error - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "error - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "error - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "error - Win32 Release" # Name "error - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\error.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/rebindpar.dsp100664 001750 000144 00000010733 11623073530 0015517# Microsoft Developer Studio Project File - Name="rebindpar" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=rebindpar - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "rebindpar.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "rebindpar.mak" CFG="rebindpar - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "rebindpar - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "rebindpar - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "rebindpar - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "rebindpar - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "rebindpar - Win32 Release" # Name "rebindpar - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\rebindpar.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/rpc.dsp100664 001750 000144 00000010623 11623073530 0014333# Microsoft Developer Studio Project File - Name="rpc" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=rpc - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "rpc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "rpc.mak" CFG="rpc - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "rpc - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "rpc - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "rpc - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "rpc - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "rpc - Win32 Release" # Name "rpc - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\rpc.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/convert_error.dsp100664 001750 000144 00000011013 11623073530 0016432# Microsoft Developer Studio Project File - Name="convert_error" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=convert_error - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "convert_error.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "convert_error.mak" CFG="convert_error - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "convert_error - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "convert_error - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "convert_error - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "convert_error - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "convert_error - Win32 Release" # Name "convert_error - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\convert_error.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/typeinfo.dsp100664 001750 000144 00000010717 11623073530 0015410# Microsoft Developer Studio Project File - Name="typeinfo" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=typeinfo - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "typeinfo.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "typeinfo.mak" CFG="typeinfo - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "typeinfo - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "typeinfo - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "typeinfo - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "typeinfo - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "typeinfo - Win32 Release" # Name "typeinfo - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\typeinfo.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/const_params.dsp100664 001750 000144 00000010777 11623073530 0016252# Microsoft Developer Studio Project File - Name="const_params" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=const_params - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "const_params.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "const_params.mak" CFG="const_params - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "const_params - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "const_params - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "const_params - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "const_params - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "const_params - Win32 Release" # Name "const_params - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\const_params.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/insert_speed.dsp100664 001750 000144 00000010777 11623073530 0016245# Microsoft Developer Studio Project File - Name="insert_speed" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=insert_speed - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "insert_speed.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "insert_speed.mak" CFG="insert_speed - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "insert_speed - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "insert_speed - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "insert_speed - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "insert_speed - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "insert_speed - Win32 Release" # Name "insert_speed - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\insert_speed.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/compute.dsp100664 001750 000144 00000010703 11623073530 0015222# Microsoft Developer Studio Project File - Name="compute" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=compute - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "compute.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "compute.mak" CFG="compute - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "compute - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "compute - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "compute - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "compute - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "compute - Win32 Release" # Name "compute - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\compute.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/timeout.dsp100664 001750 000144 00000010703 11623073530 0015234# Microsoft Developer Studio Project File - Name="timeout" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=timeout - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "timeout.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "timeout.mak" CFG="timeout - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "timeout - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "timeout - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "timeout - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "timeout - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "timeout - Win32 Release" # Name "timeout - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\timeout.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/array.dsp100664 001750 000144 00000010653 11623073530 0014670# Microsoft Developer Studio Project File - Name="array" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=array - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "array.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "array.mak" CFG="array - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "array - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "array - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "array - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "array - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "array - Win32 Release" # Name "array - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\array.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/array_out.dsp100664 001750 000144 00000010733 11623073530 0015556# Microsoft Developer Studio Project File - Name="array_out" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=array_out - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "array_out.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "array_out.mak" CFG="array_out - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "array_out - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "array_out - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "array_out - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "array_out - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "array_out - Win32 Release" # Name "array_out - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\array_out.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/cursor1.dsp100664 001750 000144 00000010703 11623073530 0015144# Microsoft Developer Studio Project File - Name="cursor1" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cursor1 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "cursor1.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "cursor1.mak" CFG="cursor1 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cursor1 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cursor1 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "cursor1 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cursor1 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "cursor1 - Win32 Release" # Name "cursor1 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\cursor1.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/scroll.dsp100664 001750 000144 00000010667 11623073530 0015055# Microsoft Developer Studio Project File - Name="scroll" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=scroll - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "scroll.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "scroll.mak" CFG="scroll - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "scroll - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "scroll - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "scroll - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "scroll - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "scroll - Win32 Release" # Name "scroll - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\scroll.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/cursor2.dsp100664 001750 000144 00000010703 11623073530 0015145# Microsoft Developer Studio Project File - Name="cursor2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cursor2 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "cursor2.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "cursor2.mak" CFG="cursor2 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cursor2 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cursor2 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "cursor2 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cursor2 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "cursor2 - Win32 Release" # Name "cursor2 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\cursor2.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/describecol.dsp100664 001750 000144 00000010763 11623073530 0016032# Microsoft Developer Studio Project File - Name="describecol" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=describecol - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "describecol.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "describecol.mak" CFG="describecol - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "describecol - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "describecol - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "describecol - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "describecol - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "describecol - Win32 Release" # Name "describecol - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\describecol.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/copydesc.dsp100664 001750 000144 00000010717 11623073530 0015364# Microsoft Developer Studio Project File - Name="copydesc" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=copydesc - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "copydesc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "copydesc.mak" CFG="copydesc - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "copydesc - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "copydesc - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "copydesc - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "copydesc - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "copydesc - Win32 Release" # Name "copydesc - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\copydesc.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/prepclose.dsp100664 001750 000144 00000010733 11623073530 0015545# Microsoft Developer Studio Project File - Name="prepclose" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=prepclose - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "prepclose.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "prepclose.mak" CFG="prepclose - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "prepclose - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "prepclose - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "prepclose - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "prepclose - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "prepclose - Win32 Release" # Name "prepclose - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\prepclose.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/warning.dsp100664 001750 000144 00000010703 11623073530 0015213# Microsoft Developer Studio Project File - Name="warning" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=warning - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "warning.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "warning.mak" CFG="warning - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "warning - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "warning - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "warning - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "warning - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "warning - Win32 Release" # Name "warning - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\warning.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/paramcore.dsp100664 001750 000144 00000010733 11623073530 0015522# Microsoft Developer Studio Project File - Name="paramcore" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=paramcore - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "paramcore.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "paramcore.mak" CFG="paramcore - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "paramcore - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "paramcore - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "paramcore - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "paramcore - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "paramcore - Win32 Release" # Name "paramcore - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\paramcore.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/timeout2.dsp100664 001750 000144 00000010717 11623073530 0015323# Microsoft Developer Studio Project File - Name="timeout2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=timeout2 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "timeout2.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "timeout2.mak" CFG="timeout2 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "timeout2 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "timeout2 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "timeout2 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "timeout2 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "timeout2 - Win32 Release" # Name "timeout2 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\timeout2.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/timeout3.dsp100664 001750 000144 00000010717 11623073530 0015324# Microsoft Developer Studio Project File - Name="timeout3" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=timeout3 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "timeout3.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "timeout3.mak" CFG="timeout3 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "timeout3 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "timeout3 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "timeout3 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "timeout3 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "timeout3 - Win32 Release" # Name "timeout3 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\timeout3.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/connect2.dsp100664 001750 000144 00000010717 11623073530 0015266# Microsoft Developer Studio Project File - Name="connect2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=connect2 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "connect2.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "connect2.mak" CFG="connect2 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "connect2 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "connect2 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "connect2 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "connect2 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "connect2 - Win32 Release" # Name "connect2 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\connect2.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/timeout4.dsp100664 001750 000144 00000010717 11623073530 0015325# Microsoft Developer Studio Project File - Name="timeout4" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=timeout4 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "timeout4.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "timeout4.mak" CFG="timeout4 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "timeout4 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "timeout4 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "timeout4 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "timeout4 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "timeout4 - Win32 Release" # Name "timeout4 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\timeout4.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/freeclose.dsp100664 001750 000144 00000010733 11623073530 0015520# Microsoft Developer Studio Project File - Name="freeclose" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=freeclose - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "freeclose.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "freeclose.mak" CFG="freeclose - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "freeclose - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "freeclose - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "freeclose - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "freeclose - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "freeclose - Win32 Release" # Name "freeclose - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\freeclose.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/cursor3.dsp100664 001750 000144 00000010703 11623073530 0015146# Microsoft Developer Studio Project File - Name="cursor3" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cursor3 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "cursor3.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "cursor3.mak" CFG="cursor3 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cursor3 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cursor3 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "cursor3 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cursor3 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "cursor3 - Win32 Release" # Name "cursor3 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\cursor3.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/cursor4.dsp100664 001750 000144 00000010703 11623073530 0015147# Microsoft Developer Studio Project File - Name="cursor4" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cursor4 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "cursor4.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "cursor4.mak" CFG="cursor4 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cursor4 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cursor4 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "cursor4 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cursor4 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "cursor4 - Win32 Release" # Name "cursor4 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\cursor4.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/cursor5.dsp100664 001750 000144 00000010703 11623073530 0015150# Microsoft Developer Studio Project File - Name="cursor5" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cursor5 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "cursor5.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "cursor5.mak" CFG="cursor5 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cursor5 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cursor5 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "cursor5 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cursor5 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "cursor5 - Win32 Release" # Name "cursor5 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\cursor5.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/attributes.dsp100664 001750 000144 00000010747 11623073530 0015744# Microsoft Developer Studio Project File - Name="attributes" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=attributes - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "attributes.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "attributes.mak" CFG="attributes - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "attributes - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "attributes - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "attributes - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "attributes - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "attributes - Win32 Release" # Name "attributes - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\attributes.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/hidden.dsp100664 001750 000144 00000010667 11623073530 0015012# Microsoft Developer Studio Project File - Name="hidden" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=hidden - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "hidden.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "hidden.mak" CFG="hidden - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "hidden - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "hidden - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "hidden - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "hidden - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "hidden - Win32 Release" # Name "hidden - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\hidden.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/blob1.dsp100664 001750 000144 00000010653 11623073530 0014551# Microsoft Developer Studio Project File - Name="blob1" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=blob1 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "blob1.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "blob1.mak" CFG="blob1 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "blob1 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "blob1 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "blob1 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "blob1 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "blob1 - Win32 Release" # Name "blob1 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\blob1.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/cancel.dsp100664 001750 000144 00000010667 11623073530 0015004# Microsoft Developer Studio Project File - Name="cancel" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cancel - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "cancel.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "cancel.mak" CFG="cancel - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cancel - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cancel - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "cancel - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cancel - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "cancel - Win32 Release" # Name "cancel - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\cancel.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/wchar.dsp100664 001750 000144 00000010653 11623073530 0014656# Microsoft Developer Studio Project File - Name="wchar" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=wchar - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "wchar.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "wchar.mak" CFG="wchar - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "wchar - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "wchar - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "wchar - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "wchar - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "wchar - Win32 Release" # Name "wchar - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\wchar.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/rowset.dsp100664 001750 000144 00000010667 11623073530 0015102# Microsoft Developer Studio Project File - Name="rowset" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=rowset - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "rowset.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "rowset.mak" CFG="rowset - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "rowset - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "rowset - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "rowset - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "rowset - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "rowset - Win32 Release" # Name "rowset - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\rowset.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/transaction2.dsp100664 001750 000144 00000010777 11623073530 0016170# Microsoft Developer Studio Project File - Name="transaction2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=transaction2 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "transaction2.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "transaction2.mak" CFG="transaction2 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "transaction2 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "transaction2 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "transaction2 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "transaction2 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "transaction2 - Win32 Release" # Name "transaction2 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\transaction2.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/cursor6.dsp100664 001750 000144 00000010703 11623073530 0015151# Microsoft Developer Studio Project File - Name="cursor6" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cursor6 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "cursor6.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "cursor6.mak" CFG="cursor6 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cursor6 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cursor6 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "cursor6 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cursor6 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "cursor6 - Win32 Release" # Name "cursor6 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\cursor6.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/cursor7.dsp100664 001750 000144 00000010703 11623073530 0015152# Microsoft Developer Studio Project File - Name="cursor7" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cursor7 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "cursor7.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "cursor7.mak" CFG="cursor7 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cursor7 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cursor7 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "cursor7 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cursor7 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "cursor7 - Win32 Release" # Name "cursor7 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\cursor7.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/utf8.dsp100664 001750 000144 00000010637 11623073530 0014442# Microsoft Developer Studio Project File - Name="utf8" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=utf8 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "utf8.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "utf8.mak" CFG="utf8 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "utf8 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "utf8 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "utf8 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "utf8 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "utf8 - Win32 Release" # Name "utf8 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\utf8.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/utf8_2.dsp100664 001750 000144 00000010667 11623073530 0014666# Microsoft Developer Studio Project File - Name="utf8_2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=utf8_2 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "utf8_2.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "utf8_2.mak" CFG="utf8_2 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "utf8_2 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "utf8_2 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "utf8_2 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "utf8_2 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "utf8_2 - Win32 Release" # Name "utf8_2 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\utf8_2.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/stats.dsp100664 001750 000144 00000010653 11623073530 0014710# Microsoft Developer Studio Project File - Name="stats" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=stats - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "stats.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "stats.mak" CFG="stats - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "stats - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "stats - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "stats - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "stats - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "stats - Win32 Release" # Name "stats - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\stats.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/descrec.dsp100664 001750 000144 00000010703 11623073530 0015156# Microsoft Developer Studio Project File - Name="descrec" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=descrec - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "descrec.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "descrec.mak" CFG="descrec - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "descrec - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "descrec - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "descrec - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "descrec - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "descrec - Win32 Release" # Name "descrec - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\descrec.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/peter.dsp100664 001750 000144 00000010653 11623073530 0014671# Microsoft Developer Studio Project File - Name="peter" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=peter - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "peter.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "peter.mak" CFG="peter - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "peter - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "peter - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "peter - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "peter - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "peter - Win32 Release" # Name "peter - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\peter.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/vc6/t0001.dsp100664 001750 000144 00000010653 11623073530 0014316# Microsoft Developer Studio Project File - Name="t0001" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=t0001 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "t0001.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "t0001.mak" CFG="t0001 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "t0001 - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "t0001 - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "t0001 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "..\Release" # PROP BASE Intermediate_Dir "..\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release" # PROP Intermediate_Dir "..\Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t0001 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "..\Debug" # PROP BASE Intermediate_Dir "..\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Debug" # PROP Intermediate_Dir "..\Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "t0001 - Win32 Release" # Name "t0001 - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\common.c # End Source File # Begin Source File SOURCE=..\t0001.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\common.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project freetds-0.91/src/odbc/unittests/odbc.dsw100664 001750 000144 00000032043 11623073531 0013770Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "t0001"=.\vc6\t0001.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0002"=.\vc6\t0002.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0003"=.\vc6\t0003.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "t0004"=.\vc6\t0004.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "connect"=.\vc6\connect.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "print"=.\vc6\print.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "date"=.\vc6\date.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "norowset"=.\vc6\norowset.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "funccall"=.\vc6\funccall.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "lang_error"=.\vc6\lang_error.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "tables"=.\vc6\tables.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "binary_test"=.\vc6\binary_test.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "moreandcount"=.\vc6\moreandcount.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "earlybind"=.\vc6\earlybind.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "putdata"=.\vc6\putdata.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "params"=.\vc6\params.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "raiserror"=.\vc6\raiserror.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "getdata"=.\vc6\getdata.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "transaction"=.\vc6\transaction.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "type"=.\vc6\type.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "genparams"=.\vc6\genparams.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "preperror"=.\vc6\preperror.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "prepare_results"=.\vc6\prepare_results.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "testodbc"=.\vc6\testodbc.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "data"=.\vc6\data.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "error"=.\vc6\error.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "rebindpar"=.\vc6\rebindpar.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "rpc"=.\vc6\rpc.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "convert_error"=.\vc6\convert_error.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "typeinfo"=.\vc6\typeinfo.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "const_params"=.\vc6\const_params.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "insert_speed"=.\vc6\insert_speed.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "compute"=.\vc6\compute.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "timeout"=.\vc6\timeout.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "array"=.\vc6\array.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "array_out"=.\vc6\array_out.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "cursor1"=.\vc6\cursor1.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "scroll"=.\vc6\scroll.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "cursor2"=.\vc6\cursor2.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "describecol"=.\vc6\describecol.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "copydesc"=.\vc6\copydesc.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "prepclose"=.\vc6\prepclose.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "warning"=.\vc6\warning.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "paramcore"=.\vc6\paramcore.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "timeout2"=.\vc6\timeout2.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "timeout3"=.\vc6\timeout3.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "connect2"=.\vc6\connect2.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "timeout4"=.\vc6\timeout4.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "freeclose"=.\vc6\freeclose.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "cursor3"=.\vc6\cursor3.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "cursor4"=.\vc6\cursor4.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "cursor5"=.\vc6\cursor5.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "attributes"=.\vc6\attributes.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "hidden"=.\vc6\hidden.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "blob1"=.\vc6\blob1.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "cancel"=.\vc6\cancel.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "wchar"=.\vc6\wchar.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "rowset"=.\vc6\rowset.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "transaction2"=.\vc6\transaction2.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "cursor6"=.\vc6\cursor6.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "cursor7"=.\vc6\cursor7.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "utf8"=.\vc6\utf8.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "utf8_2"=.\vc6\utf8_2.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "stats"=.\vc6\stats.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "descrec"=.\vc6\descrec.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "peter"=.\vc6\peter.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "test64"=.\vc6\test64.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### freetds-0.91/src/odbc/unittests/odbc.mak100664 001750 000144 00000045560 11623073531 0013753!IF "$(OS)" == "Windows_NT" NULL= !ELSE NULL=nul !ENDIF OUTDIR=.\Release INTDIR=.\Release ALL : \ "$(OUTDIR)\t0001.exe" \ "$(OUTDIR)\t0002.exe" \ "$(OUTDIR)\t0003.exe" \ "$(OUTDIR)\t0004.exe" \ "$(OUTDIR)\connect.exe" \ "$(OUTDIR)\print.exe" \ "$(OUTDIR)\date.exe" \ "$(OUTDIR)\norowset.exe" \ "$(OUTDIR)\funccall.exe" \ "$(OUTDIR)\lang_error.exe" \ "$(OUTDIR)\tables.exe" \ "$(OUTDIR)\binary_test.exe" \ "$(OUTDIR)\moreandcount.exe" \ "$(OUTDIR)\earlybind.exe" \ "$(OUTDIR)\putdata.exe" \ "$(OUTDIR)\params.exe" \ "$(OUTDIR)\raiserror.exe" \ "$(OUTDIR)\getdata.exe" \ "$(OUTDIR)\transaction.exe" \ "$(OUTDIR)\type.exe" \ "$(OUTDIR)\genparams.exe" \ "$(OUTDIR)\preperror.exe" \ "$(OUTDIR)\prepare_results.exe" \ "$(OUTDIR)\testodbc.exe" \ "$(OUTDIR)\data.exe" \ "$(OUTDIR)\error.exe" \ "$(OUTDIR)\rebindpar.exe" \ "$(OUTDIR)\rpc.exe" \ "$(OUTDIR)\convert_error.exe" \ "$(OUTDIR)\typeinfo.exe" \ "$(OUTDIR)\const_params.exe" \ "$(OUTDIR)\insert_speed.exe" \ "$(OUTDIR)\compute.exe" \ "$(OUTDIR)\timeout.exe" \ "$(OUTDIR)\array.exe" \ "$(OUTDIR)\array_out.exe" \ "$(OUTDIR)\cursor1.exe" \ "$(OUTDIR)\scroll.exe" \ "$(OUTDIR)\cursor2.exe" \ "$(OUTDIR)\describecol.exe" \ "$(OUTDIR)\copydesc.exe" \ "$(OUTDIR)\prepclose.exe" \ "$(OUTDIR)\warning.exe" \ "$(OUTDIR)\paramcore.exe" \ "$(OUTDIR)\timeout2.exe" \ "$(OUTDIR)\timeout3.exe" \ "$(OUTDIR)\connect2.exe" \ "$(OUTDIR)\timeout4.exe" \ "$(OUTDIR)\freeclose.exe" \ "$(OUTDIR)\cursor3.exe" \ "$(OUTDIR)\cursor4.exe" \ "$(OUTDIR)\cursor5.exe" \ "$(OUTDIR)\attributes.exe" \ "$(OUTDIR)\hidden.exe" \ "$(OUTDIR)\blob1.exe" \ "$(OUTDIR)\cancel.exe" \ "$(OUTDIR)\wchar.exe" \ "$(OUTDIR)\rowset.exe" \ "$(OUTDIR)\transaction2.exe" \ "$(OUTDIR)\cursor6.exe" \ "$(OUTDIR)\cursor7.exe" \ "$(OUTDIR)\utf8.exe" \ "$(OUTDIR)\utf8_2.exe" \ "$(OUTDIR)\stats.exe" \ "$(OUTDIR)\descrec.exe" \ "$(OUTDIR)\peter.exe" \ "$(OUTDIR)\test64.exe" CLEAN : -@erase "$(INTDIR)*.obj" -@erase "$(OUTDIR)*.exe" "$(OUTDIR)" : if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" CPP=cl.exe CPP_PROJ=/nologo /MD /W3 /O2 /Ob2 /I "./" /D WIN32 /D NDEBUG /D _CONSOLE /D _MBCS /D FREETDS_SRCDIR=\"..\" /D DBNTWIN32 /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c .c{$(INTDIR)}.obj:: $(CPP) $(CPP_PROJ) $< LINK32=link.exe LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib advapi32.lib ws2_32.lib odbc32.lib ntwdblib.lib /nologo /subsystem:console /incremental:no /machine:I386 "$(OUTDIR)\t0001.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0001.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0001.obj" /pdb:"$(OUTDIR)\t0001.pdb" /out:"$(OUTDIR)\t0001.exe" "$(OUTDIR)\t0002.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0002.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0002.obj" /pdb:"$(OUTDIR)\t0002.pdb" /out:"$(OUTDIR)\t0002.exe" "$(OUTDIR)\t0003.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0003.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0003.obj" /pdb:"$(OUTDIR)\t0003.pdb" /out:"$(OUTDIR)\t0003.exe" "$(OUTDIR)\t0004.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\t0004.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\t0004.obj" /pdb:"$(OUTDIR)\t0004.pdb" /out:"$(OUTDIR)\t0004.exe" "$(OUTDIR)\connect.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\connect.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\connect.obj" /pdb:"$(OUTDIR)\connect.pdb" /out:"$(OUTDIR)\connect.exe" "$(OUTDIR)\print.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\print.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\print.obj" /pdb:"$(OUTDIR)\print.pdb" /out:"$(OUTDIR)\print.exe" "$(OUTDIR)\date.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\date.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\date.obj" /pdb:"$(OUTDIR)\date.pdb" /out:"$(OUTDIR)\date.exe" "$(OUTDIR)\norowset.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\norowset.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\norowset.obj" /pdb:"$(OUTDIR)\norowset.pdb" /out:"$(OUTDIR)\norowset.exe" "$(OUTDIR)\funccall.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\funccall.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\funccall.obj" /pdb:"$(OUTDIR)\funccall.pdb" /out:"$(OUTDIR)\funccall.exe" "$(OUTDIR)\lang_error.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\lang_error.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\lang_error.obj" /pdb:"$(OUTDIR)\lang_error.pdb" /out:"$(OUTDIR)\lang_error.exe" "$(OUTDIR)\tables.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\tables.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\tables.obj" /pdb:"$(OUTDIR)\tables.pdb" /out:"$(OUTDIR)\tables.exe" "$(OUTDIR)\binary_test.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\binary_test.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\binary_test.obj" /pdb:"$(OUTDIR)\binary_test.pdb" /out:"$(OUTDIR)\binary_test.exe" "$(OUTDIR)\moreandcount.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\moreandcount.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\moreandcount.obj" /pdb:"$(OUTDIR)\moreandcount.pdb" /out:"$(OUTDIR)\moreandcount.exe" "$(OUTDIR)\earlybind.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\earlybind.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\earlybind.obj" /pdb:"$(OUTDIR)\earlybind.pdb" /out:"$(OUTDIR)\earlybind.exe" "$(OUTDIR)\putdata.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\putdata.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\putdata.obj" /pdb:"$(OUTDIR)\putdata.pdb" /out:"$(OUTDIR)\putdata.exe" "$(OUTDIR)\params.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\params.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\params.obj" /pdb:"$(OUTDIR)\params.pdb" /out:"$(OUTDIR)\params.exe" "$(OUTDIR)\raiserror.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\raiserror.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\raiserror.obj" /pdb:"$(OUTDIR)\raiserror.pdb" /out:"$(OUTDIR)\raiserror.exe" "$(OUTDIR)\getdata.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\getdata.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\getdata.obj" /pdb:"$(OUTDIR)\getdata.pdb" /out:"$(OUTDIR)\getdata.exe" "$(OUTDIR)\transaction.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\transaction.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\transaction.obj" /pdb:"$(OUTDIR)\transaction.pdb" /out:"$(OUTDIR)\transaction.exe" "$(OUTDIR)\type.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\type.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\type.obj" /pdb:"$(OUTDIR)\type.pdb" /out:"$(OUTDIR)\type.exe" "$(OUTDIR)\genparams.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\genparams.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\genparams.obj" /pdb:"$(OUTDIR)\genparams.pdb" /out:"$(OUTDIR)\genparams.exe" "$(OUTDIR)\preperror.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\preperror.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\preperror.obj" /pdb:"$(OUTDIR)\preperror.pdb" /out:"$(OUTDIR)\preperror.exe" "$(OUTDIR)\prepare_results.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\prepare_results.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\prepare_results.obj" /pdb:"$(OUTDIR)\prepare_results.pdb" /out:"$(OUTDIR)\prepare_results.exe" "$(OUTDIR)\testodbc.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\testodbc.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\testodbc.obj" /pdb:"$(OUTDIR)\testodbc.pdb" /out:"$(OUTDIR)\testodbc.exe" "$(OUTDIR)\data.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\data.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\data.obj" /pdb:"$(OUTDIR)\data.pdb" /out:"$(OUTDIR)\data.exe" "$(OUTDIR)\error.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\error.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\error.obj" /pdb:"$(OUTDIR)\error.pdb" /out:"$(OUTDIR)\error.exe" "$(OUTDIR)\rebindpar.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\rebindpar.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\rebindpar.obj" /pdb:"$(OUTDIR)\rebindpar.pdb" /out:"$(OUTDIR)\rebindpar.exe" "$(OUTDIR)\rpc.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\rpc.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\rpc.obj" /pdb:"$(OUTDIR)\rpc.pdb" /out:"$(OUTDIR)\rpc.exe" "$(OUTDIR)\convert_error.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\convert_error.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\convert_error.obj" /pdb:"$(OUTDIR)\convert_error.pdb" /out:"$(OUTDIR)\convert_error.exe" "$(OUTDIR)\typeinfo.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\typeinfo.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\typeinfo.obj" /pdb:"$(OUTDIR)\typeinfo.pdb" /out:"$(OUTDIR)\typeinfo.exe" "$(OUTDIR)\const_params.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\const_params.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\const_params.obj" /pdb:"$(OUTDIR)\const_params.pdb" /out:"$(OUTDIR)\const_params.exe" "$(OUTDIR)\insert_speed.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\insert_speed.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\insert_speed.obj" /pdb:"$(OUTDIR)\insert_speed.pdb" /out:"$(OUTDIR)\insert_speed.exe" "$(OUTDIR)\compute.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\compute.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\compute.obj" /pdb:"$(OUTDIR)\compute.pdb" /out:"$(OUTDIR)\compute.exe" "$(OUTDIR)\timeout.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\timeout.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\timeout.obj" /pdb:"$(OUTDIR)\timeout.pdb" /out:"$(OUTDIR)\timeout.exe" "$(OUTDIR)\array.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\array.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\array.obj" /pdb:"$(OUTDIR)\array.pdb" /out:"$(OUTDIR)\array.exe" "$(OUTDIR)\array_out.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\array_out.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\array_out.obj" /pdb:"$(OUTDIR)\array_out.pdb" /out:"$(OUTDIR)\array_out.exe" "$(OUTDIR)\cursor1.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\cursor1.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\cursor1.obj" /pdb:"$(OUTDIR)\cursor1.pdb" /out:"$(OUTDIR)\cursor1.exe" "$(OUTDIR)\scroll.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\scroll.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\scroll.obj" /pdb:"$(OUTDIR)\scroll.pdb" /out:"$(OUTDIR)\scroll.exe" "$(OUTDIR)\cursor2.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\cursor2.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\cursor2.obj" /pdb:"$(OUTDIR)\cursor2.pdb" /out:"$(OUTDIR)\cursor2.exe" "$(OUTDIR)\describecol.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\describecol.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\describecol.obj" /pdb:"$(OUTDIR)\describecol.pdb" /out:"$(OUTDIR)\describecol.exe" "$(OUTDIR)\copydesc.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\copydesc.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\copydesc.obj" /pdb:"$(OUTDIR)\copydesc.pdb" /out:"$(OUTDIR)\copydesc.exe" "$(OUTDIR)\prepclose.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\prepclose.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\prepclose.obj" /pdb:"$(OUTDIR)\prepclose.pdb" /out:"$(OUTDIR)\prepclose.exe" "$(OUTDIR)\warning.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\warning.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\warning.obj" /pdb:"$(OUTDIR)\warning.pdb" /out:"$(OUTDIR)\warning.exe" "$(OUTDIR)\paramcore.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\paramcore.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\paramcore.obj" /pdb:"$(OUTDIR)\paramcore.pdb" /out:"$(OUTDIR)\paramcore.exe" "$(OUTDIR)\timeout2.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\timeout2.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\timeout2.obj" /pdb:"$(OUTDIR)\timeout2.pdb" /out:"$(OUTDIR)\timeout2.exe" "$(OUTDIR)\timeout3.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\timeout3.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\timeout3.obj" /pdb:"$(OUTDIR)\timeout3.pdb" /out:"$(OUTDIR)\timeout3.exe" "$(OUTDIR)\connect2.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\connect2.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\connect2.obj" /pdb:"$(OUTDIR)\connect2.pdb" /out:"$(OUTDIR)\connect2.exe" "$(OUTDIR)\timeout4.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\timeout4.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\timeout4.obj" /pdb:"$(OUTDIR)\timeout4.pdb" /out:"$(OUTDIR)\timeout4.exe" "$(OUTDIR)\freeclose.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\freeclose.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\freeclose.obj" /pdb:"$(OUTDIR)\freeclose.pdb" /out:"$(OUTDIR)\freeclose.exe" "$(OUTDIR)\cursor3.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\cursor3.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\cursor3.obj" /pdb:"$(OUTDIR)\cursor3.pdb" /out:"$(OUTDIR)\cursor3.exe" "$(OUTDIR)\cursor4.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\cursor4.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\cursor4.obj" /pdb:"$(OUTDIR)\cursor4.pdb" /out:"$(OUTDIR)\cursor4.exe" "$(OUTDIR)\cursor5.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\cursor5.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\cursor5.obj" /pdb:"$(OUTDIR)\cursor5.pdb" /out:"$(OUTDIR)\cursor5.exe" "$(OUTDIR)\attributes.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\attributes.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\attributes.obj" /pdb:"$(OUTDIR)\attributes.pdb" /out:"$(OUTDIR)\attributes.exe" "$(OUTDIR)\hidden.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\hidden.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\hidden.obj" /pdb:"$(OUTDIR)\hidden.pdb" /out:"$(OUTDIR)\hidden.exe" "$(OUTDIR)\blob1.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\blob1.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\blob1.obj" /pdb:"$(OUTDIR)\blob1.pdb" /out:"$(OUTDIR)\blob1.exe" "$(OUTDIR)\cancel.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\cancel.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\cancel.obj" /pdb:"$(OUTDIR)\cancel.pdb" /out:"$(OUTDIR)\cancel.exe" "$(OUTDIR)\wchar.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\wchar.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\wchar.obj" /pdb:"$(OUTDIR)\wchar.pdb" /out:"$(OUTDIR)\wchar.exe" "$(OUTDIR)\rowset.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\rowset.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\rowset.obj" /pdb:"$(OUTDIR)\rowset.pdb" /out:"$(OUTDIR)\rowset.exe" "$(OUTDIR)\transaction2.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\transaction2.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\transaction2.obj" /pdb:"$(OUTDIR)\transaction2.pdb" /out:"$(OUTDIR)\transaction2.exe" "$(OUTDIR)\cursor6.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\cursor6.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\cursor6.obj" /pdb:"$(OUTDIR)\cursor6.pdb" /out:"$(OUTDIR)\cursor6.exe" "$(OUTDIR)\cursor7.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\cursor7.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\cursor7.obj" /pdb:"$(OUTDIR)\cursor7.pdb" /out:"$(OUTDIR)\cursor7.exe" "$(OUTDIR)\utf8.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\utf8.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\utf8.obj" /pdb:"$(OUTDIR)\utf8.pdb" /out:"$(OUTDIR)\utf8.exe" "$(OUTDIR)\utf8_2.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\utf8_2.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\utf8_2.obj" /pdb:"$(OUTDIR)\utf8_2.pdb" /out:"$(OUTDIR)\utf8_2.exe" "$(OUTDIR)\stats.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\stats.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\stats.obj" /pdb:"$(OUTDIR)\stats.pdb" /out:"$(OUTDIR)\stats.exe" "$(OUTDIR)\descrec.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\descrec.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\descrec.obj" /pdb:"$(OUTDIR)\descrec.pdb" /out:"$(OUTDIR)\descrec.exe" "$(OUTDIR)\peter.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\peter.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\peter.obj" /pdb:"$(OUTDIR)\peter.pdb" /out:"$(OUTDIR)\peter.exe" "$(OUTDIR)\test64.exe" : "$(OUTDIR)" "$(INTDIR)\common.obj" "$(INTDIR)\test64.obj" $(LINK32) $(LINK32_FLAGS) "$(INTDIR)\common.obj" "$(INTDIR)\test64.obj" /pdb:"$(OUTDIR)\test64.pdb" /out:"$(OUTDIR)\test64.exe" CHECK : "$(OUTDIR)\t0001.exe" "$(OUTDIR)\t0002.exe" "$(OUTDIR)\t0003.exe" "$(OUTDIR)\t0004.exe" "$(OUTDIR)\connect.exe" "$(OUTDIR)\print.exe" "$(OUTDIR)\date.exe" "$(OUTDIR)\norowset.exe" "$(OUTDIR)\funccall.exe" "$(OUTDIR)\lang_error.exe" "$(OUTDIR)\tables.exe" "$(OUTDIR)\binary_test.exe" "$(OUTDIR)\moreandcount.exe" "$(OUTDIR)\earlybind.exe" "$(OUTDIR)\putdata.exe" "$(OUTDIR)\params.exe" "$(OUTDIR)\raiserror.exe" "$(OUTDIR)\getdata.exe" "$(OUTDIR)\transaction.exe" "$(OUTDIR)\type.exe" "$(OUTDIR)\genparams.exe" "$(OUTDIR)\preperror.exe" "$(OUTDIR)\prepare_results.exe" "$(OUTDIR)\testodbc.exe" "$(OUTDIR)\data.exe" "$(OUTDIR)\error.exe" "$(OUTDIR)\rebindpar.exe" "$(OUTDIR)\rpc.exe" "$(OUTDIR)\convert_error.exe" "$(OUTDIR)\typeinfo.exe" "$(OUTDIR)\const_params.exe" "$(OUTDIR)\insert_speed.exe" "$(OUTDIR)\compute.exe" "$(OUTDIR)\timeout.exe" "$(OUTDIR)\array.exe" "$(OUTDIR)\array_out.exe" "$(OUTDIR)\cursor1.exe" "$(OUTDIR)\scroll.exe" "$(OUTDIR)\cursor2.exe" "$(OUTDIR)\describecol.exe" "$(OUTDIR)\copydesc.exe" "$(OUTDIR)\prepclose.exe" "$(OUTDIR)\warning.exe" "$(OUTDIR)\paramcore.exe" "$(OUTDIR)\timeout2.exe" "$(OUTDIR)\timeout3.exe" "$(OUTDIR)\connect2.exe" "$(OUTDIR)\timeout4.exe" "$(OUTDIR)\freeclose.exe" "$(OUTDIR)\cursor3.exe" "$(OUTDIR)\cursor4.exe" "$(OUTDIR)\cursor5.exe" "$(OUTDIR)\attributes.exe" "$(OUTDIR)\hidden.exe" "$(OUTDIR)\blob1.exe" "$(OUTDIR)\cancel.exe" "$(OUTDIR)\wchar.exe" "$(OUTDIR)\rowset.exe" "$(OUTDIR)\transaction2.exe" "$(OUTDIR)\cursor6.exe" "$(OUTDIR)\cursor7.exe" "$(OUTDIR)\utf8.exe" "$(OUTDIR)\utf8_2.exe" "$(OUTDIR)\stats.exe" "$(OUTDIR)\descrec.exe" "$(OUTDIR)\peter.exe" "$(OUTDIR)\test64.exe" freetds-0.91/src/apps/osql100755 001750 000144 00000021531 11562377051 0011244#! /bin/sh # $Id: osql,v 1.11.2.1 2011/05/11 03:10:33 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 "[${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 '{print $3}') 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 '{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 '=[[:space:]]*' '{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 "[${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:]]*=') HOST=$(echo ${SERVER_LINE} | awk '{print $3}') 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 '{print $3}') 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}\"" fi fi # Now we have a DNS hostname for the server in HOST ADDRESS=$(host ${HOST} | awk '/has address/ {print $4}' | head -1) 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-0.91/src/apps/Makefile.am100664 001750 000144 00000002245 11327730444 0012375# $Id: Makefile.am,v 1.30 2010/01/27 03:21:08 jklowden Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include SUBDIRS = fisql DIST_SUBDIRS = $(SUBDIRS) # build bsqlodbc only if the ODBC library was to be built if ODBC bin_PROGRAMS = tsql freebcp bsqldb defncopy datacopy bsqlodbc else bin_PROGRAMS = tsql freebcp bsqldb defncopy datacopy endif dist_bin_SCRIPTS = osql freebcp_LDADD = ../dblib/libsybdb.la ../replacements/libreplacements.la $(LIBICONV) $(NETWORK_LIBS) freebcp_SOURCES = freebcp.c freebcp.h tsql_LDADD = ../tds/libtds.la \ ../replacements/libreplacements.la \ $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) $(READLINE_LIBS) bsqldb_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(NETWORK_LIBS) $(LIBICONV) if ODBC bsqlodbc_CPPFLAGS = $(ODBC_INC) $(AM_CPPFLAGS) bsqlodbc_LDADD = $(ODBCLIB) $(ODBCNODMLIBAPP) \ ../replacements/libreplacements.la $(NETWORK_LIBS) $(LIBICONV) endif defncopy_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(NETWORK_LIBS) $(LIBICONV) datacopy_SOURCES= datacopy.c datacopy_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(NETWORK_LIBS) $(LIBICONV) freetds-0.91/src/apps/Makefile.in100664 001750 000144 00000075045 11623070617 0012414# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.30 2010/01/27 03:21:08 jklowden Exp $ VPATH = @srcdir@ 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_FALSE@bin_PROGRAMS = tsql$(EXEEXT) freebcp$(EXEEXT) \ @ODBC_FALSE@ bsqldb$(EXEEXT) defncopy$(EXEEXT) \ @ODBC_FALSE@ datacopy$(EXEEXT) @ODBC_TRUE@bin_PROGRAMS = tsql$(EXEEXT) freebcp$(EXEEXT) \ @ODBC_TRUE@ bsqldb$(EXEEXT) defncopy$(EXEEXT) datacopy$(EXEEXT) \ @ODBC_TRUE@ bsqlodbc$(EXEEXT) subdir = src/apps DIST_COMMON = $(dist_bin_SCRIPTS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = 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__DEPENDENCIES_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) \ $(am__DEPENDENCIES_1) defncopy_SOURCES = defncopy.c defncopy_OBJECTS = defncopy.$(OBJEXT) defncopy_DEPENDENCIES = ../dblib/libsybdb.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_freebcp_OBJECTS = freebcp.$(OBJEXT) freebcp_OBJECTS = $(am_freebcp_OBJECTS) freebcp_DEPENDENCIES = ../dblib/libsybdb.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) \ $(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' SCRIPTS = $(dist_bin_SCRIPTS) 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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ 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 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 uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags 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@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 $(LIBICONV) $(NETWORK_LIBS) freebcp_SOURCES = freebcp.c freebcp.h tsql_LDADD = ../tds/libtds.la \ ../replacements/libreplacements.la \ $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) $(READLINE_LIBS) bsqldb_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(NETWORK_LIBS) $(LIBICONV) @ODBC_TRUE@bsqlodbc_CPPFLAGS = $(ODBC_INC) $(AM_CPPFLAGS) @ODBC_TRUE@bsqlodbc_LDADD = $(ODBCLIB) $(ODBCNODMLIBAPP) \ @ODBC_TRUE@ ../replacements/libreplacements.la $(NETWORK_LIBS) $(LIBICONV) defncopy_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(NETWORK_LIBS) $(LIBICONV) datacopy_SOURCES = datacopy.c datacopy_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(NETWORK_LIBS) $(LIBICONV) 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 .PRECIOUS: 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) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 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) @rm -f bsqldb$(EXEEXT) $(LINK) $(bsqldb_OBJECTS) $(bsqldb_LDADD) $(LIBS) bsqlodbc$(EXEEXT): $(bsqlodbc_OBJECTS) $(bsqlodbc_DEPENDENCIES) @rm -f bsqlodbc$(EXEEXT) $(LINK) $(bsqlodbc_OBJECTS) $(bsqlodbc_LDADD) $(LIBS) datacopy$(EXEEXT): $(datacopy_OBJECTS) $(datacopy_DEPENDENCIES) @rm -f datacopy$(EXEEXT) $(LINK) $(datacopy_OBJECTS) $(datacopy_LDADD) $(LIBS) defncopy$(EXEEXT): $(defncopy_OBJECTS) $(defncopy_DEPENDENCIES) @rm -f defncopy$(EXEEXT) $(LINK) $(defncopy_OBJECTS) $(defncopy_LDADD) $(LIBS) freebcp$(EXEEXT): $(freebcp_OBJECTS) $(freebcp_DEPENDENCIES) @rm -f freebcp$(EXEEXT) $(LINK) $(freebcp_OBJECTS) $(freebcp_LDADD) $(LIBS) tsql$(EXEEXT): $(tsql_OBJECTS) $(tsql_DEPENDENCIES) @rm -f tsql$(EXEEXT) $(LINK) $(tsql_OBJECTS) $(tsql_LDADD) $(LIBS) install-dist_binSCRIPTS: $(dist_bin_SCRIPTS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ 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)'`; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files 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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< bsqlodbc-bsqlodbc.o: bsqlodbc.c @am__fastdepCC_TRUE@ $(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__mv) $(DEPDIR)/bsqlodbc-bsqlodbc.Tpo $(DEPDIR)/bsqlodbc-bsqlodbc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bsqlodbc.c' object='bsqlodbc-bsqlodbc.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(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@ $(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__mv) $(DEPDIR)/bsqlodbc-bsqlodbc.Tpo $(DEPDIR)/bsqlodbc-bsqlodbc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bsqlodbc.c' object='bsqlodbc-bsqlodbc.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(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. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; 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" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) 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; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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 \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool ctags ctags-recursive 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-recursive \ uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-dist_binSCRIPTS # 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-0.91/src/apps/bsqldb.c100664 001750 000144 00000065754 11537233776 0012003/* 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. */ #if HAVE_CONFIG_H #include #endif #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" static char software_version[] = "$Id: bsqldb.c,v 1.49 2011/03/13 21:32:46 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #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; }; static int set_format_string(struct METADATA * meta, const char separator[]); 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; } OPTIONS; 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__); /* * Connect to the server */ if ((dbproc = dbopen(login, options.servername)) == NULL) return 1; /* Switch to the specified database, if any */ if (options.database) dbuse(dbproc, options.database); /* * 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; 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 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 { char *buffer; int status; } *data = NULL; struct METACOMP { int numalts; struct METADATA *meta; struct DATA *data; } **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); return; } fprintf(options.verbose, "Result set %d\n", iresultset); /* Free prior allocations, if any. */ fprintf(options.verbose, "Freeing prior allocations\n"); for (c=0; c < ncols; c++) { free(metadata[c].format_string); free(data[c].buffer); } free(metadata); metadata = NULL; free(data); data = NULL; ncols = 0; 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); metacompute = NULL; 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); return; } /* * 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 = 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); return; } 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); return; } } 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); break; } free(bynames); bynames = s; } if( altcolid == -1 ) { colname = "*"; } else { assert(0 < altcolid && altcolid <= dbnumcols(dbproc)); colname = metadata[--altcolid].name; } asprintf(&metacompute[i]->meta[c].name, "%s(%s)", dbprtype(dbaltop(dbproc, i+1, c+1)), colname); assert(metacompute[i]->meta[c].name); 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); return; } 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 = 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); return; } } } 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 if (fwrite(p, len, 1, stdout) != 1) { perror("could not write to output file"); exit(EXIT_FAILURE); } 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 */ strcat(fmt, &meta->format_string[1]); 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); } 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'; } } } 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 = tds_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:S:dD:i:o:e:t:H:hqv")) != -1) { switch (ch) { case 'U': username = strdup(optarg); break; case 'P': 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 'H': strcpy(options->hostname, optarg); 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\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; } 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-0.91/src/apps/bsqlodbc.c100664 001750 000144 00000057264 11422012631 0012274/* 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. */ #if HAVE_CONFIG_H #include #endif #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" static char software_version[] = "$Id: bsqlodbc.c,v 1.17 2010/07/22 09:55:37 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 = 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 > 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 = SQLAllocHandle(SQL_HANDLE_DESC, hStmt, &hDesc)) != SQL_SUCCESS) { odbc_perror(hStmt, erc, "SQLAllocHandle", "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); } if ((erc = SQLFreeHandle(SQL_HANDLE_DESC, hStmt)) != SQL_SUCCESS) { odbc_perror(hStmt, erc, "SQLFreeHandle", "failed"); exit(EXIT_FAILURE); } } 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); 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 = 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++) { char *s; 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); s = calloc(1, 1 + data[c].len); assert(s); memcpy(s, data[c].buffer, data[c].len); fprintf(stdout, metadata[c].format_string, s); free(s); 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); } } #if 0 static int get_printable_size(int type, int size) /* adapted from src/dblib/dblib.c */ { 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: return 26; /* FIX ME */ case SYBDATETIME4: 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; } } #endif /* 0, not used */ /** * 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 width, ret; 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)? "%%-%d.%ds%s" : "%%%d.%ds%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 = tds_basename(argv[0]); options->colsep = default_colsep; /* may be overridden by -t */ options->odbc_version = SQL_OV_ODBC3; /* may be overridden by -V */ login = 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:dD: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-0.91/src/apps/datacopy.c100664 001750 000144 00000066670 11422012631 0012310/* 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. */ #if HAVE_CONFIG_H #include #endif #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 #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #if HAVE_LOCALE_H #include #endif #include #include #include "replacements.h" enum states { GET_NEXTARG, GET_BATCHSIZE, GET_PACKETSIZE, GET_OWNER, GET_SOURCE, GET_DEST }; typedef struct pd { int batchsize; int packetsize; char *suser; char *spass; char *sserver; char *sdb; char *sdbobject; char *duser; char *dpass; char *dserver; char *ddb; char *ddbobject; char *owner; int tflag; int aflag; int cflag; int Sflag; int Dflag; int bflag; int pflag; int vflag; } BCPPARAMDATA; static void pusage(void); static int process_parameters(int, char **, struct pd *); static int login_to_databases(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(BCPPARAMDATA params, DBPROCESS * dbsrc, DBPROCESS * dbdest); 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 (params.cflag) { if (create_target_table(params.sdbobject, params.owner, params.ddbobject, dbsrc, dbtarget) == FALSE) { printf("datacopy: could not create target table %s.%s . terminating\n", params.owner, params.ddbobject); dbclose(dbsrc); dbclose(dbtarget); return 1; } } if (check_table_structures(params.sdbobject, params.ddbobject, dbsrc, dbtarget) == FALSE) { printf("datacopy: table structures do not match. terminating\n"); dbclose(dbsrc); dbclose(dbtarget); return 1; } if (transfer_data(params, 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; if (fgets(reply, sizeof(reply), stdin) == NULL) return NULL; p = strchr(reply, '\n'); if (p) *p = 0; return strdup(reply); } static int process_parameters(int argc, char **argv, BCPPARAMDATA * pdata) { int state; int i; char *arg; char *tok; /* set some defaults */ pdata->batchsize = 1000; /* get the rest of the arguments */ state = GET_NEXTARG; for (i = 1; i < argc; i++) { arg = argv[i]; switch (state) { case GET_NEXTARG: if (arg[0] != '-') return FALSE; switch (arg[1]) { case 'b': pdata->bflag++; if (strlen(arg) > 2) pdata->batchsize = atoi(&arg[2]); else state = GET_BATCHSIZE; break; case 'p': pdata->pflag++; if (strlen(arg) > 2) pdata->packetsize = atoi(&arg[2]); else state = GET_PACKETSIZE; break; case 't': pdata->tflag++; break; case 'a': pdata->aflag++; break; case 'c': pdata->cflag++; if (strlen(arg) > 2) pdata->owner = strdup(&arg[2]); else state = GET_OWNER; break; case 'd': tdsdump_open(NULL); break; case 'S': pdata->Sflag++; if (strlen(arg) > 2) { tok = strtok(arg + 2, "/"); if (!tok) return FALSE; pdata->sserver = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->suser = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->spass = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->sdb = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->sdbobject = strdup(tok); } else state = GET_SOURCE; break; case 'D': pdata->Dflag++; if (strlen(arg) > 2) { tok = strtok(arg + 2, "/"); if (!tok) return FALSE; pdata->dserver = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->duser = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->dpass = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->ddb = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->ddbobject = strdup(tok); } else state = GET_DEST; break; case 'v': pdata->vflag++; break; default: return FALSE; } break; case GET_BATCHSIZE: pdata->batchsize = atoi(arg); state = GET_NEXTARG; break; case GET_PACKETSIZE: pdata->packetsize = atoi(arg); state = GET_NEXTARG; break; case GET_OWNER: if (arg[0] == '-') { fprintf(stderr, "If -c is specified an owner for the table must be provided.\n"); return FALSE; } pdata->owner = strdup(arg); state = GET_NEXTARG; break; case GET_SOURCE: tok = strtok(arg, "/"); if (!tok) return FALSE; pdata->sserver = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->suser = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->spass = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->sdb = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->sdbobject = strdup(tok); state = GET_NEXTARG; break; case GET_DEST: tok = strtok(arg, "/"); if (!tok) return FALSE; pdata->dserver = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->duser = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->dpass = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->ddb = strdup(tok); tok = strtok(NULL, "/"); if (!tok) return FALSE; pdata->ddbobject = strdup(tok); state = GET_NEXTARG; break; default: break; } } /* 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->sserver = gets_alloc(); printf("Enter Login : "); pdata->suser = gets_alloc(); printf("Enter Password : "); pdata->spass = gets_alloc(); printf("Enter Database : "); pdata->sdb = gets_alloc(); printf("Enter Table : "); pdata->sdbobject = gets_alloc(); } if (!pdata->Dflag) { printf("\nNo [-D]estination information supplied.\n\n"); printf("Enter Server : "); pdata->dserver = gets_alloc(); printf("Enter Login : "); pdata->duser = gets_alloc(); printf("Enter Password : "); pdata->dpass = gets_alloc(); printf("Enter Database : "); pdata->ddb = gets_alloc(); printf("Enter Table : "); pdata->ddbobject = gets_alloc(); } return TRUE; } static int login_to_databases(BCPPARAMDATA * pdata, DBPROCESS ** dbsrc, DBPROCESS ** dbdest) { LOGINREC *slogin; LOGINREC *dlogin; /* 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(); DBSETLUSER(slogin, pdata->suser); DBSETLPWD(slogin, pdata->spass); 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->sserver)) == (DBPROCESS *) NULL) { fprintf(stderr, "Can't connect to source server.\n"); return FALSE; } if (dbuse(*dbsrc, pdata->sdb) == FAIL) { fprintf(stderr, "Can't change database to %s .\n", pdata->sdb); return FALSE; } dlogin = dblogin(); DBSETLUSER(dlogin, pdata->duser); DBSETLPWD(dlogin, pdata->dpass); 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->dserver)) == (DBPROCESS *) NULL) { fprintf(stderr, "Can't connect to destination server.\n"); return FALSE; } if (dbuse(*dbdest, pdata->ddb) == FAIL) { fprintf(stderr, "Can't change database to %s .\n", pdata->sdb); return FALSE; } return TRUE; } static int create_target_table(char *sobjname, char *owner, char *dobjname, DBPROCESS * dbsrc, DBPROCESS * dbdest) { char ls_command[2048]; int i; DBINT num_cols; DBCHAR column_type[33]; DBCOL 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 (NO_MORE_RESULTS != dbresults(dbsrc)); sprintf(ls_command, "CREATE TABLE %s.%s ", owner, dobjname); num_cols = dbnumcols(dbsrc); for (i = 1; i <= num_cols; i++) { if (dbtablecolinfo(dbsrc, i, &colinfo) != SUCCEED) return FALSE; if (i == 1) strcat(ls_command, "( "); else strcat(ls_command, ", "); strcat(ls_command, colinfo.Name); strcat(ls_command, " "); switch (colinfo.Type) { case SYBINT1: strcat(ls_command, "tinyint"); break; case SYBBIT: strcat(ls_command, "bit"); break; case SYBINT2: strcat(ls_command, "smallint"); break; case SYBINT4: strcat(ls_command, "int"); break; case SYBDATETIME: strcat(ls_command, "datetime"); break; case SYBDATETIME4: strcat(ls_command, "smalldatetime"); break; case SYBREAL: strcat(ls_command, "real"); break; case SYBMONEY: strcat(ls_command, "money"); break; case SYBMONEY4: strcat(ls_command, "smallmoney"); break; case SYBFLT8: strcat(ls_command, "float"); break; case SYBDECIMAL: sprintf(column_type, "decimal(%d,%d)", colinfo.Precision, colinfo.Scale); strcat(ls_command, column_type); break; case SYBNUMERIC: sprintf(column_type, "numeric(%d,%d)", colinfo.Precision, colinfo.Scale); strcat(ls_command, column_type); break; case SYBCHAR: sprintf(column_type, "char(%d)", colinfo.MaxLength); strcat(ls_command, column_type); break; case SYBVARCHAR: sprintf(column_type, "varchar(%d)", colinfo.MaxLength); strcat(ls_command, column_type); break; case SYBTEXT: strcat(ls_command, "text"); break; case SYBIMAGE: strcat(ls_command, "image"); break; } if (colinfo.Null == TRUE) { strcat(ls_command, " NULL"); } else { strcat(ls_command, " NOT NULL"); } } strcat(ls_command, " ) "); 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)); return TRUE; } static int check_table_structures(char *sobjname, char *dobjname, DBPROCESS * dbsrc, DBPROCESS * dbdest) { char ls_command[256]; int i; 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 (NO_MORE_RESULTS != dbresults(dbsrc)); { if (0 == (src_numcols = dbnumcols(dbsrc))) { printf("Error in dbnumcols\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 (NO_MORE_RESULTS != dbresults(dbdest)); { if (0 == (dest_numcols = dbnumcols(dbdest))) { printf("Error in dbnumcols\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(BCPPARAMDATA params, DBPROCESS * dbsrc, DBPROCESS * dbdest) { char ls_command[256]; int col; DBINT src_numcols = 0; DBINT src_datlen; typedef struct migcoldata { DBINT coltype; DBINT collen; DBINT nullind; DBCHAR *data; } 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; struct timeval batch_start; struct timeval batch_end; double elapsed_batch = 0.0; if (params.vflag) { printf("\nStarting copy...\n"); } if (params.tflag) { sprintf(ls_command, "truncate table %s", params.ddbobject); 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.sdbobject); 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.ddbobject, (char *) NULL, (char *) NULL, DB_IN) == FAIL) { printf("Error in bcp_init\n"); return FALSE; } srcdata = (MIGCOLDATA **) malloc(sizeof(MIGCOLDATA *) * src_numcols); for (col = 0; col < src_numcols; col++) { srcdata[col] = (MIGCOLDATA *) calloc(1, sizeof(MIGCOLDATA)); srcdata[col]->coltype = dbcoltype(dbsrc, col + 1); srcdata[col]->collen = dbcollen(dbsrc, col + 1); switch (srcdata[col]->coltype) { case SYBBIT: srcdata[col]->data = malloc(sizeof(DBBIT)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, BITBIND, sizeof(DBBIT), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBBIT, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBINT1: srcdata[col]->data = malloc(sizeof(DBTINYINT)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, TINYBIND, sizeof(DBTINYINT), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBINT1, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBINT2: srcdata[col]->data = malloc(sizeof(DBSMALLINT)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, SMALLBIND, sizeof(DBSMALLINT), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBINT2, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBINT4: srcdata[col]->data = malloc(sizeof(DBINT)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, INTBIND, sizeof(DBINT), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBINT4, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBFLT8: srcdata[col]->data = malloc(sizeof(DBFLT8)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, FLT8BIND, sizeof(DBFLT8), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBFLT8, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBREAL: srcdata[col]->data = malloc(sizeof(DBREAL)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, REALBIND, sizeof(DBREAL), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBREAL, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBMONEY: srcdata[col]->data = malloc(sizeof(DBMONEY)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, MONEYBIND, sizeof(DBMONEY), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBMONEY, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBMONEY4: srcdata[col]->data = malloc(sizeof(DBMONEY4)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, SMALLMONEYBIND, sizeof(DBMONEY4), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBMONEY4, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBDATETIME: srcdata[col]->data = malloc(sizeof(DBDATETIME)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, DATETIMEBIND, sizeof(DBDATETIME), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBDATETIME, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBDATETIME4: srcdata[col]->data = malloc(sizeof(DBDATETIME4)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, SMALLDATETIMEBIND, sizeof(DBDATETIME), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBDATETIME4, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBNUMERIC: srcdata[col]->data = malloc(sizeof(DBNUMERIC)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, NUMERICBIND, sizeof(DBNUMERIC), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, sizeof(DBNUMERIC), NULL, 0, SYBNUMERIC, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBDECIMAL: srcdata[col]->data = malloc(sizeof(DBDECIMAL)); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, DECIMALBIND, sizeof(DBDECIMAL), (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, sizeof(DBDECIMAL), NULL, 0, SYBDECIMAL, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; case SYBTEXT: case SYBCHAR: srcdata[col]->data = malloc(srcdata[col]->collen + 1); if (srcdata[col]->data == (char *) NULL) { printf("allocation error\n"); return FALSE; } dbbind(dbsrc, col + 1, NTBSTRINGBIND, srcdata[col]->collen + 1, (BYTE *) srcdata[col]->data); dbnullbind(dbsrc, col + 1, &(srcdata[col]->nullind)); if (bcp_bind(dbdest, (BYTE *) srcdata[col]->data, 0, -1, NULL, 0, SYBCHAR, col + 1) == FAIL) { printf("bcp_bind error\n"); return FALSE; } break; } } gettimeofday(&start_time, 0); while (dbnextrow(dbsrc) != NO_MORE_ROWS) { rows_read++; for (col = 0; col < src_numcols; col++) { switch (srcdata[col]->coltype) { case SYBBIT: case SYBINT1: case SYBINT2: case SYBINT4: case SYBFLT8: case SYBREAL: case SYBDATETIME: case SYBDATETIME4: case SYBMONEY: case SYBMONEY4: if (srcdata[col]->nullind == -1) { /* NULL data retrieved from source */ bcp_collen(dbdest, 0, col + 1); } else { bcp_collen(dbdest, -1, col + 1); } break; case SYBNUMERIC: if (srcdata[col]->nullind == -1) { /* NULL data retrieved from source */ bcp_collen(dbdest, 0, col + 1); } else { bcp_collen(dbdest, sizeof(DBNUMERIC), col + 1); } break; case SYBDECIMAL: if (srcdata[col]->nullind == -1) { /* NULL data retrieved from source */ bcp_collen(dbdest, 0, col + 1); } else { bcp_collen(dbdest, sizeof(DBDECIMAL), col + 1); } break; case SYBTEXT: case SYBCHAR: if (srcdata[col]->nullind == -1) { /* NULL data retrieved from source */ bcp_collen(dbdest, 0, col + 1); } else { /* * if there is zero length data, then the * input data MUST have been all blanks, * trimmed down to nothing by the bind * type of NTBSTRINGBIND. * so find out the source data length and * re-set the data accordingly... */ if (strlen(srcdata[col]->data) == 0) { src_datlen = dbdatlen(dbsrc, col + 1); memset(srcdata[col]->data, ' ', src_datlen); srcdata[col]->data[src_datlen] = '\0'; } bcp_collen(dbdest, strlen(srcdata[col]->data), col + 1); } break; } } if (bcp_sendrow(dbdest) == FAIL) { fprintf(stderr, "bcp_sendrow failed. \n"); return FALSE; } else { rows_sent++; if (rows_sent == params.batchsize) { gettimeofday(&batch_start, 0); ret = bcp_batch(dbdest); gettimeofday(&batch_end, 0); elapsed_batch = elapsed_batch + ((double) (batch_end.tv_sec - batch_start.tv_sec) + ((double) (batch_end.tv_usec - batch_start.tv_usec) / 1000000.00) ); 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) { gettimeofday(&batch_start, 0); ret = bcp_done(dbdest); gettimeofday(&batch_end, 0); elapsed_batch = elapsed_batch + ((double) (batch_end.tv_sec - batch_start.tv_sec) + ((double) (batch_end.tv_usec - batch_start.tv_usec) / 1000000.00) ); 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] [-v] [-d]\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, " -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-0.91/src/apps/defncopy.c100644 001750 000144 00000053061 11550671701 0012312/* 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 */ #if HAVE_CONFIG_H #include #endif #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 */ static char software_version[] = "$Id: defncopy.c,v 1.23.2.1 2011/04/11 09:59:00 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #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); } } /* * Connect to the server */ dbproc = dbopen(login, options.servername); assert(dbproc != NULL); /* Switch to the specified database, if any */ if (options.database) dbuse(dbproc, options.database); /* * 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 as c" " join sysobjects as o" " on o.id = c.id" " where 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, c.colid" ; static const char query_table[] = " execute sp_help '%s.%s' "; parse_argument(argv[i], &procedure); erc = dbfcmd(dbproc, query, procedure.name, procedure.owner); /* 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'; tds_strlcpy(procedure->name, s+1, sizeof(procedure->name)); } else { strcpy(procedure->owner, "dbo"); tds_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; 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); return 0; } /* 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 = calloc(1, 1 + datlen); assert(index_name); memcpy(index_name, dbdata(dbproc, 1), datlen); /* kind */ datlen = dbdatlen(dbproc, 2); index_description = calloc(1, 1 + datlen); assert(index_description); memcpy(index_description, dbdata(dbproc, 2), datlen); /* columns */ datlen = dbdatlen(dbproc, 3); index_keys = 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 = 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] = 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) { fclose(create_index); return nrows; } 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 */ 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; } } } 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); } 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[8000]; 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, NTBSTRINGBIND, sizeof(sql_text), (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; int ch; int fdomain = TRUE; extern char *optarg; extern int optind; assert(options && argv); options->appname = tds_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': DBSETLPWD(login, optarg); memset(optarg, 0, strlen(optarg)); 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", software_version, "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-0.91/src/apps/freebcp.c100664 001750 000144 00000046014 11537234001 0012104/* 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. */ #if HAVE_CONFIG_H #include #endif #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 */ #if HAVE_UNISTD_H #include #endif #if HAVE_LOCALE_H #include #endif #include "tds.h" #include "replacements.h" #include #include #include "freebcp.h" static char software_version[] = "$Id: freebcp.c,v 1.59 2011/03/13 21:32:49 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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); 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(1); } if (getenv("FREEBCP")) { fprintf(stderr, "User name: \"%s\"\n", params.user); } if (login_to_database(¶ms, &dbproc) == FALSE) { exit(1); } 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) ? 0 : 1); 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 */ tds_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:ncEdvV")) != -1) { switch (ch) { case 'v': case 'V': printf("freebcp version %s\n", software_version); 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++; if ((strcmp(optarg, "-")) == 0) { char pwd[255], *nl; memset(pwd, 0, 255); fgets(pwd, 255, stdin); nl = strchr(pwd, '\n'); if(nl) *nl = '\0'; pdata->pass = strdup(pwd); memset(pwd, 0, 255); } else { pdata->pass = strdup(optarg); memset(optarg, 0, strlen(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 '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(1); } } 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(1); } } 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); } /* 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; /* set hint if any */ if (pdata->hint) { int erc = bcp_options(*pdbproc, BCPHINTS, (BYTE *) pdata->hint, strlen(pdata->hint)); if (erc != SUCCEED) fprintf(stderr, "db-lib: Unable to set hint \"%s\"\n", pdata->hint); return FALSE; } 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 (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 (FAIL == bcp_init(dbproc, pdata->dbobject, pdata->hostfilename, pdata->errorfile, dir)) 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)); } bcp_control(dbproc, BCPFIRST, pdata->firstrow); bcp_control(dbproc, BCPLAST, pdata->lastrow); bcp_control(dbproc, BCPMAXERRS, pdata->maxerrors); 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; int li_collen; RETCODE ret_code = 0; 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 (FAIL == bcp_init(dbproc, pdata->dbobject, pdata->hostfilename, pdata->errorfile, dir)) 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)); } bcp_control(dbproc, BCPFIRST, pdata->firstrow); bcp_control(dbproc, BCPLAST, pdata->lastrow); bcp_control(dbproc, BCPMAXERRS, pdata->maxerrors); 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); li_collen = dbcollen(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 (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)); } 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){ FILE *optFile; char optBuf[256]; 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) { if ((optFile = fopen(params->options, "r")) == NULL) { if (dbfcmd(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 (dbfcmd(dbproc, optBuf) == FAIL) { fprintf(stderr, "setoptions() failed preparing options at %s:%d\n", __FILE__, __LINE__); return FALSE; } } if (!feof (optFile)) { perror("freebcp"); fprintf(stderr, "error reading options file \"%s\" at %s:%d\n", params->options, __FILE__, __LINE__); 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); 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; } void pusage(void) { fprintf(stderr, "usage: freebcp [[database_name.]owner.]table_name {in | out} 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]\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-0.91/src/apps/freebcp.h100664 001750 000144 00000002311 11375512127 0012111static char rcsid_freebcp_h[] = "$Id: freebcp.h,v 1.15 2010/05/21 14:10:31 freddy77 Exp $"; static void *no_unused_freebcp_h_warn[] = { rcsid_freebcp_h, no_unused_freebcp_h_warn }; enum 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 *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-0.91/src/apps/tsql.c100664 001750 000144 00000052000 11542161101 0011445/* 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 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #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 #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 */ #include "tds.h" #include "tdsiconv.h" #include "tdsstring.h" #include "tdsconvert.h" #include "replacements.h" TDS_RCSID(var, "$Id: tsql.c,v 1.140 2011/03/22 17:54:09 jklowden Exp $"); #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 char *opt_col_term = "\t"; static char *opt_row_term = "\n"; static 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 = (char*) malloc(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 } static int do_query(TDSSOCKET * tds, char *buf, int opt_flags) { int rows = 0; int rc, 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 (rc != TDS_SUCCEED) { fprintf(stderr, "tds_submit_query() failed\n"); return 1; } while ((rc = tds_process_tokens(tds, &resulttype, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCEED) { 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->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_SUCCEED) { 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->tds_ctx, 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, 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->tds_ctx, 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->tds_ctx, tds, &msg); } } return 0; } 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 = (char **) calloc(strlen(s) + 2, sizeof(char*)); 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[]) { char ip[24] = {'\0'}; tds_lookup_host(hostname, ip); if (!*ip) return 0; return tds7_get_instance_port(ip, "MSSQLSERVER"); } #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; int opt, port=0, use_domain_login=0; const char *charset = NULL; char *opt_flags_str = NULL; while ((opt = getopt(argc, argv, "H:S:I:J:P:U:p:Co:t:r:D:Lv")) != -1) { switch (opt) { case 't': opt_col_term = strdup(optarg); break; case 'r': opt_row_term = strdup(optarg); break; case 'D': opt_default_db = strdup(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 = strdup(optarg); memset(optarg, 0, strlen(optarg)); break; case 'I': free(confile); confile = strdup(optarg); break; case 'J': 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", "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); exit(0); break; default: fprintf(stderr, "%s: error: invalid option %c\n", argv[0], (char)opt); exit(1); break; } } if (opt_flags_str != NULL) { char *minus_flags = malloc(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) { static const char template[] = "%s.instances"; char ip[24] = {'\0'}; char *filename = getenv("TDSDUMP"); if (filename) { if ((filename = malloc(sizeof(template) + strlen(filename))) == NULL) exit(1); sprintf(filename, template, getenv("TDSDUMP")); tdsdump_open(filename); free(filename); } tds_lookup_host(hostname, ip); tds7_get_instance_ports(stderr, ip); 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 = calloc(1, 1); use_domain_login = 1; } if (!password) { password = calloc(1, 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 it's a servername */ if (servername) { tds_set_user(login, username); tds_set_app(login, "TSQL"); tds_set_library(login, "TDS-Library"); tds_set_server(login, servername); if (charset) tds_set_client_charset(login, charset); tds_set_language(login, "us_english"); tds_set_passwd(login, password); if (confile) { tds_set_interfaces_file_loc(confile); } /* else we specified hostname/port */ } else { tds_set_user(login, username); tds_set_app(login, "TSQL"); tds_set_library(login, "TDS-Library"); tds_set_server(login, hostname); tds_set_port(login, port); if (charset) tds_set_client_charset(login, charset); tds_set_language(login, "us_english"); tds_set_passwd(login, password); } memset(password, 0, strlen(password)); /* free up all the memory */ free(confile); free(hostname); free(username); free(password); free(servername); } static int tsql_handle_message(const TDSCONTEXT * context, TDSSOCKET * tds, TDSMESSAGE * msg) { if (msg->msgno == 0) { fprintf(stderr, "%s\n", msg->message); return 0; } if (msg->msgno != 5701 && msg->msgno != 5703 && msg->msgno != 20018) { 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); } 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(TDSCONNECTION *connection) { if (!connection) return; if (!tds_dstr_isempty(&connection->instance_name)) printf("connecting to instance %s on port %d\n", tds_dstr_cstr(&connection->instance_name), connection->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; TDSCONNECTION *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(); 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); 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"; tds_set_client_charset(login, charset); tds_dstr_dup(&connection->client_charset, &login->client_charset); } if (!QUIET) printf("using default charset \"%s\"\n", tds_dstr_cstr(&connection->client_charset)); if (opt_default_db) { tds_dstr_copy(&connection->database, opt_default_db); if (!QUIET) fprintf(stderr, "Default database being set to %s\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_connect_and_login(tds, connection) != TDS_SUCCEED) { 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_connection(connection); /* give the buffer an initial size */ bufsz = 4096; mybuf = malloc(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, 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 = 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_free_socket(tds); tds_free_login(login); tds_free_context(context); DONESOCKET(); return 0; } freetds-0.91/src/apps/fisql/Makefile.am100664 001750 000144 00000000630 11131554716 0013506# $Id: Makefile.am,v 1.4 2009/01/09 04:59:58 jklowden Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include if MINGW32 else 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 \ $(NETWORK_LIBS) $(LIBICONV) $(READLINE_LIBS) endif freetds-0.91/src/apps/fisql/Makefile.in100664 001750 000144 00000045157 11623070617 0013533# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.4 2009/01/09 04:59:58 jklowden Exp $ VPATH = @srcdir@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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) \ @MINGW32_FALSE@ $(am__DEPENDENCIES_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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(fisql_SOURCES) DIST_SOURCES = $(am__fisql_SOURCES_DIST) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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@ $(NETWORK_LIBS) $(LIBICONV) $(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 .PRECIOUS: 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) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 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) @rm -f fisql$(EXEEXT) $(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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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 all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool ctags 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 uninstall uninstall-am \ uninstall-binPROGRAMS # 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-0.91/src/apps/fisql/fisql.c100664 001750 000144 00000045236 11471532131 0012741/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #include #include #include #include #ifdef HAVE_READLINE #include #include #endif #if HAVE_LOCALE_H #include #endif #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 *display_charset = ""; 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; BYTE *bylist; int nby; char adash; const char *database_name = NULL; 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 'a': display_charset = optarg; errflg++; 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[-a display_charset] [-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 ((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); } if (database_name) { dbuse(dbproc, database_name); } 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++); if (*cp) { add_history(line); } if (!(strncasecmp(line, "!!", 2))) { cp = line + 2; system(cp); 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++); tfn = cp; for (; *cp && !(isspace((unsigned char) *cp)); cp++); *cp = '\0'; if ((fp = fopen(tfn, "r")) == NULL) { printf("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(EXIT_SUCCESS); } 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; strcpy(tmpfn, "/tmp/fisqlXXXXXX"); tmpfd = mkstemp(tmpfn); 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 = '-'; bylist = dbbylist(dbproc, dbrc, &nby); if (nby == 0) { 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); } } } } } } } reset_term(); dbexit(); exit(EXIT_FAILURE); return (0); } freetds-0.91/src/apps/fisql/terminal.h100664 001750 000144 00000001653 10554333573 0013450/* 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-0.91/src/apps/fisql/terminal.c100664 001750 000144 00000003242 10554333573 0013437/* 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-0.91/src/apps/fisql/edit.h100664 001750 000144 00000001620 10554333573 0012554/* 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-0.91/src/apps/fisql/edit.c100664 001750 000144 00000002711 10554333573 0012551/* 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-0.91/src/apps/fisql/handlers.h100664 001750 000144 00000002166 10554333573 0013435/* 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-0.91/src/apps/fisql/handlers.c100664 001750 000144 00000003766 10554333573 0013437/* 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 > 0) { 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) { if ((severity > 0) || (msgno == 0)) { fprintf(stdout, "%s\n", msgtext); } } return (0); } freetds-0.91/src/apps/fisql/interrupt.h100664 001750 000144 00000002146 10554333573 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: 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-0.91/src/apps/fisql/interrupt.c100664 001750 000144 00000002640 10554333573 0013661/* 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-0.91/src/server/Makefile.am100664 001750 000144 00000000631 11327730444 0012735# $Id: Makefile.am,v 1.17 2010/01/27 03:21:08 jklowden 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 $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) noinst_PROGRAMS = tdssrv tdssrv_LDADD = libtdssrv.la $(LIBICONV) $(NETWORK_LIBS) tdssrv_SOURCES = unittest.c freetds-0.91/src/server/Makefile.in100664 001750 000144 00000042231 11623070620 0012740# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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__DEPENDENCIES_1) am_libtdssrv_la_OBJECTS = query.lo server.lo login.lo libtdssrv_la_OBJECTS = $(am_libtdssrv_la_OBJECTS) PROGRAMS = $(noinst_PROGRAMS) am_tdssrv_OBJECTS = unittest.$(OBJEXT) tdssrv_OBJECTS = $(am_tdssrv_OBJECTS) tdssrv_DEPENDENCIES = libtdssrv.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtdssrv_la_SOURCES) $(tdssrv_SOURCES) DIST_SOURCES = $(libtdssrv_la_SOURCES) $(tdssrv_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 2010/01/27 03:21:08 jklowden 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 $(NETWORK_LIBS) $(LIBICONV) $(FREETDS_LIBGCC) tdssrv_LDADD = libtdssrv.la $(LIBICONV) $(NETWORK_LIBS) 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 .PRECIOUS: 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)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtdssrv.la: $(libtdssrv_la_OBJECTS) $(libtdssrv_la_DEPENDENCIES) $(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) @rm -f tdssrv$(EXEEXT) $(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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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 all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ ctags 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 uninstall uninstall-am # 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-0.91/src/server/query.c100664 001750 000144 00000012650 11121365642 0012212/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include "tds.h" #include "tdssrv.h" static char software_version[] = "$Id: query.c,v 1.18 2008/12/15 05:31:14 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 = (char *) malloc(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; } /** * 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-0.91/src/server/server.c100664 001750 000144 00000032632 11473671266 0012371/* 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. */ #if HAVE_CONFIG_H #include #endif #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "tds.h" #include "tdssrv.h" static char software_version[] = "$Id: server.c,v 1.27 2010/11/26 08:41:26 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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 */ totsize = 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 */ + (IS_TDS7_PLUS(tds) ? 2 : 1) * (strlen(msgtext) + 1 + strlen(srvname) + 1 + len) + 1 + 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); } 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_put_byte(tds, TDS_LOGINACK_TOKEN); tds_put_smallint(tds, 10 + (IS_TDS7_PLUS(tds)? 2 : 1) * strlen(progname)); /* length of message */ if (IS_TDS50(tds)) { tds_put_byte(tds, 5); tds_put_byte(tds, 5); tds_put_byte(tds, 0); } else { tds_put_byte(tds, 1); tds_put_byte(tds, TDS_MAJOR(tds)); tds_put_byte(tds, TDS_MINOR(tds)); } tds_put_byte(tds, 0); /* unknown */ tds_put_byte(tds, 0); /* unknown */ tds_put_byte(tds, strlen(progname)); /* FIXME ucs2 */ tds_put_string(tds, progname, strlen(progname)); /* server version, for mssql 1.0.1 */ tds_put_byte(tds, 1); /* unknown */ tds_put_byte(tds, 0); /* unknown */ tds_put_byte(tds, 0); /* unknown */ tds_put_byte(tds, 1); /* unknown */ } 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)) 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_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]; assert(strlen(curcol->column_name) == curcol->column_namelen); hdrsize += curcol->column_namelen + 1; } tds_put_smallint(tds, hdrsize); for (col = 0; col < resinfo->num_cols; col++) { curcol = resinfo->columns[col]; tds_put_byte(tds, curcol->column_namelen); /* exclude the null */ tds_put_n(tds, curcol->column_name, curcol->column_namelen); } } 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; tds_put_byte(tds, TDS_RESULT_TOKEN); totlen = 2; for (i = 0; i < resinfo->num_cols; i++) { curcol = resinfo->columns[i]; totlen += 8; assert(strlen(curcol->column_name) == curcol->column_namelen); totlen += curcol->column_namelen; 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]; tds_put_byte(tds, curcol->column_namelen); tds_put_n(tds, curcol->column_name, curcol->column_namelen); 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)) { tds_put_smallint(tds, 2 * strlen(curcol->table_name)); for (j = 0; curcol->table_name[j] != '\0'; j++){ tds_put_byte(tds, curcol->table_name[j]); tds_put_byte(tds, 0); } } /* finally the name, in UCS16 format */ assert(strlen(curcol->column_name) == curcol->column_namelen); tds_put_byte(tds, curcol->column_namelen); for (j = 0; j < curcol->column_namelen; j++) { tds_put_byte(tds, 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)) { 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 tds8_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-0.91/src/server/login.c100664 001750 000144 00000023253 11244772137 0012165/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tds.h" #include "tdsiconv.h" #include "tdssrv.h" #include "tdsstring.h" static char software_version[] = "$Id: login.c,v 1.55 2009/08/25 14:25:35 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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, 8192); tds->s = fd; tds->out_flag = TDS_LOGIN; /* TODO proper charset */ tds_iconv_open(tds, "ISO8859-1"); /* get_incoming(tds->s); */ return tds; } static void tds_read_string(TDSSOCKET * tds, DSTR * s, int size); void tds_read_login(TDSSOCKET * tds, TDSLOGIN * login) { DSTR blockstr; TDS_USMALLINT major; /* 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] : ' '); } */ tds_dstr_init(&blockstr); tds_read_string(tds, &login->client_host_name, 30); tds_read_string(tds, &login->user_name, 30); 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 */ tds_read_string(tds, &login->app_name, 30); 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 */ 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 */ tds_read_string(tds, &login->language, 30); tds_get_n(tds, NULL, 14); /* magic */ tds_read_string(tds, &login->server_charset, 30); tds_get_n(tds, NULL, 1); /* magic */ 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 */ } static void tds7_read_string(TDSSOCKET * tds, DSTR *s, int len) { tds_dstr_alloc(s, len); /* FIXME possible truncation on char conversion ? */ len = tds_get_string(tds, len, tds_dstr_buf(s), len); tds_dstr_setlen(s, len); } int tds7_read_login(TDSSOCKET * tds, TDSLOGIN * login) { int a; int host_name_len, user_name_len, app_name_len, server_name_len; int library_name_len, language_name_len; int auth_len, database_name_len; size_t unicode_len, password_len; char *unicode_string, *psrc; char *pbuf; DSTR database; tds_dstr_init(&database); a = tds_get_int(tds); /*total packet size */ a = tds_get_int(tds); /*TDS version */ a &= 0xff; login->tds_version = ((a << 4) & 0xff00) | (a & 0xf); a = tds_get_int(tds); /*desired packet size being requested by client */ tds_get_n(tds, NULL, 24); /*magic1 */ a = tds_get_smallint(tds); /*current position */ host_name_len = tds_get_smallint(tds); a = tds_get_smallint(tds); /*current position */ user_name_len = tds_get_smallint(tds); a = tds_get_smallint(tds); /*current position */ password_len = tds_get_smallint(tds); a = tds_get_smallint(tds); /*current position */ app_name_len = tds_get_smallint(tds); a = tds_get_smallint(tds); /*current position */ server_name_len = tds_get_smallint(tds); tds_get_smallint(tds); tds_get_smallint(tds); a = tds_get_smallint(tds); /*current position */ library_name_len = tds_get_smallint(tds); a = tds_get_smallint(tds); /*current position */ language_name_len = tds_get_smallint(tds); a = tds_get_smallint(tds); database_name_len = tds_get_smallint(tds); tds_get_n(tds, NULL, 6); /* client mac address */ a = tds_get_smallint(tds); /*partial packet size */ auth_len = tds_get_smallint(tds); /*authentication len */ a = tds_get_smallint(tds); /*total packet size */ tds_get_smallint(tds); tds7_read_string(tds, &login->client_host_name, host_name_len); tds7_read_string(tds, &login->user_name, user_name_len); unicode_len = password_len * 2; unicode_string = (char *) malloc(unicode_len); tds_dstr_alloc(&login->password, password_len); 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->char_convs[client2ucs2]->suppress, 0, sizeof(tds->char_convs[client2ucs2]->suppress)); psrc = unicode_string; a = tds_iconv(tds, tds->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__); assert(-1 != a); } tds_dstr_setlen(&login->password, pbuf - tds_dstr_buf(&login->password)); free(unicode_string); tds7_read_string(tds, &login->app_name, app_name_len); tds7_read_string(tds, &login->server_name, server_name_len); tds7_read_string(tds, &login->library, library_name_len); tds7_read_string(tds, &login->language, language_name_len); /* TODO use it */ tds7_read_string(tds, &database, database_name_len); tds_dstr_free(&database); tds_get_n(tds, NULL, auth_len); tds_dstr_copy(&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 (0); } static void tds_read_string(TDSSOCKET * tds, DSTR * s, int size) { int len; /* FIXME this can fails... */ tds_dstr_alloc(s, size); tds_get_n(tds, tds_dstr_buf(s), size); len = tds_get_byte(tds); if (len <= size) tds_dstr_setlen(s, len); } /** * 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(); if (!login) return NULL; /* Use the packet type to determine which login format to expect */ switch (tds->in_flag) { case 0x02: /* TDS4/5 login */ tds->tds_version = 0x402; tds_read_login(tds, login); if (login->block_size == 0) { login->block_size = 512; } break; case 0x10: /* TDS7+ login */ tds->tds_version = 0x700; tds7_read_login(tds, login); break; case 0x12: /* TDS8+ prelogin, hopefully followed by a login */ tds->tds_version = 0x701; /* ignore client and just send our reply TODO... finish */ tds8_send_prelogin(tds); tds_flush_packet(tds); if (tds_read_packet(tds) < 0 || tds->in_flag != 0x10) { tds_free_login(login); return NULL; } tds7_read_login(tds, login); break; default: /* unexpected packet */ tds_free_login(login); return NULL; } /* Return it */ return login; } freetds-0.91/src/server/unittest.c100664 001750 000144 00000010013 11244772137 0012722/* 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. */ #if HAVE_CONFIG_H #include #endif #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 #ifdef __MINGW32__ #define sleep(s) Sleep((s)*1000) #endif static char software_version[] = "$Id: unittest.c,v 1.19 2009/08/25 14:25:35 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 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)) 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; strcpy(resinfo->columns[0]->column_name, "name"); resinfo->columns[0]->column_namelen = 4; 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); sleep(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-0.91/src/pool/README100664 001750 000144 00000006236 07361702256 0011236TDS 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-0.91/src/pool/Makefile.am100664 001750 000144 00000000756 11327730444 0012410# $Id: Makefile.am,v 1.15 2010/01/27 03:21:08 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 $(LIBICONV) $(NETWORK_LIBS) EXTRA_DIST = BUGS pool.conf ETC = $(DESTDIR)$(sysconfdir) install-data-local: $(mkinstalldirs) $(ETC) if test ! -f $(ETC)/pool.conf; then \ $(INSTALL_DATA) $(srcdir)/pool.conf $(ETC)/pool.conf; \ fi freetds-0.91/src/pool/Makefile.in100664 001750 000144 00000044545 11623070620 0012415# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) 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__DEPENDENCIES_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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(tdspool_SOURCES) DIST_SOURCES = $(tdspool_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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.15 2010/01/27 03:21:08 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 $(LIBICONV) $(NETWORK_LIBS) 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 .PRECIOUS: 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) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 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) @rm -f tdspool$(EXEEXT) $(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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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 all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool ctags 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 uninstall uninstall-am uninstall-binPROGRAMS install-data-local: $(mkinstalldirs) $(ETC) if test ! -f $(ETC)/pool.conf; then \ $(INSTALL_DATA) $(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-0.91/src/pool/TODO100664 001750 000144 00000000553 07361702256 0011042Handle 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-0.91/src/pool/config.c100664 001750 000144 00000006173 10705152326 0011760/* 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 * */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif #include "pool.h" #include "tds_configs.h" TDS_RCSID(var, "$Id: config.c,v 1.16 2007/10/16 15:12:22 freddy77 Exp $"); #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); int pool_read_conf_file(char *poolname, TDS_POOL * pool) { FILE *in; int found = 0; in = fopen(FREETDS_POOLCONFFILE, "r"); if (in) { fprintf(stderr, "Found conf file in %s reading sections\n", FREETDS_POOLCONFFILE); tds_read_conf_section(in, "global", pool_parse, pool); rewind(in); found = tds_read_conf_section(in, poolname, pool_parse, pool); fclose(in); } return found; } #if 0 static int pool_config_boolean(char *value) { if (!strcmp(value, "yes") || !strcmp(value, "on") || !strcmp(value, "true") || !strcmp(value, "1")) { return 1; } else { return 0; } } #endif static void pool_parse(const char *option, const char *value, void *param) { TDS_POOL *pool = (TDS_POOL *) param; if (!strcmp(option, POOL_STR_PORT)) { if (atoi(value)) pool->port = atoi(value); } 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)) { if (atoi(value)) pool->max_member_age = atoi(value); } else if (!strcmp(option, POOL_STR_MAX_POOL_CONN)) { if (atoi(value)) pool->max_open_conn = atoi(value); } else if (!strcmp(option, POOL_STR_MIN_POOL_CONN)) { if (atoi(value)) pool->min_open_conn = atoi(value); } } freetds-0.91/src/pool/main.c100664 001750 000144 00000013530 11213421573 0011430/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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" TDS_RCSID(var, "$Id: main.c,v 1.25 2009/06/09 08:55:23 freddy77 Exp $"); /* to be set by sig term */ static int term = 0; /* number of users in wait state */ int waiters = 0; static void term_handler(int sig); static void pool_schedule_waiters(TDS_POOL * pool); static TDS_POOL *pool_init(char *name); static void pool_main_loop(TDS_POOL * pool); static void term_handler(int sig) { fprintf(stdout, "Shutdown Requested\n"); term = 1; } /* * pool_init creates a named pool and opens connections to the database */ static TDS_POOL * pool_init(char *name) { TDS_POOL *pool; /* initialize the pool */ pool = (TDS_POOL *) calloc(1, sizeof(TDS_POOL)); /* FIXME -- read this from the conf file */ if (!pool_read_conf_file(name, pool)) { fprintf(stderr, "Configuration for pool ``%s'' not found.\n", name); exit(EXIT_FAILURE); } pool->num_members = pool->max_open_conn; pool->name = strdup(name); pool_mbr_init(pool); pool_user_init(pool); return pool; } static void pool_schedule_waiters(TDS_POOL * pool) { TDS_POOL_USER *puser; TDS_POOL_MEMBER *pmbr; int i, free_mbrs; /* first see if there are free members to do the request */ free_mbrs = 0; for (i = 0; i < pool->num_members; i++) { pmbr = (TDS_POOL_MEMBER *) & pool->members[i]; if (pmbr->tds && pmbr->state == TDS_IDLE) free_mbrs++; } if (!free_mbrs) return; for (i = 0; i < pool->max_users; i++) { puser = (TDS_POOL_USER *) & pool->users[i]; if (puser->user_state == TDS_SRV_WAIT) { /* place back in query state */ puser->user_state = TDS_SRV_QUERY; waiters--; /* now try again */ pool_user_query(pool, puser); return; } } } /* * 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_USER *puser; TDS_POOL_MEMBER *pmbr; struct sockaddr_in sin; int s, maxfd, i; int retval; fd_set rfds; 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); } /* 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); FD_ZERO(&rfds); FD_SET(s, &rfds); maxfd = s; while (!term) { /* fprintf(stderr, "waiting for a connect\n"); */ retval = select(maxfd + 1, &rfds, NULL, NULL, NULL); if (term) break; /* process the sockets */ if (FD_ISSET(s, &rfds)) { pool_user_create(pool, s, &sin); } pool_process_users(pool, &rfds); pool_process_members(pool, &rfds); /* back from members */ if (waiters) { pool_schedule_waiters(pool); } FD_ZERO(&rfds); /* add the listening socket to the read list */ FD_SET(s, &rfds); maxfd = s; /* add the user sockets to the read list */ for (i = 0; i < pool->max_users; i++) { puser = (TDS_POOL_USER *) & pool->users[i]; /* skip dead connections */ if (!IS_TDSDEAD(puser->tds)) { if (puser->tds->s > maxfd) maxfd = puser->tds->s; FD_SET(puser->tds->s, &rfds); } } /* add the pool member sockets to the read list */ for (i = 0; i < pool->num_members; i++) { pmbr = (TDS_POOL_MEMBER *) & pool->members[i]; if (!IS_TDSDEAD(pmbr->tds)) { if (pmbr->tds->s > maxfd) maxfd = pmbr->tds->s; FD_SET(pmbr->tds->s, &rfds); } } } /* while !term */ CLOSESOCKET(s); for (i = 0; i < pool->max_users; i++) { puser = (TDS_POOL_USER *) & pool->users[i]; if (!IS_TDSDEAD(puser->tds)) { fprintf(stderr, "Closing user %d\n", i); tds_close_socket(puser->tds); } } for (i = 0; i < pool->num_members; i++) { pmbr = (TDS_POOL_MEMBER *) & pool->members[i]; if (!IS_TDSDEAD(pmbr->tds)) { fprintf(stderr, "Closing member %d\n", i); tds_close_socket(pmbr->tds); } } } int main(int argc, char **argv) { TDS_POOL *pool; signal(SIGTERM, term_handler); signal(SIGINT, term_handler); if (argc < 2) { fprintf(stderr, "Usage: tdspool \n"); return 1; } pool = pool_init(argv[1]); pool_main_loop(pool); fprintf(stdout, "tdspool Shutdown\n"); return EXIT_SUCCESS; } freetds-0.91/src/pool/member.c100664 001750 000144 00000021007 11407073561 0011756/* 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 * */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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" #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 #endif /* MAXHOSTNAMELEN */ TDS_RCSID(var, "$Id: member.c,v 1.46 2010/06/19 07:53:21 freddy77 Exp $"); static int pool_packet_read(TDS_POOL_MEMBER * pmbr); static TDSSOCKET *pool_mbr_login(TDS_POOL * pool); /* * pool_mbr_login open a single pool login, to be call at init time or * to reconnect. */ static TDSSOCKET * pool_mbr_login(TDS_POOL * pool) { TDSCONTEXT *context; TDSLOGIN *login; TDSSOCKET *tds; TDSCONNECTION *connection; int rc; char *query; char hostname[MAXHOSTNAMELEN]; login = tds_alloc_login(); tds_set_passwd(login, pool->password); tds_set_user(login, pool->user); tds_set_app(login, "tdspool"); #if HAVE_GETHOSTNAME if (gethostname(hostname, MAXHOSTNAMELEN) < 0) #endif tds_strlcpy(hostname, "tdspool", MAXHOSTNAMELEN); 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_set_packet(login, 512); context = tds_alloc_context(NULL); tds = tds_alloc_socket(context, 512); connection = tds_read_config_info(tds, login, context->locale); if (!connection || tds_connect_and_login(tds, connection) != TDS_SUCCEED) { tds_free_socket(tds); tds_free_connection(connection); /* what to do? */ fprintf(stderr, "Could not open connection to server %s\n", pool->server); return NULL; } tds_free_connection(connection); /* * FIXME -- tds_connect_and_login no longer preallocates the in_buf need to * do something like what tds_read_packet does */ tds->in_buf = (unsigned char *) calloc(BLOCKSIZ, 1); if (pool->database && strlen(pool->database)) { query = (char *) malloc(strlen(pool->database) + 5); sprintf(query, "use %s", pool->database); rc = tds_submit_query(tds, query); free(query); if (rc != TDS_SUCCEED) { fprintf(stderr, "changing database failed\n"); return NULL; } if (tds_process_simple_query(tds) != TDS_SUCCEED) return NULL; } return tds; } void pool_assign_member(TDS_POOL_MEMBER * pmbr, TDS_POOL_USER *puser) { pmbr->current_user = puser; puser->assigned_member = pmbr; } void pool_deassign_member(TDS_POOL_MEMBER * pmbr) { if (pmbr->current_user) pmbr->current_user->assigned_member = NULL; pmbr->current_user = NULL; } /* * if a dead connection on the client side left this member in a questionable * state, let's clean it up. */ void pool_reset_member(TDS_POOL_MEMBER * pmbr) { pool_free_member(pmbr); } void pool_free_member(TDS_POOL_MEMBER * pmbr) { if (!IS_TDSDEAD(pmbr->tds)) { tds_close_socket(pmbr->tds); } pmbr->tds = NULL; /* * if he is allocated disconnect the client * otherwise we end up with broken client. */ if (pmbr->current_user) { pool_free_user(pmbr->current_user); pmbr->current_user = NULL; } pmbr->state = TDS_IDLE; } void pool_mbr_init(TDS_POOL * pool) { TDS_POOL_MEMBER *pmbr; int i; /* allocate room for pool members */ pool->members = (TDS_POOL_MEMBER *) calloc(pool->num_members, sizeof(TDS_POOL_MEMBER)); /* open connections for each member */ for (i = 0; i < pool->num_members; i++) { pmbr = &pool->members[i]; if (i < pool->min_open_conn) { pmbr->tds = pool_mbr_login(pool); pmbr->last_used_tm = time(NULL); if (!pmbr->tds) { fprintf(stderr, "Could not open initial connection %d\n", i); exit(1); } } pmbr->state = TDS_IDLE; } } /* * pool_process_members * check the fd_set for members returning data to the client, lookup the * client holding this member and forward the results. */ int pool_process_members(TDS_POOL * pool, fd_set * fds) { TDS_POOL_MEMBER *pmbr; TDS_POOL_USER *puser; TDSSOCKET *tds; int i, age, ret; int cnt = 0; unsigned char *buf; time_t time_now; for (i = 0; i < pool->num_members; i++) { pmbr = (TDS_POOL_MEMBER *) & pool->members[i]; if (!pmbr->tds) break; /* dead connection */ tds = pmbr->tds; time_now = time(NULL); if (FD_ISSET(tds->s, fds)) { pmbr->last_used_tm = time_now; cnt++; /* tds->in_len = read(tds->s, tds->in_buf, BLOCKSIZ); */ if (pool_packet_read(pmbr)) continue; if (tds->in_len == 0) { fprintf(stderr, "Uh oh! member %d disconnected\n", i); /* mark as dead */ pool_free_member(pmbr); } else if (tds->in_len == -1) { fprintf(stderr, "Uh oh! member %d disconnected\n", i); perror("read"); pool_free_member(pmbr); } else { /* fprintf(stderr, "read %d bytes from member %d\n", tds->in_len, i); */ if (pmbr->current_user) { puser = pmbr->current_user; buf = tds->in_buf; /* * check the netlib final packet flag * instead of looking for done tokens. * It's more efficient and generic to * all protocol versions. -- bsb * 2004-12-12 */ if (buf[1]) { /* if (pool_find_end_token(pmbr, buf + 8, tds->in_len - 8)) { */ /* we are done...deallocate member */ fprintf(stdout, "deassigning user from member %d\n",i); pool_deassign_member(pmbr); pmbr->state = TDS_IDLE; puser->user_state = TDS_SRV_IDLE; } /* cf. net.c for better technique. */ ret = WRITESOCKET(puser->tds->s, buf, tds->in_len); if (ret < 0) { /* couldn't write, ditch the user */ fprintf(stdout, "member %d received error while writing\n",i); pool_free_user(pmbr->current_user); pool_deassign_member(pmbr); pool_reset_member(pmbr); } } } } age = time_now - pmbr->last_used_tm; if (age > pool->max_member_age && i >= pool->min_open_conn) { fprintf(stderr, "member %d is %d seconds old...closing\n", i, age); pool_free_member(pmbr); } } return cnt; } /* * pool_find_idle_member * returns the first pool member in TDS_IDLE state */ TDS_POOL_MEMBER * pool_find_idle_member(TDS_POOL * pool) { int i, active_members; TDS_POOL_MEMBER *pmbr; active_members = 0; for (i = 0; i < pool->num_members; i++) { pmbr = &pool->members[i]; if (pmbr->tds) { active_members++; if (pmbr->state == TDS_IDLE) { /* * 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); return pmbr; } } } /* if we have dead connections we can open */ if (active_members < pool->num_members) { pmbr = NULL; for (i = 0; i < pool->num_members; i++) { pmbr = &pool->members[i]; if (!pmbr->tds) { fprintf(stderr, "No open connections left, opening member number %d\n", i); pmbr->tds = pool_mbr_login(pool); pmbr->last_used_tm = time(NULL); break; } } if (pmbr) return pmbr; } fprintf(stderr, "No idle members left, increase MAX_POOL_CONN\n"); return NULL; } static int pool_packet_read(TDS_POOL_MEMBER * pmbr) { TDSSOCKET *tds; int packet_len; tds = pmbr->tds; if (pmbr->need_more) { tds->in_len += read(tds->s, &tds->in_buf[tds->in_len], BLOCKSIZ - tds->in_len); } else { tds->in_len = read(tds->s, tds->in_buf, BLOCKSIZ); } packet_len = ntohs(*(short *) &tds->in_buf[2]); if (tds->in_len < packet_len) { pmbr->need_more = 1; } else { pmbr->need_more = 0; } return pmbr->need_more; } freetds-0.91/src/pool/user.c100664 001750 000144 00000017007 11151736136 0011472/* 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 * */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tdssrv.h" #include "tdsstring.h" TDS_RCSID(var, "$Id: user.c,v 1.34 2009/02/27 10:11:42 freddy77 Exp $"); static TDS_POOL_USER *pool_user_find_new(TDS_POOL * pool); static int pool_user_login(TDS_POOL * pool, TDS_POOL_USER * puser); static void pool_user_read(TDS_POOL * pool, TDS_POOL_USER * puser); extern int waiters; void pool_user_init(TDS_POOL * pool) { /* allocate room for pool users */ pool->users = (TDS_POOL_USER *) calloc(MAX_POOL_USERS, sizeof(TDS_POOL_USER)); } static TDS_POOL_USER * pool_user_find_new(TDS_POOL * pool) { TDS_POOL_USER *puser; int i; /* first check for dead users to reuse */ for (i=0; imax_users; i++) { puser = (TDS_POOL_USER *) & pool->users[i]; if (!puser->tds) return puser; } /* did we exhaust the number of concurrent users? */ if (pool->max_users >= MAX_POOL_USERS) { fprintf(stderr, "Max concurrent users exceeded, increase in pool.h\n"); return NULL; } /* else take one off the top of the pool->users */ puser = (TDS_POOL_USER *) & pool->users[pool->max_users]; pool->max_users++; return puser; } /* * 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, struct sockaddr_in *sin) { TDS_POOL_USER *puser; TDS_SYS_SOCKET fd; socklen_t len; TDSSOCKET *tds; puser = pool_user_find_new(pool); if (!puser) return NULL; fprintf(stderr, "accepting connection\n"); len = sizeof(*sin); if (TDS_IS_SOCKET_INVALID(fd = tds_accept(s, (struct sockaddr *) sin, &len))) { perror("accept"); return NULL; } tds = tds_alloc_socket(NULL, BLOCKSIZ); if (!tds) { CLOSESOCKET(fd); return NULL; } tds_set_parent(tds, NULL); /* FIX ME - little endian emulation should be config file driven */ tds->emul_little_endian = 1; tds->in_buf = (unsigned char *) calloc(1, BLOCKSIZ); tds->s = fd; if (!tds->in_buf) { tds_free_socket(tds); return NULL; } tds->in_buf_max = BLOCKSIZ; tds->out_flag = TDS_LOGIN; puser->tds = tds; puser->user_state = TDS_SRV_LOGIN; return puser; } /* * pool_free_user * close out a disconnected user. */ void pool_free_user(TDS_POOL_USER * puser) { /* make sure to decrement the waiters list if he is waiting */ if (puser->user_state == TDS_SRV_WAIT) waiters--; tds_free_socket(puser->tds); memset(puser, 0, sizeof(TDS_POOL_USER)); } /* * pool_process_users * check the fd_set for user input, allocate a pool member to it, and forward * the query to that member. */ int pool_process_users(TDS_POOL * pool, fd_set * fds) { TDS_POOL_USER *puser; int i; int cnt = 0; for (i = 0; i < pool->max_users; i++) { puser = (TDS_POOL_USER *) & pool->users[i]; if (!puser->tds) continue; /* dead connection */ if (FD_ISSET(puser->tds->s, fds)) { cnt++; switch (puser->user_state) { case TDS_SRV_LOGIN: if (pool_user_login(pool, puser)) { /* login failed...free socket */ pool_free_user(puser); } /* otherwise we have a good login */ break; case TDS_SRV_IDLE: pool_user_read(pool, puser); break; case TDS_SRV_QUERY: /* what is this? a cancel perhaps */ pool_user_read(pool, puser); break; /* just to avoid a warning */ default: break; } /* switch */ } /* if */ } /* for */ return cnt; } /* * pool_user_login * Reads clients login packet and forges a login acknowledgement sequence */ static int pool_user_login(TDS_POOL * pool, TDS_POOL_USER * puser) { TDSSOCKET *tds; TDSLOGIN *login = tds_alloc_login(); /* FIXME */ char msg[256]; tds = puser->tds; tds_read_login(tds, login); dump_login(login); if (!strcmp(tds_dstr_cstr(&login->user_name), pool->user) && !strcmp(tds_dstr_cstr(&login->password), pool->password)) { tds->out_flag = TDS_REPLY; tds_env_change(tds, 1, "master", pool->database); sprintf(msg, "Changed database context to '%s'.", pool->database); tds_send_msg(tds, 5701, 2, 10, msg, "JDBC", "ZZZZZ", 1); if (!login->suppress_language) { tds_env_change(tds, 2, NULL, "us_english"); tds_send_msg(tds, 5703, 1, 10, "Changed language setting to 'us_english'.", "JDBC", "ZZZZZ", 1); } tds_env_change(tds, 4, NULL, "512"); tds_send_login_ack(tds, "sql server"); /* tds_send_capabilities_token(tds); */ tds_send_done_token(tds, 0, 1); puser->user_state = TDS_SRV_IDLE; /* send it! */ tds_flush_packet(tds); tds_free_login(login); return 0; } else { tds_free_login(login); /* send nack before exiting */ return 1; } } /* * pool_user_read * checks the packet type of data coming from the client and allocates a * pool member if necessary. */ static void pool_user_read(TDS_POOL * pool, TDS_POOL_USER * puser) { TDSSOCKET *tds; TDS_POOL_MEMBER *pmbr; tds = puser->tds; /* FIXME read entire packet !!! */ tds->in_len = read(tds->s, tds->in_buf, tds->in_buf_max); if (tds->in_len == 0) { fprintf(stderr, "user disconnected\n"); pool_free_user(puser); return; } else if (tds->in_len == -1) { perror("read"); fprintf(stderr, "cleaning up user\n"); if (puser->assigned_member) { fprintf(stderr, "user has assigned member, freeing\n"); pmbr = puser->assigned_member; pool_deassign_member(pmbr); pool_reset_member(pmbr); } pool_free_user(puser); } else { dump_buf(tds->in_buf, tds->in_len); /* language packet or TDS5 language packet */ if (tds->in_buf[0] == 0x01 || tds->in_buf[0] == 0x0F) { pool_user_query(pool, puser); } else if (tds->in_buf[0] == 0x06) { /* cancel */ } else { fprintf(stderr, "Unrecognized packet type, closing user\n"); pool_free_user(puser); } } /* fprintf(stderr,"read %d bytes from conn %d\n",len,i); */ } void pool_user_query(TDS_POOL * pool, TDS_POOL_USER * puser) { TDS_POOL_MEMBER *pmbr; int ret; puser->user_state = TDS_SRV_QUERY; pmbr = pool_find_idle_member(pool); if (!pmbr) { /* * put into wait state * check when member is deallocated */ fprintf(stderr, "Not enough free members...placing user in WAIT\n"); puser->user_state = TDS_SRV_WAIT; waiters++; } else { pmbr->state = TDS_QUERYING; pool_assign_member(pmbr, puser); /* cf. net.c for better technique. */ ret = WRITESOCKET(pmbr->tds->s, puser->tds->in_buf, puser->tds->in_len); /* write failed, cleanup member */ if (ret < 0) { pool_free_member(pmbr); } } } freetds-0.91/src/pool/util.c100664 001750 000144 00000005145 11244772137 0011475/* 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 * */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include "pool.h" #include "tdsstring.h" static char software_version[] = "$Id: util.c,v 1.14 2009/08/25 14:25:35 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; void dump_buf(const void *buf, int length) { int i; int j; const int bytesPerLine = 16; const unsigned char *data = (const unsigned char *) buf; for (i = 0; i < length; i += bytesPerLine) { fprintf(stderr, "%04x ", i); for (j = i; j < length && (j - i) < bytesPerLine; j++) { fprintf(stderr, "%02x ", data[j]); } for (; 0 != (j % bytesPerLine); j++) { fprintf(stderr, " "); } fprintf(stderr, " |"); for (j = i; j < length && (j - i) < bytesPerLine; j++) { fprintf(stderr, "%c", (isprint(data[j])) ? data[j] : '.'); } fprintf(stderr, "|\n"); } fprintf(stderr, "\n"); } 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); } void die_if(int expr, const char *msg) { if (expr) { fprintf(stderr, "%s\n", msg); fprintf(stderr, "tdspool aborting!\n"); exit(1); } } freetds-0.91/src/pool/pool.h100664 001750 000144 00000006235 10443342167 0011473/* 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_ #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 "tds.h" TDS_RCSID(pool_h, "$Id: pool.h,v 1.15 2006/06/12 19:45:59 freddy77 Exp $"); /* defines */ #define PGSIZ 2048 #define BLOCKSIZ 512 #define MAX_POOL_USERS 1024 /* enums and typedefs */ typedef enum { TDS_SRV_LOGIN, TDS_SRV_IDLE, TDS_SRV_QUERY, TDS_SRV_WAIT, /* if no members are free wait */ TDS_SRV_CANCEL, TDS_SRV_DEAD } TDS_USER_STATE; /* forward declaration */ typedef struct tds_pool_member TDS_POOL_MEMBER; typedef struct tds_pool_user { TDSSOCKET *tds; TDS_USER_STATE user_state; TDS_POOL_MEMBER *assigned_member; } TDS_POOL_USER; struct tds_pool_member { TDSSOCKET *tds; /* sometimes we get a partial packet */ int need_more; int state; time_t last_used_tm; TDS_POOL_USER *current_user; /* * these variables are used for tracking the state of the TDS protocol * so we know when to return the state to TDS_IDLE. */ int num_bytes_left; unsigned char fragment[PGSIZ]; }; typedef 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; int num_members; TDS_POOL_MEMBER *members; int max_users; TDS_POOL_USER *users; } TDS_POOL; /* prototypes */ /* member.c */ int pool_process_members(TDS_POOL * pool, fd_set * fds); TDS_POOL_MEMBER *pool_find_idle_member(TDS_POOL * pool); void pool_mbr_init(TDS_POOL * pool); void pool_free_member(TDS_POOL_MEMBER * pmbr); void pool_assign_member(TDS_POOL_MEMBER * pmbr, TDS_POOL_USER *puser); void pool_deassign_member(TDS_POOL_MEMBER * pmbr); void pool_reset_member(TDS_POOL_MEMBER * pmbr); /* user.c */ int pool_process_users(TDS_POOL * pool, fd_set * fds); void pool_user_init(TDS_POOL * pool); TDS_POOL_USER *pool_user_create(TDS_POOL * pool, TDS_SYS_SOCKET s, struct sockaddr_in *sin); void pool_free_user(TDS_POOL_USER * puser); void pool_user_query(TDS_POOL * pool, TDS_POOL_USER * puser); /* util.c */ void dump_buf(const void *buf, int length); void dump_login(TDSLOGIN * login); void die_if(int expr, const char *msg); /* config.c */ int pool_read_conf_file(char *poolname, TDS_POOL * pool); #endif freetds-0.91/src/pool/BUGS100664 001750 000144 00000000157 07361702256 0011035Need to handle results larger than 1 packet. fixed 11/18/00 Disconnect doesn't leave the FDSET. fixed 11/18/00 freetds-0.91/src/pool/pool.conf100664 001750 000144 00000000333 07551114175 0012164[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-0.91/PWD.in100664 001750 000144 00000001372 07540130644 0007567# $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-0.91/BUGS100664 001750 000144 00000001231 11213255275 0007262 Believed Fixed -------------- 1. code to send COL_NAME and COL_INFO tokens are not in the server stuff. Needs Fixing ------------ 1. Fix formatting of dbprhead/dbprrow...its a little off (Anybody care?) 2. dbwritetext() and friends do not work under TDS 7.0 3. There is a bug with the order of returns from ct_results() such that rows affected doesn't show up in sqsh. 4. 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. 5. ML Mar 21 2009: "freebcp error HINT -b doesnt work", freebcp -n broken. freetds-0.91/freetds.conf100664 001750 000144 00000002106 10734116374 0011107# $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 = 4.2 # 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 # 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-0.91/locales.conf100664 001750 000144 00000000562 10442314511 0011066[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-0.91/autogen.sh100775 001750 000144 00000003050 11542161074 0010577#!/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-0.91/freetds.spec100664 001750 000144 00000010410 11623073515 0011106%define name freetds %define version 0.91 # compute some additional dependency from vendor name # # RedHat %define tds_builddep_redhat unixODBC-devel >= 2.0.0 %define tds_dep_suse glibc-locale # SUSE %define tds_builddep_suse unixODBC-devel >= 2.0.0 %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 %{?tds_builddep:BuildRequires: %{tds_builddep}} %{?tds_dep:Requires: %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=4.2 --with-unixodbc="$ODBCDIR" 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-%{version}" %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/doc/freetds-%{version}/userguide doc/images doc/doc/freetds-%{version}/reference %changelog * 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 * Sun 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 * Wed 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-0.91/tds.dox100664 001750 000144 00000001052 10257535317 0010113#$Id: tds.dox,v 1.9 2005/06/26 14:25:19 jklowden Exp $ PROJECT_NAME = "FreeTDS API" OUTPUT_DIRECTORY = doc/doc/freetds-$(VERSION)/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 freetds-0.91/Nmakefile100755 001750 000144 00000030204 11623070340 0010411# $Id: Nmakefile,v 1.10.2.2 2011/07/07 07:27:33 freddy77 Exp $ # Build FreeTDS and assorted utilities for Win32/Win64 without an IDE. # Makefiles, unlike Visual Studio project files, are stable over time. # Contributed to the public domain by James K. Lowden, February 2009 # Define in the environment or on the command line: # 1. CONFIGURATION = debug/release # 2. PLATFORM = win32/x64 # These will determine what is built and where outputs are placed. # # Example invocations: # nmake.exe -f Nmakefile -nologo PLATFORM=win32 CONFIGURATION=debug # nmake.exe -f Nmakefile -nologo build-win32d # !IFNDEF PLATFORM PLATFORM = Win32 !ENDIF !IFNDEF CONFIGURATION CONFIGURATION = Debug !ENDIF MKDIR = MD MV = move /Y DBLIB_DIR = src\dblib REPLACEMENTS_DIR = src\replacements TDS_DIR = src\tds APPS_DIR = src\apps DBLIB_OUT = $(DBLIB_DIR)\$(PLATFORM)\$(CONFIGURATION) REPLACEMENTS_OUT = $(REPLACEMENTS_DIR)\$(PLATFORM)\$(CONFIGURATION) TDS_OUT = $(TDS_DIR)\$(PLATFORM)\$(CONFIGURATION) APPS_OUT = $(APPS_DIR)\$(PLATFORM)\$(CONFIGURATION) DBLIB_SRC = $(DBLIB_DIR)\bcp.c \ $(DBLIB_DIR)\dblib.c \ $(DBLIB_DIR)\dbopen.c \ $(DBLIB_DIR)\dbutil.c \ $(DBLIB_DIR)\rpc.c \ $(DBLIB_DIR)\xact.c DBLIB_OBJ = $(DBLIB_OUT)\bcp.obj \ $(DBLIB_OUT)\dblib.obj \ $(DBLIB_OUT)\dbopen.obj \ $(DBLIB_OUT)\dbutil.obj \ $(DBLIB_OUT)\rpc.obj \ $(DBLIB_OUT)\xact.obj REPLACEMENTS_SRC = $(REPLACEMENTS_DIR)\asprintf.c \ $(REPLACEMENTS_DIR)\basename.c \ $(REPLACEMENTS_DIR)\fakepoll.c \ $(REPLACEMENTS_DIR)\gettimeofday.c \ $(REPLACEMENTS_DIR)\getopt.c \ $(REPLACEMENTS_DIR)\iconv.c \ $(REPLACEMENTS_DIR)\readpassphrase.c \ $(REPLACEMENTS_DIR)\strlcat.c \ $(REPLACEMENTS_DIR)\strlcpy.c \ $(REPLACEMENTS_DIR)\strtok_r.c \ $(REPLACEMENTS_DIR)\vasprintf.c REPLACEMENTS_OBJ = $(REPLACEMENTS_OUT)\asprintf.obj \ $(REPLACEMENTS_OUT)\basename.obj \ $(REPLACEMENTS_OUT)\fakepoll.obj \ $(REPLACEMENTS_OUT)\gettimeofday.obj \ $(REPLACEMENTS_OUT)\getopt.obj \ $(REPLACEMENTS_OUT)\iconv.obj \ $(REPLACEMENTS_OUT)\readpassphrase.obj \ $(REPLACEMENTS_OUT)\strlcat.obj \ $(REPLACEMENTS_OUT)\strlcpy.obj \ $(REPLACEMENTS_OUT)\strtok_r.obj \ $(REPLACEMENTS_OUT)\vasprintf.obj TDS_SRC = $(TDS_DIR)\bulk.c \ $(TDS_DIR)\challenge.c \ $(TDS_DIR)\config.c \ $(TDS_DIR)\convert.c \ $(TDS_DIR)\data.c \ $(TDS_DIR)\des.c \ $(TDS_DIR)\getmac.c \ $(TDS_DIR)\gssapi.c \ $(TDS_DIR)\hmac_md5.c \ $(TDS_DIR)\iconv.c \ $(TDS_DIR)\locale.c \ $(TDS_DIR)\log.c \ $(TDS_DIR)\login.c \ $(TDS_DIR)\md4.c \ $(TDS_DIR)\md5.c \ $(TDS_DIR)\mem.c \ $(TDS_DIR)\net.c \ $(TDS_DIR)\numeric.c \ $(TDS_DIR)\query.c \ $(TDS_DIR)\read.c \ $(TDS_DIR)\sspi.c \ $(TDS_DIR)\tds_checks.c \ $(TDS_DIR)\tdsstring.c \ $(TDS_DIR)\threadsafe.c \ $(TDS_DIR)\token.c \ $(TDS_DIR)\util.c \ $(TDS_DIR)\vstrbuild.c \ $(TDS_DIR)\win_mutex.c \ $(TDS_DIR)\write.c TDS_OBJ = $(TDS_OUT)\bulk.obj \ $(TDS_OUT)\challenge.obj \ $(TDS_OUT)\config.obj \ $(TDS_OUT)\convert.obj \ $(TDS_OUT)\data.obj \ $(TDS_OUT)\des.obj \ $(TDS_OUT)\getmac.obj \ $(TDS_OUT)\gssapi.obj \ $(TDS_OUT)\hmac_md5.obj \ $(TDS_OUT)\iconv.obj \ $(TDS_OUT)\locale.obj \ $(TDS_OUT)\log.obj \ $(TDS_OUT)\login.obj \ $(TDS_OUT)\md4.obj \ $(TDS_OUT)\md5.obj \ $(TDS_OUT)\mem.obj \ $(TDS_OUT)\net.obj \ $(TDS_OUT)\numeric.obj \ $(TDS_OUT)\query.obj \ $(TDS_OUT)\read.obj \ $(TDS_OUT)\sspi.obj \ $(TDS_OUT)\tds_checks.obj \ $(TDS_OUT)\tdsstring.obj \ $(TDS_OUT)\threadsafe.obj \ $(TDS_OUT)\token.obj \ $(TDS_OUT)\util.obj \ $(TDS_OUT)\vstrbuild.obj \ $(TDS_OUT)\win_mutex.obj \ $(TDS_OUT)\write.obj # not yet: $(APPS_DIR)\bsqlodbc.c APPS_SRC = $(APPS_DIR)\bsqldb.c \ $(APPS_DIR)\datacopy.c \ $(APPS_DIR)\defncopy.c \ $(APPS_DIR)\freebcp.c \ $(APPS_DIR)\tsql.c APPS_OBJ = $(APPS_OUT)\bsqldb.obj \ $(APPS_OUT)\datacopy.obj \ $(APPS_OUT)\defncopy.obj \ $(APPS_OUT)\freebcp.obj \ $(APPS_OUT)\tsql.obj APPS_EXE = $(APPS_OUT)\bsqldb.exe \ $(APPS_OUT)\datacopy.exe \ $(APPS_OUT)\defncopy.exe \ $(APPS_OUT)\freebcp.exe \ $(APPS_OUT)\tsql.exe db-lib: $(DBLIB_OUT)\db-lib.lib apps: $(DBLIB_OUT)\db-lib.lib $(APPS_EXE) tsql: $(APPS_OUT)\tsql.exe bsqldb: $(APPS_OUT)\bsqldb.exe help: @echo targets: db-lib, apps, tsql, bsqldb ##(APPS_OUT)\bsqldb.exe: $(APPS_DIR)\bsqldb.exe $(DBLIB_OUT)\db-lib.lib # Don't know how to create this dependency without explicitly defining every output. # # Sadly the environment settings for building for different architectures # is undocumented. Microsoft's directions are to run the requisite # batch file without explaining what it does. While it's possible to # read the file -- and it's not complicated -- it's impossible to # know the purpose of setting PATH/INCLUDE/LIB just so. Worse, the # settings are per-machine, and if the file is lost, the only way to # recreate it is to reinstall the compiler. # # The "solution" is to follow their advice. Run vcvarsall.bat with the # appropriate argument to set up the environment, and go from there. # # As of this writing, the variables are: # x86 Native: Vcvarsall "x86" # x64 Native: Vcvarsall "amd64" # x64 Cross: Vcvarsall "x86_amd64" # # Check that cl.exe is in the PATH. Cf. "help FOR" to see how this works. # See above comments regarding environment setup. # COMPILER = cl.exe !IF 0 != [for /f %I in ("$(COMPILER)") DO @dir /b "%~dp$$PATH:I\$(COMPILER)" > NUL:] !MESSAGE cl.exe not in PATH !ERROR Perhaps run vcvarsall.bat to set up the command-line development environment? !ENDIF all: build-win32d build-win32r build-win64d build-win64r build-win32d: $(MAKE) -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=debug build-win32r: $(MAKE) -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=release build-win64d: $(MAKE) -fNmakefile -nologo apps PLATFORM=win64 CONFIGURATION=debug build-win64r: $(MAKE) -fNmakefile -nologo apps PLATFORM=win64 CONFIGURATION=release clean: @if "" equ "$(PLATFORM)" PLATFORM not defined, see comments in Nmakefile >&2 && exit 1 @if "" equ "$(CONFIGURATION)" CONFIGURATION not defined, see comments in Nmakefile >&2 && exit 1 if exist $(DBLIB_OUT) del /q $(DBLIB_OUT)\*.obj $(DBLIB_OUT)\*.lib if exist $(REPLACEMENTS_OUT) del /q $(REPLACEMENTS_OUT)\*.obj $(REPLACEMENTS_OUT)\*.lib if exist $(TDS_OUT) del /q $(TDS_OUT)\*.obj $(TDS_OUT)\*.lib if exist $(APPS_OUT) del /q $(APPS_OUT)\*.obj $(APPS_OUT)\*.exe clean-app: @if "" equ "$(PLATFORM)" PLATFORM not defined, see comments in Nmakefile >&2 && exit 1 @if "" equ "$(CONFIGURATION)" CONFIGURATION not defined, see comments in Nmakefile >&2 && exit 1 if exist $(APPS_OUT) del /q $(APPS_OUT)\*.obj $(APPS_OUT)\*.exe # Create output directories $(DBLIB_OUT) $(REPLACEMENTS_OUT) $(TDS_OUT) $(APPS_OUT): @echo creating output directory for configuration: "$(PLATFORM)|$(CONFIGURATION)" @if "" equ "$(PLATFORM)" PLATFORM not defined, see comments in Nmakefile >&2 && exit 1 @if "" equ "$(CONFIGURATION)" CONFIGURATION not defined, see comments in Nmakefile >&2 && exit 1 $(MKDIR) $@ # # Some header files are generated with Perl for consistency. # The Perl scripts are maintained in CVS, and someone developing # with CVS needs Perl to build FreeTDS. # # To avoid any dependency on Perl for everyone else, the # distribution tarball contains the pre-generated files. # # The preprocessing test below checks for the existence of a CVS # directory, which wouldn't be present in a freshly unpacked tarball. # If it finds one, it enables the code to generate the header files. # !IF 0 == [dir /b /ad CVS 2>NUL:] # # Generate distributed header files # include\tdsver.h: perl -e"@a=localtime; printf qq(#undef TDS_VERSION_NO\n#define TDS_VERSION_NO \"freetds v0.83.dev.%d%02d%02d\"\n), 1900+$$a[5], 1+$$a[-1], $$a[3]" \ > $@.err move /Y $@.err $@ src\tds\tds_types.h: perl src\tds\types.pl misc\types.txt > $@.err move /Y $@.err $@ src\tds\tds_willconvert.h: src\tds\tds_willconvert.pl perl src\tds\tds_willconvert.pl > $@.tmp $(MV) $@.tmp $@ src\tds\encodings.h: src\tds\encodings.pl src\tds\alternative_character_sets.h perl src\tds\encodings.pl src\tds > $@.tmp 2> NUL: $(MV) $@.tmp $@ src\tds\num_limits.h: src\tds\num_limits.pl perl src\tds\num_limits.pl > $@.tmp $(MV) $@.tmp $@ !ENDIF GENERATED_FILES = include\tdsver.h src\tds\tds_types.h \ src\tds\tds_willconvert.h src\tds\encodings.h src\tds\num_limits.h $(DBLIB_OUT)\db-lib.lib: $(GENERATED_FILES) $(DBLIB_OUT) $(DBLIB_OBJ) $(REPLACEMENTS_OUT)\replacements.lib $(TDS_OUT)\tds.lib @echo building $@ >&2 lib -nologo -out:"$@" $(DBLIB_OBJ) \ $(REPLACEMENTS_OUT)\replacements.lib \ $(TDS_OUT)\tds.lib $(REPLACEMENTS_OUT)\replacements.lib: $(REPLACEMENTS_OUT) $(REPLACEMENTS_OBJ) lib -nologo -out:"$@" $(REPLACEMENTS_OBJ) $(TDS_OUT)\tds.lib: $(TDS_OUT) $(TDS_OBJ) lib -nologo -out:"$@" $(TDS_OBJ) # # set compiler flags # INC = -I "include" -I "win32" -I "include\x64" FLG = -nologo -W3 -Wp64 -EHsc -TC -Gm -errorReport:prompt DEF = -D "_MBCS" -D "_LIB" -D "WIN32" \ -D MSDBLIB \ -D "_CRT_SECURE_NO_WARNINGS" -D _CRT_NONSTDC_NO_DEPRECATE \ -D "HAVE_CONFIG_H" \ -D "_FREETDS_LIBRARY_SOURCE" DBG = -MTd -Od -D "_DEBUG" -ZI -RTC1 REL = -MT -O2 -D "_NDEBUG" -Zi MSLIBS = Ws2_32.lib shell32.lib CC = cl $(CFLAGS) $(FLG) $(DEF) $(INC) CC32 = $(CC) CC64 = $(CC) ## Rules ## # # dblib # #c.{$(DBLIB_DIR)\win32\debug}.obj:: {$(DBLIB_DIR)}.c{$(DBLIB_DIR)\win32\debug}.obj:: $(CC32) -c $(DBG) -Fo"$(DBLIB_OUT)\\" \ -Fd"$(DBLIB_OUT)\vc80.pdb" \ $< {$(DBLIB_DIR)\}.c{$(DBLIB_DIR)\win32\release}.obj:: $(CC32) -c $(REL) -Fo"$(DBLIB_OUT)\\" \ -Fd"$(DBLIB_OUT)\vc80.pdb" \ $< {$(DBLIB_DIR)}.c{$(DBLIB_DIR)\x64\debug}.obj:: $(CC64) -c $(DBG) -Fo"$(DBLIB_OUT)\\" \ -Fd"$(DBLIB_OUT)\vc80.pdb" \ $< {$(DBLIB_DIR)}.c{$(DBLIB_DIR)\x64\release}.obj:: $(CC64) -c $(REL) -Fo"$(DBLIB_OUT)\\" \ -Fd"$(DBLIB_OUT)\vc80.pdb" \ $< # # replacements # {$(REPLACEMENTS_DIR)}.c{$(REPLACEMENTS_DIR)\win32\debug}.obj:: $(CC32) -c $(DBG) -Fo"$(REPLACEMENTS_OUT)\\" \ -Fd"$(REPLACEMENTS_OUT)\vc80.pdb" \ $< {$(REPLACEMENTS_DIR)}.c{$(REPLACEMENTS_DIR)\win32\release}.obj:: $(CC32) -c $(REL) -Fo"$(REPLACEMENTS_OUT)\\" \ -Fd"$(REPLACEMENTS_OUT)\vc80.pdb" \ $< {$(REPLACEMENTS_DIR)}.c{$(REPLACEMENTS_DIR)\x64\debug}.obj:: $(CC64) -c $(DBG) -Fo"$(REPLACEMENTS_OUT)\\" \ -Fd"$(REPLACEMENTS_OUT)\vc80.pdb" \ $< {$(REPLACEMENTS_DIR)}.c{$(REPLACEMENTS_DIR)\x64\release}.obj:: $(CC64) -c $(REL) -Fo"$(REPLACEMENTS_OUT)\\" \ -Fd"$(REPLACEMENTS_OUT)\vc80.pdb" \ $< # # tds # {$(TDS_DIR)}.c{$(TDS_DIR)\win32\debug}.obj:: $(CC32) -c $(DBG) -Fo"$(TDS_OUT)\\" \ -Fd"$(TDS_OUT)\vc80.pdb" \ $< {$(TDS_DIR)}.c{$(TDS_DIR)\win32\release}.obj:: $(CC32) -c $(REL) -Fo"$(TDS_OUT)\\" \ -Fd"$(TDS_OUT)\vc80.pdb" \ $< {$(TDS_DIR)}.c{$(TDS_DIR)\x64\debug}.obj:: $(CC64) -c $(DBG) -Fo"$(TDS_OUT)\\" \ -Fd"$(TDS_OUT)\vc80.pdb" \ $< {$(TDS_DIR)}.c{$(TDS_DIR)\x64\release}.obj:: $(CC64) -c $(REL) -Fo"$(TDS_OUT)\\" \ -Fd"$(TDS_OUT)\vc80.pdb" \ $< # # Utilities # $(APPS_EXE): $(DBLIB_OUT)\db-lib.lib {$(APPS_DIR)}.c{$(APPS_DIR)\win32\debug}.exe: @if not exist $(APPS_OUT) $(MKDIR) $(APPS_OUT) $(CC32) $(DBG) -Fd"$(APPS_OUT)\vc80.pdb" -Fe$@ \ $< -link -LIBPATH:$(DBLIB_OUT) db-lib.lib $(MSLIBS) {$(APPS_DIR)\}.c{$(APPS_DIR)\win32\release}.exe: @if not exist $(APPS_OUT) $(MKDIR) $(APPS_OUT) $(CC32) $(REL) -Fe$@ -Fd"$(APPS_OUT)\vc80.pdb" \ $< -link -LIBPATH:$(DBLIB_OUT) db-lib.lib $(MSLIBS) {$(APPS_DIR)}.c{$(APPS_DIR)\x64\debug}.exe: @if not exist $(APPS_OUT) $(MKDIR) $(APPS_OUT) $(CC64) $(DBG) -Fe$@ -Fd"$(APPS_OUT)\vc80.pdb" \ $< -link -LIBPATH:$(DBLIB_OUT) db-lib.lib $(MSLIBS) {$(APPS_DIR)}.c{$(APPS_DIR)\x64\release}.exe: @if not exist $(APPS_OUT) $(MKDIR) $(APPS_OUT) $(CC64) $(REL) -Fe$@ -Fd"$(APPS_OUT)\vc80.pdb" \ $< -link -LIBPATH:$(DBLIB_OUT) db-lib.lib $(MSLIBS) freetds-0.91/FreeTDS.sln100775 001750 000144 00000005677 11134167216 0010575 Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TDS", "src\tds\TDS.vcproj", "{B9D6D61B-5E3B-42F4-A758-7A137594E3E9}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "db-lib", "src\dblib\db-lib.vcproj", "{F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}" ProjectSection(ProjectDependencies) = postProject {A7619118-36E9-434B-A87E-DBDEC14CF137} = {A7619118-36E9-434B-A87E-DBDEC14CF137} {B9D6D61B-5E3B-42F4-A758-7A137594E3E9} = {B9D6D61B-5E3B-42F4-A758-7A137594E3E9} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "replacements", "src\replacements\replacements.vcproj", "{A7619118-36E9-434B-A87E-DBDEC14CF137}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B9D6D61B-5E3B-42F4-A758-7A137594E3E9}.Debug|Win32.ActiveCfg = Debug|Win32 {B9D6D61B-5E3B-42F4-A758-7A137594E3E9}.Debug|Win32.Build.0 = Debug|Win32 {B9D6D61B-5E3B-42F4-A758-7A137594E3E9}.Debug|x64.ActiveCfg = Debug|x64 {B9D6D61B-5E3B-42F4-A758-7A137594E3E9}.Debug|x64.Build.0 = Debug|x64 {B9D6D61B-5E3B-42F4-A758-7A137594E3E9}.Release|Win32.ActiveCfg = Release|Win32 {B9D6D61B-5E3B-42F4-A758-7A137594E3E9}.Release|Win32.Build.0 = Release|Win32 {B9D6D61B-5E3B-42F4-A758-7A137594E3E9}.Release|x64.ActiveCfg = Release|x64 {B9D6D61B-5E3B-42F4-A758-7A137594E3E9}.Release|x64.Build.0 = Release|x64 {F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}.Debug|Win32.ActiveCfg = Debug|Win32 {F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}.Debug|Win32.Build.0 = Debug|Win32 {F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}.Debug|x64.ActiveCfg = Debug|x64 {F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}.Debug|x64.Build.0 = Debug|x64 {F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}.Release|Win32.ActiveCfg = Release|Win32 {F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}.Release|Win32.Build.0 = Release|Win32 {F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}.Release|x64.ActiveCfg = Release|x64 {F3CDE19D-7E97-4874-8E9F-994A82CDBDDA}.Release|x64.Build.0 = Release|x64 {A7619118-36E9-434B-A87E-DBDEC14CF137}.Debug|Win32.ActiveCfg = Debug|Win32 {A7619118-36E9-434B-A87E-DBDEC14CF137}.Debug|Win32.Build.0 = Debug|Win32 {A7619118-36E9-434B-A87E-DBDEC14CF137}.Debug|x64.ActiveCfg = Debug|x64 {A7619118-36E9-434B-A87E-DBDEC14CF137}.Debug|x64.Build.0 = Debug|x64 {A7619118-36E9-434B-A87E-DBDEC14CF137}.Release|Win32.ActiveCfg = Release|Win32 {A7619118-36E9-434B-A87E-DBDEC14CF137}.Release|Win32.Build.0 = Release|Win32 {A7619118-36E9-434B-A87E-DBDEC14CF137}.Release|x64.ActiveCfg = Release|x64 {A7619118-36E9-434B-A87E-DBDEC14CF137}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal freetds-0.91/include/replacements/readpassphrase.h100664 001750 000144 00000004634 11327421727 0016077/* 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 _READPASSPHRASE_H_ #define _READPASSPHRASE_H_ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif #ifndef HAVE_READPASSPHRASE #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 */ char * readpassphrase(const char *, char *, size_t, int); #endif /* HAVE_READPASSPHRASE */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif /* !_READPASSPHRASE_H_ */ freetds-0.91/include/bkpublic.h100664 001750 000144 00000005756 10140164443 0012200/* 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-0.91/include/cspublic.h100664 001750 000144 00000052652 11061262741 0012211/* 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 static const char rcsid_cspublic_h[] = "$Id: cspublic.h,v 1.61 2008/09/08 17:50:25 jklowden Exp $"; static const void *const no_unused_cspublic_h_warn[] = { rcsid_cspublic_h, no_unused_cspublic_h_warn }; #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_80 }; /* 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_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, ...); CS_RETCODE cs_dt_crack(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec); 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-0.91/include/cstypes.h100664 001750 000144 00000011357 11007721312 0012066/* 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 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_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-0.91/include/ctpublic.h100664 001750 000144 00000016227 10246046172 0012212/* 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-0.91/include/sqldb.h100664 001750 000144 00000011736 11305565646 0011523/* 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-0.91/include/sqlfront.h100644 001750 000144 00000003701 11623070340 0012236/* 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 SQLFRONT_h #define SQLFRONT_h #include "./sybfront.h" static const char rcsid_sqlfront_h[] = "$Id: sqlfront.h,v 1.6.2.3 2011/07/14 12:17:55 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-0.91/include/sybdb.h100644 001750 000144 00000166470 11623070340 0011506/* 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. */ /** \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 static const char rcsid_sybdb_h[] = "$Id: sybdb.h,v 1.100.2.1 2011/06/06 12:31:45 freddy77 Exp $"; static const void *const no_unused_sybdb_h_warn[] = { rcsid_sybdb_h, no_unused_sybdb_h_warn }; #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 #define DBMAXNAME 30 /** * 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_80 DBVERSION_71 #define DBVERSION_72 6 /* 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 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 #if !defined(_FREETDS_LIBRARY_SOURCE) || !defined(_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 }; #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 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; #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; /* 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; /* 0 - 127 (Sybase only) */ }; 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 - 997 */ DBINT datetzone; /* 0 - 127 */ }; #ifdef MSDBLIB typedef struct tds_microsoft_dbdaterec DBDATEREC; #else typedef struct tds_sybase_dbdaterec DBDATEREC; #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 BIGINTBIND 30 #define MAXBINDTYPES 31 /* 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 *dbtabsoruce(DBPROCESS * dbprocess, int colnum, int *tabnum); RETCODE dbsetlshort(LOGINREC * login, int value, int which); 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); RETCODE dbaltlen(DBPROCESS * dbproc, int computeid, int column); int dbaltop(DBPROCESS * dbproc, int computeid, int column); int dbalttype(DBPROCESS * dbproc, int computeid, int column); RETCODE 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, 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); RETCODE dbdatecmp(DBPROCESS * dbproc, DBDATETIME * d1, DBDATETIME * d2); RETCODE dbdatecrack(DBPROCESS * dbproc, DBDATEREC * di, DBDATETIME * dt); 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); RETCODE 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); #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); 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 */ 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 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)) RETCODE bcp_init(DBPROCESS * dbproc, const char *tblname, const char *hfile, const char *errfile, int direction); RETCODE bcp_done(DBPROCESS * dbproc); RETCODE 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-0.91/include/sybfront.h100664 001750 000144 00000002323 10140164444 0012237/* 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-0.91/include/syberror.h100664 001750 000144 00000002777 10140164444 0012255/* 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-0.91/include/odbcss.h100664 001750 000144 00000001743 11010265566 0011657/* 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. */ /* $Id: odbcss.h,v 1.1 2008/05/07 08:42:30 freddy77 Exp $ */ #define SQL_DIAG_SS_MSGSTATE (-1150) #define SQL_DIAG_SS_LINE (-1154) freetds-0.91/include/ctlib.h100664 001750 000144 00000014710 11452561624 0011501/* 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_ /* * Internal (not part of the exposed API) prototypes and such. */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif #ifdef __cplusplus extern "C" { #if 0 } #endif #endif static const char rcsid_ctlib_h[] = "$Id: ctlib.h,v 1.30 2010/10/05 08:36:36 freddy77 Exp $"; static const void *const no_unused_ctlib_h_warn[] = { rcsid_ctlib_h, no_unused_ctlib_h_warn }; #include /* * 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_command_list CS_COMMAND_LIST; typedef struct _cs_dynamic CS_DYNAMIC_LIST; 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_LIST *cmds; CS_DYNAMIC_LIST *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 { char *id; char *stmt; CS_DYNAMIC_PARAM *param_list; struct _cs_dynamic *next; }; /* 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 { 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_command_list { struct _cs_command *cmd; struct _cs_command_list *next; }; struct _cs_blkdesc { CS_CONNECTION *con; 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 */ int _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr); int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr); int _ct_get_server_type(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); #ifdef __cplusplus #if 0 { #endif } #endif #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif freetds-0.91/include/dblib.h100664 001750 000144 00000012146 11327421726 0011460/* 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_ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif #ifdef __cplusplus extern "C" { #if 0 } #endif #endif /* $Id: dblib.h,v 1.46 2010/01/25 23:05:58 freddy77 Exp $ */ 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; int datatype; int prefix_len; DBINT column_len; BYTE *terminator; int term_len; int tab_colnum; int column_error; BCPCOLDATA *bcp_column_data; } 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; int 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; #define MAXOPTTEXT 32 struct dboption { char text[MAXOPTTEXT]; DBSTRING *param; DBBOOL factive; }; typedef struct dboption DBOPTION; typedef struct _null_representation { const BYTE *bindval; size_t len; } NULLREP; struct tds_dblib_dbprocess { TDSSOCKET *tds_socket; TDS_INT 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]; }; /* * internal prototypes */ 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); 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_DBPROC() CHECK_PARAMETER(dbproc, SYBENULL, FAIL) #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; } #ifdef __cplusplus #if 0 { #endif } #endif #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif freetds-0.91/include/fakepoll.h100664 001750 000144 00000003215 11372461637 0012203/* $Id: fakepoll.h,v 1.4 2010/05/12 08:15:27 freddy77 Exp $ */ #if !defined(_FAKE_POLL_H) && !defined(HAVE_POLL) #define _FAKE_POLL_H #if HAVE_CONFIG_H #include #endif #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 #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 int fakepoll(struct pollfd fds[], int nfds, int timeout); #endif freetds-0.91/include/md4.h100664 001750 000144 00000001255 11327421726 0011067#ifndef MD4_H #define MD4_H /* $Id: md4.h,v 1.9 2010/01/25 23:05:58 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif struct MD4Context { TDS_UINT buf[4]; TDS_UINT bits[2]; 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); void MD4Transform(TDS_UINT buf[4], TDS_UINT const in[16]); typedef struct MD4Context MD4_CTX; #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif /* !MD4_H */ freetds-0.91/include/md5.h100664 001750 000144 00000001365 11327421726 0011072#ifndef MD5_H #define MD5_H /* $Id: md5.h,v 1.6 2010/01/25 23:05:58 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif struct MD5Context { TDS_UINT buf[4]; TDS_UINT bits[2]; 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); void MD5Transform(TDS_UINT buf[4], TDS_UINT const in[16]); /* * This is needed to make RSAREF happy on some MS-DOS compilers. */ typedef struct MD5Context MD5_CTX; #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif /* !MD5_H */ freetds-0.91/include/des.h100664 001750 000144 00000001467 11327421726 0011163#ifndef DES_H #define DES_H /* $Id: des.h,v 1.13 2010/01/25 23:05:58 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif typedef unsigned char des_cblock[8]; 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; void tds_des_set_odd_parity(des_cblock key); int tds_des_ecb_encrypt(const void *plaintext, int len, DES_KEY * akey, des_cblock output); int tds_des_set_key(DES_KEY * dkey, des_cblock user_key, int len); void tds_des_encrypt(DES_KEY * key, des_cblock block); void _mcrypt_decrypt(DES_KEY * key, unsigned char *block); #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif /* !DES_H */ freetds-0.91/include/hmac_md5.h100664 001750 000144 00000002450 11327421726 0012056/* 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_ /* $Id: hmac_md5.h,v 1.3 2010/01/25 23:05:58 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif void hmac_md5(const unsigned char key[16], const unsigned char* data, size_t data_len, unsigned char* digest); #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif freetds-0.91/include/replacements.h100644 001750 000144 00000007250 11623070340 0013053/* 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_ /* $Id: replacements.h,v 1.28.2.1 2011/07/07 07:27:33 freddy77 Exp $ */ #include #include "tds_sysdep_public.h" #ifndef HAVE_READPASSPHRASE # include #else # include #endif /* these headers are needed for basename */ #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_LIBGEN_H # include #endif #if !HAVE_POLL #include #define poll(fds, nfds, timeout) fakepoll((fds), (nfds), (timeout)) #endif /* !HAVE_POLL */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif #ifdef __cplusplus extern "C" { #endif #if !HAVE_VSNPRINTF #if HAVE__VSNPRINTF #undef vsnprintf #define vsnprintf _vsnprintf #else int vsnprintf(char *ret, size_t max, const char *fmt, va_list ap); #endif /* !HAVE__VSNPRINTF */ #endif /* HAVE_VSNPRINTF */ #if !HAVE_ASPRINTF int asprintf(char **ret, const char *fmt, ...); #endif /* !HAVE_ASPRINTF */ #if !HAVE_VASPRINTF int vasprintf(char **ret, const char *fmt, va_list ap); #endif /* !HAVE_VASPRINTF */ #if !HAVE_ATOLL tds_sysdep_int64_type atoll(const char *nptr); #endif /* !HAVE_ATOLL */ #if !HAVE_STRTOK_R char *strtok_r(char *str, const char *sep, char **lasts); #endif /* !HAVE_STRTOK_R */ #if HAVE_STRLCPY #define tds_strlcpy(d,s,l) strlcpy(d,s,l) #else size_t tds_strlcpy(char *dest, const char *src, size_t len); #endif #if HAVE_STRLCAT #define tds_strlcat(d,s,l) strlcat(d,s,l) #else size_t tds_strlcat(char *dest, const char *src, size_t len); #endif #if HAVE_BASENAME #define tds_basename(s) basename(s) #else char *tds_basename(char *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 int gettimeofday (struct timeval *tv, void *tz); int getopt(int argc, char * const argv[], const char *optstring); extern char *optarg; extern int optind, offset, opterr, optreset; #endif #ifdef __cplusplus } #endif #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif freetds-0.91/include/tds.h100644 001750 000144 00000156636 11623070341 0011201/* 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_ /* $Id: tds.h,v 1.352.2.4 2011/08/12 16:29:36 freddy77 Exp $ */ #include #include #include #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_socket TDSSOCKET; #include "tdsver.h" #include "tds_sysdep_public.h" #ifdef _FREETDS_LIBRARY_SOURCE #include "tds_sysdep_private.h" #endif /* _FREETDS_LIBRARY_SOURCE */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif #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/8.0) 5.0 */ int iodbc; /* build odbc driver against iODBC in DIR */ int unixodbc; /* build odbc driver against unixODBC in DIR */ } TDS_COMPILETIME_SETTINGS; typedef struct tds_dstr { char *dstr_s; size_t dstr_size; } 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 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 tdsvarbinary { TDS_SMALLINT len; TDS_CHAR array[256]; } TDS_VARBINARY; typedef struct tdsvarchar { TDS_SMALLINT len; TDS_CHAR array[256]; } TDS_VARCHAR; typedef struct tdsunique { TDS_UINT Data1; TDS_USMALLINT Data2; TDS_USMALLINT Data3; TDS_UCHAR Data4[8]; } TDS_UNIQUE; /** 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 week; /**< 1 - 54 (can be 54 in leap year) */ 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 millisecond; /**< 0-999 */ TDS_INT tzone; } 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[]; #define TDS_SUCCEED 1 #define TDS_FAIL 0 #define TDS_NO_MORE_RESULTS 2 #define TDS_CANCELLED 3 #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 }; #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_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_SUCCEED, 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, TDSEBPROBADTYP = 20250, TDSECLOSEIN = 20292 } TDSERRNO; #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_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_TOKEN 174 /* 0xAE TDS_CONTROL */ #define TDS_ROW_TOKEN 209 /* 0xD1 */ #define TDS_NBC_ROW_TOKEN 210 /* 0xD2 as of TDS 7.3.B */ /* not implemented */ #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_EED_TOKEN 229 /* 0xE5 */ #define TDS_DBRPC_TOKEN 230 /* 0xE6 */ #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 */ 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 }; /* 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 /* string types */ #define TDS_NULLTERM -9 /* 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 */ #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 SYBFLT8 = 62, /* 0x3E */ #define SYBFLT8 SYBFLT8 SYBDATETIME = 61, /* 0x3D */ #define SYBDATETIME SYBDATETIME SYBBIT = 50, /* 0x32 */ #define SYBBIT SYBBIT 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 SYBBITN = 104, /* 0x68 */ #define SYBBITN SYBBITN 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 /* * MS only types */ SYBNVARCHAR = 103, /* 0x67 */ #define SYBNVARCHAR SYBNVARCHAR SYBINT8 = 127, /* 0x7F */ #define SYBINT8 SYBINT8 XSYBCHAR = 175, /* 0xAF */ #define XSYBCHAR XSYBCHAR XSYBVARCHAR = 167, /* 0xA7 */ #define XSYBVARCHAR XSYBVARCHAR XSYBNVARCHAR = 231, /* 0xE7 */ #define XSYBNVARCHAR XSYBNVARCHAR XSYBNCHAR = 239, /* 0xEF */ #define XSYBNCHAR XSYBNCHAR XSYBVARBINARY = 165, /* 0xA5 */ #define XSYBVARBINARY XSYBVARBINARY XSYBBINARY = 173, /* 0xAD */ #define XSYBBINARY XSYBBINARY SYBUNIQUE = 36, /* 0x24 */ #define SYBUNIQUE SYBUNIQUE SYBVARIANT = 98, /* 0x62 */ #define SYBVARIANT SYBVARIANT SYBMSUDT = 240, /* 0xF0 */ #define SYBMSUDT SYBMSUDT SYBMSXML = 241, /* 0xF1 */ #define SYBMSXML SYBMSXML /* * Sybase only types */ SYBLONGBINARY = 225, /* 0xE1 */ #define SYBLONGBINARY SYBLONGBINARY SYBUINT1 = 64, /* 0x40 */ #define SYBUINT1 SYBUINT1 SYBUINT2 = 65, /* 0x41 */ #define SYBUINT2 SYBUINT2 SYBUINT4 = 66, /* 0x42 */ #define SYBUINT4 SYBUINT4 SYBUINT8 = 67, /* 0x43 */ #define SYBUINT8 SYBUINT8 SYBBLOB = 36, /* 0x24 */ #define SYBBLOB SYBBLOB SYBBOUNDARY = 104, /* 0x68 */ #define SYBBOUNDARY SYBBOUNDARY SYBDATE = 49, /* 0x31 */ #define SYBDATE SYBDATE SYBDATEN = 123, /* 0x7B */ #define SYBDATEN SYBDATEN SYB5INT8 = 191, /* 0xBF */ #define SYB5INT8 SYB5INT8 SYBINTERVAL = 46, /* 0x2E */ #define SYBINTERVAL SYBINTERVAL SYBLONGCHAR = 175, /* 0xAF */ #define SYBLONGCHAR SYBLONGCHAR SYBSENSITIVITY = 103, /* 0x67 */ #define SYBSENSITIVITY SYBSENSITIVITY SYBSINT1 = 176, /* 0xB0 */ #define SYBSINT1 SYBSINT1 SYBTIME = 51, /* 0x33 */ #define SYBTIME SYBTIME SYBTIMEN = 147, /* 0x93 */ #define SYBTIMEN SYBTIMEN SYBUINTN = 68, /* 0x44 */ #define SYBUINTN SYBUINTN SYBUNITEXT = 174, /* 0xAE */ #define SYBUNITEXT SYBUNITEXT SYBXML = 163, /* 0xA3 */ #define SYBXML SYBXML } TDS_SERVER_TYPE; typedef enum { USER_UNICHAR_TYPE = 34, /* 0x22 */ USER_UNIVARCHAR_TYPE = 35 /* 0x23 */ } TDS_USER_TYPE; #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 /** * 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; typedef union tds_option_arg { TDS_TINYINT ti; TDS_INT i; TDS_CHAR *c; } TDS_OPTION_ARG; 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_LEVEL1 = 1, 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, TDS_NORMAL = 15, TDS7_LOGIN = 16, TDS7_AUTH = 17, TDS8_PRELOGIN = 18 } TDS_PACKET_TYPE; 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])) #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 /* * 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) #define is_hard_end_token(x) (x==TDS_DONE_TOKEN || \ x==TDS_DONEPROC_TOKEN) #define is_msg_token(x) (x==TDS_INFO_TOKEN || \ x==TDS_ERROR_TOKEN || \ x==TDS_EED_TOKEN) #define is_result_token(x) (x==TDS_RESULT_TOKEN || \ x==TDS_ROWFMT2_TOKEN || \ x==TDS7_RESULT_TOKEN || \ x==TDS_COLFMT_TOKEN || \ x==TDS_COLNAME_TOKEN || \ x==TDS_RETURNSTATUS_TOKEN) /* FIXME -- not a complete list */ #define is_fixed_type(x) (x==SYBINT1 || \ x==SYBINT2 || \ x==SYBINT4 || \ x==SYBINT8 || \ x==SYBREAL || \ x==SYBFLT8 || \ x==SYBDATETIME || \ x==SYBDATETIME4 || \ x==SYBBIT || \ x==SYBMONEY || \ x==SYBMONEY4 || \ x==SYBVOID || \ x==SYBUNIQUE) #define is_nullable_type(x) ( \ x==SYBBITN || \ x==SYBINTN || \ x==SYBFLTN || \ x==SYBMONEYN || \ x==SYBDATETIMN || \ x==SYBVARCHAR || \ x==SYBBINARY || \ x==SYBVARBINARY || \ x==SYBTEXT || \ x==SYBNTEXT || \ x==SYBIMAGE) #define is_variable_type(x) ( \ (x)==SYBTEXT || \ (x)==SYBIMAGE || \ (x)==SYBNTEXT || \ (x)==SYBCHAR || \ (x)==SYBVARCHAR || \ (x)==SYBBINARY || \ (x)==SYBVARBINARY || \ (x)==SYBLONGBINARY || \ (x)==XSYBCHAR || \ (x)==XSYBVARCHAR || \ (x)==XSYBNVARCHAR || \ (x)==XSYBNCHAR) #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) #define is_unicode_type(x) (x==XSYBNVARCHAR || x==XSYBNCHAR || x==SYBNTEXT || x==SYBMSXML) #define is_collate_type(x) (x==XSYBVARCHAR || x==XSYBCHAR || x==SYBTEXT || x==XSYBNVARCHAR || x==XSYBNCHAR || x==SYBNTEXT) #define is_ascii_type(x) ( x==XSYBCHAR || x==XSYBVARCHAR || x==SYBTEXT || x==SYBCHAR || x==SYBVARCHAR) #define is_char_type(x) (is_unicode_type(x) || is_ascii_type(x)) #define is_similar_type(x, y) ((is_char_type(x) && is_char_type(y)) || ((is_unicode_type(x) && is_unicode_type(y)))) #define TDS_MAX_CAPABILITY 22 #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 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 #else #define TDS_DEFAULT_VERSION 0x500 #define TDS_DEF_PORT 4000 #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_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_ENCRYPTION "encryption" #define TDS_STR_USENTLMV2 "use ntlmv2" /* 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" /* TODO do a better check for alignment than this */ typedef union { void *p; int i; } tds_align_struct; #define TDS_ALIGN_SIZE sizeof(tds_align_struct) #define TDS_MAX_LOGIN_STR_SZ 30 typedef struct tds_login { DSTR server_name; int port; TDS_USMALLINT tds_version; /* TDS version */ int block_size; DSTR language; /* e.g. us-english */ DSTR server_charset; /* e.g. iso_1 */ TDS_INT connect_timeout; DSTR client_host_name; DSTR app_name; DSTR user_name; DSTR password; DSTR library; /* Ct-Library, DB-Library, TDS-Library or ODBC */ TDS_TINYINT encryption_level; TDS_INT query_timeout; unsigned char capabilities[TDS_MAX_CAPABILITY]; DSTR client_charset; DSTR database; unsigned int bulk_copy:1; unsigned int suppress_language:1; } TDSLOGIN; typedef struct tds_connection { /* first part of structure is the same of login one */ DSTR server_name; /**< server name (in freetds.conf) */ int port; /**< port of database service */ TDS_USMALLINT tds_version; int block_size; DSTR language; DSTR server_charset; /**< charset of server */ TDS_INT connect_timeout; DSTR client_host_name; DSTR server_host_name; DSTR server_realm_name; /**< server realm name (in freetds.conf) */ DSTR app_name; DSTR user_name; /**< account for login */ DSTR password; /**< password of account login */ DSTR library; TDS_TINYINT encryption_level; TDS_INT query_timeout; unsigned char capabilities[TDS_MAX_CAPABILITY]; unsigned char option_flag2; DSTR client_charset; DSTR ip_addr; /**< ip of server */ DSTR instance_name; DSTR database; DSTR dump_file; int debug_flags; int text_size; unsigned int broken_dates:1; unsigned int emul_little_endian:1; unsigned int bulk_copy:1; unsigned int suppress_language:1; unsigned int gssapi_use_delegation:1; unsigned int use_ntlmv2:1; } TDSCONNECTION; 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]; } 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_UCHAR type; TDS_UCHAR collation[5]; } TDSVARIANT; /** * TDS 8.0 collation informations. */ typedef struct { TDS_USMALLINT locale_id; /* master..syslanguages.lcid */ TDS_USMALLINT flags; TDS_UCHAR charset_id; /* or zero */ } TDS8_COLLATION; /* 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 /** * Information relevant to libiconv. The name is an iconv name, not * the same as found in master..syslanguages. */ typedef struct tds_encoding { const char *name; unsigned char min_bytes_per_char; unsigned char max_bytes_per_char; unsigned char canonic; } TDS_ENCODING; typedef struct tds_bcpcoldata { TDS_UCHAR *data; TDS_INT datalen; TDS_INT is_null; } BCPCOLDATA; enum { TDS_SYSNAME_SIZE = 512 }; /** * Metadata about columns in regular and compute rows */ typedef struct tds_column { TDS_SMALLINT 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_INT column_usertype; TDS_INT column_flags; TDS_INT column_size; /**< maximun size of data. For fixed is the size. */ 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 */ TDS_SMALLINT column_namelen; /**< length of column name */ TDS_SMALLINT table_namelen; struct { TDS_SMALLINT column_type; /**< type of data, saved from wire */ TDS_INT column_size; } on_server; TDSICONV *char_conv; /**< refers to previously allocated iconv information */ TDS_CHAR table_name[TDS_SYSNAME_SIZE]; TDS_CHAR column_name[TDS_SYSNAME_SIZE]; char * 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; } TDSCOLUMN; /** Hold information for any results */ typedef struct tds_result_info { /* TODO those fields can became a struct */ TDS_SMALLINT num_cols; TDSCOLUMN **columns; TDS_INT row_size; TDS_INT ref_count; unsigned char *current_row; void (*row_free)(struct tds_result_info* result, unsigned char *row); TDS_SMALLINT rows_exist; /* TODO remove ?? used only in dblib */ TDS_INT row_count; /* TODO remove ?? used only in dblib */ TDS_TINYINT more_results; TDS_SMALLINT computeid; TDS_SMALLINT *bycolumns; TDS_SMALLINT by_cols; } TDSRESULTINFO; /** values for tds->state */ typedef enum _TDS_STATE { TDS_IDLE, /**< no data expected */ TDS_QUERYING, /**< client is sending request */ TDS_PENDING, /**< cilent is waiting for data */ TDS_READING, /**< client is reading data */ TDS_DEAD /**< no connection */ } TDS_STATE; #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_UINT 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 */ TDS_TINYINT cursor_name_len; /**< length of cursor name > 0 and <= 30 */ 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 */ TDS_TINYINT hasargs; /**< cursor parameters exists ? */ TDS_USMALLINT query_len; /**< SQL query length */ 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_SMALLINT 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 { int block_size; char *language; char *charset; 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 */ /** * id of dynamic. * Usually this id correspond to server one but if not specified * is generated automatically by libTDS */ char id[30]; /* int dyn_state; */ /* TODO use it */ /** numeric id for mssql7+*/ TDS_INT num_id; 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; /** * 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. */ int emulated; /** 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 , iso2server_metadata , initial_char_conv_count /* keep last */ }; typedef struct tds_authentication { TDS_UCHAR *packet; int packet_len; int (*free)(TDSSOCKET * tds, struct tds_authentication * auth); int (*handle_next)(TDSSOCKET * tds, struct tds_authentication * auth, size_t len); } TDSAUTHENTICATION; /** * Information for a server connection */ struct tds_socket { TDS_SYS_SOCKET s; /**< tcp socket, INVALID_SOCKET if not connected */ TDS_USMALLINT tds_version; TDS_UINT product_version; /**< version of product (Sybase/MS and full version) */ char *product_name; unsigned char capabilities[TDS_MAX_CAPABILITY]; unsigned int broken_dates:1; unsigned int emul_little_endian:1; unsigned int use_iconv:1; unsigned int tds71rev1:1; unsigned char *in_buf; /**< input buffer */ unsigned char *out_buf; /**< output buffer */ unsigned int in_buf_max; /**< allocated input buffer */ 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; /** * 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_INT num_comp_info; TDSCOMPUTEINFO **comp_info; TDSPARAMINFO *param_info; TDSCURSOR *cur_cursor; /**< cursor in use */ TDSCURSOR *cursors; /**< linked list of cursors allocated for this connection */ TDS_TINYINT has_status; /**< true is ret_status is valid */ 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 */ TDS_INT8 rows_affected; /**< rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid */ TDS_INT query_timeout; TDSENV env; TDSDYNAMIC *cur_dyn; /**< dynamic structure in use */ TDSDYNAMIC *dyns; /**< list of dynamic allocate for this connection */ const TDSCONTEXT *tds_ctx; int char_conv_count; TDSICONV **char_convs; TDSCONNECTION *connection; /**< config for login stuff. After login this field is NULL */ int spid; TDS_UCHAR collation[5]; TDS_UCHAR tds9_transaction[8]; void (*env_chg_func) (TDSSOCKET * tds, int type, char *oldval, char *newval); int internal_sp_called; void *tls_session; void *tls_credentials; TDSAUTHENTICATION *authentication; int option_value; }; int tds_init_write_buf(TDSSOCKET * tds); void tds_free_result_info(TDSRESULTINFO * info); void tds_free_socket(TDSSOCKET * tds); void tds_free_connection(TDSCONNECTION * connection); 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(TDSSOCKET *tds, TDSCURSOR *cursor); void tds_release_cursor(TDSSOCKET *tds, TDSCURSOR *cursor); void tds_free_bcp_column_data(BCPCOLDATA * coldata); 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); TDSRESULTINFO *tds_alloc_results(int num_cols); TDSCOMPUTEINFO **tds_alloc_compute_results(TDSSOCKET * tds, int num_cols, int by_cols); TDSCONTEXT *tds_alloc_context(void * parent); void tds_free_context(TDSCONTEXT * locale); TDSSOCKET *tds_alloc_socket(TDSCONTEXT * context, int bufsize); /* config.c */ int tds_default_port(int major, int minor); 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(TDSCONNECTION * connection, const char *server); void tds_parse_conf_section(const char *option, const char *value, void *param); TDSCONNECTION *tds_read_config_info(TDSSOCKET * tds, TDSLOGIN * login, TDSLOCALE * locale); void tds_fix_connection(TDSCONNECTION * connection); TDS_USMALLINT tds_config_verstr(const char *tdsver, TDSCONNECTION * connection); int tds_lookup_host(const char *servername, char *ip); int tds_set_interfaces_file_loc(const char *interfloc); extern const char STD_DATETIME_FMT[]; int tds_config_boolean(const char *value); TDSLOCALE *tds_get_locale(void); int tds_alloc_row(TDSRESULTINFO * res_info); int tds_alloc_compute_row(TDSCOMPUTEINFO * res_info); BCPCOLDATA * tds_alloc_bcp_column_data(int column_size); unsigned char *tds7_crypt_pass(const unsigned char *clear_pass, size_t len, unsigned char *crypt_pass); TDSDYNAMIC *tds_lookup_dynamic(TDSSOCKET * tds, const char *id); /*@observer@*/ const char *tds_prtype(int token); int tds_get_varint_size(TDSSOCKET * tds, int datatype); int tds_get_cardinal_type(int datatype, int usertype); /* iconv.c */ void tds_iconv_open(TDSSOCKET * tds, const char *charset); void tds_iconv_close(TDSSOCKET * tds); void tds_srv_charset_changed(TDSSOCKET * tds, const char *charset); void tds7_srv_charset_changed(TDSSOCKET * tds, int sql_collate, int lcid); int tds_iconv_alloc(TDSSOCKET * tds); void tds_iconv_free(TDSSOCKET * tds); TDSICONV *tds_iconv_from_collate(TDSSOCKET * tds, 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); struct hostent *tds_gethostbyaddr_r(const char *addr, int len, int type, struct hostent *result, char *buffer, int buflen, int *h_errnop); struct servent *tds_getservbyname_r(const char *name, const char *proto, struct servent *result, char *buffer, int buflen); #ifdef INADDR_NONE const char *tds_inet_ntoa_r(struct in_addr iaddr, char *ip, size_t len); #endif char *tds_get_homedir(void); /* mem.c */ TDSPARAMINFO *tds_alloc_param_result(TDSPARAMINFO * old_param); void tds_free_input_params(TDSDYNAMIC * dyn); void tds_free_dynamic(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(void); TDSDYNAMIC *tds_alloc_dynamic(TDSSOCKET * tds, const char *id); void tds_free_login(TDSLOGIN * login); TDSCONNECTION *tds_alloc_connection(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); /* login.c */ void tds_set_packet(TDSLOGIN * tds_login, int packet_size); void tds_set_port(TDSLOGIN * tds_login, int port); void tds_set_passwd(TDSLOGIN * tds_login, const char *password); void tds_set_bulk(TDSLOGIN * tds_login, TDS_TINYINT enabled); void tds_set_user(TDSLOGIN * tds_login, const char *username); void tds_set_app(TDSLOGIN * tds_login, const char *application); void tds_set_host(TDSLOGIN * tds_login, const char *hostname); void tds_set_library(TDSLOGIN * tds_login, const char *library); void tds_set_server(TDSLOGIN * tds_login, const char *server); void tds_set_client_charset(TDSLOGIN * tds_login, const char *charset); void tds_set_language(TDSLOGIN * tds_login, const char *language); void tds_set_database_name(TDSLOGIN * tds_login, const char *dbname); void tds_set_version(TDSLOGIN * tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver); void tds_set_capabilities(TDSLOGIN * tds_login, unsigned char *capabilities, int size); int tds_connect_and_login(TDSSOCKET * tds, TDSCONNECTION * connection); /* query.c */ int tds_submit_query(TDSSOCKET * tds, const char *query); int tds_submit_query_params(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params); int tds_submit_queryf(TDSSOCKET * tds, const char *queryf, ...); int tds_submit_prepare(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params); int tds_submit_execdirect(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params); int tds8_submit_prepexec(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params); int tds_submit_execute(TDSSOCKET * tds, TDSDYNAMIC * dyn); int tds_send_cancel(TDSSOCKET * tds); const char *tds_next_placeholder(const char *start); int tds_count_placeholders(const char *query); int tds_needs_unprepare(TDSSOCKET * tds, TDSDYNAMIC * dyn); int tds_submit_unprepare(TDSSOCKET * tds, TDSDYNAMIC * dyn); int tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params); int tds_submit_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size); int tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id, int idlen); int tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str, int len); const char *tds_skip_quoted(const char *s); int tds_cursor_declare(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send); int tds_cursor_setrows(TDSSOCKET * tds, TDSCURSOR * cursor, int *send); int tds_cursor_open(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send); int tds_cursor_fetch(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row); int tds_cursor_get_cursor_info(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_UINT * row_number, TDS_UINT * row_count); int tds_cursor_close(TDSSOCKET * tds, TDSCURSOR * cursor); int tds_cursor_dealloc(TDSSOCKET * tds, TDSCURSOR * cursor); int tds_cursor_update(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO * params); int tds_cursor_setname(TDSSOCKET * tds, TDSCURSOR * cursor); int tds_multiple_init(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type); int tds_multiple_done(TDSSOCKET *tds, TDSMULTIPLE *multiple); int tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO * params); int tds_multiple_execute(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC * dyn); /* token.c */ int tds_process_cancel(TDSSOCKET * tds); #ifdef WORDS_BIGENDIAN void tds_swap_datatype(int coltype, unsigned char *buf); #endif void tds_swap_numeric(TDS_NUMERIC *num); int tds_get_token_size(int marker); int tds_process_login_tokens(TDSSOCKET * tds); int 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); int tds_process_tokens(TDSSOCKET * tds, /*@out@*/ TDS_INT * result_type, /*@out@*/ int *done_flags, unsigned flag); /* data.c */ void tds_set_param_type(TDSSOCKET * tds, TDSCOLUMN * curcol, TDS_SERVER_TYPE type); void tds_set_column_type(TDSSOCKET * tds, TDSCOLUMN * curcol, int type); TDS_INT tds_data_get_info(TDSSOCKET *tds, TDSCOLUMN *col); /* tds_convert.c */ TDS_INT tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC * dr); int tds_get_conversion_type(int srctype, int colsize); extern const char tds_hex_digits[]; /* write.c */ int 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_SMALLINT tds_get_smallint(TDSSOCKET * tds); TDS_INT tds_get_int(TDSSOCKET * tds); TDS_INT8 tds_get_int8(TDSSOCKET * tds); int tds_get_string(TDSSOCKET * tds, int string_len, char *dest, size_t dest_size); int tds_get_char_data(TDSSOCKET * tds, char *dest, size_t wire_size, TDSCOLUMN * curcol); void *tds_get_n(TDSSOCKET * tds, /*@out@*/ /*@null@*/ void *dest, int n); int tds_get_size_by_type(int servertype); /* 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_set_parent(TDSSOCKET * tds, void *the_parent); int tds_swap_bytes(unsigned char *buf, int bytes); int tds_version(TDSSOCKET * tds_socket, char *pversion_string); unsigned int tds_gettime_ms(void); /* log.c */ void tdsdump_off(void); void tdsdump_on(void); int tdsdump_isopen(void); #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif int tdsdump_open(const char *filename); #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif 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 __attribute__ ((__format__ (__printf__, 3, 4))) #endif ; #define tdsdump_log if (TDS_UNLIKELY(tds_write_dump)) tdsdump_log extern int tds_write_dump; extern int tds_debug_flags; extern int tds_g_append_mode; /* net.c */ int tds_lastpacket(TDSSOCKET * tds); TDSERRNO tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int timeout, int *p_oserr); int tds_close_socket(TDSSOCKET * tds); int tds_read_packet(TDSSOCKET * tds); int tds_write_packet(TDSSOCKET * tds, unsigned char final); int tds7_get_instance_ports(FILE *output, const char *ip_addr); int tds7_get_instance_port(const char *ip_addr, const char *instance); int tds_ssl_init(TDSSOCKET *tds); void tds_ssl_deinit(TDSSOCKET *tds); const char *tds_prwsaerror(int erc); /* vstrbuild.c */ int tds_vstrbuild(char *buffer, int buflen, int *resultlen, 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]); #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 /* bulk.c */ /** bcp direction */ enum tds_bcp_directions { TDS_BCP_IN = 1, TDS_BCP_OUT = 2, TDS_BCP_QUERYOUT = 3 }; typedef struct tds_bcpinfo { const char *hint; void *parent; TDS_CHAR *tablename; TDS_CHAR *insert_stmt; TDS_INT direction; TDS_INT identity_insert_on; TDS_INT xfer_init; TDS_INT var_cols; TDS_INT bind_count; TDSRESULTINFO *bindinfo; } TDSBCPINFO; int tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); typedef int (*tds_bcp_get_col_data) (TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset); typedef void (*tds_bcp_null_error) (TDSBCPINFO *bulk, int index, int offset); int tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset); int tds_bcp_done(TDSSOCKET *tds, int *rows_copied); int tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); int tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); int tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size); int tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size); int tds_writetext_end(TDSSOCKET *tds); #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_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 TDS_MAJOR(x) ((x)->tds_version >> 8) #define TDS_MINOR(x) ((x)->tds_version & 0xff) #define IS_TDSDEAD(x) (((x) == NULL) || TDS_IS_SOCKET_INVALID((x)->s)) /** Check if product is Sybase (such as Adaptive Server Enterrprice). x should be a TDS_SOCKET*. */ #define TDS_IS_SYBASE(x) (!(x->product_version & 0x80000000u)) /** Check if product is Microsft SQL Server. x should be a TDS_SOCKET*. */ #define TDS_IS_MSSQL(x) ((x->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 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #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-0.91/include/tdsver.h100664 001750 000144 00000001766 11623073513 0011715/* 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 _tdsver_h_ #define _tdsver_h_ /* $Id: tdsver.h.in,v 1.6 2006/04/12 13:54:10 freddy77 Exp $ */ #define TDS_VERSION_NO "freetds v0.91" #endif freetds-0.91/include/tdsconvert.h100664 001750 000144 00000005413 11327421726 0012576/* 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_ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif #ifdef __cplusplus extern "C" { #if 0 } #endif #endif /* $Id: tdsconvert.h,v 1.26 2010/01/25 23:05:58 freddy77 Exp $ */ typedef union conv_result { TDS_TINYINT ti; TDS_SMALLINT si; TDS_INT i; TDS_INT8 bi; TDS_FLOAT f; TDS_REAL r; TDS_CHAR *c; TDS_MONEY m; TDS_MONEY4 m4; TDS_DATETIME dt; TDS_DATETIME4 dt4; TDS_NUMERIC n; TDS_CHAR *ib; TDS_UNIQUE u; /* sizef 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 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_ms; /**< milliseconds (0-999) */ }; unsigned char tds_willconvert(int srctype, int desttype); TDS_INT tds_get_null_type(int 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); #ifdef __cplusplus #if 0 { #endif } #endif #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif /* _tdsconvert_h_ */ freetds-0.91/include/tds_sysdep_private.h100664 001750 000144 00000014664 11506373026 0014324/* 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_ /* $Id: tds_sysdep_private.h,v 1.36 2010/12/28 14:37:10 freddy77 Exp $ */ #undef TDS_RCSID #if defined(__GNUC__) && __GNUC__ >= 3 #define TDS_RCSID(name, id) \ static const char rcsid_##name[] __attribute__ ((unused)) = id #else #define TDS_RCSID(name, id) \ static const char rcsid_##name[] = id; \ static const void *const no_unused_##name##_warn[] = { rcsid_##name, no_unused_##name##_warn } #endif #define TDS_ADDITIONAL_SPACE 0 #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 #define vsnprintf _vsnprintf /* 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 #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_WOULDBLOCK(e) ((e)==WSAEWOULDBLOCK) #define sock_errno WSAGetLastError() #define sock_strerror(n) tds_prwsaerror(n) #ifndef __MINGW32__ typedef DWORD pid_t; #endif #define strcasecmp stricmp #define strncasecmp strnicmp #define atoll _atoi64 #define vsnprintf _vsnprintf #define snprintf _snprintf #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) #define getpid() _getpid() #define strdup(s) _strdup(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 sock_strerror #define sock_strerror(n) strerror(n) #endif #ifndef TDSSOCK_EINTR #define TDSSOCK_EINTR EINTR #endif #ifndef TDSSOCK_EINPROGRESS #define TDSSOCK_EINPROGRESS EINPROGRESS #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 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_FORMAT #endif #ifdef __cplusplus #if 0 { #endif } #endif #endif /* _tds_sysdep_private_h_ */ freetds-0.91/include/tdsbytes.h100664 001750 000144 00000016326 11420406440 0012237/* 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_ /* $Id: tdsbytes.h,v 1.5 2010/07/17 20:05:52 freddy77 Exp $ */ #ifndef _tds_h_ #error tds.h must be included before tdsbytes.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) /* architecture dependent */ #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_USMALLINT*)(ptr))) # define TDS_GET_A4BE(ptr) (*((TDS_UINT*)(ptr))) # 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_USMALLINT*)(ptr)) = (val)) # define TDS_PUT_A4BE(ptr,val) (*((TDS_UINT*)(ptr)) = (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_USMALLINT*)(ptr))) # define TDS_GET_A4LE(ptr) (*((TDS_UINT*)(ptr))) # 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_USMALLINT*)(ptr)) = (val)) # define TDS_PUT_A4LE(ptr,val) (*((TDS_UINT*)(ptr)) = (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 */ #if defined(__i386__) || defined(__amd64__) || defined(__CRIS__) ||\ defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) || defined(__ppc64__) ||\ defined(__s390__) || defined(__s390x__) || defined(__m68k__) # 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__) # 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 #endif freetds-0.91/include/tdsiconv.h100664 001750 000144 00000010155 11422774163 0012235/* 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_ /* $Id: tdsiconv.h,v 1.40 2010/07/25 08:40:19 freddy77 Exp $ */ #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 */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif #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; struct tdsiconvinfo { TDS_ENCODING client_charset; TDS_ENCODING server_charset; #define TDS_ENCODING_INDIRECT 1 #define TDS_ENCODING_SWAPBYTE 2 #define TDS_ENCODING_MEMCPY 4 unsigned int flags; iconv_t to_wire; /* conversion from client charset to server's format */ iconv_t from_wire; /* conversion from server's format to client charset */ iconv_t to_wire2; /* conversion from client charset to server's format - indirect */ iconv_t from_wire2; /* conversion from server's format to client charset - indirect */ /* * 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_fread(iconv_t cd, FILE * stream, size_t field_len, size_t term_len, char *outbuf, size_t * outbytesleft); size_t tds_iconv(TDSSOCKET * tds, const 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); const char *tds_sybase_charset_name(const char *charset_name); TDSICONV *tds_iconv_get(TDSSOCKET * tds, const char *client_charset, const char *server_charset); #ifdef __cplusplus } #endif #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif /* _tds_iconv_h_ */ freetds-0.91/include/tdsodbc.h100664 001750 000144 00000045553 11466266342 0012043/* 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_ #include "tds.h" #if defined(UNIXODBC) || defined(TDS_NO_DM) #include #include #ifdef UNIXODBC #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 /* $Id: tdsodbc.h,v 1.127 2010/11/09 15:46:42 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #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; }; 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); #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) #else #define ODBC_RETURN(handle, rc) \ do { return (handle->errs.lastrc = (rc)); } while(0) #define ODBC_RETURN_(handle) \ do { return handle->errs.lastrc; } while(0) #endif /** 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); 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 */ 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 */ }; struct _henv { SQLSMALLINT htype; /* do not reorder this field */ struct _sql_errors errs; /* do not reorder this field */ 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 cursor_type; #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 */ struct _henv *env; TDSSOCKET *tds_socket; DSTR dsn; DSTR server; /* aka Instance */ #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; TDS_INT default_query_timeout; }; 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; */ }; 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 */ struct _hdbc *dbc; /** query to execute */ char *query; /** next in list */ struct _hstmt *next; /** previous in list */ struct _hstmt *prev; /* begin prepared query stuff */ char *prepared_query; 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; unsigned char cancel_sent; }; typedef struct _henv TDS_ENV; typedef struct _hdbc TDS_DBC; typedef struct _hstmt TDS_STMT; typedef struct _hchk TDS_CHK; #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, TDSCONNECTION * connection); #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) #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, TDSCONNECTION * connection, TDS_PARSED_PARAM *parsed_params); int odbc_get_dsn_info(TDS_ERRS *errs, const char *DSN, TDSCONNECTION * connection); #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); int odbc_set_stmt_prepared_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); SQLSMALLINT odbc_server_to_sql_type(int col_type, int col_size); int odbc_sql_to_c_type_default(int sql_type); int odbc_sql_to_server_type(TDSSOCKET * tds, int sql_type); int odbc_c_to_server_type(int c_type); void odbc_set_sql_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver); SQLINTEGER odbc_sql_to_displaysize(int sqltype, TDSCOLUMN *col); int odbc_get_string_size(int size, 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, 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, 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, char *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); /* * 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); /* * sqlwchar.c */ #if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T size_t sqlwcslen(const SQLWCHAR * s); #else #define sqlwcslen wcslen #endif #if SIZEOF_SQLWCHAR == 2 # if WORDS_BIGENDIAN # define ODBC_WIDE_NAME "UCS-2BE" # else # define ODBC_WIDE_NAME "UCS-2LE" # endif #elif SIZEOF_SQLWCHAR == 4 # if WORDS_BIGENDIAN # define ODBC_WIDE_NAME "UCS-4BE" # else # define ODBC_WIDE_NAME "UCS-4LE" # endif #else #error SIZEOF_SQLWCHAR not supported !! #endif #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-0.91/include/tdssrv.h100664 001750 000144 00000005605 10740431031 0011717/* 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 _tdssrv_h_ #define _tdssrv_h_ #endif #ifdef __cplusplus extern "C" { #endif #if 0 } #endif static const char rcsid_tdssrv_h[] = "$Id: tdssrv.h,v 1.10 2008/01/07 14:07:21 freddy77 Exp $"; static const void *const no_unused_tdssrv_h_warn[] = { rcsid_tdssrv_h, no_unused_tdssrv_h_warn }; /* 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); void 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 tds8_send_prelogin(TDSSOCKET * tds); #if 0 { #endif #ifdef __cplusplus } #endif freetds-0.91/include/tdsstring.h100664 001750 000144 00000004520 11327421727 0012423/* 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_ /* $Id: tdsstring.h,v 1.21 2010/01/25 23:05:59 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif extern const char tds_str_empty[1]; /* TODO do some function and use inline if available */ /** \addtogroup dstring * @{ */ #if ENABLE_EXTRA_CHECKS void tds_dstr_init(DSTR * s); int tds_dstr_isempty(DSTR * s); char *tds_dstr_buf(DSTR * s); size_t tds_dstr_len(DSTR * s); #else /** init a string with empty */ #define tds_dstr_init(s) \ do { DSTR *_tds_s = (s); _tds_s->dstr_size = 0; _tds_s->dstr_s = (char*) tds_str_empty; } while(0) /** test if string is empty */ #define tds_dstr_isempty(s) \ ((s)->dstr_size == 0) #define tds_dstr_buf(s) \ ((s)->dstr_s) #define tds_dstr_len(s) \ ((s)->dstr_size) #endif #define tds_dstr_cstr(s) \ ((const char* ) tds_dstr_buf(s)) void tds_dstr_zero(DSTR * s); void tds_dstr_free(DSTR * s); DSTR* tds_dstr_dup(DSTR * s, const DSTR * src); DSTR* tds_dstr_copy(DSTR * s, const char *src); DSTR* tds_dstr_copyn(DSTR * s, const char *src, size_t length); DSTR* tds_dstr_set(DSTR * s, char *src); /** limit length of string, MUST be <= current length */ DSTR* tds_dstr_setlen(DSTR *s, size_t length); /** allocate space for length char */ DSTR* tds_dstr_alloc(DSTR *s, size_t length); /** @} */ #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif #endif /* _tdsstring_h_ */ freetds-0.91/include/tdsthread.h100664 001750 000144 00000005070 11444375610 0012364/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * * Copyright (C) 2005 Liam Widdowson * 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 TDSTHREAD_H #define TDSTHREAD_H 1 /* $Id: tdsthread.h,v 1.9 2010/09/16 11:12:08 freddy77 Exp $ */ #undef TDS_HAVE_MUTEX #if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX) #include #define TDS_MUTEX_DEFINE(name) pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER #define TDS_MUTEX_LOCK(mtx) pthread_mutex_lock(mtx) #define TDS_MUTEX_UNLOCK(mtx) pthread_mutex_unlock(mtx) #define TDS_MUTEX_DECLARE(name) pthread_mutex_t name #define TDS_MUTEX_INIT(mtx) pthread_mutex_init(mtx, NULL) #define TDS_MUTEX_FREE(mtx) pthread_mutex_destroy(mtx) #define TDS_HAVE_MUTEX 1 #elif defined(_WIN32) struct ptw32_mcs_node_t_; typedef struct tds_win_mutex_t_ { struct ptw32_mcs_node_t_ *lock; LONG done; CRITICAL_SECTION crit; } tds_win_mutex_t; void tds_win_mutex_lock(tds_win_mutex_t *mutex); static inline int tds_win_mutex_init(tds_win_mutex_t *mtx) { mtx->lock = NULL; mtx->done = 0; return 0; } /* void tds_win_mutex_unlock(tds_win_mutex_t *mutex); */ #define TDS_MUTEX_DEFINE(name) tds_win_mutex_t name = { NULL, 0 } #define TDS_MUTEX_LOCK(mtx) \ do { if ((mtx)->done) EnterCriticalSection(&(mtx)->crit); else tds_win_mutex_lock(mtx); } while(0) #define TDS_MUTEX_UNLOCK(mtx) LeaveCriticalSection(&(mtx)->crit) #define TDS_MUTEX_DECLARE(name) tds_win_mutex_t name #define TDS_MUTEX_INIT(mtx) tds_win_mutex_init(mtx) #define TDS_MUTEX_FREE(mtx) do { if ((mtx)->done) { DeleteCriticalSection(&(mtx)->crit); (mtx)->done = 0; } } while(0) #define TDS_HAVE_MUTEX 1 #else #define TDS_MUTEX_DEFINE(name) int name #define TDS_MUTEX_LOCK(mtx) #define TDS_MUTEX_UNLOCK(mtx) #define TDS_MUTEX_DECLARE(name) int name #define TDS_MUTEX_INIT(mtx) #define TDS_MUTEX_FREE(mtx) #endif #endif freetds-0.91/include/tds_configs.h100664 001750 000144 00000002665 10263433735 0012714/* 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 "freetds_sysconfdir.h" #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-0.91/include/Makefile.am100664 001750 000144 00000001301 11131015130 0012233AUTOMAKE_OPTIONS = 1.5.3 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 \ fakepoll.h \ md4.h md5.h des.h hmac_md5.h \ replacements.h \ replacements/readpassphrase.h \ tds.h tdsver.h tdsconvert.h \ tds_sysdep_private.h \ tdsbytes.h \ tdsiconv.h \ tdsodbc.h \ tdssrv.h \ tdsstring.h \ tdsthread.h \ tds_configs.h DISTCLEANFILES = tds_sysdep_public.h freetds_sysconfdir.h freetds_sysconfdir.h: Makefile echo '#define FREETDS_SYSCONFDIR "$(sysconfdir)"' >$@ all-am: freetds_sysconfdir.h freetds-0.91/include/Makefile.in100664 001750 000144 00000043305 11623070617 0012277# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = $(include_HEADERS) $(noinst_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/config.h.in $(srcdir)/tds_sysdep_public.h.in \ $(srcdir)/tdsver.h.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = tdsver.h tds_sysdep_public.h CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = 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__installdirs = "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)" HEADERS = $(include_HEADERS) $(nodist_include_HEADERS) \ $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 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 \ fakepoll.h \ md4.h md5.h des.h hmac_md5.h \ replacements.h \ replacements/readpassphrase.h \ tds.h tdsver.h tdsconvert.h \ tds_sysdep_private.h \ tdsbytes.h \ tdsiconv.h \ tdsodbc.h \ tdssrv.h \ tdsstring.h \ tdsthread.h \ tds_configs.h DISTCLEANFILES = tds_sysdep_public.h freetds_sysconfdir.h all: config.h $(MAKE) $(AM_MAKEFLAGS) 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/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu include/Makefile .PRECIOUS: 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 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi 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 tdsver.h: $(top_builddir)/config.status $(srcdir)/tdsver.h.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 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) test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ 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|^.*/||'`; \ test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(includedir)" && rm -f $$files install-nodist_includeHEADERS: $(nodist_include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ 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|^.*/||'`; \ test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(includedir)" && rm -f $$files ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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) config.h installdirs: for dir in "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)"; 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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-hdr distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-includeHEADERS install-nodist_includeHEADERS 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: uninstall-includeHEADERS uninstall-nodist_includeHEADERS .MAKE: all install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool ctags 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 maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-includeHEADERS \ uninstall-nodist_includeHEADERS freetds_sysconfdir.h: Makefile echo '#define FREETDS_SYSCONFDIR "$(sysconfdir)"' >$@ all-am: freetds_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-0.91/include/config.h.in100664 001750 000144 00000041132 11623070616 0012250/* 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 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 ODBC wide string support */ #undef ENABLE_ODBC_WIDE /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* 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 `atoll' function. */ #undef HAVE_ATOLL /* 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 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 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 `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 to 1 if you have the `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 `getnameinfo' function. */ #undef HAVE_GETNAMEINFO /* 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 to 1 if you have GNU tls. */ #undef HAVE_GNUTLS /* Define to 1 if you have the `gnutls_record_disable_padding' function. */ #undef HAVE_GNUTLS_RECORD_DISABLE_PADDING /* Define if you have the iconv() function. */ #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 a 64-bit integral type. */ #undef HAVE_INT64 /* 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 `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 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 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 you have the `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO /* Define to 1 if you have the header file. */ #undef HAVE_ODBCSS_H /* 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 `putenv' function. */ #undef HAVE_PUTENV /* 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 the header file. */ #undef HAVE_READPASSPHRASE_H /* 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 `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 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 --enable-sspi and SSPI detected */ #undef HAVE_SSPI /* 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 `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_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 `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 `_fseeki64' function. */ #undef HAVE__FSEEKI64 /* Define to 1 if you have the `_ftelli64' function. */ #undef HAVE__FTELLI64 /* Define to 1 if you have the `_lseeki64' function. */ #undef HAVE__LSEEKI64 /* Define to 1 if you have the `_telli64' function. */ #undef HAVE__TELLI64 /* 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 in which 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 your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* 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 /* 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 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 to format string used for 64bit integers */ #undef TDS_I64_FORMAT /* 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 /* 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 /* type to use in place of socklen_t if not defined */ #undef socklen_t freetds-0.91/include/tds_sysdep_public.h.in100664 001750 000144 00000005355 11437410512 0014525/* 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_sysdep_public_h_ #define _tds_sysdep_public_h_ /* $Id: tds_sysdep_public.h.in,v 1.14 2010/09/01 08:39:38 freddy77 Exp $ */ #ifdef __cplusplus extern "C" { #endif /* ** This is where platform-specific changes need to be made. */ #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) #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 #ifdef __cplusplus } #endif #endif /* _tds_sysdep_public_h_ */ freetds-0.91/include/tdsver.h.in100664 001750 000144 00000001775 10417203202 0012310/* 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 _tdsver_h_ #define _tdsver_h_ /* $Id: tdsver.h.in,v 1.6 2006/04/12 13:54:10 freddy77 Exp $ */ #define TDS_VERSION_NO "@PACKAGE@ v@VERSION@" #endif freetds-0.91/doc/doc/freetds-0.91/userguide/index.html100664 001750 000144 00000057233 11623070656 0016143 FreeTDS User Guide

FreeTDS User Guide

A Guide to Installing, Configuring, and Running FreeTDS

Brian Bruns

James K. Lowden

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.


Table of Contents
About this User Guide
1. What is FreeTDS?
Background: The TDS Protocol and related APIs
History of TDS Versions
History of FreeTDS
Current Projects, Language Bindings, and Alternatives
Current Projects
Status
Languages besides C and Java
Alternatives
2. Build FreeTDS
The GNU World
What to build: Packages, Tarballs, and the CVS repository
How to build: Configure and make
For Experts
For Everyone Else
OS-specific Issues
Win32 and Win64
VMS®
OS X®
AIX®
GNU/Linux distributions that use RPMs
3. Install FreeTDS
The local environment
Choosing a TDS protocol version
servername Lookup
The freetds.conf file
What it does
Where it goes
What it looks like
The locales.conf file
What it does
Where it goes
What it looks like
Environment variables
What they're for
Setting environment variables
Checking your work
Port override syntax
Confirm the installation
tsql
Unit Tests
4. Preparing ODBC
Background and Terminology
Connection attributes
DSN-less configuration
ODBC-only configuration
ODBC-combined configuration
Troubleshooting ODBC connections
With iODBC
With unixODBC
5. Advanced Configurations
Big Endian Clients with Buggy SQL Servers
Localization and TDS 7.0
Microsoft Server Note
Domain Logins
Implementation details
Kerberos Support
Threading in unixODBC
Appending Dump Files
TDS Connection Pooling
stunnel HOWTO
6. Use FreeTDS
FreeTDS Utilities
7. How to get what works with it working
SQSH
Perl
DBD::Sybase
DBD::ODBC
Sybperl
Building and using the Perl modules
PHP
DB-Library
CT-Library
ODBC
SybSQL
Python
Qt
ODBC on Unix
ODBC and 64-bit
sizeof(SQLWCHAR)
Default charset
8. Troubleshooting
Known Issues
Porting Issues
Text Fields
Endianism
Datetime and Money
Microsoft's "Integrated Security"
Is the server there?
Start with ping
Test with telnet
Test with tsql
Logging
Environment Variables that Control Logging
freetds.conf variables that Control Logging
Logging in ODBC land
"Page contains no data"
Slow connection or data retrieval
9. Getting Help
Reconfirm the installation
Isolate the cause
Try a different client
Check permissions
The Mailing List
The Archive
Ask the list
What to include when asking for help
Waddya got?
Attach a logfile
Show your work
10. Helping
Pick a weak spot and fix it.
Send a patch
Correct this User Guide
Document an API
Be the Webmaster
Light another's taper
Ambitious ideas
libtds2
libstddb
Server code
Advocacy
11. Programming
TDS protocol reference
API Reference Manual
DB-Library API Implementation Summary
ct-lib API Implementation Summary
ODBC API Implementation Summary
DB-Library for the Tenderfoot
Header files
Prolog
Initialize
Connect to the server
Send a query
Fetch Results
Messages and Errors
Last Remarks
12. Acknowledgments
Codesmyths
Contributors
A. On Linkers
What is a C function?
What is a C library?
Static libraries
Dynamic libraries
Checking if a Library Provides a Function
How Dost Thy Linker Link?
Static Linker
Dynamic Linker
Keep in Mind
B. The interfaces File
Where it came from
Where it goes
What it does
What it looks like
C. About Unicode, UCS-2, and UTF-8
ASCII: What everyone knows
The ASCII Compact
ISO 8859: What everyone would like to forget
Unicode: East meets West
Unicode's Pluses and Minuses
Unicode Transformation Format: UTF-8
Unicode and FreeTDS
For further information
D. GNU Free Documentation License
PREAMBLE
APPLICABILITY AND DEFINITIONS
VERBATIM COPYING
COPYING IN QUANTITY
MODIFICATIONS
COMBINING DOCUMENTS
COLLECTIONS OF DOCUMENTS
AGGREGATION WITH INDEPENDENT WORKS
TRANSLATION
TERMINATION
FUTURE REVISIONS OF THIS LICENSE
How to use this License for your documents
List of Examples
2-1. Missing include file in Windows
3-1. A freetds.conf file example
3-2. Show compile-time settings with tsql
3-3. Failure to find servername in freetds.conf
3-4. Failure to resolve hostname for servername
3-5. Failing to connect with tsql
3-6. Getting instance information with tsql
3-7. Using the wrong protocol for the server
3-8. Login failure
3-9. Connect with tsql using a hostname and port number
4-1. Sample files for a DSN-less configuration
4-2. Connecting with a DSN-less configuration
4-3. Connecting with a DSN-less configuration that does not use freetds.conf
4-4. Sample ODBC-only odbc.ini file
4-5. Sample ODBC-combined odbc.ini file
4-6. Sample ODBC-combined freetds.conf file
4-7. Compile odbctest without a driver manager.
4-8. Use osql to test the ODBC setup.
5-1. Emulate Little Endian freetds.conf setting
5-2. Configuring for GREEK freetds.conf setting
5-3. Configuring for UTF-8 freetds.conf setting
5-4. Logging in with a domain login
5-5. Sample odbcinst.ini for threading model
5-6. Sample odbc.ini for threading model
5-7. Turning on Dump File Append mode in freetds.conf
5-8. pool.conf
5-9. Unencrypted entry in freetds.conf
5-10. Encrypted entry in freetds.conf
7-1. The SQSH Makefile
7-2. Building DBD::Sybase
7-3. Connect to a server with DBD::Sybase
7-4. Building DBD::ODBC
7-5. Connect to a server with DBD::ODBC
7-6. PHP and DB-Library for "Sybase"
8-1. Finding the server's host
8-2. Finding the server
8-3. Connecting to the server, bypassing freetds.conf
8-4. Connecting to the server using freetds.conf
11-1. Building the Sample Code
11-2. Sample Code: DB-Library header files
11-3. Sample Code: DB-Library prolog
11-4. Sample Code: DB-Library Initialize
11-5. Sample Code: DB-Library Connect to the server
11-6. Sample Code: DB-Library Send a query
11-7. Sample Code: DB-Library Fetch Results
11-8. Sample Code: DB-Library Error and Message handlers
A-1. Missing library name
A-2. Library not found
B-1. An interfaces file example
C-1. "HELLO" in UCS-2 and UTF-8
freetds-0.91/doc/doc/freetds-0.91/userguide/index.htm100664 001750 000144 00000057233 11623070656 0015767 FreeTDS User Guide

FreeTDS User Guide

A Guide to Installing, Configuring, and Running FreeTDS

Brian Bruns

James K. Lowden

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.


Table of Contents
About this User Guide
1. What is FreeTDS?
Background: The TDS Protocol and related APIs
History of TDS Versions
History of FreeTDS
Current Projects, Language Bindings, and Alternatives
Current Projects
Status
Languages besides C and Java
Alternatives
2. Build FreeTDS
The GNU World
What to build: Packages, Tarballs, and the CVS repository
How to build: Configure and make
For Experts
For Everyone Else
OS-specific Issues
Win32 and Win64
VMS®
OS X®
AIX®
GNU/Linux distributions that use RPMs
3. Install FreeTDS
The local environment
Choosing a TDS protocol version
servername Lookup
The freetds.conf file
What it does
Where it goes
What it looks like
The locales.conf file
What it does
Where it goes
What it looks like
Environment variables
What they're for
Setting environment variables
Checking your work
Port override syntax
Confirm the installation
tsql
Unit Tests
4. Preparing ODBC
Background and Terminology
Connection attributes
DSN-less configuration
ODBC-only configuration
ODBC-combined configuration
Troubleshooting ODBC connections
With iODBC
With unixODBC
5. Advanced Configurations
Big Endian Clients with Buggy SQL Servers
Localization and TDS 7.0
Microsoft Server Note
Domain Logins
Implementation details
Kerberos Support
Threading in unixODBC
Appending Dump Files
TDS Connection Pooling
stunnel HOWTO
6. Use FreeTDS
FreeTDS Utilities
7. How to get what works with it working
SQSH
Perl
DBD::Sybase
DBD::ODBC
Sybperl
Building and using the Perl modules
PHP
DB-Library
CT-Library
ODBC
SybSQL
Python
Qt
ODBC on Unix
ODBC and 64-bit
sizeof(SQLWCHAR)
Default charset
8. Troubleshooting
Known Issues
Porting Issues
Text Fields
Endianism
Datetime and Money
Microsoft's "Integrated Security"
Is the server there?
Start with ping
Test with telnet
Test with tsql
Logging
Environment Variables that Control Logging
freetds.conf variables that Control Logging
Logging in ODBC land
"Page contains no data"
Slow connection or data retrieval
9. Getting Help
Reconfirm the installation
Isolate the cause
Try a different client
Check permissions
The Mailing List
The Archive
Ask the list
What to include when asking for help
Waddya got?
Attach a logfile
Show your work
10. Helping
Pick a weak spot and fix it.
Send a patch
Correct this User Guide
Document an API
Be the Webmaster
Light another's taper
Ambitious ideas
libtds2
libstddb
Server code
Advocacy
11. Programming
TDS protocol reference
API Reference Manual
DB-Library API Implementation Summary
ct-lib API Implementation Summary
ODBC API Implementation Summary
DB-Library for the Tenderfoot
Header files
Prolog
Initialize
Connect to the server
Send a query
Fetch Results
Messages and Errors
Last Remarks
12. Acknowledgments
Codesmyths
Contributors
A. On Linkers
What is a C function?
What is a C library?
Static libraries
Dynamic libraries
Checking if a Library Provides a Function
How Dost Thy Linker Link?
Static Linker
Dynamic Linker
Keep in Mind
B. The interfaces File
Where it came from
Where it goes
What it does
What it looks like
C. About Unicode, UCS-2, and UTF-8
ASCII: What everyone knows
The ASCII Compact
ISO 8859: What everyone would like to forget
Unicode: East meets West
Unicode's Pluses and Minuses
Unicode Transformation Format: UTF-8
Unicode and FreeTDS
For further information
D. GNU Free Documentation License
PREAMBLE
APPLICABILITY AND DEFINITIONS
VERBATIM COPYING
COPYING IN QUANTITY
MODIFICATIONS
COMBINING DOCUMENTS
COLLECTIONS OF DOCUMENTS
AGGREGATION WITH INDEPENDENT WORKS
TRANSLATION
TERMINATION
FUTURE REVISIONS OF THIS LICENSE
How to use this License for your documents
List of Examples
2-1. Missing include file in Windows
3-1. A freetds.conf file example
3-2. Show compile-time settings with tsql
3-3. Failure to find servername in freetds.conf
3-4. Failure to resolve hostname for servername
3-5. Failing to connect with tsql
3-6. Getting instance information with tsql
3-7. Using the wrong protocol for the server
3-8. Login failure
3-9. Connect with tsql using a hostname and port number
4-1. Sample files for a DSN-less configuration
4-2. Connecting with a DSN-less configuration
4-3. Connecting with a DSN-less configuration that does not use freetds.conf
4-4. Sample ODBC-only odbc.ini file
4-5. Sample ODBC-combined odbc.ini file
4-6. Sample ODBC-combined freetds.conf file
4-7. Compile odbctest without a driver manager.
4-8. Use osql to test the ODBC setup.
5-1. Emulate Little Endian freetds.conf setting
5-2. Configuring for GREEK freetds.conf setting
5-3. Configuring for UTF-8 freetds.conf setting
5-4. Logging in with a domain login
5-5. Sample odbcinst.ini for threading model
5-6. Sample odbc.ini for threading model
5-7. Turning on Dump File Append mode in freetds.conf
5-8. pool.conf
5-9. Unencrypted entry in freetds.conf
5-10. Encrypted entry in freetds.conf
7-1. The SQSH Makefile
7-2. Building DBD::Sybase
7-3. Connect to a server with DBD::Sybase
7-4. Building DBD::ODBC
7-5. Connect to a server with DBD::ODBC
7-6. PHP and DB-Library for "Sybase"
8-1. Finding the server's host
8-2. Finding the server
8-3. Connecting to the server, bypassing freetds.conf
8-4. Connecting to the server using freetds.conf
11-1. Building the Sample Code
11-2. Sample Code: DB-Library header files
11-3. Sample Code: DB-Library prolog
11-4. Sample Code: DB-Library Initialize
11-5. Sample Code: DB-Library Connect to the server
11-6. Sample Code: DB-Library Send a query
11-7. Sample Code: DB-Library Fetch Results
11-8. Sample Code: DB-Library Error and Message handlers
A-1. Missing library name
A-2. Library not found
B-1. An interfaces file example
C-1. "HELLO" in UCS-2 and UTF-8
freetds-0.91/doc/doc/freetds-0.91/userguide/about.htm100664 001750 000144 00000012204 11623070653 0015754 About this User Guide

About this User Guide

This User Guide describes FreeTDS 0.91. 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 [1] 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 CVS tree. 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

Notes

[1]

The version you're reading is:

$Revision: 1.139.2.1 $
$Date: 2011/05/21 18:31:37 $
CVS control number $Id: userguide.sgml,v 1.139.2.1 2011/05/21 18:31:37 jklowden Exp $.

freetds-0.91/doc/doc/freetds-0.91/userguide/what.htm100664 001750 000144 00000017550 11623070653 0015616 What is FreeTDS?

Chapter 1. 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 DB-Library and CT-Library

  • Microsoft's DB-Library (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 TDS Protocol and related APIs

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, DB-Library, and CT-Library 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 DB-Library.

DB-Library 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 DB-Library API and added ODBC. (Microsoft has since added other APIs, too. It no longer supports its own DB-Library implementation.) At about the same time, Sybase introduced a more powerful "successor" to DB-Library, called CT-Library, and called the pair OpenClient.

CT-Library, DB-Library, 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/tdshistory.htm100664 001750 000144 00000012246 11623070653 0017064 History of TDS Versions

History of 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 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 [1]

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.

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/freetdshistory.htm100664 001750 000144 00000010710 11623070653 0017720 History of FreeTDS

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 CT-Library API. The older DB-Library API was missing.

Brian Bruns, a Sybase DBA and originator of the FreeTDS project, had some DB-Library programs he wanted to run under Linux, and thus began the FreeTDS project. The original work focused on DB-Library and version 5.0 of the protocol, but quickly expanded to include a CT-Library 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 CT-Library. Your humble author 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/projects.htm100664 001750 000144 00000026416 11623070653 0016505 Current Projects, Language Bindings, and Alternatives

Current Projects, Language Bindings, and Alternatives

Current Projects

FreeTDS consists of two projects. The FreeTDS C libraries and FreeTDS/ JDBC.

  • The FreeTDS C libraries support three separate APIs: DB-Library, CT-Library, 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.

  • 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.

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 DB-Library and CT-Library 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.0 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.

Note

For Microsoft servers, FreeTDS now offers the best DB-Library for any OS on the planet (including Windows!) thanks not only to the hard work of its contributors, but also to Microsoft's[1] strategy. It is the only Win64 implementation of DB-Library, 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 DB-Library API, FreeTDS includes a full implementation of DB-Library'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 and Java

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 DB-Library or CT-Library 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 (DB-Library) and sybase-ct (CT-Library) APIs.

Alternatives

Should FreeTDS not suit your needs, some alternatives

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.

Notes

[1]

Microsoft ceased enhancing DB-Library in 2001, advising customers to "avoid using DB-Library". For Microsoft's unmaintained product, that's good advice. But if the DB-Library specification meets your needs, FreeTDS permits you to keep using it with little loss (and some gain) of functionality.

freetds-0.91/doc/doc/freetds-0.91/userguide/build.htm100664 001750 000144 00000011347 11623070653 0015750 Build FreeTDS

Chapter 2. Build FreeTDS

 

If you build it they will come.

The GNU World

FreeTDS uses GNU Autoconf, Automake, and libtool[1] 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!

Notes

[1]

Versions used for this release

  • autoconf (GNU Autoconf) 2.65

  • automake (GNU automake) 1.11.1

  • ltmain.sh (GNU libtool) 2.2.6b

freetds-0.91/doc/doc/freetds-0.91/userguide/packages.htm100664 001750 000144 00000010672 11623070653 0016427 What to build: Packages, Tarballs, and the CVS repository

What to build: Packages, Tarballs, and the CVS repository

The latest FreeTDS package is always available from iBiblio and its mirrors.

Code changes by the developers are immediately available in the CVS repository. If you've run into a problem, you may want to check out from CVS to see if it's fixed there.

No password is needed to obtain the current CVS copy of FreeTDS; you need only have a CVS client installed on your machine. Then:

	$ cvs -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds login
	$ cvs -z3 -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds checkout -P freetds
	Password: 
	$ 

For those behind firewalls or otherwise unable to access CVS, nightly snapshots of CVS are rolled up into tarballs for your convenience. They can be downloaded from ibiblio.org. Tarballs are generated around 3am EST (GMT-5).

In general, the CVS HEAD revision (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 CVS HEAD.

Tip

As with any project of this sort, if you want to use the CVS HEAD revision, it's a good idea to join the mailing list.

freetds-0.91/doc/doc/freetds-0.91/userguide/config.htm100664 001750 000144 00000042250 11623070653 0016113 How to build: Configure and make

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.

Note

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 CVS is described in the file INSTALL.CVS.

For Everyone Else

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.

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.

configure options

Directories and TDS version

--prefix=PREFIX

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.

--sysconfdir=DIR

read-only single-machine data in DIR

The default is PREFIX/etc (PREFIX being the value of --prefix=PREFIX, above) if this argument is not passed to configure.

--with-libiconv-prefix=DIR

Specifies the location of the iconv library to use. configure will search for libiconv in the usual places; use --with-libiconv-prefix if it's unsuccessful (assuming you want to use iconv, of course). Overridden by --disable-libiconv, below.

--with-tdsver=VER

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 and 7.2.

The default is 5.0 if this argument is not passed to configure.

ODBC Driver Managers

--with-iodbc=DIR , --with-unixodbc=DIR

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.)

--with-odbc-nodm=DIR

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

--disable-odbc

Do not attempt to detect ODBC, and do not build the ODBC driver. In case you don't care about ODBC.

--disable-apps

Do not attempt to build applications like tsql.

--disable-server

Do not attempt to build server stuff.

--disable-pool

Do not attempt to build pool stuff.

--disable-libiconv

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.

--disable-threadsafe

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.

--disable-debug

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.

Things you can turn on

--enable-msdblib

Enable Microsoft behavior in the DB-Library 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-sybase-compat

Enable close compatibility with Sybase's ABI, at the expense of other features. Currently, this enables the generation of a dbopen() entry point in DB-Library, which may clash with the DBM function with the same name. Absolutely not required for use with other free software.

--enable-krb5

Enable Kerberos support. With Kerberos you can connect to server using your stored Kerberos ticket. Obviously requires Kerberos be configured on the machine.

--enable-sspi

Enable SSPI support. SSPI is a Micrsoft library that allows you to use your current logged-in account for authentication. With this option enabled, FreeTDS supports "trusted logins" for Win32/64, just as Microsoft's own implementations do.

--enable-extra-checks

Intended for debugging purposes, enables certain internal consistency checks against problems like memory corruption and buffer exhaustion.

--enable-developing

Enable some code still in development. Should be used only by a developer or a brave user :)

SSL support

--with-gnutls

Enable SSL using GnuTLS. Use version 1.2.3 or newer.

--with-openssl=DIR

Enable SSL using OpenSSL. Unlike FreeTDS, OpenSSL does not use the LGPL. Please read the OpenSSL license before distributing binaries compiled with this option.

Make

Now you're ready to build. Follow these easy steps.

  1. Download the tarball and unpack it.

    Alternatively, get the latest build from CVS [1] .

  2. Change to the freetds directory.

  3. run ./configure with any options you need.

  4. make; make install; make clean

You normally need to be root to make install, unless you used the --prefix option during configuration to install into your own directory.

With any luck, you've built and installed the FreeTDS libraries.

TipTwo 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.

Notes

[1]

CVS users will need the GNU autotools: Autoconf, Automake, and libtool.

freetds-0.91/doc/doc/freetds-0.91/userguide/osissues.htm100664 001750 000144 00000024203 11623070653 0016521 OS-specific Issues

OS-specific Issues

Win32 and Win64

Building for Windows using Microsoft's compiler is supported via the NMakefile included in the distribution. Set up the command-line build environment per Microsoft's instructions, and run e.g.

	$ nmake -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=debug
The assumed availability of standard .h files is captured in win32/config.h. If you encounter difficulties related to missing include files, examine the indicated file for an include guard, and compare it to win32/config.h. For example, you get an error like this:

Example 2-1. Missing include file in Windows

…
asprintf.c
include\tds_sysdep_private.h(239) : fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory
src/replacements/asprintf.c includes include/tds_sysdep_private.h, where you find
238  #ifdef HAVE_INTTYPES_H
239  #include <inttypes.h>
240  #endif
and, sure enough, asprintf.c earlier includes win32/config.h, which says
91  /* Define to 1 if you have the <inttypes.h> header file. */
92  #define HAVE_INTTYPES_H 1
Which shouldn't be defined unless inttypes.h exists on your system.

Let's review: config.h has preprocessor definitions that (try to) describe the build environment to the compiler. In this example, it got one wrong, causing the compiler to look for a file that isn't present, creating the error. The solution is not to change the FreeTDS source code, but merely to comment out line 92 in config.h.

Note

Perhaps you're shaking your head at such an "old school" approach. Over the years, Microsoft's proprietary project-configuration files have proved difficult to support. Every version is different, and there are a great many versions in use "in the wild" at any one time. As the project changes, it becomes impossible to maintain these kinds of files.

For Windows applications that use FreeTDS the hard-won wisdom is just use the NMakefile, please, thanks! If you like a visual environment and visual debugging, no problem: Microsoft's tools support "Makefile projects". The author has direct knowledge of developers for whom that arrangement works quite well.

Other ways to build under Windows®

  • Visual Studio. Project files are included in the win32 directory. See above note for why these might be out of date.

  • Dev-C++

  • MingW

  • gcc under cygwin.

  • The Borland Builder 6.0 compiler is also reported to work, but requires some tweaking of the #include statements. We would apply any patches that make this work cleanly.

From the Department of Double Emulation: FreeTDS builds as a .dll under WINE and as a .a under Interix. See the mailing list archives (second half of 2003) for details.

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 in the source distribution.

OS X®

As of this writing ($Date: 2011/05/21 18:31:37 $), the regular distribution compiles on OS X.

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 --disable-shared configure option.

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.63RC9.tar.gz

freetds-0.91/doc/doc/freetds-0.91/userguide/install.htm100664 001750 000144 00000013133 11623070653 0016312 Install FreeTDS

Chapter 3. Install FreeTDS

 

If you install it they will stay?

NoteConfusing 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 freetds.conf. 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/choosingtdsprotocol.htm100664 001750 000144 00000015170 11623070653 0020755 Choosing a TDS protocol version

Choosing a 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.

Table 3-1. Versions of the TDS Protocol, by Product

ProductTDS VersionComment
Sybase before System 10, Microsoft SQL Server 6.x4.2Still works with all products, subject to its limitations.
Sybase System 10 and above5.0Still the most current protocol used by Sybase.
Sybase System SQL Anywhere5.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.07.0Includes 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 20007.1Include support for bigint (64 bit integers), variant and collation on all fields. Collation is not widely used.
Microsoft SQL Server 20057.2Includes support for varchar(max), varbinary(max), xml datatypes and MARS[a].
Microsoft SQL Server 20087.2 (unchanged) 
Notes:
a. Multiple Active Result Sets. FreeTDS does not support MARS.

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! [1]

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.

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/name.lookup.htm100664 001750 000144 00000010224 11623070653 0017072 servername Lookup

servername Lookup

FreeTDS converts the servername to an IP address by following the steps below, stopping when it succeeds.

Name lookup sequence [1]

  1. Find servername in freetds.conf. If a section with that name exists, use the hostname, port, and TDS version specified therein.

  2. Attempt to convert servername to an IP address with inet_addr(3).

  3. Request name-lookup from the operating system via gethostbyname(3) or similar.

If the TDS version and port are not read from freetds.conf, 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 freetds.conf. You can simply compile in the right defaults — or set the TDSPORT and TDSVER environment variables — and rely on DNS for name resolution.

Notes

[1]

This description applies to DB-Library and CT-Library. ODBC lookup is different.

freetds-0.91/doc/doc/freetds-0.91/userguide/freetdsconf.htm100664 001750 000144 00000044614 11623070653 0017156 The freetds.conf file

The freetds.conf file

What it does

Just as DNS defines hostnames for network addresses, freetds.conf uses a servername to define the properties of your server. [1] 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

Note

FreeTDS also supports an older configuration file format, known as the interfaces file. Use freetds.conf 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 freetds.conf first, falling back on interfaces only if freetds.conf is not found.

Should you need it, more information about interfaces can be found in the Appendix.

Where it goes

The default location of freetds.conf 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 freetds.conf 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/freetds.conf. The file used is the first one that is readable and contains a section for the server.

What it looks like

Tip

The following information is also provided in the freetds.conf manual page, cf. man freetds.conf.

The freetds.conf 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

Example 3-1. A freetds.conf 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.

Tip

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 freetds.conf. That is no longer the case. If the username has the form DOMAIN\username, FreeTDS will automatically use a domain login.

Table 3-2. freetds.conf settings

NamePossible ValuesDefaultMeaning
tds version4.2, 5.0, 7.0, 7.1, 7.2, 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.
hosthost name or IP addressnoneThe host that the servername is running on.
portany valid port
ProductVersionDefault Port
Sybase SQL Serverprior to System 101433
Sybase SQL Server10 and up5000
Sybase SQL Anywhere72638
Microsoft SQL Serverall1433
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.
instanceinstance namenone

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 databasevalid database nameservername [section] nameSpecifies 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.
initial block sizemultiple of 512512Specifies the maximum size of a protocol block. Don't mess with unless you know what you are doing.
dump fileany valid file namenone Overridden by TDSDUMP. Specifies the location of a tds dump file and turns on logging
dump file appendyes/nonoAppends dump file instead of overwriting it. Useful for debugging when many processes are active.
timeout0-noneSets period to wait for response of query before timing out.
connect timeout0-noneSets period to wait for response from connect before timing out.
emulate little endianyes/nonoForces 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 charsetany valid iconv character setISO-8859-1[a]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 size0 to 4,294,967,2954,294,967,295default 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 flagsAny number even in hex or octal notation0x4fffSets granularity of logging. A bitmask. See table below for specification.
encryptionoff/request/requiredoffSpecify if encryption is desidered. Supported for Microsoft servers. off disables encryption (only if needed); request means use if available; required means create and allow encrypted connections only.
enable gssapi delegationon/offoffEnable delegation flag using Kerberos.
Notes:
a. Valid for ISO 8859-1 character set. See Localization and TDS 7.0 for more information.

Overrides

Many settings in freetds.conf can be overridden by environment variables.

The servername can also be decorated adding the port or instance name using port override syntax.

Controlling log details

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.

The log's granularity can be controlled with the debug flags entry. The default value (4FFF hex) gives a level of detail that is useful for resolving problems via the mailing list.

Table 3-3. Valid bitmask values for debug flags entry in freetds.conf

ValueMeaning
0x80function trace and info
0x40information level 2
0x20information level 1
0x10network
0x08warning
0x04error
0x02severe error
0x1000show pid
0x2000show time
0x4000show source level info (source file and line)
0x8000thread id (not implemented)

For more about the wonderful world of FreeTDS logs, see Logging.

Deprecated options

The following options have long been deprecated.

Deprecated freetds.conf settings

  • try server login

  • try domain login

  • nt domain

  • cross domain login

  • debug level

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/locales.htm100664 001750 000144 00000015621 11623070653 0016272 The locales.conf file

The locales.conf 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.

Important

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 freetds.conf. That's the direction we're headed.

If your purpose is to affect the client charset description, use freetds.conf 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 freetds.conf, the location of locales.conf is determined by the value of --sysconfdir to configure. The default is PREFIX/etc.

What it looks like

The format of locales.conf is similar to that of freetds.conf. 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.

Note

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.

Note

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/envvar.htm100664 001750 000144 00000015664 11623070653 0016160 Environment variables

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 freetds.conf 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.

  1. The value specified in TDSVER

  2. A freetds.conf file entry (see below)

  3. The interfaces file entry (see below)

  4. The --with-tdsver option passed to configure

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, 4000 for TDS 5.0) as well as any port specified in the freetds.conf 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 freetds.conf.

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

freetds-0.91/doc/doc/freetds-0.91/userguide/portoverride.htm100664 001750 000144 00000007562 11623070653 0017401 Port override syntax

Port 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 freetds.conf 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 freetds.conf 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/confirminstall.htm100664 001750 000144 00000040527 11623070653 0017677 Confirm the installation

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 freetds.conf

  • servername exists in freetds.conf

  • 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.

tsql

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., DB-Library). It can also report where it looks for freetds.conf and other compile-time settings (with tsql -C).

Example 3-2. Show compile-time settings with tsql

	$ tsql -C 
	Password: 
		locale is "C"
	locale charset is "646"
	Compile-time settings (established with the "configure" script):
	Version: freetds 0.91
	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
	

For details on the use of tsql, consult its man page.

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.

Example 3-3. Failure to find servername in freetds.conf

	$ 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 freetds.conf. 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.

Example 3-4. Failure to resolve hostname for 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 freetds.conf) 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.

Example 3-5. 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.

Example 3-6. 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.

Example 3-7. 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. [1]

Example 3-8. 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 freetds.conf:

tsql {-H hostname} {-p port} {-U username} [-Ppassword] [-C]

Keep in mind that the TDS protocol version normally comes from freetds.conf. 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.

Example 3-9. Connect with 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.

Unit Tests

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/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.

Tip

The PWD provided by FreeTDS includes usernames and passwords that probably don't exist on your server.

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/prepodbc.htm100664 001750 000144 00000023614 11623070654 0016450 Preparing ODBC

Chapter 4. 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 DB-Library and CT-Library), and has always had its own way to store server properties: freetds.conf. 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 freetds.conf. 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 freetds.conf. For installations that don't need DB-Library and CT-Library, 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 freetds.conf.

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 three 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 freetds.conf. This is the "traditional" ODBC setup.

ODBC-combined

Connection information maintained in freetds.conf. odbc.ini contains DSN entries that refer to servernames in freetds.conf.

TipLibrary 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/dsnless.htm100664 001750 000144 00000013731 11623070654 0016324 DSN-less configuration

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 freetds.conf, or explicitly specify the servername's hostname (bypassing freetds.conf).

Example 4-1. Sample files for a DSN-less configuration

The odbcinst.ini is quite brief:

	;
	; odbcinst.ini
	;
	[FreeTDS]
	Driver = /usr/local/freetds/lib/libtdsodbc.so
	

The freetds.conf might look something like:

	;
	; freetds.conf
	;
	[JDBC]
	host = jdbc.sybase.com
	port = 4444
	tds version = 5.0
	

Example 4-2. Connecting with a DSN-less configuration

	/*
	 * application call
	 */
	const char servername[] = "JDBC"; [1]
	sprintf(tmp, "DRIVER=FreeTDS[2];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.

Example 4-3. Connecting with a DSN-less configuration that does not use freetds.conf

	/*
	 * application call
	 */
	const char servername[] = "jdbc.sybase.com"; [3]
	sprintf(tmp, "DRIVER=FreeTDS[4];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);
	}
	

Notes

[1]

refers to the [JDBC] entry in freetds.conf.

[2]

refers to the [FreeTDS] entry in odbcinst.ini.

[3]

refers to the real server name.

[4]

refers to the [FreeTDS] entry in odbcinst.ini.

freetds-0.91/doc/doc/freetds-0.91/userguide/odbcconnattr.htm100664 001750 000144 00000016476 11623070654 0017342 Connection attributes

Connection attributes

The following table defines 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.

Table 4-1. Connection attributes used only in connection strings

NamePossible ValuesDefaultMeaning
DSNA valid DSN entrynoneThe 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.
UIDAny valid usernamenoneThe username to be used when connecting. To use domain authentication, specify the domain using the format domain\username.
PWDAnyemptyThe password to be used when connecting.
WSIDAnyComputer nameThe name of the local computer, sent to server. Can be specified only for a DSN-less connection.

Table 4-2. Connection attributes that may appear in odbc.ini

NamePossible ValuesDefaultMeaning
ServernameA valid freetds.conf server sectionnoneA freetds.conf servername, not a hostname as known to DNS. If you want to use ODBC-only configuration, use Server instead.
ServerA server name or (ip) addressnoneHostname of a server. Used in an ODBC-only configuration. To specify a Microsoft SQL Server instance, use the form server\instance.
PortAny TCP portDepends on the TDS version specified with configureThe TCP port where the servername is listening.
TDS_VersionAny valid protocol versionDepends on the TDS version specified with configureTDS protocol version to use (e.g., 5.0, 7.0).
ClientCharsetA name recognized by the iconv library linked to FreeTDS. Corresponds to client charset in freetds.conf.ISO 8859-1Character set (encoding) used by the client.
APPFree form text, up to 30 characters. noneApplication name. Identifies the connecting application to the server.
LANGUAGEAnyus_english(Human) language the server should use for error messages.
AddressAnynoneIP 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.
DatabaseAnynoneSpecify which database you want to access. If the database does not exist or the user lacks permission to access it, the connection will fail.
TextSizeAnyServer-dependentMaximum size returned from server for blobs.
PacketSizeAnyServer-dependentSize of packets to server. Some users saw some performance gain by increasing this value. Normally you shouldn't set it.
Trusted_ConnectionYes/NoNoUse your current account instead of UID/PWD attributes. This option require SSPI or Kerberos and supersedes any UID/PWD attributes passed from the application.

freetds-0.91/doc/doc/freetds-0.91/userguide/odbcinionly.htm100664 001750 000144 00000006740 11623070654 0017164 ODBC-only configuration

ODBC-only configuration

An ODBC-only configuration relies solely on odbc.ini for server properties. Other FreeTDS libraries don't know about odbc.ini.

Example 4-4. Sample ODBC-only odbc.ini file

	[ODBC Data Sources][1]
	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
	

Notes

[1]

Several DSNs might be listed here. In this example, we have only one, "JDBC". It matches the [JDBC] entry later in the file.

freetds-0.91/doc/doc/freetds-0.91/userguide/odbcombo.htm100664 001750 000144 00000010676 11623070654 0016442 ODBC-combined configuration

ODBC-combined configuration

Like the DSN-less configuration, ODBC-combined keeps server properties in freetds.conf. 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 freetds.conf.

Example 4-5. Sample ODBC-combined odbc.ini file

	[ODBC Data Sources][1]
	JDBCdsn = Sybase JDBC Server
	
	[JDBCdsn]
	Driver          = /usr/local/freetds/lib/libtdsodbc.so
	Description     = Sybase JDBC Server
	Trace           = No
	Servername      = JDBC[2]
	Database        = pubs2
	
	[Default]
	Driver          = /usr/local/freetds/lib/libtdsodbc.so
	

Example 4-6. Sample ODBC-combined freetds.conf 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).

Notes

[1]

Several DSNs might be listed here. In this example, we have only one, "JDBCdsn". It matches the [JDBCdsn] entry later in the file.

[2]

Refers to the [JDBC] entry in freetds.conf.

freetds-0.91/doc/doc/freetds-0.91/userguide/odbcdiagnose.htm100664 001750 000144 00000021607 11623070654 0017273 Troubleshooting ODBC connections

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 freetds.conf, 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.

Tip

For debugging purposes, you may wish to link a program such as odbctest directly to FreeTDS instead of to the driver manager. [1] To do so, compile and install the ODBC driver with iODBC as normal [2], then compile and link the program:

Example 4-7. Compile 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 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.

Example 4-8. Use osql to test the ODBC setup.

	$ make odbctest.o
	
	$ 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.

Notes

[1]

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.

[2]

When linking directly to FreeTDS you still need the Driver Manager's header files.

freetds-0.91/doc/doc/freetds-0.91/userguide/configs.htm100664 001750 000144 00000011632 11623070654 0016277 Advanced Configurations

Chapter 5. Advanced Configurations

This chapter details some advanced configurations that need expanded explanation.

Big Endian Clients with Buggy SQL Servers

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.

Note

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 freetds.conf setting. You shouldn't use this option, set another protocol version instead (7.0, 7.1 or 7.2).

Example 5-1. Emulate Little Endian freetds.conf setting

	[mssql]
	host = ntbox.mydomain.com
	port = 1433
	tds version = 4.2
	emulate little endian = yes
	
freetds-0.91/doc/doc/freetds-0.91/userguide/localization.htm100664 001750 000144 00000026507 11623070654 0017346 Localization and TDS 7.0

Localization and TDS 7.0

TDS 7.0 uses 2-byte Unicode (technically, UCS-2) 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, and UCS-2.

To learn what character set the client wants, FreeTDS prefers the applicable freetds.conf 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 replacment). [1]. 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.

Example 5-2. Configuring for GREEK freetds.conf 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.

Important

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-*)[2]. 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.

Example 5-3. Configuring for UTF-8 freetds.conf 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.[3] 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 infomation.

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.

Notes

[1]

The built-in replacement expects GNU iconv names: ISO-8859-1, US-ASCII, or UTF-8.

[2]

not EBCDIC or other weird charsets

[3]

The precise rules are unknown to the author.

freetds-0.91/doc/doc/freetds-0.91/userguide/domains.htm100664 001750 000144 00000014340 11623070654 0016300 Domain Logins

Domain Logins

Note

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 [1] 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.

Example 5-4. 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

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/kerberos.htm100664 001750 000144 00000007653 11623070654 0016473 Kerberos Support

Kerberos Support

Perhaps surprisingly, [1] Kerberos can be used to authenticate to Microsoft SQL Servers. 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 [2] 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. Options to configure).

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.

Notes

[1]

It works because much of Active Directory is based on Kerberos. From each according to his ability; to each according to his needs.

[2]

No, the author does not really know what he's talking about.

freetds-0.91/doc/doc/freetds-0.91/userguide/uothread.htm100664 001750 000144 00000006301 11623070654 0016457 Threading in unixODBC

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.

Example 5-5. Sample odbcinst.ini for threading model

	[FreeTDS]
	Driver = /usr/local/freetds/lib/libtdsodbc.so
	Threading = 1
	

Example 5-6. Sample 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;.

freetds-0.91/doc/doc/freetds-0.91/userguide/appendmode.htm100664 001750 000144 00000010152 11623070654 0016757 Appending Dump Files

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.

Example 5-7. Turning on Dump File Append mode in freetds.conf

				[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.

Important

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/tdspool.htm100664 001750 000144 00000017340 11623070654 0016335 TDS Connection Pooling

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.

Note

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 --with-prefix flag option).

Edit pool.conf in the FreeTDS's etc directory. The pool.conf file is formatted like freetds.conf, with a section name in brackets and options for each section in key/value pairs.

Just as in freetds.conf 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.

Table 5-1. pool.conf settings

NamePossible ValuesDefaultMeaning
userAny valid usernoneThe username used to connect to the servername.
passwordAnynoneThe password of the user at the servername.
serverAny TDS 4.2 entry in the freetds.conf filenoneThe alias from the freetds.conf file representing the servername that will be connected to.
databaseAny valid databaseUser's default databaseThe database on the servername to use.
portAny TCP portnonePort on which tdspool will listen.
min pool conn1 or morenoneMinimum number of open connections to maintain to the servername.
max pool conn1 or morenoneMaximum number of open connections to open against the servername.
max member age0 (no limit) or a number of seconds0Maximum age of idle members before connection is closed.

Now, let's put this into practice.

Example 5-8. 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 freetds.conf to include the host and port of the pooling server, and point your clients at it.

freetds-0.91/doc/doc/freetds-0.91/userguide/stunnel.htm100664 001750 000144 00000010155 11623070654 0016336 stunnel HOWTO

stunnel HOWTO

Contributed by Bradley Bell.

To set up FreeTDS over stunnel between a Linux webserver and a W2k SQL server:

  1. Get unencrypted freetds working

  2. Install openssl and stunnel on the Linux box: stunnel.org

  3. Download the stunnel binary and openssl dll's for Windows.

  4. Generate stunnel.pem (complete with Diffie-Hellman parameters) for placement on the W2k box. See instructions in the stunnel FAQ.

  5. Start stunnel on the W2k box:

    	$ stunnel.exe -d 61666 -r localhost:1433

    61666 is just an arbitrary port number.

  6. 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.

  7. Set up FreeTDS to use the tunnel. If this is your unencrypted entry in freetds.conf:

    Example 5-9. Unencrypted entry in freetds.conf

    	[win2kserver]
    	host = win2kserver
    	port = 1433
    	

    the encrypted equivalent uses:

    Example 5-10. Encrypted entry in freetds.conf

    	[win2kserver]
    	host = localhost
    	port = 1433
    	
freetds-0.91/doc/doc/freetds-0.91/userguide/usefreetds.htm100664 001750 000144 00000014413 11623070654 0017020 Use FreeTDS

Chapter 6. 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

(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 DB-Library 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 DB-Library 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 DB-Library 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/software.htm100664 001750 000144 00000013447 11623070654 0016507 How to get what works with it working

Chapter 7. 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.

SQSH

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.

Tip

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.

Example 7-1. The SQSH 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/perl.htm100664 001750 000144 00000016554 11623070654 0015621 Perl

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 CT-Library 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 DB-Library.

Building and using the Perl modules

Example 7-2. Building DBD::Sybase

	$ 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):

Example 7-3. Connect to a server with DBD::Sybase

	#!/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";
	}
	}
	

Example 7-4. Building DBD::ODBC

	$ 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

Note

We used the public JDBC server logins for our configuration here. You'll want to replace these with ones suitable to your environment.

Example 7-5. Connect to a server with DBD::ODBC

	#!/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!

freetds-0.91/doc/doc/freetds-0.91/userguide/php.htm100664 001750 000144 00000017347 11623070654 0015447 PHP

PHP

There are three options for building PHP with support for FreeTDS corresponding to the three APIs that FreeTDS supports: DB-Library, CT-Library, and ODBC.

Note

All these examples build the CGI version. Consult PHP's documentation for building the Apache module and including other extensions.

DB-Library

PHP can be configured with DB-Library access for a "Sybase" server (which also works with Microsoft servers), or with the mssql extension, intended exclusively for Microsoft servers.

Example 7-6. PHP and DB-Library for "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!

CT-Library

Option 2 is to use the CT-Library 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 DB-Library in with DB-Library, above. Then configure PHP with CT-Library.

	$ 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 Preparing ODBC. 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/sybsql.htm100664 001750 000144 00000011074 11623070654 0016164 SybSQL

SybSQL

SybSQL is a Qt-based GUI interface to Sybase databases that uses the DB-Library API.

SybSQL has a fairly basic build process that simply uses a Makefile. In order for SybSQL to find Qt and FreeTDS you need to define QTDIR and SYBASE environment variables. If you have Qt installed, you may have QTDIR defined already. To verify, type echo $QTDIR at the shell prompt. This example uses my own installation path of qt-2.3.1 (from RedHat 7.2), YMMV.

	$ export QTDIR=/usr/lib/qt-2.3.1
	$ export SYBASE=/usr/local
	$ make
When finished you'll have an executable named sybsql that you can run.

One caveat to the way in which SybSQL and FreeTDS interact is that SybSQL expects to be running under OpenClient, and makes the assumption that a valid $SYBASE/interfaces file exists. Since FreeTDS has deprecated use of the interfaces file in favor of the freetds.conf config file, you may have to create a interfaces file just to satisfy SybSQL.

By defining SYBASE to the parent directory of the interfaces file, you may put it wherever you like; it does not have to be in /usr/local. When using freetds.conf, FreeTDS does not rely on the SYBASE variable for finding its own components, so it is safe to point it elsewhere.

freetds-0.91/doc/doc/freetds-0.91/userguide/python.htm100664 001750 000144 00000010016 11623070654 0016163 Python

Python

Tip

Your humble author is not enlightened enough to use Python, and the information contained in this section is a little rough. Please contact the list for more assistance or (better yet) to improve these instructions.

Install distutils if you haven't already.

	$ tar xvfz distutils-latest.tgz
	$ cd distutils
	$ python setup.py install

You can obtain the Python Sybase module here. This example uses version 0.34, the most current at the time of this writing, please adjust accordingly if using a different version.

	$ tar xvfz sybase-0.34.tgz
	$ cd sybase-0.34
	$ 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

freetds-0.91/doc/doc/freetds-0.91/userguide/qt.htm100664 001750 000144 00000005300 11623070654 0015266 Qt

Qt

Qt has two drivers to access SQL Server databases: QTDS and QODBC. At the time of writing (January 2010) QTDS has a performance problem because rather than maintaining a connection, it instead re-connects for every query. So use QODBC.

There are however 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/uodbc.htm100664 001750 000144 00000013312 11623070654 0015740 ODBC on Unix

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-bit[1]. 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.

Notes

[1]

In fact, the earliest versions were 16-bit.

freetds-0.91/doc/doc/freetds-0.91/userguide/troubleshooting.htm100664 001750 000144 00000025534 11623070654 0020104 Troubleshooting

Chapter 8. Troubleshooting

 

He's like motherf**king McGuiver, no he's better than McGuiver!

 Jason Mewes (Mall Rats)

Known Issues

Porting Issues

Date Structures and Offsets

Microsoft and Sybase use different DB-Library date structures and conventions. Notably months can by [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 DB-Library 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.

Text 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

A related problem is that some people have reported problems with text field using TDS version 7.0. One known workaround is to convert long strings to varchar(8000) in your query text with CAST( variable_name as varchar(8000) ) as variable_name. Text datatype handling is fixed in FreeTDS 0.60, except for bcp operations.

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. The usual manifestation is some sort of spurious "out of memory" error or segment fault. To avoid this, 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 freetds.conf.

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.

Datetime and Money

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.

Note

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 "Integrated Security"

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.

Note

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/serverthere.htm100664 001750 000144 00000015136 11623070654 0017210 Is the server there?

Is the server there?

Start with ping

First ping the host to make sure you can talk to the machine the server resides on.

Example 8-1. 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 telnet

Attempt to telnet to the port, to verify that the servername is listening.

Example 8-2. 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. [1]

Test with tsql

tsql can be run in two ways, one which uses freetds.conf and one which connects directly using the host and port. First attempt a connection using host and port.

Example 8-3. Connecting to the server, bypassing freetds.conf

	$ 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.

Example 8-4. Connecting to the server using freetds.conf

	$ ./tsql -S myserver -U user
If this fails, FreeTDS is either not finding your freetds.conf file, finding the wrong one, or there is an error in the file.

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/rtl.htm100664 001750 000144 00000016344 11623070656 0015457 On Linkers

Appendix A. 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 shrugs[1] 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.

Notes

[1]

You have to watch carefully. Modern compilers shrug quickly.

freetds-0.91/doc/doc/freetds-0.91/userguide/logging.htm100664 001750 000144 00000016551 11623070654 0016302 Logging

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.

Tip

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 freetds.conf 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.

Tip

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.

freetds.conf variables that Control Logging

See Valid bitmask values for debug flags entry in freetds.conf

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/pagenodata.htm100664 001750 000144 00000013607 11623070654 0016756 "Page contains no data"

"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.

freetds-0.91/doc/doc/freetds-0.91/userguide/seemtooslow.htm100664 001750 000144 00000011336 11623070654 0017230 Slow connection or data retrieval

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 freetds.conf. 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 freetds.conf. Give particular attention to reverse DNS lookups, if you were forced (or thought you were forced) to identify the server by number, instead of by name, as Vint intended. You can defeat FreeTDS's automatic reverse-DNS lookup feature by inserting

    	#define NOREVERSELOOKUPS
    	
    in src/tds/config.c, rebuilding, and reinstalling.

    Note

    Reverse lookup code has been removed as of version 0.62 because it was poorly implemented.

  • Packet size. The default packet size setting in freetds.conf (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.

freetds-0.91/doc/doc/freetds-0.91/userguide/help.htm100664 001750 000144 00000012473 11623070654 0015603 Getting Help

Chapter 9. Getting Help

 

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?

 Beatles

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 Confirm the installation. 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.83.dev.20110124
             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.

freetds-0.91/doc/doc/freetds-0.91/userguide/isolatecause.htm100664 001750 000144 00000010614 11623070654 0017327 Isolate the cause

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

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.

Check permissions

If your query works in tsql but not with Apache, make sure the account running Apache can find and read freetds.conf.

freetds-0.91/doc/doc/freetds-0.91/userguide/mailinglist.htm100664 001750 000144 00000010150 11623070654 0017155 The Mailing List

The Mailing List

 

In them I trust; for they are [hackers]
Witty, courteous, liberal, full of spirit.

 3 Henry VI, I, ii, approximately

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/askingforhelp.htm100664 001750 000144 00000012560 11623070654 0017504 What to include when asking for help

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)
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.

freetds-0.91/doc/doc/freetds-0.91/userguide/contrib.htm100664 001750 000144 00000013756 11623070655 0016321 Helping

Chapter 10. Helping

 

The time you enjoy wasting is not wasted time.

 Bertrand Russell

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 FreeTDS FAQ Master, or post a message to the 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 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 DB-Library, 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 your friendly project maintainer, James K. Lowden.

freetds-0.91/doc/doc/freetds-0.91/userguide/light.taper.htm100664 001750 000144 00000006041 11623070654 0017066 Light another's taper

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/ambition.htm100664 001750 000144 00000007031 11623070655 0016450 Ambitious ideas

Ambitious ideas

If you want to get your hands really dirty, here are some big ideas to contemplate.

libtds2

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.

libstddb

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/advocacy.htm100664 001750 000144 00000007260 11623070655 0016443 Advocacy

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 CT-Library for Microsoft SQL Server. This feature alone allows DBD::Sybase and sqsh, among others, to connect to Microsoft's product.

  • Provide a modern DB-Library 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/programming.htm100664 001750 000144 00000005412 11623070655 0017171 Programmingfreetds-0.91/doc/doc/freetds-0.91/userguide/apireference.htm100664 001750 000144 00000011322 11623070655 0017274 API Reference Manual

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 DB-Library 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 [1] the extent to which it is implemented. The Status field may be:

DB-Library 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.

Notes

[1]

Sybase and Microsoft sometimes use slightly different names for the same function. It is the intention of the --enable-msdblib option to align FreeTDS with one or the other's convention.

freetds-0.91/doc/doc/freetds-0.91/userguide/dblib.api.summary.htm100664 001750 000144 00000070510 11623070655 0020170 DB-Library API Implementation Summary

DB-Library API Implementation Summary

Microsoft's version of DB-Library is online. Sybase's is both online and can be downloaded as a PDF file. [1]

Table 11-1. db-lib API Implementation Summary

CategoryMicrosoft nameSybase nameStatusComments
(none) n/adb12hour  
(none) n/adbaltbind_ps  
(none) n/adbbind_ps  
(none) n/adbbufsize  
(none) n/adbcharsetconv  
(none) n/adbcoltypeinfoOK 
(none) n/adbconvert_psOK 
(none) n/adbfreesortnever 
(none) n/adbfree_xlatenever 
(none) n/adbgetcharset  
(none) n/adbgetloginfonever 
(none) n/adbgetlusername  
(none) n/adbgetnatlang  
(none) n/aDBIORDESCOK 
(none) n/aDBIOWDESCOK 
(none) n/adbloadsortnever 
(none) n/adbload_xlatenever 
(none) n/adbnpcreatenever 
(none) n/adbnpdefinenever 
(none) n/adbpoll  
(none) n/aDBRBUFnever 
(none) n/adbreadpagenever 
(none) n/adbrecftosOK 
(none) n/adbrecvpassthrunever 
(none) n/adbregdropnever 
(none) n/adbregexecnever 
(none) n/adbreghandlenever 
(none) n/adbreginitnever 
(none) n/adbreglistnever 
(none) n/adbregnowatchnever 
(none) n/adbregparamnever 
(none) n/adbregwatchnever 
(none) n/adbregwatchlistnever 
(none) n/adbrpwclrnever 
(none) n/adbrpwsetnever 
(none) n/adbsafestrOK 
(none) n/adbsechandle  
(none) n/adbsendpassthrunever 
(none) n/adbsetbusy  
(none) n/adbsetdefcharset  
(none) n/adbsetdeflang  
(none) n/adbsetidle  
(none) n/adbsetifileOK 
(none) n/adbsetinterruptOK 
(none) n/aDBSETLCHARSET  
(none) n/aDBSETLENCRYPT  
(none) n/adbsetloginfonever 
(none) n/adbsetrowOK 
(none) n/adbsetversionOK 
(none) n/adbspr1rowOK 
(none) n/adbspr1rowlenOK 
(none) n/adbsprheadOK 
(none) n/adbsprlineOK 
(none) n/adbstrcmpnever 
(none) n/adbstrsortnever 
(none) n/adbtextsize  
(none) n/adbwritepagenever 
(none) n/adbxlatenever 
bcp bcp_batch(same)OK 
bcp bcp_bind(same)OK 
bcp bcp_colfmt(same)OK 
bcp n/abcp_colfmt_ps  
bcp bcp_collen(same)OK 
bcp bcp_colptr(same)OK 
bcp bcp_columns(same)OK 
bcp bcp_control(same)OK 
bcp bcp_done(same)OK 
bcp bcp_exec(same)OK 
bcp n/abcp_getlOK 
bcp bcp_init(same)OK 
bcp bcp_moretext(same)stub 
bcp n/abcp_optionspartial 
bcp bcp_readfmt(same)OK 
bcp bcp_sendrow(same)OK 
bcp BCP_SETL(same)OK 
bcp bcp_writefmt(same)  
browse dbcolbrowsen/anever 
browse dbcolsourcen/anever 
browse dbfreequaln/anever 
browse dbqualn/anever 
browse dbtabbrowsen/anever 
browse dbtabcountn/anever 
browse dbtabnamen/anever 
browse dbtabsourcen/anever 
browse dbtsnewlenn/anever 
browse dbtsnewvaln/anever 
browse dbtsputn/anever 
core dbadata(same)OK 
core dbadlen(same)OK 
core dbaltbind(same)OK 
core dbaltcolid(same)OK 
core dbaltlen(same)OK 
core dbaltop(same)OK 
core dbalttype(same)OK 
core dbaltutype(same)OK 
core dbanullbind(same)OK 
core dbbind(same)OK 
core dbbylist(same)OK 
core dbcancel(same)OK 
core dbcanquery(same)OK 
core dbchange(same)OK 
core dbclose(same)OK 
core dbclrbuf(same)OK 
core dbclropt(same)partial 
core dbcmd(same)OK 
core dbcmdrowDBCMDROWOK 
core dbcolinfon/aOK 
core dbcollen(same)OK 
core dbcolname(same)OK 
core dbcoltype(same)OK 
core dbcolutype(same)OK 
core dbconvert(same)OK 
core dbcountDBCOUNTOK 
core dbcurcmdDBCURCMDstub 
core dbcurrowDBCURROWstub 
core dbdata(same)OK 
core dbdatareadyn/a  
core dbdatecrack(same)OK 
core dbdatlen(same)OK 
core dbdeadDBDEADOK 
core dbenlisttransn/anever 
core dbenlistxatransn/anever 
core dberrhandle(same)OK 
core dbexit(same)OK 
core dbfcmd(same)OK 
core dbfirstrowDBFIRSTROWOK 
core dbfreebuf(same)OK 
core dbgetchar(same)OK 
core dbgetmaxprocs(same)OK 
core dbgetoff(same)never 
core dbgetpacket(same)OK 
core dbgetrow(same)OK 
core dbgettimeDBGETTIMEOK 
core dbgetuserdata(same)OK 
core dbinit(same)OK 
core dbisavailDBISAVAILOK 
core dbiscountn/aOK 
core dbisopt(same)partial 
core dblastrowDBLASTROWOK 
core dblogin(same)OK 
core dbfreelogindbloginfreeOK 
moneyn/adbmny4addOK 
moneyn/adbmny4cmpOK 
moneyn/adbmny4copyOK 
moneyn/adbmny4dividestub 
moneyn/adbmny4minusOK 
moneyn/adbmny4mulstub 
moneyn/adbmny4subOK 
moneyn/adbmny4zeroOK 
moneyn/adbmnyaddstub 
moneyn/adbmnycmpOK 
moneyn/adbmnycopyOK 
moneyn/adbmnydecOK 
moneyn/adbmnydividestub 
moneyn/adbmnydownstub 
moneyn/adbmnyincOK 
moneyn/adbmnyinitstub 
moneyn/adbmnymaxnegOK 
moneyn/adbmnymaxposOK 
moneyn/adbmnyminusOK 
moneyn/adbmnymulstub 
moneyn/adbmnyndigitstub 
moneyn/adbmnyscalestub 
moneyn/adbmnysubstub 
moneyn/adbmnyzeroOK 
core dbmorecmdsDBMORECMDSOK 
core dbmsghandle(same)OK 
core dbname(same)OK 
core dbnextrow(same)OK 
core dbnullbind(same)OK 
core dbnumalts(same)OK 
core dbnumcols(same)OK 
core dbnumcompute(same)OK 
core dbnumordersDBNUMORDERSnever 
core dbopen(same)OK 
core dbordercol(same)never 
core dbprhead(same)OK 
core dbprocerrhandlen/aaliases dberrhandle 
core dbprocinfon/anever 
core dbprocmsghandlen/aaliases dbmsghandle 
core dbprrow(same)OK 
core dbprtype(same)OK 
core dbresults(same)OK 
core dbrowsDBROWSOK 
core dbrowtypeDBROWTYPEOK 
core n/adbservcharsetOK 
core dbserverenumn/anever 
core dbsetavail(same)OK 
core dbsetlappDBSETLAPPOK 
core dbsetlfallbackn/anever 
core dbsetlhostDBSETLHOSTOK 
core dbsetlnatlangDBSETLNATLANGOK 
core dbsetlogintime(same)OK 
core dbsetlpacketDBSETLPACKETOK 
core dbsetlpwdDBSETLPWDOK 
core dbsetlsecuren/a  
core dbsetltimen/a  
core dbsetluserDBSETLUSEROK 
core dbsetlversionn/aOK 
core dbsetmaxprocs(same)OK 
core dbsetnull(same)OK 
core dbsetopt(same)partial 
core dbsettime(same)OK 
core dbsetuserdata(same)OK 
core n/adbspidOK 
core dbsqlexec(same)OK 
core dbsqlok(same)OK 
core dbsqlsend(same)OK 
core n/adbstrbuildOK 
core dbstrcpy(same)OK 
core dbstrlen(same)OK 
core n/aDBTDSOK 
core dbuse(same)OK 
core dbvarylen(same)OK 
core n/adbversionOK 
core dbwillconvert(same)OK 
core dbwinexit (Windows only)n/ano-op macro 
cursor dbcursor(same)never 
cursor dbcursorbind(same)never 
cursor dbcursorclose(same)never 
cursor dbcursorcolinfo(same)never 
cursor dbcursorfetch(same)never 
cursor dbcursorfetchexn/anever 
cursor dbcursorinfo(same)never 
cursor dbcursorinfoexn/anever 
cursor dbcursoropen(same)never 
datetime n/adbdate4cmpnever 
datetime n/adbdate4zeronever 
datetime n/adbdatecharnever 
datetime n/adbdatecmpOK 
datetime n/adbdatenamenever 
datetime n/adbdateordernever 
datetime n/adbdatepartnever 
datetime n/adbdatezeronever 
datetime n/adbdaynamenever 
datetime n/adbmonthnameOK 
proceduredbhasretstat(same)OK 
proceduredbnumrets(same)OK 
proceduredbretdata(same)OK 
proceduredbretlen(same)OK 
proceduredbretname(same)OK 
proceduredbretstatus(same)OK 
proceduredbrettype(same)OK 
proceduredbrpcexecn/a  
proceduredbrpcinit(same)OK 
proceduredbrpcparam(same)OK 
proceduredbrpcsend(same)OK 
text dbmoretext(same)OK 
text dbreadtext(same)OK 
text dbtxptr(same)OK 
text dbtxtimestamp(same)OK 
text dbtxtsnewval(same)  
text dbtxtsput(same)  
text dbupdatetextn/a  
text dbwritetext(same)OK 

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/ctlib.api.summary.htm100664 001750 000144 00000035603 11623070655 0020215 ct-lib API Implementation Summary

ct-lib API Implementation Summary

Sybase ct-lib documentation can be found online and in PDF form. [1]

Table 11-2. ct-lib API Implementation Summary

CategoryFunctionStatusComments
(all)ct_bindOKBind server results to program variables.
(all)ct_br_column Retrieve information about a column generated by a browse mode select.
(all)ct_br_table Return information about browse mode tables.
(all)ct_callbackOKInstall or retrieve a Client-Library callback routine.
(all)ct_cancelOKCancel a command or the results of a command.
(all)ct_capabilityOKSet or retrieve a client/server capability.
(all)ct_closeOKClose a server connection.
(all)ct_cmd_allocOKAllocate a CS_COMMAND structure.
(all)ct_cmd_dropOKDeallocate a CS_COMMAND structure.
(all)ct_cmd_propsOKSet or retrieve command structure properties. For use by applications that resend commands.
(all)ct_commandOKInitiate a language, package, RPC, message, or send-data command.
(all)ct_compute_infoOKRetrieve compute result information.
(all)ct_con_allocOKAllocate a CS_CONNECTION structure.
(all)ct_con_dropOKDeallocate a CS_CONNECTION structure.
(all)ct_con_propsOKSet or retrieve connection structure properties.
(all)ct_configOKSet or retrieve context properties.
(all)ct_connectOKConnect to a server.
(all)ct_cursorOKInitiate a Client-Library cursor command.
(all)ct_data_infoOKDefine or retrieve a data I/O descriptor structure.
(all)ct_debug Manage debug library operations.
(all)ct_describeOKReturn a description of result data.
(all)ct_diagOKManage inline error handling.
(all)ct_ds_dropobj Release the memory associated with a directory object.
(all)ct_ds_lookup Initiate or cancel a directory lookup operation.
(all)ct_ds_objinfo Retrieve information associated with a directory object.
(all)ct_dynamicOKInitiate a dynamic SQL command.
(all)ct_dyndesc Perform operations on a dynamic SQL descriptor area.
(all)ct_dynsqlda Operate on a SQLDA structure.
(all)ct_exitOKExit Client-Library.
(all)ct_fetchOKFetch result data.
(all)ct_get_dataOKRead a chunk of data from the server.
(all)ct_getformat Return the server user-defined format string associated with a result column.
(all)ct_getloginfo Transfer TDS login response information from a CS_CONNECTION structure to a newly allocated CS_LOGINFO structure.
(all)ct_initOKInitialize Client-Library for an application context.
(all)ct_keydata Specify or extract the contents of a key column.
(all)ct_labels Define a security label or clear security labels for a connection.
(all)ct_optionsOKSet, retrieve, or clear the values of server query-processing options.
(all)ct_paramOKSupply values for a server command's input parameters.
(all)ct_pollstubPoll connections for asynchronous operation completions and registered procedure notifications.
(all)ct_recvpassthru Receive a TDS (Tabular Data Stream) packet from a server.
(all)ct_remote_pwd Define or clear passwords to be used for server-to-server connections.
(all)ct_res_infoOKRetrieve current result set or command information.
(all)ct_resultsOKSet up result data to be processed.
(all)ct_sendOKSend a command to the server.
(all)ct_send_dataOKSend a chunk of text or image data to the server.
(all)ct_sendpassthru Send a Tabular Data Stream (TDS) packet to a server.
(all)ct_setloginfo Transfer TDS login response information from a CS_LOGINFO structure to a CS_CONNECTION structure.
(all)ct_setparamOKSpecify source variables from which ct_send reads input parameter values for a server command.
(all)ct_wakeup Call a connection's completion callback.
(all)cs_calc Perform an arithmetic operation on two operands.
(all)cs_cmp Compare two data values.
(all)cs_configpartialSet or retrieve CS-Library properties.
(all)cs_conv_multstubRetrieve the conversion multiplier for converting character data from one character set to another.
(all)cs_convertOKConvert a data value from one datatype, locale, or format to another datatype, locale, or format.
(all)cs_ctx_allocOKAllocate a CS_CONTEXT structure.
(all)cs_ctx_dropOKDeallocate a CS_CONTEXT structure.
(all)cs_ctx_globalOKAllocate or return a CS_CONTEXT structure.
(all)cs_diagOKManage inline error handling.
(all)cs_dt_crackOKConvert a machine-readable datetime value into a user-accessible format.
(all)cs_dt_infostubSet or retrieve language-specific datetime information.
(all)cs_loc_allocOKAllocate a CS_LOCALE structure.
(all)cs_loc_dropOKDeallocate a CS_LOCALE structure.
(all)cs_localepartialLoad a CS_LOCALE structure with localization values or retrieve the locale name previously used to load a CS_LOCALE structure.
(all)cs_manage_convertstubInstall or retrieve a user-defined character set conversion routine.
(all)cs_objectsstubSave, retrieve, or clear objects and data associated with them.
(all)cs_set_convertstubInstall or retrieve a user-defined conversion routine.
(all)cs_setnullstubDefine a null substitution value to be used when binding or converting NULL data.
(all)cs_strbuildOKConstruct native language message strings.
(all)cs_strcmpstubCompare two strings using a specified sort order.
(all)cs_timestubRetrieve the current date and time.
(all)cs_will_convertOKIndicate whether a specific datatype conversion is available in the Client/Server libraries.
(all)blk_allocOKAllocate a CS_BLKDESC structure.
(all)blk_bindOKBind a program variable and a database column.
(all)blk_colvalstubServer-side routine to obtain the column value from a formatted bulk copy row.
(all)blk_defaultstubRetrieve a column's default value.
(all)blk_describeOKRetrieve a description of a database column.
(all)blk_doneOKMark a complete bulk copy operation or a complete bulk copy batch.
(all)blk_dropOKDeallocate a CS_BLKDESC structure.
(all)blk_getrowstubServer-side routine to retrieve and store a formatted bulk copy row.
(all)blk_gettextstubServer-side routine to retrieve the text, image, sensitivity, or boundary portion of an incoming bulk copy formatted row.
(all)blk_initOKInitiate a bulk copy operation.
(all)blk_propsOKSet or retrieve bulk descriptor structure properties.
(all)blk_rowallocstubServer-side routine to allocate space for a formatted bulk copy row.
(all)blk_rowdropstubServer-side routine to free space previously allocated for a formatted bulk copy row.
(all)blk_rowxferOKTransfer one or more rows during a bulk copy operation without specifying or receiving a row count.
(all)blk_rowxfer_multOKTransfer one or more rows during a bulk copy operation.
(all)blk_sendrowstubServer-side routine to send a formatted bulk copy row obtained from blk_getrow.
(all)blk_sendtextstubServer-side routine to send text, image, sensitivity, or boundary data in a formatted bulk copy row obtained from blk_sendtext.
(all)blk_srvinitstubServer-side routine to copy descriptions of server table columns to the client, if required.
(all)blk_textxferstubTransfer a column's data in chunks during a bulk copy operation.

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/odbc.api.summary.htm100664 001750 000144 00000041232 11623070655 0020022 ODBC API Implementation Summary

ODBC API Implementation Summary

Microsoft's ODBC documentation is online.

The functions are linked to the reference page on Microsoft's website. [1]

Table 11-3. ODBC API Implementation Summary

CategoryFunctionStatusComments
(all)SQLAllocConnectOK 
(all)SQLAllocEnvOK 
(all)SQLAllocHandleOK 
(all)SQLAllocStmtOK 
(all)SQLBindColOK 
(all)SQLBindParamOK 
(all)SQLBindParameterOK 
(all)SQLBrowseConnect  
(all)SQLCancelOK 
(all)SQLCloseCursorOK 
(all)SQLColAttributeOK 
(all)SQLColAttributesOK 
(all)SQLColumnPrivilegesOK 
(all)SQLColumnsOK 
(all)SQLConnectOK 
(all)SQLCopyDescOK 
(all)SQLDescribeColOK 
(all)SQLDescribeParamunimplemented 
(all)SQLDisconnectOK 
(all)SQLDriverConnectOK 
(all)SQLEndTranOK 
(all)SQLErrorOK 
(all)SQLExecDirectOK 
(all)SQLExecuteOK 
(all)SQLExtendedFetchOK 
(all)SQLFetchOK 
(all)SQLFetchScrollOK 
(all)SQLForeignKeysOK 
(all)SQLFreeConnectOK 
(all)SQLFreeEnvOK 
(all)SQLFreeHandleOK 
(all)SQLFreeStmtOK 
(all)SQLGetConnectAttrOK 
(all)SQLGetConnectOptionOK 
(all)SQLGetCursorNameOK 
(all)SQLGetDataOK 
(all)SQLGetDescFieldOK 
(all)SQLGetDescRecOK 
(all)SQLGetDiagFieldOK 
(all)SQLGetDiagRecOK 
(all)SQLGetEnvAttrOK 
(all)SQLGetFunctionsOK 
(all)SQLGetInfoOK 
(all)SQLGetStmtAttrOK 
(all)SQLGetStmtOptionOK 
(all)SQLGetTypeInfoOK 
(all)SQLMoreResultsOK 
(all)SQLNativeSqlpartial 
(all)SQLNumParamsOK 
(all)SQLNumResultColsOK 
(all)SQLParamDataOK 
(all)SQLParamOptionsOK 
(all)SQLPrepareOK 
(all)SQLPrimaryKeysOK 
(all)SQLProcedureColumnsOK 
(all)SQLProceduresOK 
(all)SQLPutDataOK 
(all)SQLRowCountOK 
(all)SQLSetConnectAttrOK 
(all)SQLSetConnectOptionOK 
(all)SQLSetCursorNameOK 
(all)SQLSetDescFieldOK 
(all)SQLSetDescRecOK 
(all)SQLSetEnvAttrpartial 
(all)SQLSetPosOK 
(all)SQLSetParamOK 
(all)SQLSetScrollOptionOK 
(all)SQLSetStmtAttrOK 
(all)SQLSetStmtOptionOK 
(all)SQLSpecialColumnsOK 
(all)SQLStatisticsOK 
(all)SQLTablePrivilegesOK 
(all)SQLTablesOK 
(all)SQLTransactOK 

Notes

[1]

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/samplecode.htm100664 001750 000144 00000140306 11623070655 0016765 DB-Library for the Tenderfoot

DB-Library for the Tenderfoot

 

Few things are harder to put up with than the annoyance of a good example.

 Mark Twain

Below is a complete sample working DB-Library 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.

Important

How to Get and Build the sample code

  1. Run doc/grep_sample_code to extract the C code from the User Guide SGML source.

  2. Compile

  3. 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.

Example 11-1. 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 DB-Library. 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.

Example 11-2. Sample Code: DB-Library header files

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <libgen.h>
						
						
#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.

Example 11-3. Sample Code: DB-Library 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;	(1)
	DBPROCESS *dbproc;	(2)
	RETCODE erc;		(3)
	
	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);
	}
	

111Prolog Notes

(1)
LOGINREC is a structure that describes the client. It's passed to the server at connect time.
(2)
DBPROCESS is a structure that describes the connection. It is returned by dbopen().
(3)
RETCODE is the most common return code type for DB-Library functions.

Initialize

Initialize the library. Create and populate a LOGINREC record.

Example 11-4. Sample Code: DB-Library Initialize

	
	(1)
	if (dbinit() == FAIL) {
	fprintf(stderr, "%s:%d: dbinit() failed\n",
	options.appname, __LINE__);
	exit(1);
	}
	
	(2)
	dberrhandle(err_handler);
	dbmsghandle(msg_handler);
	
	(3)
	if ((login = dblogin()) == NULL) {
	fprintf(stderr, "%s:%d: unable to allocate login structure\n",
	options.appname, __LINE__);
	exit(1);
	}
	
	(4)
	DBSETLUSER(login, options.username);
	DBSETLPWD(login, options.password);
													
	

112Initialization Notes

(1)
Always make dbinit() the first db-lib call.
(2)
Install the error- and mesage-handlers right away. They're explained in more detail later.
(3)
dblogin() almost never fails. But check! No point in trying to use a null pointer.
(4)
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.

Example 11-5. Sample Code: DB-Library 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

DB-Library 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.

Example 11-6. Sample Code: DB-Library 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);	(1)
							
	}
	}
	printf("\n");
	
	if ((erc = dbsqlexec(dbproc)) == FAIL) {
	fprintf(stderr, "%s:%d: dbsqlexec() failed\n", options.appname, __LINE__);
	exit(1);		(2)
	
	}
	

113Initialization Notes

(1)
Failure at this juncture is rare. The library is merely allocating memory to hold the SQL.
(2)
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. Broadly, that entails providing buffers to DB-Library to fill, and iterating 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.

Table 11-4. Kinds of Results

TypeMetadataRegular RowsCompute RowsReturn StatusExample SQL
NoneNoneNoneNoneNoneAny INSERT, UPDATE, or DELETE statement
Empty1 setNone0 or moreNoneSELECT 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 moreEXEC 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 a SELECT statement that produced no rows).

Table 11-5. Result-fetching functions

FunctionFetchesReturnsComment
dbresults()metadataSUCCEED, 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.
nextrow()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. DB-Library 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 DB-Library to fill and indicate which datatype the buffer is meant to hold. [1]

It may be well to pause here to observe the three ways a datatype is described in a DB-Library program.

db-lib 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 more convenient to have DB-Library 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

Table 11-6. Data-fetching functions

TypeRegular rowsCompute rowsReturn statusOUTPUT 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.

Table 11-7. Putting it all together

Step Function Once Per Many Times Per
Query dbsqlexec() QueryProgram
Fetch metadata dbresults() SQL statement Query
Prepare variables dbbind() ColumnStatement
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

ImportantFetch All Rows!
 

Now, at last, some sample code that fetches data. In the interest of simplicity, we don't bind anything except regular rows.

Example 11-7. Sample Code: DB-Library Fetch Results

	while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) {
	struct COL 						(1)
	{
	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);		(2)
	pcol->type = dbcoltype(dbproc, c);
	pcol->size = dbcollen(dbproc, c);
	
	if (SYBCHAR != pcol->type) {			(3)
	pcol->size = dbwillconvert(pcol->type, SYBCHAR);
	}
	
	printf("%*s ", pcol->size, pcol->name);
	
	if ((pcol->buffer = calloc(1, pcol->size + 1)) == NULL){
	perror(NULL);
	exit(1);
	}
	
	erc = dbbind(dbproc, c, NTBSTRINGBIND,	(4)
	pcol->size+1, (BYTE*)pcol->buffer);
	if (erc == FAIL) {
	fprintf(stderr, "%s:%d: dbbind(%d) failed\n",
	options.appname, __LINE__, c);
	exit(1);
	}
	erc = dbnullbind(dbproc, c, &pcol->status);	(5)
	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){	(6)
	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: 					(7)
	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);
	}
	

114Data-fetching Notes

(1)
As soon as dbresults() reports SUCCESS, the row's metadata are available.
(2)
DB-Library columns start with 1.
(3)
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, which FreeTDS's dbwillconvert() returns (for fixed-length datatypes). [2]
(4)
NTBSTRINGBIND null-terminates the character array for us. "NTB" might perhaps stand for "null terminating byte".
(5)
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.
(6)
Each time dbnextrow() returns REG_ROW, it has filled the bound buffers with the converted values for the row.
(7)
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 DB-Library), and thinking about how to handle different types of errors.

Kinds of Errors

Messages

Messages arise because the server has something to say. [3]. 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 DB-Library 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 DB-Library use your handler, pass its name to the appropriate dberrhandle() or dbmsghandle() function immediately after calling dbinit().

Example 11-8. Sample Code: DB-Library Error and Message handlers

	int
	msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity,
	char *msgtext, char *srvname, char *procname, int line)
	{									(1)
	enum {changed_database = 5701, changed_language = 5703 };	(2)
	
	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) {						(3)
	fprintf(stderr, "%s: error: severity %d > 10, exiting\n",
	options.appname, severity);
	exit(severity);
	}
	
	return 0;							(4)
	}
	
	int
	err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr,
	char *dberrstr, char *oserrstr)
	{									(5)
	if (dberr) {							(6)
	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;						(7)
	}
	

Note

Handlers are always called before the function that engendered them returns control to the application.

115Error Handling Notes

(1)
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(). [4]
(2)
Some messages don't convey much, as though the server gets lonely sometimes. You're not obliged to print every one.
(3)
Severities are defined in the server documentation, and can be set by the T-SQL RAISERROR statement.
(4)
Message handlers always and only ever return zero.
(5)
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(). [5]
(6)
Some messages are so severe they provoke DB-Library 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.
(7)
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 DB-Library keeps retrying timeout errors. See the documentation for details.

Note

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 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.

  1. Set a global variable.

  2. Use setuserdata() and getuserdata().

Tip

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 DB-Library. You can put a throw() in your handler and it will compile. But when it executes, it's going to rip through DB-Library'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 DB-Library tour. The almost 300 lines of C above constitute program with these features:

Sample Code features

  • Accepts command-line parameters and SQL.

  • Checks for errors and server messages.

  • Processes any number of results..

  • Prints results in columns of suitable widths.

There are things it doesn't do, in the name of simplicity.

Sample Code nonfeatures

  • No BCP (bulk copy) mode

  • No RPC (remote procedure call) mode, preventing it from retrieving output parameters.

Your humble author hopes you found it worthwhile. Happy Hacking.

Notes

[1]

This is the sort of thing C++'s type system does so much better

[2]

For IMAGE data, we need to multiply by 2, because dbbind() will convert each byte to a hexadecimal pair. The example program will report an error with IMAGE data.

[3]

Just one more way in which databases differ from files.

[4]

Back in K&R days, that wasn't such a problem. But there were other problems, some much worse.

[5]

If that advice sounds familiar, it's because it bears repeating.

freetds-0.91/doc/doc/freetds-0.91/userguide/acknowledgments.htm100664 001750 000144 00000010615 11623070655 0020035 Acknowledgments

Chapter 12. Acknowledgments

Table of Contents
Codesmyths
Contributors

Codesmyths

Many people, too many to mention, have contributed patches and located bugs. The primary names are:

Brian Bruns (brian@bruns.org) Arno Pedusaar (psaar@fenar.ee)
Started this crazy thingDonated his TDS4.2 code to the cause
Mihai Ibanescu (misa@dntis.ro) Mark Schaal (mark@champ.tstonramp.com)
GNUified the packetCleaned up message handling, more datatype support, bug fixes
Gregg Jensen (greggj@savvis.com) Craig Spannring (cts@internetcds.com)
Message handlers and extra datatype support and some sybperl stuffWrote the JDBC and DBI drivers
James K. Lowden (jklowden@schemamania.org) Bill Thompson (thompbil@exchange.uk.ml.com)
Wrote most of the documentation. Helped out here and there. Completer of the DB-Library bcp API and author of freebcp.
Steve Murphree (smurph@smcomp.com) Frediano Ziglio (freddy77@gmail.com)
Added more ODBC functionality. Extended the ODBC library, and added many, many fixes and enhancements to libtds.

freetds-0.91/doc/doc/freetds-0.91/userguide/contributors.htm100664 001750 000144 00000004741 11623070655 0017410 Contributors

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

freetds-0.91/doc/doc/freetds-0.91/userguide/linker.how.htm100664 001750 000144 00000033165 11623070656 0016736 How Dost Thy Linker Link?

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

  1. Object modules to be linked, including libraries

  2. Locations of libraries

  3. 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:

Example A-1. 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:

Example A-2. 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 DB-Library, 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

Note

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 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.

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/rtl.define.library.htm100664 001750 000144 00000020671 11623070655 0020350 What is a C library?

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)[1].

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 name[2]. 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.

NoteWhat about .h 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:

  1. 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.

  2. A new program could use the old library, passing an address that the library interprets as an integer. Hillarity ensues.

  3. 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.

Notes

[1]

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.

[2]

Or, depending on how you look at it, the name of each address.

freetds-0.91/doc/doc/freetds-0.91/userguide/linker.library.check.htm100664 001750 000144 00000012473 11623070655 0020657 Checking if a Library Provides a Function

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 implementation[1], and focus on the last five in this abbreviated list.

Some unresolved functions in bsqldb.o

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 DB-Library:

$ 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.

Notes

[1]

Why 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/linker.conclusion.htm100664 001750 000144 00000005402 11623070656 0020306 Keep in Mind

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/interfacesfile.htm100664 001750 000144 00000007213 11623070656 0017634 The interfaces File

Appendix B. The interfaces 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 freetds.conf. Note also that make install will install a skeleton freetds.conf, which you'll have to remove if you want to use interfaces instead.

freetds-0.91/doc/doc/freetds-0.91/userguide/interfaceslocation.htm100664 001750 000144 00000004715 11623070656 0020531 Where it goes

Where it goes

Anywhere. The SYBASE environment variable must contain the location of interfaces; that is how FreeTDS will find it.

freetds-0.91/doc/doc/freetds-0.91/userguide/interfacespurpose.htm100664 001750 000144 00000011527 11623070656 0020415 What it does

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.

Tip
freetds-0.91/doc/doc/freetds-0.91/userguide/interfacesformat.htm100664 001750 000144 00000011333 11623070656 0020203 What it looks like

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.

Example B-1. An interfaces 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.

Table B-1. Services Line

NameExampleMeaning
servicequeryThe only supported service
transporttcpThe transport protocol to use. Only tcp is supported by FreeTDS.
physical4.2Historically 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/IP127.0.0.1The hostname or IP address where the SQL Server resides.
port4000The 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/aboutunicode.htm100664 001750 000144 00000015302 11623070656 0017330 About Unicode, UCS-2, and UTF-8

Appendix C. 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.

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 [1] 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 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.

Notes

[1]

czyborra.com is offline at the time of this writing (December 2003). It contained good information, so it's still included here, in case it comes back to life.

freetds-0.91/doc/doc/freetds-0.91/userguide/iso8859.htm100664 001750 000144 00000012474 11623070656 0016006 ISO 8859: What everyone would like to forget

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.)

freetds-0.91/doc/doc/freetds-0.91/userguide/unicode.htm100664 001750 000144 00000010106 11623070656 0016272 Unicode: East meets West

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 is the system employed by Microsoft NT-based systems. Microsoft database servers store UCS-2 strings in nchar and nvarchar datatypes. Microsoft also designed version 7.0 (and up) of the TDS protocol around UCS-2: all metadata (table names and such) are encoded according to UCS-2 on the wire.

freetds-0.91/doc/doc/freetds-0.91/userguide/unicodegoodbad.htm100664 001750 000144 00000011762 11623070656 0017623 Unicode's Pluses and Minuses

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/unicodeutf.htm100664 001750 000144 00000012503 11623070656 0017014 Unicode Transformation Format: UTF-8

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.

Example C-1. "HELLO" 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/unicodefreetds.htm100664 001750 000144 00000011734 11623070656 0017657 Unicode and FreeTDS

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 freetds.conf. 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.

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl.htm100664 001750 000144 00000010722 11623070656 0015564 GNU Free Documentation License

Appendix D. GNU Free Documentation License

Version 1.1, March 2000

Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-1.htm100664 001750 000144 00000012656 11623070656 0015732 APPLICABILITY AND DEFINITIONS

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-2.htm100664 001750 000144 00000005625 11623070656 0015731 VERBATIM COPYING

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-3.htm100664 001750 000144 00000010264 11623070656 0015725 COPYING IN QUANTITY

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-4.htm100664 001750 000144 00000016404 11623070656 0015730 MODIFICATIONS

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:

  1. 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.

  2. 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).

  3. State on the Title page the name of the publisher of the Modified Version, as the publisher.

  4. Preserve all the copyright notices of the Document.

  5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.

  6. 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.

  7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.

  8. Include an unaltered copy of this License.

  9. 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.

  10. 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.

  11. 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.

  12. 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.

  13. Delete any section entitled "Endorsements". Such a section may not be included in the Modified Version.

  14. 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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-5.htm100664 001750 000144 00000006572 11623070656 0015736 COMBINING DOCUMENTS

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."

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-6.htm100664 001750 000144 00000005524 11623070656 0015733 COLLECTIONS OF DOCUMENTS

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-7.htm100664 001750 000144 00000006106 11623070656 0015731 AGGREGATION WITH INDEPENDENT WORKS

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-8.htm100664 001750 000144 00000005463 11623070656 0015737 TRANSLATION

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-9.htm100664 001750 000144 00000005143 11623070656 0015733 TERMINATION

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-10.htm100664 001750 000144 00000006157 11623070656 0016011 FUTURE REVISIONS OF THIS LICENSE

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.

freetds-0.91/doc/doc/freetds-0.91/userguide/gfdl-11.htm100664 001750 000144 00000006514 11623070656 0016007 How to use this License for your documents

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:

Copyright (c) YEAR YOUR NAME. 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 the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. A copy of the license is included in the section entitled "GNU Free Documentation License".

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-0.91/doc/doc/freetds-0.91/userguide/userguide.css100664 001750 000144 00000000447 11623070657 0016650/* * $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-0.91/doc/doc/freetds-0.91/reference/search/nomatches.html100664 001750 000144 00000000715 11623073546 0020216
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/close.png100664 001750 000144 00000000421 11623073545 0017153‰PNG  IHDR ©¬w&ØIDATuQ½F@ Ü Cë5¼§Cg3(ÐÞw{#*ß—ŸÛË&9Áƒ}ßͲ,ض çy"Š"ÄqŒ<Ï‘¦©æŽišÌ8ޏ®Kß¾6 C”e‰¢(Ä;Žã/‘/¨ÂBVÑxó<»/Ú¶EUUte,"¸ïëºÂgL}ߣ®kçÓ2VçSF1 ƒs•¨1“œÇãÔ ¶ DZÆÆwÍA½$I”ûYQ[Òíú Üo×uŸkÓ*A iWY(G™/0Ï{ûAÏ,ëë)el«n]? yEÂIEND®B`‚freetds-0.91/doc/doc/freetds-0.91/reference/search/search.css100664 001750 000144 00000007403 11623073545 0017326/*---------------- Search Box */ #FSearchBox { float: left; } #MSearchBox { padding: 0px; margin: 0px; border: none; border: 1px solid #84B0C7; white-space: nowrap; -moz-border-radius: 8px; -webkit-border-top-left-radius: 8px; -webkit-border-top-right-radius: 8px; -webkit-border-bottom-left-radius: 8px; -webkit-border-bottom-right-radius: 8px; } #MSearchField { font: 9pt Arial, Verdana, sans-serif; color: #999999; background-color: #FFFFFF; font-style: normal; cursor: text; padding: 1px 1px; margin: 0px 6px 0px 0px; border: none; outline: none; vertical-align: middle; } .MSearchBoxActive #MSearchField { color: #000000; } #MSearchSelect { float : none; display : inline; background : none; font: 9pt Verdana, sans-serif; border: none; margin: 0px 0px 0px 6px; vertical-align: middle; padding: 0px 0px; } #MSearchClose { float : none; display : none; background : none; border: none; margin: 0px 4px 0px 0px; padding: 0px 0px; outline: none; } #MSearchCloseImg { vertical-align: middle; } .MSearchBoxLeft { display: block; text-align: left; float: left; margin-left: 6px; } .MSearchBoxRight { display: block; float: right; text-align: right; margin-right: 6px; } .MSearchBoxSpacer { font-size: 0px; clear: both; } .MSearchBoxRow { font-size: 0px; clear: both; } /*---------------- Search filter selection */ #MSearchSelectWindow { display: none; position: absolute; left: 0; top: 0; border: 1px solid #A0A0A0; background-color: #FAFAFA; z-index: 1; padding-top: 4px; padding-bottom: 4px; -moz-border-radius: 4px; -webkit-border-top-left-radius: 4px; -webkit-border-top-right-radius: 4px; -webkit-border-bottom-left-radius: 4px; -webkit-border-bottom-right-radius: 4px; -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); } .SelectItem { font: 8pt Arial, Verdana, sans-serif; padding-left: 2px; padding-right: 12px; border: 0px; } span.SelectionMark { margin-right: 4px; font-family: monospace; outline-style: none; text-decoration: none; } a.SelectItem { display: block; outline-style: none; color: #000000; text-decoration: none; padding-left: 6px; padding-right: 12px; } a.SelectItem:focus, a.SelectItem:active { color: #000000; outline-style: none; text-decoration: none; } a.SelectItem:hover { color: #FFFFFF; background-color: #2A50E4; outline-style: none; text-decoration: none; cursor: pointer; display: block; } /*---------------- Search results window */ iframe#MSearchResults { width: 60ex; height: 15em; } #MSearchResultsWindow { display: none; position: absolute; left: 0; top: 0; border: 1px solid #000000; background-color: #EEF3F5; } /* ----------------------------------- */ #SRIndex { clear:both; padding-bottom: 15px; } .SREntry { font-size: 10pt; padding-left: 1ex; } .SRPage .SREntry { font-size: 8pt; padding: 1px 5px; } body.SRPage { margin: 5px 2px; } .SRChildren { padding-left: 3ex; padding-bottom: .5em } .SRPage .SRChildren { display: none; } .SRSymbol { font-weight: bold; color: #153788; font-family: Arial, Verdana, sans-serif; text-decoration: none; outline: none; } a.SRScope { display: block; color: #153788; font-family: Arial, Verdana, sans-serif; text-decoration: none; outline: none; } a.SRSymbol:focus, a.SRSymbol:active, a.SRScope:focus, a.SRScope:active { text-decoration: underline; } .SRPage .SRStatus { padding: 2px 5px; font-size: 8pt; font-style: italic; } .SRResult { display: none; } freetds-0.91/doc/doc/freetds-0.91/reference/search/all_5f.html100664 001750 000144 00000045021 11623073545 0017375 freetds-0.91/doc/doc/freetds-0.91/reference/search/all_62.html100664 001750 000144 00000044451 11623073545 0017320
Loading...
bcp_prefix_len tds_column
BCP_SETL sybdb.h
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_63.html100664 001750 000144 00000024730 11623073545 0017317
Loading...
cb_t conv_result
cc_t conv_result
char_conv tds_column
column_cur_size tds_column
column_namelen tds_column
column_prec tds_column
column_scale tds_column
column_size tds_column
column_type tds_column
column_varint_size tds_column
cur_cursor tds_socket
cur_dyn tds_socket
current_results tds_socket
cursor_id tds_cursor
cursor_name tds_cursor
cursor_name_len tds_cursor
cursor_rows tds_cursor
cursors tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_64.html100664 001750 000144 00000462163 11623073545 0017326
Loading...
day tdsdaterec
dayofyear tdsdaterec
dbgetnull dblib.c
DBISAVAIL sybdb.h
DBLIBCONTEXT dblib.c
dbopen dbopen.c
dbperror dblib.c
dbrpcinit rpc.c
dbrpcparam rpc.c
dbrpcsend rpc.c
DBSETLAPP sybdb.h
DBSETLCHARSET sybdb.h
DBSETLENCRYPT sybdb.h
DBSETLHOST sybdb.h
DBSETLLABELED sybdb.h
DBSETLPWD sybdb.h
DBSETLUSER sybdb.h
DBTDS_UNKNOWN sybdb.h
dsn DSNINFO
dyns tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_65.html100664 001750 000144 00000002247 11623073545 0017320
Loading...
emulated tds_dynamic
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_66.html100664 001750 000144 00000002136 11623073545 0017316
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_68.html100664 001750 000144 00000003622 11623073545 0017321
Loading...
has_status tds_socket
hasargs tds_cursor
hour tdsdaterec
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_69.html100664 001750 000144 00000007355 11623073545 0017331
Loading...
id tds_dynamic
in_buf tds_socket
in_buf_max tds_socket
in_cancel tds_socket
in_flag tds_socket
in_len tds_socket
in_pos tds_socket
ip_addr tds_connection
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_6c.html100664 001750 000144 00000002741 11623073545 0017375
Loading...
login_timeout dblib_context
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_6d.html100664 001750 000144 00000006235 11623073545 0017400
Loading...
millisecond tdsdaterec
minute tdsdaterec
month tdsdaterec
msdblib tds_dblib_dbprocess
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_6e.html100664 001750 000144 00000007207 11623073545 0017401
Loading...
nullreps tds_dblib_dbprocess
num_id tds_dynamic
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_6f.html100664 001750 000144 00000005201 11623073545 0017372
Loading...
options tds_cursor
origdsn DSNINFO
out_buf tds_socket
out_flag tds_socket
out_pos tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_70.html100664 001750 000144 00000012756 11623073545 0017322
Loading...
param_count _hstmt
param_num _hstmt
password tds_connection
pd
port tds_connection
prepared_pos _hstmt
prev _hstmt
product_version tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_71.html100664 001750 000144 00000006146 11623073545 0017317
Loading...
quarter tdsdaterec
query_len tds_cursor
query_timeout dblib_context
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_72.html100664 001750 000144 00000012064 11623073545 0017314
Loading...
res_info tds_dynamic
resinfo dblib_buffer_row
ret_status tds_socket
row dblib_buffer_row
row_count _hstmt
row_data dblib_buffer_row
row_status _hstmt
rows_affected tds_socket
rtrim bcp.c
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_73.html100664 001750 000144 00000011755 11623073545 0017323
Loading...
s tds_socket
second tdsdaterec
server_charset tds_connection
server_name tds_connection
server_realm_name tds_connection
sizes dblib_buffer_row
status tds_cursor
stmt_list _hdbc
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_74.html100664 001750 000144 00000200516 11623073545 0017317
Loading...
tds7_crypt_pass login.c
tds_ctx dblib_context
tds_ctx_ref_count dblib_context
tds_datecrack convert.c
TDS_DEAD tds.h
tds_end tds.h
tds_get_homedir threadsafe.c
tds_get_int read.c
tds_get_locale locale.c
tds_get_n read.c
tds_iconv_alloc iconv.c
TDS_IDLE tds.h
TDS_IS_MSSQL tds.h
tds_lookup_host config.c
TDS_MS_VER tds.h
tds_ntlm_get_auth challenge.c
TDS_PENDING tds.h
tds_put_string write.c
TDS_QUERYING tds.h
tds_quote_id query.c
TDS_RCSID dblib.c
TDS_READING tds.h
tds_send_cancel query.c
tds_set_server login.c
tds_set_state util.c
tds_skip_quoted query.c
TDS_STATE tds.h
tds_submit_rpc query.c
TDS_SYB_VER tds.h
tds_timestamp_str threadsafe.c
tds_version util.c
TDSBLOB tds.h
TDSCOLUMN tds.h
TDSCURSOR tds.h
tdsdump_col log.c
tdsdump_log log.c
tdsdump_off log.c
tdsdump_on log.c
tdsdump_open log.c
TDSDYNAMIC tds.h
TDSENV tds.h
tdserror util.c
TDSVARIANT tds.h
tm_hour tds_time
tm_mday tds_time
tm_min tds_time
tm_mon tds_time
tm_ms tds_time
tm_sec tds_time
tm_year tds_time
type tds_cursor
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_75.html100664 001750 000144 00000003027 11623073545 0017316
Loading...
uad _hdbc
user_name tds_connection
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_77.html100664 001750 000144 00000003024 11623073545 0017315
Loading...
week tdsdaterec
weekday tdsdaterec
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/all_79.html100664 001750 000144 00000002236 11623073545 0017323
Loading...
year tdsdaterec
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_5f.html100664 001750 000144 00000034356 11623073545 0020273 freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_62.html100664 001750 000144 00000002650 11623073545 0020200
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_63.html100664 001750 000144 00000005300 11623073545 0020174
Loading...
cb_t conv_result
cc_t conv_result
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_64.html100664 001750 000144 00000013052 11623073545 0020200
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_66.html100664 001750 000144 00000002136 11623073545 0020203
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_6c.html100664 001750 000144 00000002132 11623073545 0020254
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_6d.html100664 001750 000144 00000003272 11623073545 0020263
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_6e.html100664 001750 000144 00000003326 11623073545 0020264
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_70.html100664 001750 000144 00000003760 11623073545 0020202
Loading...
pd
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_73.html100664 001750 000144 00000003330 11623073545 0020176
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/classes_74.html100664 001750 000144 00000043352 11623073545 0020207 freetds-0.91/doc/doc/freetds-0.91/reference/search/files_62.html100664 001750 000144 00000002126 11623073545 0017643
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/files_64.html100664 001750 000144 00000002132 11623073545 0017642
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/files_73.html100664 001750 000144 00000002132 11623073545 0017642
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/files_74.html100664 001750 000144 00000002126 11623073545 0017646
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/functions_5f.html100664 001750 000144 00000011252 11623073545 0020634
Loading...
_bcp_exec_in bcp.c
_bcp_fgets bcp.c
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/functions_62.html100664 001750 000144 00000041153 11623073545 0020554
Loading...
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/functions_64.html100664 001750 000144 00000417311 11623073545 0020561
Loading...
dbgetnull dblib.c
dbopen dbopen.c
dbperror dblib.c
dbrpcinit rpc.c
dbrpcparam rpc.c
dbrpcsend rpc.c
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/functions_72.html100664 001750 000144 00000002234 11623073545 0020552
Loading...
rtrim bcp.c
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/functions_74.html100664 001750 000144 00000072760 11623073545 0020567
Loading...
tds7_crypt_pass login.c
tds_datecrack convert.c
tds_get_homedir threadsafe.c
tds_get_int read.c
tds_get_locale locale.c
tds_get_n read.c
tds_iconv_alloc iconv.c
tds_lookup_host config.c
tds_ntlm_get_auth challenge.c
tds_put_string write.c
tds_quote_id query.c
TDS_RCSID dblib.c
tds_send_cancel query.c
tds_set_server login.c
tds_set_state util.c
tds_skip_quoted query.c
tds_submit_rpc query.c
tds_timestamp_str threadsafe.c
tds_version util.c
tdsdump_col log.c
tdsdump_log log.c
tdsdump_off log.c
tdsdump_on log.c
tdsdump_open log.c
tdserror util.c
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_62.html100664 001750 000144 00000002266 11623073545 0020516
Loading...
bcp_prefix_len tds_column
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_63.html100664 001750 000144 00000021046 11623073545 0020514
Loading...
char_conv tds_column
column_cur_size tds_column
column_namelen tds_column
column_prec tds_column
column_scale tds_column
column_size tds_column
column_type tds_column
column_varint_size tds_column
cur_cursor tds_socket
cur_dyn tds_socket
current_results tds_socket
cursor_id tds_cursor
cursor_name tds_cursor
cursor_name_len tds_cursor
cursor_rows tds_cursor
cursors tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_64.html100664 001750 000144 00000004361 11623073545 0020516
Loading...
day tdsdaterec
dayofyear tdsdaterec
dsn DSNINFO
dyns tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_65.html100664 001750 000144 00000002247 11623073545 0020520
Loading...
emulated tds_dynamic
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_68.html100664 001750 000144 00000003622 11623073545 0020521
Loading...
has_status tds_socket
hasargs tds_cursor
hour tdsdaterec
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_69.html100664 001750 000144 00000007355 11623073545 0020531
Loading...
id tds_dynamic
in_buf tds_socket
in_buf_max tds_socket
in_cancel tds_socket
in_flag tds_socket
in_len tds_socket
in_pos tds_socket
ip_addr tds_connection
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_6c.html100664 001750 000144 00000002265 11623073545 0020576
Loading...
login_timeout dblib_context
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_6d.html100664 001750 000144 00000004421 11623073545 0020573
Loading...
millisecond tdsdaterec
minute tdsdaterec
month tdsdaterec
msdblib tds_dblib_dbprocess
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_6e.html100664 001750 000144 00000005337 11623073545 0020603
Loading...
nullreps tds_dblib_dbprocess
num_id tds_dynamic
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_6f.html100664 001750 000144 00000005201 11623073545 0020572
Loading...
options tds_cursor
origdsn DSNINFO
out_buf tds_socket
out_flag tds_socket
out_pos tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_70.html100664 001750 000144 00000010444 11623073545 0020512
Loading...
param_count _hstmt
param_num _hstmt
password tds_connection
port tds_connection
prepared_pos _hstmt
prev _hstmt
product_version tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_71.html100664 001750 000144 00000006146 11623073545 0020517
Loading...
quarter tdsdaterec
query_len tds_cursor
query_timeout dblib_context
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_72.html100664 001750 000144 00000011306 11623073545 0020512
Loading...
res_info tds_dynamic
resinfo dblib_buffer_row
ret_status tds_socket
row dblib_buffer_row
row_count _hstmt
row_data dblib_buffer_row
row_status _hstmt
rows_affected tds_socket
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_73.html100664 001750 000144 00000007417 11623073545 0020523
Loading...
s tds_socket
second tdsdaterec
server_charset tds_connection
server_name tds_connection
server_realm_name tds_connection
sizes dblib_buffer_row
status tds_cursor
stmt_list _hdbc
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_74.html100664 001750 000144 00000011603 11623073545 0020514
Loading...
tds_ctx dblib_context
tds_ctx_ref_count dblib_context
tm_hour tds_time
tm_mday tds_time
tm_min tds_time
tm_mon tds_time
tm_ms tds_time
tm_sec tds_time
tm_year tds_time
type tds_cursor
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_75.html100664 001750 000144 00000003027 11623073545 0020516
Loading...
uad _hdbc
user_name tds_connection
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_77.html100664 001750 000144 00000003024 11623073546 0020516
Loading...
week tdsdaterec
weekday tdsdaterec
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/variables_79.html100664 001750 000144 00000002236 11623073546 0020524
Loading...
year tdsdaterec
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/typedefs_64.html100664 001750 000144 00000003073 11623073546 0020371
Loading...
DBLIBCONTEXT dblib.c
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/typedefs_74.html100664 001750 000144 00000011551 11623073546 0020372
Loading...
TDS_ENCODING tds.h
TDS_STATE tds.h
TDSBLOB tds.h
TDSCOLUMN tds.h
TDSCURSOR tds.h
TDSDATEREC tds.h
TDSDYNAMIC tds.h
TDSENV tds.h
TDSVARIANT tds.h
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/enums_5f.html100664 001750 000144 00000002251 11623073546 0017753
Loading...
_TDS_STATE tds.h
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/enums_74.html100664 001750 000144 00000003657 11623073546 0017706
Loading...
tds_end tds.h
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/enumvalues_74.html100664 001750 000144 00000014172 11623073546 0020735
Loading...
TDS_DEAD tds.h
TDS_IDLE tds.h
TDS_PENDING tds.h
TDS_QUERYING tds.h
TDS_READING tds.h
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/defines_62.html100664 001750 000144 00000002246 11623073546 0020162
Loading...
BCP_SETL sybdb.h
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/defines_64.html100664 001750 000144 00000027165 11623073546 0020173
Loading...
DBCMDROW sybdb.h
DBCOUNT sybdb.h
DBCURCMD sybdb.h
DBCURROW sybdb.h
DBDEAD sybdb.h
DBFIRSTROW sybdb.h
DBIORDESC sybdb.h
DBIOWDESC sybdb.h
DBISAVAIL sybdb.h
DBLASTROW sybdb.h
DBMORECMDS sybdb.h
DBROWS sybdb.h
DBROWTYPE sybdb.h
DBSETLAPP sybdb.h
DBSETLCHARSET sybdb.h
DBSETLENCRYPT sybdb.h
DBSETLHOST sybdb.h
DBSETLLABELED sybdb.h
DBSETLPWD sybdb.h
DBSETLUSER sybdb.h
DBSETLVERSION sybdb.h
DBTDS sybdb.h
DBTDS_UNKNOWN sybdb.h
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/defines_74.html100664 001750 000144 00000005253 11623073546 0020166
Loading...
TDS_IS_MSSQL tds.h
TDS_MS_VER tds.h
TDS_SYB_VER tds.h
Searching...
No Matches
freetds-0.91/doc/doc/freetds-0.91/reference/search/search.js100664 001750 000144 00000053236 11623073546 0017160// Search script generated by doxygen // Copyright (C) 2009 by Dimitri van Heesch. // The code in this file is loosly based on main.js, part of Natural Docs, // which is Copyright (C) 2003-2008 Greg Valure // Natural Docs is licensed under the GPL. var indexSectionsWithContent = { 0: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010011111011001111111111010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 1: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010011101000001110100110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 2: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 3: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010010100000000000001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 4: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110011001111111111010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 5: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 6: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 7: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 8: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }; var indexSectionNames = { 0: "all", 1: "classes", 2: "files", 3: "functions", 4: "variables", 5: "typedefs", 6: "enums", 7: "enumvalues", 8: "defines" }; function 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 hexCode; if (code<16) { hexCode="0"+code.toString(16); } else { hexCode=code.toString(16); } var resultsPage; var resultsPageWithSearch; var hasResultsPage; if (indexSectionsWithContent[this.searchIndex].charAt(code) == '1') { 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.href = 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) + domSearchBox.offsetWidth; var top = getYPos(domSearchBox) + 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; } } freetds-0.91/doc/doc/freetds-0.91/reference/search/search.png100664 001750 000144 00000001017 11623073545 0017315‰PNG  IHDR™zÈLÖIDAT(’»®AQ†Ïf "D#J·Ð qI¼‚Â+ Ö)tBëDACE'H‘QºB!‘—󱜗“3ÅÚ³fþÿŸY3[º^¯_w»\.ÒÝÄõ?§¬0;N¿ßŸN§DÜn·ßï‡ÃKH§Ó‰zÕjµ\.ŸÏgêCP©Tjµ:‘HÄãq²Ÿ$dp­V«T* †P(äõz‡Ãv»MÐb±D£ÑdÝn—ú‘H„:Z­–RN§ÑZ­FŠæñßòU l2™pRÖh4êõzN‡ÃU¤ÞÒDP!ÞIMY~Ì#‚6ŠÅâo•T*ÅoýÐ$g¯×CHApÅw¹\œà@+Ùd2)Fs#û|>Îf³Y©TV«Õr¹Äi4Ù™˜6èt:M¦ÀãKtµÛíØS½^§m&ÊÎ!¥l6[.—3™L±Á` 0¹ªóù<»Ýn6›A#ßãñ°¡ívKãñ8 2ÐV«õ¦ñc’x uöûýáp5 Š›Í¦P(¬×k‡Ã‘ÍfYÁëñ½µ-^… ¦\ ¢µX,࣒ÉdÀ3Ypÿ)G þ|>ŸÍf±XŒ_à öhÜSB?̵¿þg2Ðß ¿¶ðVú!6ÓMæIEND®B`‚freetds-0.91/doc/doc/freetds-0.91/reference/a00002.html100664 001750 000144 00000012170 11623073550 0015563 FreeTDS API: _cs_blkdesc Struct Reference

_cs_blkdesc Struct Reference

List of all members.

Public Attributes

TDSBCPINFO bcpinfo
CS_CONNECTIONcon

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00003.html100664 001750 000144 00000017002 11623073550 0015563 FreeTDS API: _cs_clientmsg Struct Reference

_cs_clientmsg Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00004.html100664 001750 000144 00000026325 11623073550 0015574 FreeTDS API: _cs_command Struct Reference

_cs_command Struct Reference

List of all members.

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
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:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00005.html100664 001750 000144 00000012237 11623073550 0015572 FreeTDS API: _cs_command_list Struct Reference

_cs_command_list Struct Reference

List of all members.

Public Attributes

struct _cs_commandcmd
struct _cs_command_listnext

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00006.html100664 001750 000144 00000011421 11623073550 0015565 FreeTDS API: _cs_config Struct Reference

_cs_config Struct Reference

List of all members.

Public Attributes

short cs_expose_formats

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00007.html100664 001750 000144 00000017763 11623073550 0015605 FreeTDS API: _cs_connection Struct Reference

_cs_connection Struct Reference

List of all members.

Public Attributes

CS_CLIENTMSG_FUNC _clientmsg_cb
CS_SERVERMSG_FUNC _servermsg_cb
CS_COMMAND_LISTcmds
CS_CONTEXTctx
CS_DYNAMIC_LISTdynlist
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:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00008.html100664 001750 000144 00000023053 11623073550 0015573 FreeTDS API: _cs_context Struct Reference

_cs_context Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00009.html100664 001750 000144 00000017310 11623073550 0015573 FreeTDS API: _cs_datafmt Struct Reference

_cs_datafmt Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00010.html100664 001750 000144 00000016621 11623073550 0015567 FreeTDS API: _cs_daterec Struct Reference

_cs_daterec Struct Reference

List of all members.

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 datesecond
CS_INT datetzone
CS_INT dateyear

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00011.html100664 001750 000144 00000012054 11623073550 0015564 FreeTDS API: _cs_datetime Struct Reference

_cs_datetime Struct Reference

List of all members.

Public Attributes

CS_INT dtdays
CS_INT dttime

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00012.html100664 001750 000144 00000012065 11623073550 0015567 FreeTDS API: _cs_datetime4 Struct Reference

_cs_datetime4 Struct Reference

List of all members.

Public Attributes

CS_USHORT days
CS_USHORT minutes

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00013.html100664 001750 000144 00000013313 11623073550 0015565 FreeTDS API: _cs_dynamic Struct Reference

_cs_dynamic Struct Reference

List of all members.

Public Attributes

char * id
struct _cs_dynamicnext
CS_DYNAMIC_PARAMparam_list
char * stmt

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00014.html100664 001750 000144 00000020545 11623073550 0015573 FreeTDS API: _cs_iodesc Struct Reference

_cs_iodesc Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00015.html100664 001750 000144 00000013154 11623073550 0015572 FreeTDS API: _cs_locale Struct Reference

_cs_locale Struct Reference

List of all members.

Public Attributes

char * charset
char * collate
char * language
char * time

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00016.html100664 001750 000144 00000012040 11623073550 0015564 FreeTDS API: _cs_money Struct Reference

_cs_money Struct Reference

List of all members.

Public Attributes

CS_INT mnyhigh
CS_UINT mnylow

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00017.html100664 001750 000144 00000011372 11623073550 0015574 FreeTDS API: _cs_money4 Struct Reference

_cs_money4 Struct Reference

List of all members.

Public Attributes

CS_INT mny4

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00018.html100664 001750 000144 00000012602 11623073550 0015572 FreeTDS API: _cs_numeric Struct Reference

_cs_numeric Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00019.html100664 001750 000144 00000014016 11623073550 0015574 FreeTDS API: _cs_objdata Struct Reference

_cs_objdata Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/cspublic.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00020.html100664 001750 000144 00000016665 11623073550 0015600 FreeTDS API: _cs_objname Struct Reference

_cs_objname Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/cspublic.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00021.html100664 001750 000144 00000020377 11623073550 0015574 FreeTDS API: _cs_param Struct Reference

_cs_param Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00022.html100664 001750 000144 00000020553 11623073550 0015571 FreeTDS API: _cs_servermsg Struct Reference

_cs_servermsg Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00023.html100664 001750 000144 00000012072 11623073550 0015567 FreeTDS API: _cs_varbinary Struct Reference

_cs_varbinary Struct Reference

List of all members.

Public Attributes

CS_CHAR array [256]
CS_SMALLINT len

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00024.html100664 001750 000144 00000012054 11623073550 0015570 FreeTDS API: _cs_varchar Struct Reference

_cs_varchar Struct Reference

List of all members.

Public Attributes

CS_SMALLINT len
CS_CHAR str [256]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/cstypes.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00025.html100664 001750 000144 00000012633 11623073550 0015574 FreeTDS API: _csremote_proc Struct Reference

_csremote_proc Struct Reference

List of all members.

Public Attributes

char * name
CS_SMALLINT options
CSREMOTE_PROC_PARAMparam_list

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00026.html100664 001750 000144 00000011416 11623073550 0015573 FreeTDS API: _ct_colinfo Struct Reference

_ct_colinfo Struct Reference

List of all members.

Public Attributes

TDS_SMALLINT * indicator

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00027.html100664 001750 000144 00000013352 11623073550 0015575 FreeTDS API: _dblib_error_message Struct Reference

_dblib_error_message Struct Reference
[Internals]

List of all members.

Public Attributes

DBINT msgno
char * msgtext
int severity

Detailed Description

For internal use only.

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:
  • /home/jklowden/releases/freetds-0.91/src/dblib/dblib.c
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00028.html100664 001750 000144 00000013364 11623073550 0015601 FreeTDS API: _DBREMOTE_PROC Struct Reference

_DBREMOTE_PROC Struct Reference

List of all members.

Public Attributes

char * name
struct _DBREMOTE_PROCnext
DBSMALLINT options
DBREMOTE_PROC_PARAMparam_list

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00029.html100664 001750 000144 00000015141 11623073550 0015575 FreeTDS API: _DBREMOTE_PROC_PARAM Struct Reference

_DBREMOTE_PROC_PARAM Struct Reference

List of all members.

Public Attributes

DBINT datalen
DBINT maxlen
char * name
struct _DBREMOTE_PROC_PARAMnext
BYTE status
int type
BYTE * value

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00030.html100664 001750 000144 00000015256 11623073550 0015574 FreeTDS API: _dheader Struct Reference

_dheader Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00031.html100664 001750 000144 00000036675 11623073550 0015605 FreeTDS API: _drecord Struct Reference

_drecord Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00032.html100664 001750 000144 00000022467 11623073550 0015600 FreeTDS API: _hcattr Struct Reference

_hcattr Struct Reference

List of all members.

Public Attributes

SQLUINTEGER access_mode
SQLUINTEGER async_enable
SQLUINTEGER auto_ipd
SQLUINTEGER autocommit
SQLUINTEGER connection_dead
SQLUINTEGER connection_timeout
DSTR current_catalog
SQLUINTEGER cursor_type
SQLUINTEGER login_timeout
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:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00033.html100664 001750 000144 00000012071 11623073550 0015567 FreeTDS API: _hchk Struct Reference

_hchk Struct Reference

List of all members.

Public Attributes

struct _sql_errors errs
SQLSMALLINT htype

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00034.html100664 001750 000144 00000023111 11623073550 0015565 FreeTDS API: _hdbc Struct Reference

_hdbc Struct Reference

List of all members.

Public Attributes

struct _hcattr attr
struct _hstmtcurrent_statement
 Statement executing.
unsigned int cursor_support
 <>0 if server handle cursors
TDS_INT default_query_timeout
DSTR dsn
struct _henvenv
struct _sql_errors errs
SQLSMALLINT htype
DSTR server
struct _hstmtstmt_list
 list of all statements allocated from this connection
TDSSOCKETtds_socket
TDS_DESCuad [TDS_MAX_APP_DESC]
 descriptors associated to connection

Member Data Documentation

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:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00035.html100664 001750 000144 00000014432 11623073550 0015574 FreeTDS API: _hdesc Struct Reference

_hdesc Struct Reference

List of all members.

Public Attributes

struct _sql_errors errs
struct _dheader header
SQLSMALLINT htype
SQLHANDLE parent
struct _drecordrecords
int type

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00036.html100664 001750 000144 00000013227 11623073550 0015576 FreeTDS API: _heattr Struct Reference

_heattr Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00037.html100664 001750 000144 00000013315 11623073551 0015576 FreeTDS API: _henv Struct Reference

_henv Struct Reference

List of all members.

Public Attributes

struct _heattr attr
struct _sql_errors errs
SQLSMALLINT htype
TDSCONTEXTtds_ctx

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00038.html100664 001750 000144 00000023042 11623073551 0015575 FreeTDS API: _hsattr Struct Reference

_hsattr Struct Reference

List of all members.

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
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:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00039.html100664 001750 000144 00000040310 11623073551 0015573 FreeTDS API: _hstmt Struct Reference

_hstmt Struct Reference

List of all members.

Public Attributes

TDS_DESCapd
TDS_DESCard
struct _hsattr attr
unsigned char cancel_sent
unsigned int curr_param_row
TDSCURSORcursor
DSTR cursor_name
struct _hdbcdbc
TDSDYNAMICdyn
struct _sql_errors errs
SQLSMALLINT htype
TDS_DESCipd
TDS_DESCird
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
char * prepared_query
unsigned prepared_query_is_func:1
unsigned prepared_query_is_rpc:1
struct _hstmtprev
 previous in list
char * 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

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00040.html100664 001750 000144 00000012124 11623073551 0015565 FreeTDS API: _null_representation Struct Reference

_null_representation Struct Reference

List of all members.

Public Attributes

const BYTE * bindval
size_t len

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00041.html100664 001750 000144 00000021147 11623073551 0015573 FreeTDS API: _options Struct Reference

_options Struct Reference

List of all members.

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
char * servername
FILE * verbose

The documentation for this struct was generated from the following files:
  • /home/jklowden/releases/freetds-0.91/src/apps/bsqldb.c
  • /home/jklowden/releases/freetds-0.91/src/apps/bsqlodbc.c
  • /home/jklowden/releases/freetds-0.91/src/apps/defncopy.c
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00042.html100664 001750 000144 00000012004 11623073551 0015564 FreeTDS API: _procedure Struct Reference

_procedure Struct Reference

List of all members.

Public Attributes

char name [512]
char owner [512]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/apps/defncopy.c
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00043.html100664 001750 000144 00000014742 11623073551 0015600 FreeTDS API: _sql_error Struct Reference

_sql_error Struct Reference

List of all members.

Public Attributes

int linenum
const char * msg
int msgstate
TDS_UINT native
char * server
char state2 [6]
char state3 [6]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00044.html100664 001750 000144 00000013245 11623073551 0015576 FreeTDS API: _sql_errors Struct Reference

_sql_errors Struct Reference

List of all members.

Public Attributes

struct _sql_errorerrs
SQLRETURN lastrc
int num_errors
char ranked

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00045.html100664 001750 000144 00000016300 11623073551 0015572 FreeTDS API: BCP_HOSTCOLINFO Struct Reference

BCP_HOSTCOLINFO Struct Reference

List of all members.

Public Attributes

BCPCOLDATAbcp_column_data
int column_error
DBINT column_len
int 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:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00046.html100664 001750 000144 00000016334 11623073551 0015602 FreeTDS API: BCP_HOSTFILEINFO Struct Reference

BCP_HOSTFILEINFO Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00047.html100664 001750 000144 00000012274 11623073551 0015602 FreeTDS API: conv_result::cb_t Struct Reference

conv_result::cb_t Struct Reference

List of all members.

Public Attributes

TDS_CHAR * ib
TDS_UINT len

The documentation for this struct was generated from the following file:
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00048.html100664 001750 000144 00000012272 11623073551 0015601 FreeTDS API: conv_result::cc_t Struct Reference

conv_result::cc_t Struct Reference

List of all members.

Public Attributes

TDS_CHAR * c
TDS_UINT len

The documentation for this struct was generated from the following file:
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00049.html100664 001750 000144 00000023240 11623073551 0015577 FreeTDS API: conv_result Union Reference

conv_result Union Reference

List of all members.

Classes

struct  cb_t
struct  cc_t

Public Attributes

TDS_INT8 bi
TDS_CHAR * c
struct conv_result::cb_t cb
struct conv_result::cc_t cc
TDS_DATETIME dt
TDS_DATETIME4 dt4
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_UNIQUE u

The documentation for this union was generated from the following file:
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00050.html100664 001750 000144 00000012173 11623073551 0015572 FreeTDS API: cs_diag_msg Struct Reference

cs_diag_msg Struct Reference

List of all members.

Public Attributes

CS_CLIENTMSGmsg
struct cs_diag_msgnext

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00051.html100664 001750 000144 00000012261 11623073551 0015571 FreeTDS API: cs_diag_msg_client Struct Reference

cs_diag_msg_client Struct Reference

List of all members.

Public Attributes

CS_CLIENTMSGclientmsg
struct cs_diag_msg_clientnext

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00052.html100664 001750 000144 00000012237 11623073551 0015575 FreeTDS API: cs_diag_msg_svr Struct Reference

cs_diag_msg_svr Struct Reference

List of all members.

Public Attributes

struct cs_diag_msg_svrnext
CS_SERVERMSGservermsg

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/ctlib.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00053.html100664 001750 000144 00000012357 11623073551 0015601 FreeTDS API: DATA Struct Reference

DATA Struct Reference

List of all members.

Public Attributes

char * buffer
SQLLEN len
int status

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/apps/bsqlodbc.c
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00054.html100664 001750 000144 00000021014 11623073551 0015570 FreeTDS API: DBCOL Struct Reference

DBCOL Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00055.html100664 001750 000144 00000012036 11623073551 0015575 FreeTDS API: DBDATETIME Struct Reference

DBDATETIME Struct Reference

List of all members.

Public Attributes

DBINT dtdays
DBINT dttime

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00056.html100664 001750 000144 00000012055 11623073551 0015577 FreeTDS API: DBDATETIME4 Struct Reference

DBDATETIME4 Struct Reference

List of all members.

Public Attributes

DBUSMALLINT days
DBUSMALLINT minutes

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00057.html100664 001750 000144 00000014543 11623073551 0015604 FreeTDS API: dblib_buffer_row Struct Reference

dblib_buffer_row Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/src/dblib/buffering.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00058.html100664 001750 000144 00000021161 11623073551 0015577 FreeTDS API: dblib_context Struct Reference

dblib_context Struct Reference

List of all members.

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

For internal use only.

Remarks:
A db-lib connection has an implicit TDS context.

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/dblib/dblib.c
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00059.html100664 001750 000144 00000012052 11623073551 0015577 FreeTDS API: DBMONEY Struct Reference

DBMONEY Struct Reference

List of all members.

Public Attributes

DBINT mnyhigh
unsigned tds_sysdep_int32_type mnylow

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00060.html100664 001750 000144 00000011357 11623073552 0015577 FreeTDS API: DBMONEY4 Struct Reference

DBMONEY4 Struct Reference

List of all members.

Public Attributes

DBINT mny4

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00061.html100664 001750 000144 00000012536 11623073552 0015600 FreeTDS API: DBNUMERIC Struct Reference

DBNUMERIC Struct Reference

List of all members.

Public Attributes

unsigned char array [33]
unsigned char precision
unsigned char scale

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00062.html100664 001750 000144 00000012564 11623073552 0015602 FreeTDS API: dboption Struct Reference

dboption Struct Reference

List of all members.

Public Attributes

DBBOOL factive
DBSTRINGparam
char text [MAXOPTTEXT]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00063.html100664 001750 000144 00000012561 11623073552 0015600 FreeTDS API: dbstring Struct Reference

dbstring Struct Reference

List of all members.

Public Attributes

struct dbstringstrnext
BYTE * strtext
DBINT strtotlen

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00064.html100664 001750 000144 00000012042 11623073552 0015573 FreeTDS API: dbtypeinfo Struct Reference

dbtypeinfo Struct Reference

List of all members.

Public Attributes

DBINT precision
DBINT scale

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00065.html100664 001750 000144 00000012051 11623073552 0015574 FreeTDS API: DBVARYBIN Struct Reference

DBVARYBIN Struct Reference

List of all members.

Public Attributes

unsigned char array [256]
DBSMALLINT len

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00066.html100664 001750 000144 00000012041 11623073552 0015574 FreeTDS API: DBVARYCHAR Struct Reference

DBVARYCHAR Struct Reference

List of all members.

Public Attributes

DBSMALLINT len
char str [256]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00067.html100664 001750 000144 00000013240 11623073552 0015577 FreeTDS API: des_key Struct Reference

des_key Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/des.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00068.html100664 001750 000144 00000013563 11623073552 0015610 FreeTDS API: DSNINFO Struct Reference

DSNINFO Struct Reference

List of all members.

Public Attributes

TDSCONNECTIONconnection
 everything else
DSTR dsn
 edited name of the data source
DSTR origdsn
 original name of the data source

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/win32/winsetup.c
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00069.html100664 001750 000144 00000013114 11623073552 0015601 FreeTDS API: func_info Struct Reference

func_info Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/src/odbc/native.c
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00070.html100664 001750 000144 00000014272 11623073552 0015577 FreeTDS API: LOGINREC Struct Reference

LOGINREC Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/src/apps/bsqlodbc.c
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00071.html100664 001750 000144 00000012522 11623073552 0015574 FreeTDS API: MD4Context Struct Reference

MD4Context Struct Reference

List of all members.

Public Attributes

TDS_UINT bits [2]
TDS_UINT buf [4]
unsigned char in [64]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/md4.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00072.html100664 001750 000144 00000012522 11623073552 0015575 FreeTDS API: MD5Context Struct Reference

MD5Context Struct Reference

List of all members.

Public Attributes

TDS_UINT bits [2]
TDS_UINT buf [4]
unsigned char in [64]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/md5.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00073.html100664 001750 000144 00000016475 11623073552 0015611 FreeTDS API: METADATA Struct Reference

METADATA Struct Reference

List of all members.

Public Attributes

char * format_string
char * name
SQLINTEGER nchars
SQLULEN size
int size
const char * source
SQLSMALLINT type
int type
SQLULEN width
int width

The documentation for this struct was generated from the following files:
  • /home/jklowden/releases/freetds-0.91/src/apps/bsqldb.c
  • /home/jklowden/releases/freetds-0.91/src/apps/bsqlodbc.c
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00074.html100664 001750 000144 00000012142 11623073552 0015575 FreeTDS API: namelist Struct Reference

namelist Struct Reference
[Results processing]

List of all members.

Public Attributes

char * name
struct namelistnext

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/tds/token.c
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00075.html100664 001750 000144 00000015762 11623073552 0015611 FreeTDS API: names_blob_prefix_t Struct Reference

names_blob_prefix_t Struct Reference
[Authentication]

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/src/tds/challenge.c
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00076.html100664 001750 000144 00000011756 11623073552 0015611 FreeTDS API: native_info Struct Reference

native_info Struct Reference

List of all members.

Public Attributes

char * d
int length

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/odbc/native.c
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00077.html100664 001750 000144 00000050477 11623073552 0015615 FreeTDS API: pd Struct Reference

pd Struct Reference

List of all members.

Public Attributes

int Aflag
int aflag
int batchsize
int bflag
int cflag
char * charset
char dbdirection [10]
char * dbobject
char * ddb
char * ddbobject
int Dflag
DBINT direction
char * dpass
char * dserver
char * duser
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 * sdb
char * sdbobject
char * server
int Sflag
char * spass
char * sserver
char * suser
int textsize
int Tflag
int tflag
int Uflag
char * user
int vflag

The documentation for this struct was generated from the following files:
  • /home/jklowden/releases/freetds-0.91/src/apps/datacopy.c
  • /home/jklowden/releases/freetds-0.91/src/apps/freebcp.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00078.html100664 001750 000144 00000012444 11623073552 0015606 FreeTDS API: pollfd Struct Reference

pollfd Struct Reference

List of all members.

Public Attributes

short events
int fd
short revents

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/fakepoll.h
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00079.html100664 001750 000144 00000013565 11623073552 0015614 FreeTDS API: ProfileParam Struct Reference

ProfileParam Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/src/odbc/connectparams.c
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00080.html100664 001750 000144 00000013353 11623073553 0015600 FreeTDS API: ptw32_mcs_node_t_ Struct Reference

ptw32_mcs_node_t_ Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/src/tds/ptw32_MCS_lock.c
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00081.html100664 001750 000144 00000012003 11623073553 0015570 FreeTDS API: s_SqlMsgMap Struct Reference

s_SqlMsgMap Struct Reference

List of all members.

Public Attributes

const char * msg
char sqlstate [6]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/odbc/error.c
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00082.html100664 001750 000144 00000011757 11623073553 0015610 FreeTDS API: s_v3to2map Struct Reference

s_v3to2map Struct Reference

List of all members.

Public Attributes

char v2 [6]
char v3 [6]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/odbc/error.c
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00083.html100664 001750 000144 00000012120 11623073553 0015572 FreeTDS API: string_linked_list Struct Reference

string_linked_list Struct Reference

List of all members.

Public Attributes

struct string_linked_listnext
char * str

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/tds/vstrbuild.c
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00084.html100664 001750 000144 00000014426 11623073553 0015606 FreeTDS API: tag_DBPROC_ROWBUF Struct Reference

tag_DBPROC_ROWBUF Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00085.html100664 001750 000144 00000013173 11623073553 0015605 FreeTDS API: TDS8_COLLATION Struct Reference

TDS8_COLLATION Struct Reference

TDS 8.0 collation informations. More...

#include <tds.h>

List of all members.

Public Attributes

TDS_UCHAR charset_id
TDS_USMALLINT flags
TDS_USMALLINT locale_id

Detailed Description

TDS 8.0 collation informations.


The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00086.html100664 001750 000144 00000012042 11623073553 0015600 FreeTDS API: tds_align_struct Union Reference

tds_align_struct Union Reference

List of all members.

Public Attributes

int i
void * p

The documentation for this union was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00087.html100664 001750 000144 00000012150 11623073553 0015601 FreeTDS API: tds_answer Struct Reference

tds_answer Struct Reference
[Authentication]

List of all members.

Public Attributes

unsigned char lm_resp [24]
unsigned char nt_resp [24]

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/tds/challenge.c
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00088.html100664 001750 000144 00000014042 11623073553 0015604 FreeTDS API: tds_authentication Struct Reference

tds_authentication Struct Reference

List of all members.

Public Attributes

int(* free )(TDSSOCKET *tds, struct tds_authentication *auth)
int(* 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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00089.html100664 001750 000144 00000012541 11623073553 0015607 FreeTDS API: tds_bcpcoldata Struct Reference

tds_bcpcoldata Struct Reference

List of all members.

Public Attributes

TDS_UCHAR * data
TDS_INT datalen
TDS_INT is_null

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00090.html100664 001750 000144 00000016714 11623073553 0015605 FreeTDS API: tds_bcpinfo Struct Reference

tds_bcpinfo Struct Reference

List of all members.

Public Attributes

TDS_INT bind_count
TDSRESULTINFObindinfo
TDS_INT direction
const char * hint
TDS_INT identity_insert_on
TDS_CHAR * insert_stmt
void * parent
TDS_CHAR * tablename
TDS_INT var_cols
TDS_INT xfer_init

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00091.html100664 001750 000144 00000013231 11623073553 0015575 FreeTDS API: tds_blob Struct Reference

tds_blob Struct Reference

Information about blobs (e.g. More...

#include <tds.h>

List of all members.

Public Attributes

TDS_CHAR textptr [16]
TDS_CHAR * textvalue
TDS_CHAR timestamp [8]

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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00092.html100664 001750 000144 00000052462 11623073553 0015607 FreeTDS API: tds_column Struct Reference

tds_column Struct Reference

Metadata about columns in regular and compute rows. More...

#include <tds.h>

List of all members.

Public Attributes

BCPCOLDATAbcp_column_data
TDS_INT bcp_prefix_len
 The length, in bytes, of any length prefix this column may have.
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).
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
TDS_CHAR column_name [TDS_SYSNAME_SIZE]
TDS_SMALLINT column_namelen
 length of 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.
TDS_INT column_text_sqlgetdatapos
TDS_CHAR column_text_sqlputdatainfo
TDS_INT column_textpos
unsigned int column_timestamp:1
TDS_SMALLINT column_type
 This type can be different from wire type because conversion (e.g.
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
struct {
   TDS_INT   column_size
   TDS_SMALLINT   column_type
 type of data, saved from wire
on_server
char * table_column_name
TDS_CHAR table_name [TDS_SYSNAME_SIZE]
TDS_SMALLINT table_namelen

Detailed Description

Metadata about columns in regular and compute rows.


Member Data Documentation

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.

size written in variable (ie: char, text, binary).

-1 if NULL.

maximun size of data.

For fixed is the size.

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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00093.html100664 001750 000144 00000017651 11623073553 0015611 FreeTDS API: tds_compiletime_settings Struct Reference

tds_compiletime_settings Struct Reference

A structure to hold all the compile-time settings. More...

#include <tds.h>

List of all members.

Public Attributes

const char * freetds_version
int iodbc
const char * last_update
int libiconv
int msdblib
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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00094.html100664 001750 000144 00000037020 11623073553 0015602 FreeTDS API: tds_connection Struct Reference

tds_connection Struct Reference

List of all members.

Public Attributes

DSTR app_name
int block_size
unsigned int broken_dates:1
unsigned int bulk_copy:1
unsigned char capabilities [TDS_MAX_CAPABILITY]
DSTR client_charset
DSTR client_host_name
TDS_INT connect_timeout
DSTR database
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
DSTR ip_addr
 ip of server
DSTR language
DSTR library
unsigned char option_flag2
DSTR password
 password of account login
int port
 port of database service
TDS_INT query_timeout
DSTR server_charset
 charset of server
DSTR server_host_name
DSTR server_name
 server name (in freetds.conf)
DSTR server_realm_name
 server realm name (in freetds.conf)
unsigned int suppress_language:1
TDS_USMALLINT tds_version
int text_size
unsigned int use_ntlmv2:1
DSTR user_name
 account for login

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00095.html100664 001750 000144 00000014612 11623073553 0015605 FreeTDS API: tds_context Struct Reference

tds_context Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00096.html100664 001750 000144 00000027333 11623073553 0015612 FreeTDS API: tds_cursor Struct Reference

tds_cursor Struct Reference

Holds informations about a cursor. More...

#include <tds.h>

List of all members.

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_TINYINT cursor_name_len
 length of cursor name > 0 and <= 30
TDS_INT cursor_rows
 < number of updatable columns
TDS_TINYINT hasargs
 cursor parameters exists ?
struct tds_cursornext
 next in linked list, keep first
TDS_TINYINT options
 read only|updatable
char * query
 SQL query.
TDS_USMALLINT query_len
 SQL query length.
TDS_INT ref_count
 reference counter so client can retain safely a pointer
TDSRESULTINFOres_info
TDS_SMALLINT 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

< number of updatable columns

< updatable column list number of cursor rows to fetch


The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00097.html100664 001750 000144 00000014455 11623073553 0015614 FreeTDS API: tds_cursor_status Struct Reference

tds_cursor_status Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00098.html100664 001750 000144 00000033756 11623073553 0015622 FreeTDS API: tds_dblib_dbprocess Struct Reference

tds_dblib_dbprocess Struct Reference

List of all members.

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
TDS_INT 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:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00099.html100664 001750 000144 00000011513 11623073553 0015606 FreeTDS API: tds_dblib_loginrec Struct Reference

tds_dblib_loginrec Struct Reference

List of all members.

Public Attributes

TDSLOGINtds_login

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/dblib.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00100.html100664 001750 000144 00000012032 11623073553 0015562 FreeTDS API: tds_dstr Struct Reference

tds_dstr Struct Reference

List of all members.

Public Attributes

char * dstr_s
size_t dstr_size

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00101.html100664 001750 000144 00000023507 11623073554 0015575 FreeTDS API: tds_dynamic Struct Reference

tds_dynamic Struct Reference

Holds information for a dynamic (also called prepared) query. More...

#include <tds.h>

List of all members.

Public Attributes

int emulated
 this dynamic query cannot be prepared so libTDS have to construct a simple query.
char id [30]
 id of dynamic.
struct tds_dynamicnext
 next in linked list, keep first
TDS_INT num_id
 numeric id for mssql7+
TDSPARAMINFOparams
 query parameters.
char * query
 saved query, we need to know original query if prepare is impossible
TDSPARAMINFOres_info
 query results

Detailed Description

Holds information for a dynamic (also called prepared) query.


Member Data Documentation

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.

char tds_dynamic::id[30]

id of dynamic.

Usually this id correspond to server one but if not specified is generated automatically by libTDS

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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00102.html100664 001750 000144 00000014027 11623073554 0015573 FreeTDS API: tds_encoding Struct Reference

tds_encoding Struct Reference

Information relevant to libiconv. More...

#include <tds.h>

List of all members.

Public Attributes

unsigned char canonic
unsigned char max_bytes_per_char
unsigned char min_bytes_per_char
const char * name

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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00103.html100664 001750 000144 00000013602 11623073554 0015572 FreeTDS API: tds_env Struct Reference

tds_env Struct Reference

Current environment as reported by the server. More...

#include <tds.h>

List of all members.

Public Attributes

int block_size
char * charset
char * database
char * language

Detailed Description

Current environment as reported by the server.


The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00104.html100664 001750 000144 00000012653 11623073554 0015600 FreeTDS API: tds_errno_message_flags Struct Reference

tds_errno_message_flags Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/tdsiconv.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00105.html100664 001750 000144 00000012504 11623073554 0015574 FreeTDS API: tds_error_message Struct Reference

tds_error_message Struct Reference

List of all members.

Public Attributes

TDSERRNO msgno
char * msgtext
int severity

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/tds/util.c
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00106.html100664 001750 000144 00000012532 11623073554 0015576 FreeTDS API: tds_locale Struct Reference

tds_locale Struct Reference

List of all members.

Public Attributes

char * date_fmt
char * language
char * server_charset

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00107.html100664 001750 000144 00000024722 11623073554 0015603 FreeTDS API: tds_login Struct Reference

tds_login Struct Reference

List of all members.

Public Attributes

DSTR app_name
int block_size
unsigned int bulk_copy:1
unsigned char capabilities [TDS_MAX_CAPABILITY]
DSTR client_charset
DSTR client_host_name
TDS_INT connect_timeout
DSTR database
TDS_TINYINT encryption_level
DSTR language
DSTR library
DSTR password
int port
TDS_INT query_timeout
DSTR server_charset
DSTR server_name
unsigned int suppress_language:1
TDS_USMALLINT tds_version
DSTR user_name

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00108.html100664 001750 000144 00000016617 11623073554 0015610 FreeTDS API: tds_message Struct Reference

tds_message Struct Reference

List of all members.

Public Attributes

TDS_INT line_number
TDS_CHAR * message
TDS_UINT 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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00109.html100664 001750 000144 00000020075 11623073554 0015602 FreeTDS API: tds_microsoft_dbdaterec Struct Reference

tds_microsoft_dbdaterec Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00110.html100664 001750 000144 00000012063 11623073554 0015570 FreeTDS API: tds_multiple Struct Reference

tds_multiple Struct Reference

List of all members.

Public Attributes

unsigned int flags
TDS_MULTIPLE_TYPE type

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00111.html100664 001750 000144 00000011540 11623073554 0015570 FreeTDS API: tds_ntlm_auth Struct Reference

tds_ntlm_auth Struct Reference
[Authentication]

List of all members.

Public Attributes

TDSAUTHENTICATION tds_auth

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/tds/challenge.c
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00112.html100664 001750 000144 00000012505 11623073554 0015573 FreeTDS API: tds_option_arg Union Reference

tds_option_arg Union Reference

List of all members.

Public Attributes

TDS_CHAR * c
TDS_INT i
TDS_TINYINT ti

The documentation for this union was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00113.html100664 001750 000144 00000012066 11623073554 0015576 FreeTDS API: TDS_PARSED_PARAM Struct Reference

TDS_PARSED_PARAM Struct Reference

List of all members.

Public Attributes

size_t len
const char * p

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsodbc.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00114.html100664 001750 000144 00000012421 11623073554 0015572 FreeTDS API: tds_pbcb Struct Reference

tds_pbcb Struct Reference

List of all members.

Public Attributes

unsigned int cb
unsigned int from_malloc
char * pb

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/tds/bulk.c
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00115.html100664 001750 000144 00000020420 11623073554 0015571 FreeTDS API: tds_pool Struct Reference

tds_pool Struct Reference

List of all members.

Public Attributes

char * database
int max_member_age
int max_open_conn
int max_users
TDS_POOL_MEMBERmembers
int min_open_conn
char * name
int num_members
char * password
int port
char * server
char * user
TDS_POOL_USERusers

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/pool/pool.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00116.html100664 001750 000144 00000015225 11623073554 0015601 FreeTDS API: tds_pool_member Struct Reference

tds_pool_member Struct Reference

List of all members.

Public Attributes

TDS_POOL_USERcurrent_user
unsigned char fragment [PGSIZ]
time_t last_used_tm
int need_more
int num_bytes_left
int state
TDSSOCKETtds

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/pool/pool.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00117.html100664 001750 000144 00000012714 11623073554 0015602 FreeTDS API: tds_pool_user Struct Reference

tds_pool_user Struct Reference

List of all members.

Public Attributes

TDS_POOL_MEMBERassigned_member
TDSSOCKETtds
TDS_USER_STATE user_state

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/pool/pool.h
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00118.html100664 001750 000144 00000021013 11623073555 0015574 FreeTDS API: tds_result_info Struct Reference

tds_result_info Struct Reference

Hold information for any results. More...

#include <tds.h>

List of all members.

Public Attributes

TDS_SMALLINT by_cols
TDS_SMALLINT * bycolumns
TDSCOLUMN ** columns
TDS_SMALLINT computeid
unsigned char * current_row
TDS_TINYINT more_results
TDS_SMALLINT num_cols
TDS_INT ref_count
TDS_INT row_count
void(* row_free )(struct tds_result_info *result, unsigned char *row)
TDS_INT row_size
TDS_SMALLINT rows_exist

Detailed Description

Hold information for any results.


The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00119.html100664 001750 000144 00000014051 11623073555 0015601 FreeTDS API: tds_save_context Struct Reference

tds_save_context Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/src/tds/login.c
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00120.html100664 001750 000144 00000012435 11623073555 0015575 FreeTDS API: tds_save_env Struct Reference

tds_save_env Struct Reference

List of all members.

Public Attributes

char * newval
char * oldval
int type

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/tds/login.c
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00121.html100664 001750 000144 00000012033 11623073555 0015570 FreeTDS API: tds_save_msg Struct Reference

tds_save_msg Struct Reference

List of all members.

Public Attributes

TDSMESSAGE msg
char type

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/tds/login.c
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00122.html100664 001750 000144 00000057544 11623073555 0015611 FreeTDS API: tds_socket Struct Reference

tds_socket Struct Reference

Information for a server connection. More...

#include <tds.h>

List of all members.

Public Attributes

TDSAUTHENTICATIONauthentication
unsigned int broken_dates:1
unsigned char capabilities [TDS_MAX_CAPABILITY]
int char_conv_count
TDSICONV ** char_convs
TDS_UCHAR collation [5]
TDSCOMPUTEINFO ** comp_info
TDSCONNECTIONconnection
 config for login stuff.
TDSCURSORcur_cursor
 cursor in use
TDSDYNAMICcur_dyn
 dynamic structure in use
TDSRESULTINFOcurrent_results
 Current query information.
TDSCURSORcursors
 linked list of cursors allocated for this connection
TDSDYNAMICdyns
 list of dynamic allocate for this connection
unsigned int emul_little_endian:1
TDSENV env
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
unsigned int in_buf_max
 allocated input buffer
volatile unsigned char in_cancel
 indicate we are waiting a cancel reply; discard tokens till acknowledge
unsigned char in_flag
 input buffer type
unsigned in_len
 input buffer length
unsigned in_pos
 current position in in_buf
int internal_sp_called
TDS_INT num_comp_info
int option_value
unsigned char * out_buf
 output buffer
unsigned char out_flag
 output buffer type
unsigned out_pos
 current position in out_buf
TDSPARAMINFOparam_info
void * parent
char * product_name
TDS_UINT product_version
 version of product (Sybase/MS and full version)
TDS_INT query_timeout
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
TDS_SYS_SOCKET s
 tcp socket, INVALID_SOCKET if not connected
int spid
TDS_STATE state
unsigned int tds71rev1:1
TDS_UCHAR tds9_transaction [8]
const TDSCONTEXTtds_ctx
TDS_USMALLINT tds_version
void * tls_credentials
void * tls_session
unsigned int use_iconv:1

Detailed Description

Information for a server connection.


Member Data Documentation

config for login stuff.

After login this field is NULL

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.


The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00123.html100664 001750 000144 00000020122 11623073555 0015570 FreeTDS API: tds_sybase_dbdaterec Struct Reference

tds_sybase_dbdaterec Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/sybdb.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00124.html100664 001750 000144 00000016764 11623073555 0015612 FreeTDS API: tds_time Struct Reference

tds_time Struct Reference

List of all members.

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_ms
 milliseconds (0-999)
int tm_sec
 seconds (0-59)
int tm_year
 year (0=1900)

The documentation for this struct was generated from the following file:
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00125.html100664 001750 000144 00000012616 11623073555 0015603 FreeTDS API: tds_upd_col Struct Reference

tds_upd_col Struct Reference

List of all members.

Public Attributes

TDS_INT colnamelength
char * columnname
struct tds_upd_colnext

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00126.html100664 001750 000144 00000014237 11623073555 0015605 FreeTDS API: tds_variant Struct Reference

tds_variant Struct Reference

Store variant informations. More...

#include <tds.h>

List of all members.

Public Attributes

TDS_UCHAR collation [5]
TDS_CHAR * data
TDS_INT data_len
TDS_INT size
TDS_UCHAR type

Detailed Description

Store variant informations.


The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00127.html100664 001750 000144 00000023450 11623073555 0015603 FreeTDS API: tdsdaterec Struct Reference

tdsdaterec Struct Reference

Used by tds_datecrack. More...

#include <tds.h>

List of all members.

Public Attributes

TDS_INT day
 day of month (1-31)
TDS_INT dayofyear
 day of year (1-366)
TDS_INT hour
 0-23
TDS_INT millisecond
 0-999
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 tzone
TDS_INT week
 1 - 54 (can be 54 in leap year)
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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00128.html100664 001750 000144 00000012045 11623073555 0015602 FreeTDS API: tdsdatetime Struct Reference

tdsdatetime Struct Reference

List of all members.

Public Attributes

TDS_INT dtdays
TDS_INT dttime

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00129.html100664 001750 000144 00000012064 11623073555 0015604 FreeTDS API: tdsdatetime4 Struct Reference

tdsdatetime4 Struct Reference

List of all members.

Public Attributes

TDS_USMALLINT days
TDS_USMALLINT minutes

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00130.html100664 001750 000144 00000015735 11623073555 0015604 FreeTDS API: tdsiconvinfo Struct Reference

tdsiconvinfo Struct Reference

List of all members.

Public Attributes

TDS_ENCODING client_charset
unsigned int flags
iconv_t from_wire
iconv_t from_wire2
TDS_ENCODING server_charset
TDS_ERRNO_MESSAGE_FLAGS suppress
iconv_t to_wire
iconv_t to_wire2

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsiconv.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00131.html100664 001750 000144 00000012103 11623073555 0015567 FreeTDS API: tdsmoney Union Reference

tdsmoney Union Reference

List of all members.

Public Attributes

TDS_INT8 mny
TDS_OLD_MONEY tdsoldmoney

The documentation for this union was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00132.html100664 001750 000144 00000011363 11623073556 0015600 FreeTDS API: tdsmoney4 Struct Reference

tdsmoney4 Struct Reference

List of all members.

Public Attributes

TDS_INT mny4

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00133.html100664 001750 000144 00000012542 11623073556 0015601 FreeTDS API: tdsnumeric Struct Reference

tdsnumeric Struct Reference

List of all members.

Public Attributes

unsigned char array [33]
unsigned char precision
unsigned char scale

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00134.html100664 001750 000144 00000012050 11623073556 0015574 FreeTDS API: tdsoldmoney Struct Reference

tdsoldmoney Struct Reference

List of all members.

Public Attributes

TDS_INT mnyhigh
TDS_UINT mnylow

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00135.html100664 001750 000144 00000013161 11623073556 0015601 FreeTDS API: tdsunique Struct Reference

tdsunique Struct Reference

List of all members.

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:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00136.html100664 001750 000144 00000012063 11623073556 0015602 FreeTDS API: tdsvarbinary Struct Reference

tdsvarbinary Struct Reference

List of all members.

Public Attributes

TDS_CHAR array [256]
TDS_SMALLINT len

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00137.html100664 001750 000144 00000012051 11623073556 0015600 FreeTDS API: tdsvarchar Struct Reference

tdsvarchar Struct Reference

List of all members.

Public Attributes

TDS_CHAR array [256]
TDS_SMALLINT len

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00138.html100664 001750 000144 00000012106 11623073556 0015602 FreeTDS API: tmp_col_struct Struct Reference

tmp_col_struct Struct Reference

List of all members.

Public Attributes

char * column_name
struct tmp_col_structnext

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/src/pool/stream.c
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00139_source.html100664 001750 000144 00000026675 11623073546 0017202 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/bkpublic.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00140_source.html100664 001750 000144 00000241676 11623073546 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/cspublic.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00141_source.html100664 001750 000144 00000054010 11623073546 0017153 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/cstypes.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00142_source.html100664 001750 000144 00000073437 11623073546 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/ctlib.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00143_source.html100664 001750 000144 00000054253 11623073546 0017166 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/ctpublic.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00144_source.html100664 001750 000144 00000055267 11623073546 0017175 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/dblib.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00145_source.html100664 001750 000144 00000016610 11623073546 0017163 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/des.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00146_source.html100664 001750 000144 00000027763 11623073546 0017177 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/fakepoll.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00147_source.html100664 001750 000144 00000017506 11623073546 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/hmac_md5.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00148_source.html100664 001750 000144 00000016116 11623073546 0017167 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/md4.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00149_source.html100664 001750 000144 00000016443 11623073546 0017173 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/md5.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00150_source.html100664 001750 000144 00000014674 11623073546 0017167 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/odbcss.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00151_source.html100664 001750 000144 00000043600 11623073546 0017157 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/replacements.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00152_source.html100664 001750 000144 00000024556 11623073546 0017171 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/replacements/readpassphrase.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00153_source.html100664 001750 000144 00000062117 11623073546 0017165 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/sqldb.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00154_source.html100664 001750 000144 00000024276 11623073546 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/sqlfront.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00155_source.html100664 001750 000144 00000017540 11623073546 0017167 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/sybdb.dox.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00156.html100664 001750 000144 00001041644 11623073547 0015614 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/sybdb.h File Reference

/home/jklowden/releases/freetds-0.91/include/sybdb.h File Reference

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

#include "tds_sysdep_public.h"

Go to the source code of this file.

Classes

struct  DBCOL
struct  DBDATETIME
struct  DBDATETIME4
struct  DBMONEY
struct  DBMONEY4
struct  DBNUMERIC
struct  dbstring
struct  dbtypeinfo
struct  DBVARYBIN
struct  DBVARYCHAR
struct  tds_microsoft_dbdaterec
struct  tds_sybase_dbdaterec

Defines

#define BCP_SETL(x, y)   dbsetlbool((x), (y), DBSETBCP)
 Enable (or prevent) bcp operations for connections made with a login.
#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 BIGINTBIND   30
#define BINARYBIND   15
#define BITBIND   16
#define BUF_FULL   -3
#define CHARBIND   0
#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.
#define DBCMDSENT   2
#define DBCONFIRM   12
#define DBCOUNT(x)   dbcount((x))
 Sybase macro mapping to the Microsoft (lower-case) function.
#define DBCURCMD(x)   dbcurcmd((x))
 Sybase macro mapping to the Microsoft (lower-case) function.
#define DBCURROW(x)   dbcurrow((x))
 Sybase macro mapping to the Microsoft (lower-case) function.
#define DBDATEFIRST   25
#define DBDATEFORMAT   19
#define DBDATESHORT   32
#define DBDEAD(x)   dbdead((x))
 Sybase macro mapping to the Microsoft (lower-case) function.
#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.
#define DBGETTIME   dbgettime
#define DBIDENTITY   30
#define DBINTERRUPT   4
#define DBIORDESC(x)   dbiordesc((x))
 Sybase macro, maps to the internal (lower-case) function.
#define DBIOWDESC(x)   dbiowdesc((x))
 Sybase macro, maps to the internal (lower-case) function.
#define DBISAVAIL(x)   dbisavail((x))
 Sybase macro mapping to the Microsoft (lower-case) function.
#define DBISOLATION   28
#define DBLASTROW(x)   dblastrow((x))
 Sybase macro mapping to the Microsoft (lower-case) function.
#define DBLFCONVERT   24
#define DBMAXNAME   30
#define DBMAXNUMLEN   33
#define DBMORECMDS(x)   dbmorecmds((x))
 Sybase macro mapping to the Microsoft (lower-case) function.
#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.
#define DBROWTYPE(x)   dbrowtype((x))
 Sybase macro mapping to the Microsoft (lower-case) function.
#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)
#define DBSETLAPP(x, y)   dbsetlname((x), (y), DBSETAPP)
 Set the (client) application name in the login packet.
#define DBSETLCHARSET(x, y)   dbsetlname((x), (y), DBSETCHARSET)
 Set the client character set in the login packet.
#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.
#define dbsetlhost(x, y)   dbsetlname((x), (y), DBSETHOST)
#define DBSETLHOST(x, y)   dbsetlname((x), (y), DBSETHOST)
 Set the (client) host name in the login packet.
#define DBSETLLABELED(x, y)   dbsetlbool((x), (y), DBSETLABELED)
 Alternative way to set login packet fields.
#define dbsetlnatlang(x, y)   dbsetlname((x), (y), DBSETNATLANG)
 Set the language the server should use for messages.
#define DBSETLNATLANG(x, y)   dbsetlname((x), (y), DBSETNATLANG)
 Set the language the server should use for messages.
#define dbsetlpacket(x, y)   dbsetllong((x), (y), DBSETPACKET)
 Set the packet size in the login packet for new connections.
#define DBSETLPACKET(x, y)   dbsetllong((x), (y), DBSETPACKET)
 Set the packet size in the login packet for new connections.
#define dbsetlpwd(x, y)   dbsetlname((x), (y), DBSETPWD)
#define DBSETLPWD(x, y)   dbsetlname((x), (y), DBSETPWD)
 Set the password in the login packet.
#define DBSETLSECURE(x)   dbsetlbool((x), (1), DBSETBCP)
#define dbsetluser(x, y)   dbsetlname((x), (y), DBSETUSER)
#define DBSETLUSER(x, y)   dbsetlname((x), (y), DBSETUSER)
 Set the username in the login packet.
#define DBSETLVERSION(login, version)   dbsetlversion((login), (version))
 maps to the Microsoft (lower-case) function.
#define DBSETNATLANG   7
#define DBSETPACKET   11
#define DBSETPWD   3
#define DBSETTIME   34
#define DBSETUSER   2
#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.
#define DBTDS_2_0   1
#define DBTDS_3_4   2
#define DBTDS_4_0   3
#define DBTDS_4_2   4
#define DBTDS_4_6   5
#define DBTDS_4_9_5   6
#define DBTDS_5_0   7
#define DBTDS_7_0   8
#define DBTDS_7_1   9
#define DBTDS_7_2   10
#define DBTDS_8_0   9
#define DBTDS_9_0   10
#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
#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_80   DBVERSION_71
#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   31
#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 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 SYBBINARY   SYBBINARY
#define SYBBIT   SYBBIT
#define SYBBITN   SYBBITN
#define SYBCHAR   SYBCHAR
#define SYBDATETIME   SYBDATETIME
#define SYBDATETIME4   SYBDATETIME4
#define SYBDATETIMN   SYBDATETIMN
#define SYBDECIMAL   SYBDECIMAL
#define SYBEAAMT   20035
#define SYBEABMT   20033
#define SYBEABNC   20032
#define SYBEABNP   20034
#define SYBEABNV   20046
#define SYBEACNV   20148
#define SYBEADST   20128
#define SYBEAICF   20127
#define SYBEALTT   20129
#define SYBEAOLF   20133
#define SYBEAPCT   20130
#define SYBEAPUT   20040
#define SYBEARDI   20134
#define SYBEARDL   20136
#define SYBEASEC   20091
#define SYBEASNL   20041
#define SYBEASTF   20089
#define SYBEASTL   20197
#define SYBEASUL   20043
#define SYBEATTNACK   20296
#define SYBEAUTN   20062
#define SYBEBADPK   20201
#define SYBEBADTYPE   20254
#define SYBEBBCI   20068
#define SYBEBBFL   20297
#define SYBEBBL   20215
#define SYBEBCBC   20081
#define SYBEBCBNPR   20230
#define SYBEBCBNTYP   20231
#define SYBEBCBPREF   20236
#define SYBEBCFO   20082
#define SYBEBCHLEN   20235
#define SYBEBCIS   20075
#define SYBEBCIT   20107
#define SYBEBCITBLEN   20239
#define SYBEBCITBNM   20238
#define SYBEBCMTXT   20228
#define SYBEBCNL   20105
#define SYBEBCNN   20073
#define SYBEBCNT   20064
#define SYBEBCOR   20074
#define SYBEBCPB   20078
#define SYBEBCPCTYP   20233
#define SYBEBCPI   20076
#define SYBEBCPN   20077
#define SYBEBCPOPT   20294
#define SYBEBCPREC   20229
#define SYBEBCPREF   20237
#define SYBEBCRE   20070
#define SYBEBCRO   20111
#define SYBEBCSA   20108
#define SYBEBCSET   20221
#define SYBEBCSI   20106
#define SYBEBCSNDROW   20240
#define SYBEBCSNTYP   20232
#define SYBEBCUC   20085
#define SYBEBCUO   20084
#define SYBEBCVH   20083
#define SYBEBCVLEN   20234
#define SYBEBCWE   20072
#define SYBEBDIO   20063
#define SYBEBEOF   20104
#define SYBEBIHC   20103
#define SYBEBIVI   20080
#define SYBEBNCR   20024
#define SYBEBNUM   20214
#define SYBEBOOL   20293
#define SYBEBPKS   20193
#define SYBEBPREC   20216
#define SYBEBPROBADDEF   20249
#define SYBEBPROBADLEN   20251
#define SYBEBPROBADPREC   20252
#define SYBEBPROBADSCL   20253
#define SYBEBPROBADTYP   20250
#define SYBEBPROCOL   20241
#define SYBEBPRODEF   20242
#define SYBEBPRODEFID   20244
#define SYBEBPRODEFTYP   20246
#define SYBEBPROEXTDEF   20247
#define SYBEBPROEXTRES   20248
#define SYBEBPRONODEF   20245
#define SYBEBPRONUMDEF   20243
#define SYBEBRFF   20100
#define SYBEBSCALE   20217
#define SYBEBTMT   20095
#define SYBEBTOK   20020
#define SYBEBTYP   20023
#define SYBEBTYPSRV   20220
#define SYBEBUCE   20087
#define SYBEBUCF   20099
#define SYBEBUDF   20102
#define SYBEBUFF   20147
#define SYBEBUFL   20005
#define SYBEBULKINSERT   20599
#define SYBEBUOE   20086
#define SYBEBUOF   20098
#define SYBEBWEF   20088
#define SYBEBWFF   20101
#define SYBECAP   20203
#define SYBECAPTYP   20213
#define SYBECDNS   20031
#define SYBECDOMAIN   20218
#define SYBECINTERNAL   20219
#define SYBECLOS   20056
#define SYBECLOSEIN   20292
#define SYBECLPR   20051
#define SYBECNOR   20026
#define SYBECNOV   20052
#define SYBECOFL   20049
#define SYBECONN   20009
#define SYBECRNC   20116
#define SYBECRSAGR   20263
#define SYBECRSBROL   20266
#define SYBECRSBSKEY   20268
#define SYBECRSBUFR   20260
#define SYBECRSDIS   20262
#define SYBECRSFLAST   20265
#define SYBECRSFRAND   20264
#define SYBECRSFROWN   20267
#define SYBECRSFTYPE   20280
#define SYBECRSINV   20277
#define SYBECRSINVALID   20281
#define SYBECRSMROWS   20282
#define SYBECRSNOBIND   20279
#define SYBECRSNOCOUNT   20270
#define SYBECRSNOFREE   20261
#define SYBECRSNOIND   20256
#define SYBECRSNOKEYS   20278
#define SYBECRSNOLEN   20284
#define SYBECRSNOPTCC   20285
#define SYBECRSNORDER   20286
#define SYBECRSNORES   20255
#define SYBECRSNOTABLE   20287
#define SYBECRSNOUPD   20276
#define SYBECRSNOWHERE   20273
#define SYBECRSNROWS   20283
#define SYBECRSNUNIQUE   20288
#define SYBECRSORD   20259
#define SYBECRSRO   20269
#define SYBECRSSET   20274
#define SYBECRSTAB   20271
#define SYBECRSUPDNB   20272
#define SYBECRSUPDTAB   20275
#define SYBECRSVAR   20289
#define SYBECRSVIEW   20257
#define SYBECRSVIIND   20258
#define SYBECS   20299
#define SYBECSYN   20050
#define SYBECUFL   20048
#define SYBECWLL   20123
#define SYBEDBPS   20011
#define SYBEDCL   20298
#define SYBEDDNE   20047
#define SYBEDIVZ   20196
#define SYBEDNTI   20094
#define SYBEDPOR   20149
#define SYBEDVOR   20152
#define SYBEECAN   20184
#define SYBEECRT   20183
#define SYBEEINI   20182
#define SYBEEQVA   20059
#define SYBEERRLABEL   20295
#define SYBEESSL   20172
#define SYBEETD   20164
#define SYBEEUNR   20185
#define SYBEEVOP   20178
#define SYBEEVST   20181
#define SYBEFCON   20002
#define SYBEFENC   20222
#define SYBEFGTL   20122
#define SYBEFMODE   20167
#define SYBEFRES   20223
#define SYBEFSHD   20132
#define SYBEFUNC   20204
#define SYBEGENOS   20161
#define SYBEICN   20038
#define SYBEICONV2BIG   2404
#define SYBEICONVAVAIL   2401
#define SYBEICONVI   2403
#define SYBEICONVIU   2400
#define SYBEICONVO   2402
#define SYBEIDCL   20143
#define SYBEIDECCL   20227
#define SYBEIFCL   20145
#define SYBEIFNB   20065
#define SYBEIICL   20025
#define SYBEIMCL   20144
#define SYBEINLN   20016
#define SYBEINTF   20012
#define SYBEINUMCL   20226
#define SYBEIPV   20194
#define SYBEISOI   20142
#define SYBEISRVPREC   20224
#define SYBEISRVSCL   20225
#define SYBEITIM   20021
#define SYBEIVERS   20206
#define SYBEKBCI   20069
#define SYBEKBCO   20067
#define SYBELBLEN   20211
#define SYBEMEM   20010
#define SYBEMOV   20195
#define SYBEMPLL   20112
#define SYBEMVOR   20151
#define SYBENBUF   20175
#define SYBENBVP   20153
#define SYBENDC   20150
#define SYBENDTP   20155
#define SYBENEG   20210
#define SYBENEHA   20179
#define SYBENHAN   20174
#define SYBENLNL   20173
#define SYBENMOB   20039
#define SYBENOEV   20200
#define SYBENOTI   20177
#define SYBENOVALUE   20290
#define SYBENPRM   20027
#define SYBENSIP   20045
#define SYBENTLL   20042
#define SYBENTST   20170
#define SYBENTTN   20093
#define SYBENULL   20109
#define SYBENULP   20176
#define SYBENUM   20159
#define SYBENXID   20036
#define SYBEONCE   20207
#define SYBEOOB   20022
#define SYBEOPIN   20015
#define SYBEOPNA   20121
#define SYBEOPTNO   20163
#define SYBEOREN   20141
#define SYBEORPF   20096
#define SYBEOSSL   20171
#define SYBEPAGE   20162
#define SYBEPOLL   20199
#define SYBEPORT   2500
#define SYBEPRTF   20191
#define SYBEPWD   20014
#define SYBERDCN   20053
#define SYBERDNR   20044
#define SYBEREAD   20004
#define SYBERESP   20205
#define SYBERFILE   20166
#define SYBERPCS   20186
#define SYBERPIL   20113
#define SYBERPNA   20120
#define SYBERPND   20019
#define SYBERPNULL   20208
#define SYBERPTXTIM   20209
#define SYBERPUL   20114
#define SYBERTCC   20117
#define SYBERTSC   20118
#define SYBERTYPE   20165
#define SYBERXID   20037
#define SYBESECURE   20202
#define SYBESEFA   20198
#define SYBESEOF   20017
#define SYBESFOV   20054
#define SYBESLCT   20168
#define SYBESMSG   20018
#define SYBESOCK   20008
#define SYBESPID   20154
#define SYBESYNC   20001
#define SYBETDSVER   2410
#define SYBETEXS   20188
#define SYBETIME   20003
#define SYBETMCF   20126
#define SYBETMTD   20092
#define SYBETPAR   20187
#define SYBETPTN   20071
#define SYBETRAC   20189
#define SYBETRAN   20180
#define SYBETRAS   20190
#define SYBETRSN   20192
#define SYBETSIT   20061
#define SYBETTS   20066
#define SYBETYPE   20160
#define SYBEUACS   20090
#define SYBEUAVE   20057
#define SYBEUCPT   20125
#define SYBEUCRR   20119
#define SYBEUDTY   20060
#define SYBEUFDS   20124
#define SYBEUFDT   20029
#define SYBEUHST   20013
#define SYBEUMSG   20212
#define SYBEUNAM   20110
#define SYBEUNOP   20115
#define SYBEUNT   20055
#define SYBEURCI   20135
#define SYBEUREI   20140
#define SYBEUREM   20138
#define SYBEURES   20139
#define SYBEURMI   20137
#define SYBEUSCT   20058
#define SYBEUTDS   20146
#define SYBEUVBF   20097
#define SYBEUVDT   20028
#define SYBEVDPT   20079
#define SYBEVERDOWN   100
#define SYBEVMS   20007
#define SYBEVOIDRET   20291
#define SYBEWAID   20030
#define SYBEWRIT   20006
#define SYBEXOCI   20131
#define SYBEXTDN   20157
#define SYBEXTN   20156
#define SYBEXTSN   20158
#define SYBEZTXT   20169
#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 SYBNTEXT   SYBNTEXT
#define SYBNUMERIC   SYBNUMERIC
#define SYBNVARCHAR   SYBNVARCHAR
#define SYBREAL   SYBREAL
#define SYBTEXT   SYBTEXT
#define SYBVARBINARY   SYBVARBINARY
#define SYBVARCHAR   SYBVARCHAR
#define SYBVOID   SYBVOID
#define TDS_STATIC_CAST(type, a)   ((type)(a))
#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 DBNUMERIC DBDECIMAL
typedef tds_sysdep_real64_type DBFLT8
typedef tds_sysdep_int32_type DBINT
typedef void DBLOGINFO
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_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 }
enum  { MAXCOLNAMELEN = 512 }
enum  CI_TYPE { CI_REGULAR = 1, CI_ALTERNATE = 2, CI_CURSOR = 3 }

Functions

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

Variables

static const void *const no_unused_sybdb_h_warn [] = { rcsid_sybdb_h, no_unused_sybdb_h_warn }
static const char rcsid_sybdb_h [] = "$Id: sybdb.h,v 1.100.2.1 2011/06/06 12:31:45 freddy77 Exp $"

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

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:
dbproc contains all information needed by db-lib to manage communications with the server.
type must be CI_REGULAR or CI_ALTERNATE (CI_CURSOR is defined by the vendor, but is not yet implemented).
column Nth in the result set, starting from 1.
computeid (ignored)
pdbcol address 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.
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().

Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00156_source.html100664 001750 000144 00000561066 11623073546 0017177 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/sybdb.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00157_source.html100664 001750 000144 00000022564 11623073546 0017173 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/syberror.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00158_source.html100664 001750 000144 00000020360 11623073546 0017164 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/sybfront.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00159.html100664 001750 000144 00001012626 11623073547 0015615 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tds.h File Reference

/home/jklowden/releases/freetds-0.91/include/tds.h File Reference

Main include file for libtds. More...

#include <stdarg.h>
#include <stdio.h>
#include <time.h>
#include "tdsver.h"
#include "tds_sysdep_public.h"

Go to the source code of this file.

Classes

struct  TDS8_COLLATION
 TDS 8.0 collation informations. More...
union  tds_align_struct
struct  tds_authentication
struct  tds_bcpcoldata
struct  tds_bcpinfo
struct  tds_blob
 Information about blobs (e.g. More...
struct  tds_column
 Metadata about columns in regular and compute rows. More...
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_dstr
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_locale
struct  tds_login
struct  tds_message
struct  tds_multiple
union  tds_option_arg
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...
struct  tdsdatetime
struct  tdsdatetime4
union  tdsmoney
struct  tdsmoney4
struct  tdsnumeric
struct  tdsoldmoney
struct  tdsunique
struct  tdsvarbinary
struct  tdsvarchar

Defines

#define is_ascii_type(x)   ( x==XSYBCHAR || x==XSYBVARCHAR || x==SYBTEXT || x==SYBCHAR || x==SYBVARCHAR)
#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)   (is_unicode_type(x) || is_ascii_type(x))
#define is_collate_type(x)   (x==XSYBVARCHAR || x==XSYBCHAR || x==SYBTEXT || x==XSYBNVARCHAR || x==XSYBNCHAR || x==SYBNTEXT)
#define is_end_token(x)
#define is_fixed_type(x)
#define is_hard_end_token(x)
#define is_msg_token(x)
#define is_nullable_type(x)
#define is_numeric_type(x)   (x==SYBNUMERIC || x==SYBDECIMAL)
#define is_result_token(x)
#define is_similar_type(x, y)   ((is_char_type(x) && is_char_type(y)) || ((is_unicode_type(x) && is_unicode_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_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_TDS7_PLUS(x)   ((x)->tds_version>=0x700)
#define IS_TDSDEAD(x)   (((x) == NULL) || TDS_IS_SOCKET_INVALID((x)->s))
#define is_unicode_type(x)   (x==XSYBNVARCHAR || x==XSYBNCHAR || x==SYBNTEXT || x==SYBMSXML)
#define is_variable_type(x)
#define MAXPRECISION   77
#define SYB5INT8   SYB5INT8
#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 SYBBINARY   SYBBINARY
#define SYBBIT   SYBBIT
#define SYBBITN   SYBBITN
#define SYBBLOB   SYBBLOB
#define SYBBOUNDARY   SYBBOUNDARY
#define SYBCHAR   SYBCHAR
#define SYBDATE   SYBDATE
#define SYBDATEN   SYBDATEN
#define SYBDATETIME   SYBDATETIME
#define SYBDATETIME4   SYBDATETIME4
#define SYBDATETIMN   SYBDATETIMN
#define SYBDECIMAL   SYBDECIMAL
#define SYBFLT8   SYBFLT8
#define SYBFLTN   SYBFLTN
#define SYBIMAGE   SYBIMAGE
#define SYBINT1   SYBINT1
#define SYBINT2   SYBINT2
#define SYBINT4   SYBINT4
#define SYBINT8   SYBINT8
#define SYBINTERVAL   SYBINTERVAL
#define SYBINTN   SYBINTN
#define SYBLONGBINARY   SYBLONGBINARY
#define SYBLONGCHAR   SYBLONGCHAR
#define SYBMONEY   SYBMONEY
#define SYBMONEY4   SYBMONEY4
#define SYBMONEYN   SYBMONEYN
#define SYBMSUDT   SYBMSUDT
#define SYBMSXML   SYBMSXML
#define SYBNTEXT   SYBNTEXT
#define SYBNUMERIC   SYBNUMERIC
#define SYBNVARCHAR   SYBNVARCHAR
#define SYBREAL   SYBREAL
#define SYBSENSITIVITY   SYBSENSITIVITY
#define SYBSINT1   SYBSINT1
#define SYBTEXT   SYBTEXT
#define SYBTIME   SYBTIME
#define SYBTIMEN   SYBTIMEN
#define SYBUINT1   SYBUINT1
#define SYBUINT2   SYBUINT2
#define SYBUINT4   SYBUINT4
#define SYBUINT8   SYBUINT8
#define SYBUINTN   SYBUINTN
#define SYBUNIQUE   SYBUNIQUE
#define SYBUNITEXT   SYBUNITEXT
#define SYBVARBINARY   SYBVARBINARY
#define SYBVARCHAR   SYBVARCHAR
#define SYBVARIANT   SYBVARIANT
#define SYBVOID   SYBVOID
#define SYBXML   SYBXML
#define TDS5_DYNAMIC_TOKEN   231
#define TDS5_PARAMFMT2_TOKEN   32
#define TDS5_PARAMFMT_TOKEN   236
#define TDS5_PARAMS_TOKEN   215
#define TDS7_COMPUTE_RESULT_TOKEN   136
#define TDS7_RESULT_TOKEN   129
#define TDS_ALIGN_SIZE   sizeof(tds_align_struct)
#define TDS_AUTH_TOKEN   237
#define TDS_BYTE_SWAP16(value)
#define TDS_BYTE_SWAP32(value)
#define TDS_CANCELLED   3
#define TDS_CAPABILITY_TOKEN   226
#define TDS_CMD_DONE   4046
#define TDS_CMD_FAIL   4048
#define TDS_CMD_SUCCEED   4047
#define TDS_CMP_ROW_TOKEN   211
#define TDS_COLFMT_TOKEN   161
#define TDS_COLINFO_TOKEN   165
#define TDS_COLNAME_TOKEN   160
#define TDS_COMPUTE_NAMES_TOKEN   167
#define TDS_COMPUTE_RESULT   4045
#define TDS_COMPUTE_RESULT_TOKEN   168
#define TDS_COMPUTEFMT_RESULT   4050
#define TDS_CONTROL_TOKEN   174
#define TDS_CURCLOSE_TOKEN   128
#define TDS_CURDECLARE_TOKEN   134
#define TDS_CURDELETE_TOKEN   129
#define TDS_CURFETCH_TOKEN   130
#define TDS_CURINFO_TOKEN   131
#define TDS_CUROPEN_TOKEN   132
#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_DBRPC_TOKEN   230
#define TDS_DEF_BLKSZ   512
#define TDS_DEF_CHARSET   "iso_1"
#define TDS_DEF_LANG   "us_english"
#define TDS_DEF_PORT   4000
#define TDS_DEF_SERVER   "SYBASE"
#define TDS_DEFAULT_VERSION   0x500
#define TDS_DESCRIBE_RESULT   4051
#define TDS_DONE_RESULT   4052
#define TDS_DONE_TOKEN   253
#define TDS_DONEINPROC_RESULT   4054
#define TDS_DONEINPROC_TOKEN   255
#define TDS_DONEPROC_RESULT   4053
#define TDS_DONEPROC_TOKEN   254
#define TDS_DYNAMIC2_TOKEN   163
#define TDS_EED_TOKEN   229
#define TDS_ENV_BEGINTRANS   8
#define TDS_ENV_CHARSET   3
#define TDS_ENV_COMMITTRANS   9
#define TDS_ENV_DATABASE   1
#define TDS_ENV_LANG   2
#define TDS_ENV_LCID   5
#define TDS_ENV_PACKSIZE   4
#define TDS_ENV_ROLLBACKTRANS   10
#define TDS_ENV_SQLCOLLATION   7
#define TDS_ENVCHANGE_TOKEN   227
#define TDS_ERROR_TOKEN   170
#define TDS_FAIL   0
#define TDS_GSSAPI_DELEGATION   "enable gssapi delegation"
#define TDS_INFO_TOKEN   171
#define TDS_INT_CANCEL   2
#define TDS_INT_CONTINUE   1
#define TDS_INT_TIMEOUT   3
#define TDS_IS_MSSQL(x)   ((x->product_version & 0x80000000u)!=0)
 Check if product is Microsft SQL Server.
#define TDS_IS_SYBASE(x)   (!(x->product_version & 0x80000000u))
 Check if product is Sybase (such as Adaptive Server Enterrprice).
#define TDS_LANGUAGE_TOKEN   33
#define TDS_LIKELY(x)   (x)
#define TDS_LOGINACK_TOKEN   173
#define TDS_LOGOUT_TOKEN   113
#define TDS_MAJOR(x)   ((x)->tds_version >> 8)
#define TDS_MAX_CAPABILITY   22
#define TDS_MAX_CONN   4096
#define TDS_MAX_DYNID_LEN   30
#define TDS_MAX_LOGIN_STR_SZ   30
#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.
#define TDS_MSG_RESULT   4044
#define TDS_NBC_ROW_TOKEN   210 /* 0xD2 as of TDS 7.3.B */
#define TDS_NO_COUNT   -1
#define TDS_NO_MORE_RESULTS   2
#define TDS_NULLTERM   -9
#define TDS_OPTIONCMD_TOKEN   166
#define TDS_ORDERBY2_TOKEN   34
#define TDS_ORDERBY_TOKEN   169
#define TDS_OTHERS_RESULT   4055
#define TDS_PARAM_RESULT   4042
#define TDS_PARAM_TOKEN   172
#define TDS_PROCID_TOKEN   124
#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_RESULT_TOKEN   238
#define TDS_RETURNSTATUS_TOKEN   121
#define TDS_ROW_RESULT   4040
#define TDS_ROW_TOKEN   209
#define TDS_ROWFMT2_TOKEN   97
#define TDS_ROWFMT_RESULT   4049
#define TDS_SF_ACCENT_SENSITIVE   (TDS_USMALLINT) 0x020
#define TDS_SF_BIN   (TDS_USMALLINT) 0x100
#define TDS_SF_CASE_INSENSITIVE   (TDS_USMALLINT) 0x010
#define TDS_SF_KATATYPE_INSENSITIVE   (TDS_USMALLINT) 0x040
#define TDS_SF_WIDTH_INSENSITIVE   (TDS_USMALLINT) 0x080
#define TDS_SP_CURSOR   1
#define TDS_SP_CURSORCLOSE   9
#define TDS_SP_CURSOREXECUTE   4
#define TDS_SP_CURSORFETCH   7
#define TDS_SP_CURSOROPEN   2
#define TDS_SP_CURSOROPTION   8
#define TDS_SP_CURSORPREPARE   3
#define TDS_SP_CURSORPREPEXEC   5
#define TDS_SP_CURSORUNPREPARE   6
#define TDS_SP_EXECUTE   12
#define TDS_SP_EXECUTESQL   10
#define TDS_SP_PREPARE   11
#define TDS_SP_PREPEXEC   13
#define TDS_SP_PREPEXECRPC   14
#define TDS_SP_UNPREPARE   15
#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_CHARSET   "charset"
#define TDS_STR_CLCHARSET   "client charset"
#define TDS_STR_CONNTIMEOUT   "connect timeout"
#define TDS_STR_DATEFMT   "date format"
#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_REALM   "realm"
#define TDS_STR_SWAPDT   "swap broken dates"
#define TDS_STR_TEXTSZ   "text size"
#define TDS_STR_TIMEOUT   "timeout"
#define TDS_STR_USENTLMV2   "use ntlmv2"
#define TDS_STR_VERSION   "tds version"
#define TDS_SUCCEED   1
#define TDS_SYB_VER(maj, min, x)   (((maj)<<24)|((min)<<16)|(x)<<8)
 Calc a version number for Sybase.
#define TDS_TABNAME_TOKEN   164
#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_UT_TIMESTAMP   80
#define TDS_VECTOR_SIZE(x)   (sizeof(x)/sizeof(x[0]))
#define TDS_ZERO_FREE(x)   do {free((x)); (x) = NULL;} while(0)
#define tdsdump_log   if (TDS_UNLIKELY(tds_write_dump)) tdsdump_log
#define XSYBBINARY   XSYBBINARY
#define XSYBCHAR   XSYBCHAR
#define XSYBNCHAR   XSYBNCHAR
#define XSYBNVARCHAR   XSYBNVARCHAR
#define XSYBVARBINARY   XSYBVARBINARY
#define XSYBVARCHAR   XSYBVARCHAR

Typedefs

typedef struct tds_bcpcoldata BCPCOLDATA
typedef struct tds_dstr DSTR
typedef int(* err_handler_t )(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
typedef int(* tds_bcp_get_col_data )(TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset)
typedef void(* tds_bcp_null_error )(TDSBCPINFO *bulk, int index, int offset)
typedef char TDS_CHAR
typedef struct
tds_compiletime_settings 
TDS_COMPILETIME_SETTINGS
 A structure to hold all the compile-time settings.
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 tdsdatetime TDS_DATETIME
typedef struct tdsdatetime4 TDS_DATETIME4
typedef struct tds_encoding TDS_ENCODING
 Information relevant to libiconv.
typedef enum tds_encryption_level TDS_ENCRYPTION_LEVEL
typedef tds_sysdep_real64_type TDS_FLOAT
typedef tds_sysdep_int32_type TDS_INT
typedef tds_sysdep_int64_type TDS_INT8
typedef tds_sysdep_intptr_type TDS_INTPTR
typedef union tdsmoney TDS_MONEY
typedef struct tdsmoney4 TDS_MONEY4
typedef struct tdsnumeric TDS_NUMERIC
typedef struct tdsoldmoney TDS_OLD_MONEY
typedef union tds_option_arg TDS_OPTION_ARG
typedef enum tds_packet_type TDS_PACKET_TYPE
typedef tds_sysdep_real32_type TDS_REAL
typedef tds_sysdep_int16_type TDS_SMALLINT
typedef enum _TDS_STATE 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 struct tdsunique TDS_UNIQUE
typedef unsigned
tds_sysdep_int16_type 
TDS_USMALLINT
typedef struct tdsvarbinary TDS_VARBINARY
typedef struct tdsvarchar TDS_VARCHAR
typedef struct tds_authentication TDSAUTHENTICATION
typedef struct tds_bcpinfo TDSBCPINFO
typedef struct tds_blob TDSBLOB
 Information about blobs (e.g.
typedef struct tds_column TDSCOLUMN
 Metadata about columns in regular and compute rows.
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 tdsiconvinfo TDSICONV
typedef struct tds_locale TDSLOCALE
typedef struct tds_login TDSLOGIN
typedef struct tds_message TDSMESSAGE
typedef struct tds_multiple TDSMULTIPLE
typedef TDSRESULTINFO TDSPARAMINFO
typedef struct tds_result_info TDSRESULTINFO
 Hold information for any results.
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_OPT_ARITHOVERFLOW = 0x01, TDS_OPT_NUMERICTRUNC = 0x02 }
enum  { TDS_SYSNAME_SIZE = 512 }
enum  _TDS_STATE {
  TDS_IDLE, TDS_QUERYING, TDS_PENDING, TDS_READING,
  TDS_DEAD
}
 

values for tds->state

More...
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, iso2server_metadata, initial_char_conv_count }
enum  TDS_MULTIPLE_TYPE { TDS_MULTIPLE_QUERY, TDS_MULTIPLE_EXECUTE, TDS_MULTIPLE_RPC }
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, 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_LEVEL1 = 1, TDS_OPT_LEVEL3 = 3 }
enum  TDS_OPTION {
  TDS_OPT_DATEFIRST = 1, TDS_OPT_TEXTSIZE = 2, TDS_OPT_STAT_TIME = 3, TDS_OPT_STAT_IO = 4,
  TDS_OPT_ROWCOUNT = 5, TDS_OPT_NATLANG = 6, TDS_OPT_DATEFORMAT = 7, TDS_OPT_ISOLATION = 8,
  TDS_OPT_AUTHON = 9, TDS_OPT_CHARSET = 10, TDS_OPT_SHOWPLAN = 13, TDS_OPT_NOEXEC = 14,
  TDS_OPT_ARITHIGNOREON = 15, TDS_OPT_ARITHABORTON = 17, TDS_OPT_PARSEONLY = 18, TDS_OPT_GETDATA = 20,
  TDS_OPT_NOCOUNT = 21, TDS_OPT_FORCEPLAN = 23, TDS_OPT_FORMATONLY = 24, TDS_OPT_CHAINXACTS = 25,
  TDS_OPT_CURCLOSEONXACT = 26, TDS_OPT_FIPSFLAG = 27, TDS_OPT_RESTREES = 28, TDS_OPT_IDENTITYON = 29,
  TDS_OPT_CURREAD = 30, TDS_OPT_CURWRITE = 31, TDS_OPT_IDENTITYOFF = 32, TDS_OPT_AUTHOFF = 33,
  TDS_OPT_ANSINULL = 34, TDS_OPT_QUOTED_IDENT = 35, TDS_OPT_ARITHIGNOREOFF = 36, TDS_OPT_ARITHABORTOFF = 37,
  TDS_OPT_TRUNCABORT = 38
}
enum  TDS_OPTION_CMD { TDS_OPT_SET = 1, TDS_OPT_DEFAULT = 2, TDS_OPT_LIST = 3, TDS_OPT_INFO = 4 }
 

options that can be sent with a TDS_OPTIONCMD token


enum  tds_packet_type {
  TDS_QUERY = 1, TDS_LOGIN = 2, TDS_RPC = 3, TDS_REPLY = 4,
  TDS_CANCEL = 6, TDS_BULK = 7, TDS_NORMAL = 15, TDS7_LOGIN = 16,
  TDS7_AUTH = 17, TDS8_PRELOGIN = 18
}
enum  TDS_SERVER_TYPE { SYBCHAR = 47, SYBCHAR = 47 }
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_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
}
enum  TDS_USER_TYPE { USER_UNICHAR_TYPE = 34, USER_UNIVARCHAR_TYPE = 35 }
enum  TDSERRNO {
  TDSEOK = TDS_SUCCEED, 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, TDSEBPROBADTYP = 20250,
  TDSECLOSEIN = 20292
}

Functions

int tds5_send_optioncmd (TDSSOCKET *tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG *tds_argument, TDS_INT *tds_argsize)
unsigned char * tds7_crypt_pass (const unsigned char *clear_pass, size_t len, unsigned char *crypt_pass)
 tds7_crypt_pass() -- 'encrypt' TDS 7.0 style passwords.
int tds7_get_instance_port (const char *ip_addr, const char *instance)
 Get port of given instance.
int tds7_get_instance_ports (FILE *output, const char *ip_addr)
 Get port of all instances.
void tds7_srv_charset_changed (TDSSOCKET *tds, int sql_collate, int lcid)
int tds8_submit_prepexec (TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
 tds8_submit_prepexec() creates a temporary stored procedure in the server.
BCPCOLDATAtds_alloc_bcp_column_data (int column_size)
char * tds_alloc_client_sqlstate (int msgno)
TDSCOMPUTEINFO ** tds_alloc_compute_results (TDSSOCKET *tds, int num_cols, int by_cols)
int tds_alloc_compute_row (TDSCOMPUTEINFO *res_info)
TDSCONNECTIONtds_alloc_connection (TDSLOCALE *locale)
 Allocate space for configure structure and initialize with default values.
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 (TDSSOCKET *tds, const char *id)
 Allocate a dynamic statement.
TDSLOCALEtds_alloc_locale (void)
TDSLOGINtds_alloc_login (void)
char * tds_alloc_lookup_sqlstate (TDSSOCKET *tds, int msgno)
void * tds_alloc_param_data (TDSCOLUMN *curparam)
 Allocate data for a parameter.
TDSPARAMINFOtds_alloc_param_result (TDSPARAMINFO *old_param)
 Adds a output parameter to TDSPARAMINFO.
TDSRESULTINFOtds_alloc_results (int num_cols)
int tds_alloc_row (TDSRESULTINFO *res_info)
 Allocate space for row store return NULL on out of memory.
TDSSOCKETtds_alloc_socket (TDSCONTEXT *context, int bufsize)
int tds_bcp_done (TDSSOCKET *tds, int *rows_copied)
int tds_bcp_init (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
int tds_bcp_send_record (TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset)
int tds_bcp_start (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
int tds_bcp_start_copy_in (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
int tds_close_socket (TDSSOCKET *tds)
int tds_config_boolean (const char *value)
TDS_USMALLINT tds_config_verstr (const char *tdsver, TDSCONNECTION *connection)
 Set TDS version from given string.
int tds_connect_and_login (TDSSOCKET *tds, TDSCONNECTION *connection)
int tds_count_placeholders (const char *query)
 Count the number of placeholders in query.
int tds_cursor_close (TDSSOCKET *tds, TDSCURSOR *cursor)
int tds_cursor_dealloc (TDSSOCKET *tds, TDSCURSOR *cursor)
 Send a deallocation request to server libTDS care for all deallocation stuff (memory and server cursor) Caller should not use cursor pointer anymore.
void tds_cursor_deallocated (TDSSOCKET *tds, TDSCURSOR *cursor)
int tds_cursor_declare (TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
int tds_cursor_fetch (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row)
int tds_cursor_get_cursor_info (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *row_number, TDS_UINT *row_count)
int tds_cursor_open (TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
int tds_cursor_setname (TDSSOCKET *tds, TDSCURSOR *cursor)
int tds_cursor_setrows (TDSSOCKET *tds, TDSCURSOR *cursor, int *send)
int tds_cursor_update (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO *params)
TDS_INT tds_data_get_info (TDSSOCKET *tds, TDSCOLUMN *col)
TDS_INT tds_datecrack (TDS_INT datetype, const void *di, TDSDATEREC *dr)
 Convert from db date format to a structured date format.
int tds_default_port (int major, int minor)
void tds_fix_connection (TDSCONNECTION *connection)
 Fix configuration after reading it.
int tds_flush_packet (TDSSOCKET *tds)
 Flush packet to server.
void tds_free_all_results (TDSSOCKET *tds)
void tds_free_bcp_column_data (BCPCOLDATA *coldata)
void tds_free_connection (TDSCONNECTION *connection)
void tds_free_context (TDSCONTEXT *locale)
void tds_free_dynamic (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 Frees dynamic statement and remove from TDS.
void tds_free_input_params (TDSDYNAMIC *dyn)
 Frees all allocated input parameters of a dynamic statement.
void tds_free_locale (TDSLOCALE *locale)
void tds_free_login (TDSLOGIN *login)
void tds_free_msg (TDSMESSAGE *message)
void tds_free_param_result (TDSPARAMINFO *param_info)
 Delete latest parameter.
void tds_free_param_results (TDSPARAMINFO *param_info)
void tds_free_result_info (TDSRESULTINFO *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)
int tds_get_cardinal_type (int datatype, int usertype)
int tds_get_char_data (TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol)
 Fetch character data the wire.
const TDS_COMPILETIME_SETTINGStds_get_compiletime_settings (void)
 Return a structure capturing the compile-time settings provided to the configure script.
int tds_get_conversion_type (int srctype, int colsize)
char * tds_get_homedir (void)
 Get user home directory.
TDS_INT tds_get_int (TDSSOCKET *tds)
 Get an int32 from the server.
TDS_INT8 tds_get_int8 (TDSSOCKET *tds)
TDSLOCALEtds_get_locale (void)
 Get locale information.
void * tds_get_n (TDSSOCKET *tds, void *dest, int n)
 Get N bytes from the buffer and return them in the already allocated space given to us.
int tds_get_size_by_type (int servertype)
TDS_SMALLINT tds_get_smallint (TDSSOCKET *tds)
 Get an int16 from the server.
int tds_get_string (TDSSOCKET *tds, int string_len, char *dest, size_t dest_size)
 Fetch a string from the wire.
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
int tds_get_varint_size (TDSSOCKET *tds, int datatype)
struct hostent * tds_gethostbyaddr_r (const char *addr, int len, int type, struct hostent *result, char *buffer, int buflen, int *h_errnop)
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])
struct servent * tds_getservbyname_r (const char *name, const char *proto, struct servent *result, char *buffer, int buflen)
unsigned int tds_gettime_ms (void)
TDSAUTHENTICATIONtds_gss_get_auth (TDSSOCKET *tds)
int tds_iconv_alloc (TDSSOCKET *tds)
 Allocate iconv stuff.
void tds_iconv_close (TDSSOCKET *tds)
void tds_iconv_free (TDSSOCKET *tds)
TDSICONVtds_iconv_from_collate (TDSSOCKET *tds, TDS_UCHAR collate[5])
 Get iconv information from a LCID (to support different column encoding under MSSQL2K).
void tds_iconv_open (TDSSOCKET *tds, const char *charset)
int tds_init_write_buf (TDSSOCKET *tds)
int tds_lastpacket (TDSSOCKET *tds)
struct tm * tds_localtime_r (const time_t *timep, struct tm *result)
TDSDYNAMICtds_lookup_dynamic (TDSSOCKET *tds, const char *id)
 Find a dynamic given string id.
int tds_lookup_host (const char *servername, char *ip)
 Get the IP address for a hostname.
char * tds_money_to_string (const TDS_MONEY *money, char *s)
int tds_multiple_done (TDSSOCKET *tds, TDSMULTIPLE *multiple)
int tds_multiple_execute (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC *dyn)
int tds_multiple_init (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type)
int tds_multiple_query (TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO *params)
int tds_needs_unprepare (TDSSOCKET *tds, TDSDYNAMIC *dyn)
const char * tds_next_placeholder (const char *start)
 Get position of next placeholder.
TDSAUTHENTICATIONtds_ntlm_get_auth (TDSSOCKET *tds)
 Build a NTLMSPP packet to send to server.
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, const char *ip_addr, unsigned int port, int timeout, int *p_oserr)
void tds_parse_conf_section (const char *option, const char *value, void *param)
unsigned char tds_peek (TDSSOCKET *tds)
int tds_process_cancel (TDSSOCKET *tds)
int tds_process_login_tokens (TDSSOCKET *tds)
 tds_process_login_tokens() is called after sending the login packet to the server.
int 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.
int tds_process_tokens (TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
 process all streams.
const char * tds_prtype (int token)
const char * tds_prwsaerror (int erc)
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_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.
int tds_quote_id (TDSSOCKET *tds, char *buffer, const char *id, int idlen)
 Quote an id.
int tds_quote_string (TDSSOCKET *tds, char *buffer, const char *str, int len)
 Quote a string.
int tds_read_conf_file (TDSCONNECTION *connection, const char *server)
 Read configuration info for given server return 0 on error.
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).
TDSCONNECTIONtds_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
int tds_read_packet (TDSSOCKET *tds)
 Read in one 'packet' from the server.
TDSSOCKETtds_realloc_socket (TDSSOCKET *tds, size_t bufsize)
void tds_release_cursor (TDSSOCKET *tds, TDSCURSOR *cursor)
int 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.
void tds_set_app (TDSLOGIN *tds_login, const char *application)
void tds_set_bulk (TDSLOGIN *tds_login, TDS_TINYINT enabled)
void tds_set_capabilities (TDSLOGIN *tds_login, unsigned char *capabilities, int size)
void tds_set_client_charset (TDSLOGIN *tds_login, const char *charset)
void tds_set_column_type (TDSSOCKET *tds, TDSCOLUMN *curcol, int type)
 Set type of column initializing all dependency.
void tds_set_database_name (TDSLOGIN *tds_login, const char *dbname)
void tds_set_host (TDSLOGIN *tds_login, const char *hostname)
int tds_set_interfaces_file_loc (const char *interfloc)
 Set the full name of interface file.
void tds_set_language (TDSLOGIN *tds_login, const char *language)
void tds_set_library (TDSLOGIN *tds_login, const char *library)
void tds_set_packet (TDSLOGIN *tds_login, int packet_size)
void tds_set_param_type (TDSSOCKET *tds, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
 Set type of column initializing all dependency.
void tds_set_parent (TDSSOCKET *tds, void *the_parent)
void tds_set_passwd (TDSLOGIN *tds_login, const char *password)
void tds_set_port (TDSLOGIN *tds_login, int port)
void tds_set_server (TDSLOGIN *tds_login, const char *server)
 Set the servername in a TDSLOGIN structure.
TDS_STATE tds_set_state (TDSSOCKET *tds, TDS_STATE state)
 Set state of TDS connection, with logging and checking.
void tds_set_user (TDSLOGIN *tds_login, const char *username)
void tds_set_version (TDSLOGIN *tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver)
const char * tds_skip_quoted (const char *s)
 Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd]).
void tds_srv_charset_changed (TDSSOCKET *tds, const char *charset)
void tds_ssl_deinit (TDSSOCKET *tds)
int tds_ssl_init (TDSSOCKET *tds)
int tds_submit_execdirect (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params)
 Submit a prepared query with parameters.
int tds_submit_execute (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 tds_submit_execute() sends a previously prepared dynamic statement to the server.
int tds_submit_optioncmd (TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size)
int 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.
int tds_submit_query (TDSSOCKET *tds, const char *query)
 tds_submit_query() sends a language string to the database server for processing.
int tds_submit_query_params (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params)
 tds_submit_query_params() sends a language string to the database server for processing.
int tds_submit_queryf (TDSSOCKET *tds, const char *queryf,...)
int tds_submit_rpc (TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params)
 tds_submit_rpc() call a RPC from server.
int tds_submit_unprepare (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 Send a unprepare request for a prepared query.
int tds_swap_bytes (unsigned char *buf, int bytes)
void tds_swap_numeric (TDS_NUMERIC *num)
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.
int tds_version (TDSSOCKET *tds_socket, char *pversion_string)
 Returns the version of the TDS protocol in effect for the link as a decimal integer.
int tds_vstrbuild (char *buffer, int buflen, int *resultlen, char *text, int textlen, const char *formats, int formatlen, va_list ap)
int tds_write_packet (TDSSOCKET *tds, unsigned char final)
int tds_writetext_continue (TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size)
int tds_writetext_end (TDSSOCKET *tds)
int tds_writetext_start (TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size)
void tdsdump_close (void)
 Close the TDS dump log file.
void tdsdump_col (const TDSCOLUMN *col)
 Write a column value to the debug log.
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.
int tdsdump_isopen (void)
void tdsdump_log (const char *file, unsigned int level_line, const char *fmt,...)
 Write a message to the debug log.
void tdsdump_off (void)
 Temporarily turn off logging.
void tdsdump_on (void)
 Turn logging back on.
int tdsdump_open (const char *filename)
 Create and truncate a human readable dump file for the TDS traffic.
int tdserror (const TDSCONTEXT *tds_ctx, TDSSOCKET *tds, int msgno, int errnum)
 Call the client library's error handler (for library-generated errors only).

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.
int tds_write_dump

Detailed Description

Main include file for libtds.


Define Documentation

#define is_end_token (  ) 
Value:
(x==TDS_DONE_TOKEN    || \
                        x==TDS_DONEPROC_TOKEN    || \
                        x==TDS_DONEINPROC_TOKEN)
#define is_fixed_type (  ) 
Value:
(x==SYBINT1    || \
                        x==SYBINT2      || \
                        x==SYBINT4      || \
                        x==SYBINT8      || \
                        x==SYBREAL      || \
                        x==SYBFLT8      || \
                        x==SYBDATETIME  || \
                        x==SYBDATETIME4 || \
                        x==SYBBIT       || \
                        x==SYBMONEY     || \
                        x==SYBMONEY4    || \
                        x==SYBVOID      || \
                        x==SYBUNIQUE)
#define is_hard_end_token (  ) 
Value:
(x==TDS_DONE_TOKEN    || \
                        x==TDS_DONEPROC_TOKEN)
#define is_msg_token (  ) 
Value:
(x==TDS_INFO_TOKEN    || \
                        x==TDS_ERROR_TOKEN    || \
                        x==TDS_EED_TOKEN)
#define is_nullable_type (  ) 
Value:
( \
                        x==SYBBITN      || \
                     x==SYBINTN      || \
                     x==SYBFLTN      || \
                     x==SYBMONEYN    || \
                     x==SYBDATETIMN  || \
                     x==SYBVARCHAR   || \
                     x==SYBBINARY    || \
                     x==SYBVARBINARY || \
                     x==SYBTEXT      || \
                     x==SYBNTEXT     || \
                     x==SYBIMAGE)
#define is_result_token (  ) 
Value:
(x==TDS_RESULT_TOKEN || \
                        x==TDS_ROWFMT2_TOKEN    || \
                        x==TDS7_RESULT_TOKEN    || \
                        x==TDS_COLFMT_TOKEN     || \
                        x==TDS_COLNAME_TOKEN    || \
                        x==TDS_RETURNSTATUS_TOKEN)
#define is_variable_type (  ) 
Value:
( \
        (x)==SYBTEXT    || \
        (x)==SYBIMAGE   || \
        (x)==SYBNTEXT   || \
        (x)==SYBCHAR    || \
        (x)==SYBVARCHAR || \
        (x)==SYBBINARY  || \
        (x)==SYBVARBINARY       || \
        (x)==SYBLONGBINARY      || \
        (x)==XSYBCHAR   || \
        (x)==XSYBVARCHAR        || \
        (x)==XSYBNVARCHAR       || \
        (x)==XSYBNCHAR)
#define TDS_BYTE_SWAP16 ( value   ) 
Value:
(((((unsigned short)value)<<8) & 0xFF00)   | \
          ((((unsigned short)value)>>8) & 0x00FF))
#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))
#define TDS_IS_MSSQL (  )     ((x->product_version & 0x80000000u)!=0)

Check if product is Microsft SQL Server.

x should be a TDS_SOCKET*.

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

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

x should be a TDS_SOCKET*.

#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))

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

Calc a version number for Sybase.


Typedef Documentation

A structure to hold all the compile-time settings.

This structure is returned by tds_get_compiletime_settings

typedef struct tds_encoding TDS_ENCODING

Information relevant to libiconv.

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

typedef struct tds_blob TDSBLOB

Information about blobs (e.g.

text or image). current_row contains this structure.


Enumeration Type Documentation

enum _TDS_STATE

values for tds->state

Enumerator:
TDS_IDLE 

no data expected

TDS_QUERYING 

client is sending request

TDS_PENDING 

cilent is waiting for data

TDS_READING 

client is reading data

TDS_DEAD 

no connection

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.


Function Documentation

unsigned char* tds7_crypt_pass ( const unsigned char *  clear_pass,
size_t  len,
unsigned char *  crypt_pass 
)

tds7_crypt_pass() -- 'encrypt' TDS 7.0 style passwords.

the calling function is responsible for ensuring crypt_pass is at least 'len' characters

int tds_bcp_send_record ( TDSSOCKET tds,
TDSBCPINFO bcpinfo,
tds_bcp_get_col_data  get_col_data,
tds_bcp_null_error  null_error,
int  offset 
)
Returns:
TDS_SUCCEED or TDS_FAIL.
char* tds_get_homedir ( void   ) 

Get user home directory.

Returns:
home directory or NULL if error. Should be freed with free
TDSLOCALE* tds_get_locale ( void   ) 

Get locale information.

Returns:
allocated structure with all information or NULL if error
int tds_iconv_alloc ( TDSSOCKET tds  ) 

Allocate iconv stuff.

Returns:
0 for success
void tds_set_column_type ( TDSSOCKET tds,
TDSCOLUMN curcol,
int  type 
)

Set type of column initializing all dependency.

Parameters:
curcol column to set
type type to set
void tds_set_param_type ( TDSSOCKET tds,
TDSCOLUMN curcol,
TDS_SERVER_TYPE  type 
)

Set type of column initializing all dependency.

Parameters:
tds state information for the socket and the TDS protocol
curcol column to set
type type to set
void 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_login points to a TDSLOGIN structure
server the servername, or NULL, or a zero-length string
Todo:
open the log file earlier, so these messages can be seen.
TDS_STATE tds_set_state ( TDSSOCKET tds,
TDS_STATE  state 
)

Set state of TDS connection, with logging and checking.

Parameters:
tds state information for the socket and the TDS protocol
state the new state of the connection, cf. TDS_STATE.
Returns:
the new state, which might not be state.
char* tds_timestamp_str ( char *  str,
int  maxlen 
)

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

int tds_version ( TDSSOCKET tds_socket,
char *  pversion_string 
)

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".

void tdsdump_col ( const TDSCOLUMN col  ) 

Write a column value to the debug log.

Parameters:
file name of the log file
col column to dump
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:
msg message to print before dump
buf buffer to dump
length number of bytes in the buffer
void tdsdump_log ( const char *  file,
unsigned int  level_line,
const char *  fmt,
  ... 
)

Write a message to the debug log.

Parameters:
file name of the log file
level_line kind of detail to be included
fmt printf-like format string
void tdsdump_on ( void   ) 

Turn logging back on.

You must call tdsdump_open() before calling this routine.

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.
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_ctx points to a TDSCONTEXT structure
tds the connection structure, may be NULL if not connected
msgno an enumerated libtds msgno, cf. tds.h
errnum the OS errno, if it matters, else zero
Returns:
client library function's return code

Variable Documentation

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

Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00159_source.html100664 001750 000144 00000630720 11623073546 0017174 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tds.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00160_source.html100664 001750 000144 00000021327 11623073546 0017161 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tds_configs.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00161_source.html100664 001750 000144 00000075053 11623073546 0017167 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tds_sysdep_private.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00190.html100664 001750 000144 00000051704 11623073547 0015607 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/dblib/bcp.c File Reference

/home/jklowden/releases/freetds-0.91/src/dblib/bcp.c File Reference

Implementation of db-lib bulk copy functions. More...

#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include <tds.h>
#include <tdsiconv.h>
#include <tdsconvert.h>
#include <replacements.h>
#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>
#include <dblib.h>

Defines

#define fseeko(f, o, w)   fseek(f,o,w)
#define ftello(f)   ftell(f)
#define HOST_COL_CONV_ERROR   1
#define HOST_COL_NULL_ERROR   2
#define MAX(a, b)   ( (a) > (b) ? (a) : (b) )

Typedefs

typedef long offset_type

Functions

static RETCODE _bcp_check_eof (DBPROCESS *dbproc, FILE *file, int icol)
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 int _bcp_get_col_data (TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset)
 For a bcp in from program variables, get the data from the host variable.
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.
static offset_type _bcp_measure_terminated_field (FILE *hostfile, BYTE *terminator, int term_len)
static int _bcp_no_get_col_data (TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset)
static void _bcp_null_error (TDSBCPINFO *bcpinfo, int index, int offset)
static RETCODE _bcp_read_hostfile (DBPROCESS *dbproc, FILE *hostfile, int *row_error)
static int _bcp_readfmt_colinfo (DBPROCESS *dbproc, char *buf, BCP_HOSTCOLINFO *ci)
DBINT bcp_batch (DBPROCESS *dbproc)
 Commit a set of rows to the table.
RETCODE bcp_bind (DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int vartype, int table_column)
 Bind a program host variable to a database column.
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.
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.
RETCODE bcp_collen (DBPROCESS *dbproc, DBINT varlen, int table_column)
 Set the length of a host variable to be written to a table.
RETCODE bcp_colptr (DBPROCESS *dbproc, BYTE *colptr, int table_column)
 Override bcp_bind() by pointing to a different host variable.
RETCODE bcp_columns (DBPROCESS *dbproc, int host_colcount)
 Indicate how many columns are to be found in the datafile.
RETCODE bcp_control (DBPROCESS *dbproc, int field, DBINT value)
 Set BCP options for uploading a datafile.
DBINT bcp_done (DBPROCESS *dbproc)
 Conclude the transfer of data from program variables.
RETCODE bcp_exec (DBPROCESS *dbproc, DBINT *rows_copied)
 Write a datafile to a table.
int bcp_getbatchsize (DBPROCESS *dbproc)
DBBOOL bcp_getl (LOGINREC *login)
 See if BCP_SETL() was used to set the LOGINREC for BCP work.
RETCODE bcp_init (DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction)
 Prepare for bulk copy operation on a table.
RETCODE bcp_options (DBPROCESS *dbproc, int option, BYTE *value, int valuelen)
 Set "hints" for uploading a file.
RETCODE bcp_readfmt (DBPROCESS *dbproc, const char filename[])
 Read a format definition file.
RETCODE bcp_sendrow (DBPROCESS *dbproc)
 Write data in host variables to the table.
static void init_hostfile_columns (DBPROCESS *dbproc)
static int rtrim (char *str, int len)
 trim a string of trailing blanks
 TDS_RCSID (var,"$Id: bcp.c,v 1.197.2.8 2011/06/07 08:52:29 freddy77 Exp $")

Detailed Description

Implementation of db-lib bulk copy functions.

Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00162_source.html100664 001750 000144 00000062571 11623073546 0017171 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tdsbytes.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00163_source.html100664 001750 000144 00000037004 11623073546 0017163 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tdsconvert.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00164_source.html100664 001750 000144 00000045704 11623073546 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tdsiconv.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00165_source.html100664 001750 000144 00000217211 11623073546 0017165 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tdsodbc.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00166_source.html100664 001750 000144 00000035563 11623073546 0017176 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tdssrv.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00167_source.html100664 001750 000144 00000031007 11623073546 0017164 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tdsstring.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00168_source.html100664 001750 000144 00000027516 11623073546 0017177 FreeTDS API: /home/jklowden/releases/freetds-0.91/include/tdsthread.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00175_source.html100664 001750 000144 00000014373 11623073546 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/apps/fisql/edit.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00178_source.html100664 001750 000144 00000016036 11623073546 0017173 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/apps/fisql/handlers.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00180_source.html100664 001750 000144 00000015526 11623073546 0017167 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/apps/fisql/interrupt.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00182_source.html100664 001750 000144 00000014601 11623073546 0017162 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/apps/fisql/terminal.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00184_source.html100664 001750 000144 00000022707 11623073546 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/apps/freebcp.h Source File
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00191_source.html100664 001750 000144 00000137665 11623073547 0017203 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/dblib/buffering.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00192.html100664 001750 000144 00000264272 11623073547 0015617 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/dblib/dblib.c File Reference

/home/jklowden/releases/freetds-0.91/src/dblib/dblib.c File Reference

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

#include <stdarg.h>
#include <time.h>
#include <assert.h>
#include <stdio.h>
#include <tds.h>
#include <tdsthread.h>
#include <tdsconvert.h>
#include <replacements.h>
#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>
#include <dblib.h>
#include "buffering.h"

Classes

struct  _dblib_error_message
struct  dblib_context

Typedefs

typedef struct _dblib_error_message DBLIB_ERROR_MESSAGE
typedef struct dblib_context DBLIBCONTEXT

Functions

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

Variables

EHANDLEFUNC _dblib_err_handler = default_err_handler
MHANDLEFUNC _dblib_msg_handler = NULL
static const DBLIB_ERROR_MESSAGE dblib_error_messages []
static NULLREP default_null_representations [MAXBINDTYPES]
static int errno = 0
static DBLIBCONTEXT g_dblib_ctx
static int g_dblib_version
static const DBBIGINT null_BIGINT = 0
static const DBBINARY null_BINARY = 0
static const DBCHAR null_CHAR = '\0'
static const DBDATETIME null_DATETIME = { 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

typedef struct dblib_context DBLIBCONTEXT

For internal use only.

Remarks:
A db-lib connection has an implicit TDS context.

Function Documentation

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:
dbproc contains all information needed by db-lib to manage communications with the server.
type must be CI_REGULAR or CI_ALTERNATE (CI_CURSOR is defined by the vendor, but is not yet implemented).
column Nth in the result set, starting from 1.
computeid (ignored)
pdbcol address 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.
static RETCODE dbgetnull ( DBPROCESS dbproc,
int  bindtype,
int  varlen,
BYTE *  varaddr 
) [static]

For internal use only.

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 NTBSTRINGBIND DBCHAR none VARYCHARBIND DBVARYCHAR none none BOUNDARYBIND DBCHAR none SENSITIVITYBIND DBCHAR none

Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00195_source.html100664 001750 000144 00000157770 11623073547 0017206 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/dblib/error_table.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00209_source.html100664 001750 000144 00000037172 11623073547 0017173 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/odbc/sqlwparams.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00214_source.html100664 001750 000144 00000037760 11623073547 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/pool/pool.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00238_source.html100664 001750 000144 00000222651 11623073547 0017173 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/tds/alternative_character_sets.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00241_source.html100664 001750 000144 00000044426 11623073547 0017167 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/tds/character_sets.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00245_source.html100664 001750 000144 00000036715 11623073547 0017175 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/tds/enum_cap.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00261_source.html100664 001750 000144 00000047355 11623073547 0017175 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/tds/sybase_character_sets.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00264_source.html100664 001750 000144 00000026322 11623073547 0017167 FreeTDS API: /home/jklowden/releases/freetds-0.91/src/tds/tds_checks.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00272_source.html100664 001750 000144 00000026164 11623073547 0017172 FreeTDS API: /home/jklowden/releases/freetds-0.91/vms/vargdefs.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00277_source.html100664 001750 000144 00000067152 11623073547 0017201 FreeTDS API: /home/jklowden/releases/freetds-0.91/win32/config.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00278_source.html100664 001750 000144 00000010423 11623073547 0017167 FreeTDS API: /home/jklowden/releases/freetds-0.91/win32/freetds_sysconfdir.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00281_source.html100664 001750 000144 00000016361 11623073547 0017170 FreeTDS API: /home/jklowden/releases/freetds-0.91/win32/resource.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00282_source.html100664 001750 000144 00000023624 11623073547 0017171 FreeTDS API: /home/jklowden/releases/freetds-0.91/win32/tds_sysdep_public.h Source File
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00285.html100664 001750 000144 00000031461 11623073547 0015612 FreeTDS API: The db-lib API

The db-lib API

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

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.


Defines

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

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.


Define Documentation

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

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

See also:
bcp_setl()
DBSETLAPP ( x,
 )     dbsetlname((x), (y), DBSETAPP)

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

See also:
dbsetlapp()
DBSETLHOST ( x,
 )     dbsetlname((x), (y), DBSETHOST)

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

See also:
dbsetlhost()
DBSETLPWD ( x,
 )     dbsetlname((x), (y), DBSETPWD)

Set the password in the login packet.

See also:
dbsetlpwd()
DBSETLUSER ( x,
 )     dbsetlname((x), (y), DBSETUSER)

Set the username in the login packet.

See also:
dbsetluser()
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00286.html100664 001750 000144 00001073210 11623073547 0015612 FreeTDS API: Primary functions

Primary functions
[The db-lib API]

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

Defines

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

Functions

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

Detailed Description

Core functions needed by most db-lib programs.


Define Documentation

DBCMDROW (  )     dbcmdrow((x))

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

See also:
dbcmdrow()
DBCOUNT (  )     dbcount((x))

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

See also:
dbcount()
DBCURCMD (  )     dbcurcmd((x))

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

See also:
dbcurcmd()
DBCURROW (  )     dbcurrow((x))

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

See also:
dbcurrow()
DBDEAD (  )     dbdead((x))

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

See also:
dbdead()
DBFIRSTROW (  )     dbfirstrow((x))

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

See also:
dbfirstrow()
DBIORDESC (  )     dbiordesc((x))

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

See also:
dbiordesc()
DBIOWDESC (  )     dbiowdesc((x))

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

See also:
dbiowdesc()
DBISAVAIL (  )     dbisavail((x))

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

See also:
dbisavail()
DBLASTROW (  )     dblastrow((x))

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

See also:
dblastrow(), DBFIRSTROW()
DBMORECMDS (  )     dbmorecmds((x))

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

See also:
dbmorecmds()
DBROWS (  )     dbrows((x))

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

See also:
dbrows()
DBROWTYPE (  )     dbrowtype((x))

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

See also:
dbrowtype()
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 ( 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 ( x,
 )     dbsetlname((x), (y), DBSETNATLANG)

Set the language the server should use for messages.

See also:
DBSETLNATLANG(), dbsetlname()
DBSETLNATLANG ( x,
 )     dbsetlname((x), (y), DBSETNATLANG)

Set the language the server should use for messages.

See also:
dbsetlnatlang(), dbsetlname()
dbsetlpacket ( x,
 )     dbsetllong((x), (y), DBSETPACKET)

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

See also:
DBSETLPACKET(), dbsetllong()
DBSETLPACKET ( x,
 )     dbsetllong((x), (y), DBSETPACKET)

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

See also:
dbsetlpacket(), dbsetllong()
DBTDS (  )     dbtds(a)

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

See also:
dbtds()

Function Documentation

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

Get address of compute column data.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
column Nth column in computeid, starting from 1.
Returns:
pointer to columns's data buffer.
Return values:
NULL no such computeid or column.
See also:
dbadlen(), dbaltbind(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().
DBINT dbadlen ( DBPROCESS dbproc,
int  computeid,
int  column 
)

Get size of data in a compute column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
column Nth column in computeid, starting from 1.
Returns:
size of the data, in bytes.
Return values:
-1 no such column or computeid.
0 data are NULL.
See also:
dbadata(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().
RETCODE dbaltbind ( DBPROCESS dbproc,
int  computeid,
int  column,
int  vartype,
DBINT  varlen,
BYTE *  varaddr 
)

Bind a compute column to a program variable.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
column Nth column in computeid, starting from 1.
vartype datatype of the host variable that will receive the data
varlen size of host variable pointed to varaddr
varaddr address of host variable
Return values:
SUCCEED everything worked.
FAIL no 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().
int dbaltcolid ( DBPROCESS dbproc,
int  computeid,
int  column 
)

Get column ID of a compute column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
column Nth 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().
DBINT dbaltlen ( DBPROCESS dbproc,
int  computeid,
int  column 
)

Get size of data in compute column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
column Nth column in computeid, starting from 1.
See also:
dbadata(), dbadlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().
int dbaltop ( DBPROCESS dbproc,
int  computeid,
int  column 
)

Get aggregation operator for a compute column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
column Nth column in computeid, starting from 1.
Returns:
token value for the type of the compute column's aggregation operator.
Return values:
-1 no such computeid or column.
See also:
dbadata(), dbadlen(), dbaltlen(), dbnextrow(), dbnumalts(), dbprtype().
int dbalttype ( DBPROCESS dbproc,
int  computeid,
int  column 
)

Get datatype for a compute column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
column Nth column in computeid, starting from 1.
Returns:
SYB* dataype token.
Return values:
-1 no such column or computeid.
See also:
dbadata(), dbadlen(), dbaltlen(), dbnextrow(), dbnumalts(), dbprtype().
DBINT dbaltutype ( DBPROCESS dbproc,
int  computeid,
int  column 
)

Get user-defined datatype of a compute column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
column Nth column in computeid, starting from 1.
Returns:
user-defined datatype of compute column, else -1.
See also:
dbalttype(), dbcolutype().
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:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid identifies which one of potientially many compute rows is meant. The first compute clause has computeid == 1.
column Nth column in the result set, starting with 1.
indicator address of host variable.
Return values:
SUCCEED variable accepted.
FAIL indicator 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.
RETCODE dbbind ( DBPROCESS dbproc,
int  column,
int  vartype,
DBINT  varlen,
BYTE *  varaddr 
)

Tie a host variable to a resultset column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth column, starting at 1.
vartype datatype of the host variable that will receive the data
varlen size of host variable pointed to varaddr
varaddr address of host variable
Return values:
SUCCEED everything worked.
FAIL no such column or no such conversion possible, or target buffer too small.
See also:
BYTE* dbbylist ( DBPROCESS dbproc,
int  computeid,
int *  size 
)

Get bylist for a compute row.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of COMPUTE clause to which we're referring.
size output: size of bylist buffer whose address is returned, possibly zero.
Returns:
address of bylist for computeid.
Return values:
NULL no such computeid.
Remarks:
Do not free returned pointer.
See also:
dbadata(), dbadlen(), dbaltlen(), dbalttype(), dbcolname(), dbgetrow(), dbnextrow().
RETCODE dbcancel ( DBPROCESS dbproc  ) 

Cancel the current command batch.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
SUCCEED always.
See also:
dbcanquery(), dbnextrow(), dbresults(), dbsetinterrupt(), dbsqlexec(), dbsqlok(), dbsqlsend().
Todo:
Check for failure and return accordingly.
RETCODE dbcanquery ( DBPROCESS dbproc  ) 

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
char* dbchange ( DBPROCESS dbproc  ) 

See if a command caused the current database to change.

Parameters:
dbproc contains 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().
void dbclose ( DBPROCESS dbproc  ) 

Close a connection to the server and free associated resources.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
dbexit(), dbopen().
void dbclrbuf ( DBPROCESS dbproc,
DBINT  n 
)

Clear n rows from the row buffer.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
n number of rows to remove, >= 0.
See also:
dbgetrow(), dbnextrow(), dbsetopt().
RETCODE dbclropt ( DBPROCESS dbproc,
int  option,
const char  param[] 
)

Reset an option.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
option to be turned off.
param clearing some options requires a parameter, believe it or not.
Return values:
SUCCEED option and parameter seem sane.
FAIL no such option.
Remarks:
Only the following options are recognized:
  • DBARITHABORT
  • DBARITHIGNORE
  • DBCHAINXACTS
  • DBFIPSFLAG
  • DBISOLATION
  • DBNOCOUNT
  • DBNOEXEC
  • DBPARSEONLY
  • DBSHOWPLAN
  • DBSTORPROCID
  • DBQUOTEDIDENT
See also:
dbisopt(), dbsetopt().
RETCODE dbcmd ( DBPROCESS dbproc,
const char  cmdstring[] 
)

Append SQL to the command buffer.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
cmdstring SQL to append to the command buffer.
Return values:
SUCCEED success.
FAIL insufficient 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().
DBINT dbcollen ( DBPROCESS dbproc,
int  column 
)

Get size of a regular result column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth 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().
char* dbcolname ( DBPROCESS dbproc,
int  column 
)

Return name of a regular result column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth in the result set, starting with 1.
Returns:
pointer to ASCII null-terminated string, the name of the column.
Return values:
NULL column 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.
char* dbcolsource ( DBPROCESS dbproc,
int  column 
)

Get base database column name for a result set column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth 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().
int dbcoltype ( DBPROCESS dbproc,
int  column 
)

Get the datatype of a regular result set column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth 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().
DBTYPEINFO* dbcoltypeinfo ( DBPROCESS dbproc,
int  column 
)

Get precision and scale information for a regular result column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth 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().
int dbcolutype ( DBPROCESS dbproc,
int  column 
)

Get user-defined datatype of a regular result column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth in the result set, starting from 1.
Returns:
SYB* datetype token value, or -1 if column out of range
See also:
dbaltutype(), dbcoltype().
DBINT dbconvert ( DBPROCESS dbproc,
int  srctype,
const BYTE *  src,
DBINT  srclen,
int  desttype,
BYTE *  dest,
DBINT  destlen 
)

Convert one datatype to another.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
srctype datatype of the data to convert.
src buffer to convert
srclen length of src
desttype target datatype
dest output buffer
destlen size 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.

DBINT dbconvert_ps ( DBPROCESS dbproc,
int  srctype,
BYTE *  src,
DBINT  srclen,
int  desttype,
BYTE *  dest,
DBINT  destlen,
DBTYPEINFO typeinfo 
)

cf.

dbconvert(), above

Sybase: Convert numeric types.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
srctype datatype of the data to convert.
src buffer to convert
srclen length of src
desttype target datatype
dest output buffer
destlen size of dest
typeinfo address of a DBTYPEINFO structure that governs the precision & scale of the output, may be NULL.
See also:
dbaltbind(), dbaltbind_ps(), dbbind(), dbbind_ps(), dbconvert(), dberrhandle(), dbsetnull(), dbsetversion(), dbwillconvert().
DBINT dbcount ( DBPROCESS dbproc  ) 

Get count of rows processed.

Parameters:
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.
See also:
DBCOUNT(), dbnextrow(), dbresults().
BYTE* dbdata ( DBPROCESS dbproc,
int  column 
)

Get address of data in a regular result column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth 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().
RETCODE dbdatecrack ( DBPROCESS dbproc,
DBDATEREC output,
DBDATETIME datetime 
)

Break a DBDATETIME value into useful pieces.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
di output: structure to contain the exploded parts of datetime.
datetime input: DBDATETIME to be converted.
Return values:
SUCCEED always.
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().
DBINT dbdatlen ( DBPROCESS dbproc,
int  column 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth in the result set, starting from 1.
Returns:
size of the data, in bytes.
See also:
dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbnumcols().
EHANDLEFUNC dberrhandle ( EHANDLEFUNC  handler  ) 

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

Parameters:
handler pointer 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().
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.
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:
dbproc contains all information needed by db-lib to manage communications with the server.
fmt  man vasprintf for details.
Return values:
SUCCEED success.
FAIL insufficient memory, or dbcmd() failed.
See also:
dbcmd(), dbfreebuf(), dbgetchar(), dbopen(), dbstrcpy(), dbstrlen().
void dbfreebuf ( DBPROCESS dbproc  ) 

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
dbcmd(), dbfcmd(), dbgetchar(), dbsqlexec(), dbsqlsend(), dbsetopt(), dbstrcpy(), dbstrlen().
char* dbgetchar ( DBPROCESS dbproc,
int  pos 
)

Get address of a position in the command buffer.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
pos offset within the command buffer, starting at 0.
Remarks:
A bit overspecialized, this one.
See also:
dbcmd(), dbfcmd(), dbfreebuf(), dbstrcpy(), dbstrlen(),
int dbgetmaxprocs ( void   ) 

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

Returns:
Current maximum.
See also:
dbsetmaxprocs(), dbopen()
int dbgetpacket ( DBPROCESS dbproc  ) 

Get TDS packet size for the connection.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Returns:
TDS packet size, in bytes.
See also:
DBSETLPACKET()
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:
dbproc contains all information needed by db-lib to manage communications with the server.
row Nth row to read, starting with 1.
Return values:
REG_ROW returned row is a regular row.
Returns:
computeid when returned row is a compute row.
Return values:
NO_MORE_ROWS no such row in the row buffer. Current row is unchanged.
FAIL unsuccessful; row buffer may be full.
See also:
dbaltbind(), dbbind(), dbclrbuf(), DBCURROW(), DBFIRSTROW(), DBLASTROW(), dbnextrow(), dbsetrow().
int dbgettime ( void   ) 

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

Return values:
query timeout limit, in seconds
See also:
dberrhandle(), DBSETTIME(), dbsetlogintime(), dbsqlexec(), dbsqlok(), dbsqlsend().
BYTE* dbgetuserdata ( DBPROCESS dbproc  ) 

Get address of user-allocated data from a DBPROCESS.

Parameters:
dbproc contains 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().
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:
SUCCEED normal.
FAIL cannot allocate an array of TDS_MAX_CONN TDSSOCKET pointers.
BOOL dbiscount ( DBPROCESS dbproc  ) 

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

Parameters:
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.
See also:
DBCOUNT(), dbcount().
DBBOOL dbisopt ( DBPROCESS dbproc,
int  option,
const char  param[] 
)

Get value of an option.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
option the option
param a parameter to option.
See also:
dbclropt(), dbsetopt().
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:
NULL the LOGINREC cannot be allocated.
LOGINREC* to valid memory, otherwise.
void dbloginfree ( LOGINREC login  ) 

free the LOGINREC

RETCODE dbmorecmds ( DBPROCESS dbproc  ) 

See if more commands are to be processed.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
DBMORECMDS(). DBCMDROW(), dbresults(), DBROWS(), DBROWTYPE().
RETCODE dbmoretext ( DBPROCESS dbproc,
DBINT  size,
const BYTE  text[] 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
size count of bytes to send.
text textpointer, obtained from dbtxptr.
Return values:
SUCCEED always.
See also:
dbtxptr(), dbtxtimestamp(), dbwritetext().
Todo:
Check return value of called functions and return FAIL if appropriate.
MHANDLEFUNC dbmsghandle ( MHANDLEFUNC  handler  ) 

Set a message handler, for messages from the server.

Parameters:
handler address of the function that will process the messages.
See also:
DBDEAD(), dberrhandle().
char* dbname ( DBPROCESS dbproc  ) 

Get name of current database.

Parameters:
dbproc contains 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().
RETCODE dbnextrow ( DBPROCESS dbproc  ) 

Read result row into the row buffer and into any bound host variables.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
REG_ROW regular row has been read.
Returns:
computeid when a compute row is read.
Return values:
BUF_FULL reading next row would cause the buffer to be exceeded (and buffering is turned on). No row was read from the server
See also:
dbaltbind(), dbbind(), dbcanquery(), dbclrbuf(), dbgetrow(), dbprrow(), dbsetrow().
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:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth column in the result set, starting with 1.
indicator address of host variable.
Return values:
SUCCEED variable accepted.
FAIL indicator 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().
int dbnumalts ( DBPROCESS dbproc,
int  computeid 
)

Get count of columns in a compute row.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
computeid of 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().
int dbnumcols ( DBPROCESS dbproc  ) 

Return number of regular columns in a result set.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
dbcollen(), dbcolname(), dbnumalts().
int dbnumcompute ( DBPROCESS dbproc  ) 

Get count of COMPUTE clauses for a result set.

Parameters:
dbproc contains 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().
void dbprhead ( DBPROCESS dbproc  ) 

Print result set headings to stdout.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
RETCODE dbprrow ( DBPROCESS dbproc  ) 

Print a result set to stdout.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
dbbind(), dbnextrow(), dbprhead(), dbresults(), dbspr1row(), dbsprhead(), dbsprline().
const char* dbprtype ( int  token  ) 

Print a token value's name to a buffer.

Parameters:
token server SYB* value, e.g. SYBINT.
Returns:
ASCII null-terminated string.
See also:
dbaltop(), dbalttype(), dbcoltype(), dbrettype().
STATUS dbreadtext ( DBPROCESS dbproc,
void *  buf,
DBINT  bufsize 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
buf output: buffer into which text will be placed.
bufsize size 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().
void dbrecftos ( const char  filename[]  ) 

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

Parameters:
filename name 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().
RETCODE dbresults ( DBPROCESS dbproc  ) 

Set up query results.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
SUCCEED Some results are available.
FAIL query was not processed successfully by the server
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 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:

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()
RETCODE dbsafestr ( DBPROCESS dbproc,
const char *  src,
DBINT  srclen,
char *  dest,
DBINT  destlen,
int  quotetype 
)

safely quotes character values in SQL text.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
src input string.
srclen length of src in bytes, or -1 to indicate it's null-terminated.
dest output: client-provided output buffer.
destlen size 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:
SUCCEED everything worked.
FAIL no such quotetype, or insufficient room in dest.
See also:
dbcmd(), dbfcmd().
char* dbservcharset ( DBPROCESS dbproc  ) 

Get syscharset name of the server character set.

Parameters:
dbproc contains 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().
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:
filename name of interfaces
See also:
dbopen()
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:
dbproc contains all information needed by db-lib to manage communications with the server.
chkintr 
hndlintr 
See also:
dbcancel(), dbgetuserdata(), dbsetuserdata(), dbsetbusy(), dbsetidle().
RETCODE dbsetlogintime ( int  seconds  ) 

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

Parameters:
seconds New limit for application.
Return values:
SUCCEED Always.
See also:
dberrhandle(), dbsettime()
RETCODE dbsetlversion ( LOGINREC login,
BYTE  version 
)

Set TDS version for future connections.

RETCODE dbsetmaxprocs ( int  maxprocs  ) 

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

Parameters:
maxprocs Limit for process.
Return values:
SUCCEED Always.
See also:
dbgetmaxprocs(), dbopen()
RETCODE dbsetnull ( DBPROCESS dbproc,
int  bindtype,
int  bindlen,
BYTE *  bindval 
)

Define substitution values to be used when binding null values.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
bindtype type of binding to which the substitute value will apply.
bindlen size of the substitute value you are supplying, in bytes. Ignored except for CHARBIND and BINARYBIND.
bindval pointer to a buffer containing the substitute value.
Return values:
SUCCEED query was processed without errors.
FAIL query was not processed
See also:
dbaltbind(), dbbind(), dbconvert(), dbnullbind().
RETCODE dbsetopt ( DBPROCESS dbproc,
int  option,
const char *  char_param,
int  int_param 
)

Set db-lib or server option.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
option option to set.
char_param value to set option to, if it wants a null-teminated ASCII string.
int_param value to set option to, if it wants an integer value.
Return values:
SUCCEED everything worked.
FAIL no such option, or insufficient memory, or unimplemented.
Remarks:
Many are unimplemented.
See also:
dbclropt(), dbisopt().
Todo:
Implement more options.
RETCODE dbsetrow ( DBPROCESS dbproc,
DBINT  row 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
MORE_ROWS row found
NO_MORE_ROWS row not found
FAIL dbproc is dead or not enabled
See also:
dbaltbind(), dbbind(), dbcanquery(), dbclrbuf(), dbgetrow(), dbnextrow(), dbprrow().
RETCODE dbsettime ( int  seconds  ) 

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

Parameters:
seconds New limit for application.
Return values:
SUCCEED Always.
See also:
dberrhandle(), DBGETTIME(), dbsetlogintime(), dbsqlexec(), dbsqlok(), dbsqlsend().
void dbsetuserdata ( DBPROCESS dbproc,
BYTE *  ptr 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
ptr address 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().
RETCODE dbsetversion ( DBINT  version  ) 

Specify a db-lib version level.

Parameters:
version anything, really.
Return values:
SUCCEED Always.
Remarks:
No effect on behavior of db-lib in FreeTDS.
See also:
int dbspid ( DBPROCESS dbproc  ) 

Get server process ID for a DBPROCESS.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Returns:
"spid", the server's process ID.
See also:
dbopen().
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:
dbproc contains all information needed by db-lib to manage communications with the server.
buffer output: Address of a buffer to hold ASCII null-terminated string.
buf_len size of buffer, in bytes.
Return values:
SUCCEED on success.
FAIL trouble encountered.
See also:
dbclropt(), dbisopt(), dbprhead(), dbprrow(), dbspr1rowlen(), dbsprhead(), dbsprline().
DBINT dbspr1rowlen ( DBPROCESS dbproc  ) 

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

Parameters:
dbproc contains 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().
RETCODE dbsprhead ( DBPROCESS dbproc,
char *  buffer,
DBINT  buf_len 
)

Print result set headings to a buffer.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
buffer output buffer
buf_len size of buffer
Return values:
SUCCEED buffer filled.
FAIL insufficient spaace in buffer, usually.
See also:
dbprhead(), dbprrow(), dbsetopt(), dbspr1row(), dbspr1rowlen(), dbsprline().
RETCODE dbsprline ( DBPROCESS dbproc,
char *  buffer,
DBINT  buf_len,
DBCHAR  line_char 
)

Get formatted string for underlining dbsprhead() column names.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
buffer output buffer
buf_len size of buffer
line_char character to use to represent underlining.
Return values:
SUCCEED buffer filled.
FAIL insufficient space in buffer, usually.
See also:
dbprhead(), dbprrow(), dbspr1row(), dbspr1rowlen(), dbsprhead().
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:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
SUCCEED query was processed without errors.
FAIL was returned by dbsqlsend() or dbsqlok().
See also:
dbcmd(), dbfcmd(), dbnextrow(), dbresults(), dbretstatus(), dbsettime(), dbsqlok(), dbsqlsend()
RETCODE dbsqlok ( DBPROCESS dbproc  ) 

Wait for results of a query from the server.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
SUCCEED everything worked, fetch results with dbnextresults().
FAIL SQL syntax error, typically.
See also:
dbcmd(), dbfcmd(), DBIORDESC(), DBIOWDESC(), dbmoretext(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbretstatus(), dbrpcsend(), dbsettime(), dbsqlexec(), dbsqlsend(), dbwritetext().
RETCODE dbsqlsend ( DBPROCESS dbproc  ) 

Transmit the command buffer to the server.

Non-blocking, does not wait for a response.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
SUCCEED SQL sent.
FAIL protocol 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().
int dbstrbuild ( DBPROCESS dbproc,
char *  charbuf,
int  bufsize,
char *  text,
char *  formats,
  ... 
)

Build a printable string from text containing placeholders for variables.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
charbuf output: buffer that will contain the ASCII null-terminated string built by dbstrbuild().
bufsize size of charbuf, in bytes.
text null-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
formats null-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().
RETCODE dbstrcpy ( DBPROCESS dbproc,
int  start,
int  numbytes,
char *  dest 
)

Get a copy of a chunk of the command buffer.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
start position 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].
numbytes number 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.
dest output: the buffer to write to. Make sure it's big enough.
Return values:
SUCCEED the inputs were valid and dest was affected.
FAIL start < 0 or numbytes < -1.
See also:
dbcmd(), dbfcmd(), dbfreebuf(), dbgetchar(), dbstrlen().
int dbstrlen ( DBPROCESS dbproc  ) 

Get size of the command buffer, in bytes.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
dbcmd(), dbfcmd(), dbfreebuf(), dbgetchar(), dbstrcpy().
RETCODE dbtablecolinfo ( DBPROCESS dbproc,
DBINT  column,
DBCOL pdbcol 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth in the result set, starting from 1.
pdbcol address of structure to be populated by this function.
Returns:
SUCCEED or FAIL.
See also:
dbcolinfo().
DBBINARY* dbtxptr ( DBPROCESS dbproc,
int  column 
)

Get text pointer for a column in the current row.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column number of the column in the SELECT statement, starting at 1.
Returns:
text pointer for column, may be NULL.
See also:
dbtxtimestamp(), dbwritetext().
DBBINARY* dbtxtimestamp ( DBPROCESS dbproc,
int  column 
)

Get text timestamp for a column in the current row.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column number of the column in the SELECT statement, starting at 1.
Returns:
timestamp for column, may be NULL.
See also:
dbtxptr(), dbwritetext().
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:
dbproc contains all information needed by db-lib to manage communications with the server.
name database to use.
Return values:
SUCCEED query was processed without errors.
FAIL query was not processed
Todo:
name should be quoted.
See also:
dbchange(), dbname().
DBINT dbvarylen ( DBPROCESS dbproc,
int  column 
)

Determine whether a column can vary in size.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
column Nth in the result set, starting from 1.
Return values:
TRUE datatype of column can vary in size, or is nullable.
FALSE datatype of column is fixed and is not nullable.
See also:
dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(), dbprtype().
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:
DBBOOL dbwillconvert ( int  srctype,
int  desttype 
)

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

Parameters:
srctype type converting from
desttype type 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:
TRUE convertible, or should be. For conversions from a fix-length type to a character type (e.g. INT to VARCHAR), the value returned is the number of bytes needed hold the output.
FAIL not convertible.
See also:
dbaltbind(), dbbind(), dbconvert(), dbconvert_ps(), src/dblib/unittests/convert().c().
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:
dbproc contains all information needed by db-lib to manage communications with the server.
objname table name
textptr text pointer to be modified, obtained from dbtxptr().
textptrlen Ignored. Supposed to be DBTXPLEN.
timestamp text timestamp to be modified, obtained from dbtxtimestamp() or dbtxtsnewval(), may be NULL.
log TRUE if the operation is to be recorded in the transaction log.
size overall size of the data (in total, not just for this call), in bytes. A guideline, must not overstate the case.
text the chunk of data to write.
Return values:
SUCCEED everything worked.
FAIL not sent, possibly because timestamp is invalid or was changed in the database since it was fetched.
See also:
dbmoretext(), dbtxptr(), dbtxtimestamp(), dbwritetext(), dbtxtsput().
TDS_RCSID ( var  ,
"$Id: dblib.  c,
v 1.378.2.4 2011/06/07 08:52:29 freddy77 Exp $"   
)
Remarks:
Either SYBDBLIB or MSDBLIB (not both) must be defined. This affects how certain application-addressable strucures are defined.
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00287.html100664 001750 000144 00000105315 11623073547 0015614 FreeTDS API: Remote Procedure functions

Remote Procedure functions
[The db-lib API]

Functions used with stored procedures. More...

Functions

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

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

DBBOOL dbhasretstat ( DBPROCESS dbproc  ) 

Determine if query generated a return status number.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
TRUE fetch return status with dbretstatus().
FALSE no return status.
See also:
dbnextrow(), dbresults(), dbretdata(), dbretstatus(), dbrpcinit(), dbrpcparam(), dbrpcsend().
int dbnumrets ( DBPROCESS dbproc  ) 

Get count of output parameters filled by a stored procedure.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Returns:
How many, possibly zero.
Remarks:
This name sounds funny.
See also:
BYTE* dbretdata ( DBPROCESS dbproc,
int  retnum 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
retnum Nth 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.
int dbretlen ( DBPROCESS dbproc,
int  retnum 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
retnum Nth 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().
char* dbretname ( DBPROCESS dbproc,
int  retnum 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
retnum Nth 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().
DBINT dbretstatus ( DBPROCESS dbproc  ) 

Fetch status value returned by query or remote procedure call.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Returns:
return value
See also:
dbhasretstat(), dbnextrow(), dbresults(), dbretdata(), dbrpcinit(), dbrpcparam(), dbrpcsend().
int dbrettype ( DBPROCESS dbproc,
int  retnum 
)

Get datatype of a stored procedure's return parameter.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
retnum Nth 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().
RETCODE dbrpcinit ( DBPROCESS dbproc,
const char  rpcname[],
DBSMALLINT  options 
)

Initialize a remote procedure call.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
rpcname name of the stored procedure to be run.
options Only 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:
SUCCEED normal.
FAIL on error
See also:
dbrpcparam(), dbrpcsend()
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.

Call between dbrpcinit() and dbrpcsend()

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
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.
status must be DBRPCRETURN, if this parameter is a return parameter, else 0.
type datatype of the value parameter e.g., SYBINT4, SYBCHAR.
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.
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.
value Address of your host variable.
Return values:
SUCCEED normal.
FAIL on error
See also:
dbrpcinit(), dbrpcsend()
RETCODE dbrpcsend ( DBPROCESS dbproc  ) 

Execute the procedure and free associated memory.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
SUCCEED normal.
FAIL on error
See also:
dbrpcinit(), dbrpcparam()
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00288.html100664 001750 000144 00000176201 11623073547 0015617 FreeTDS API: Bulk copy functions

Bulk copy functions
[The db-lib API]

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

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.
RETCODE bcp_bind (DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int vartype, int table_column)
 Bind a program host variable to a database column.
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.
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.
RETCODE bcp_collen (DBPROCESS *dbproc, DBINT varlen, int table_column)
 Set the length of a host variable to be written to a table.
RETCODE bcp_colptr (DBPROCESS *dbproc, BYTE *colptr, int table_column)
 Override bcp_bind() by pointing to a different host variable.
RETCODE bcp_columns (DBPROCESS *dbproc, int host_colcount)
 Indicate how many columns are to be found in the datafile.
RETCODE bcp_control (DBPROCESS *dbproc, int field, DBINT value)
 Set BCP options for uploading a datafile.
DBINT bcp_done (DBPROCESS *dbproc)
 Conclude the transfer of data from program variables.
RETCODE bcp_exec (DBPROCESS *dbproc, DBINT *rows_copied)
 Write a datafile to a table.
DBBOOL bcp_getl (LOGINREC *login)
 See if BCP_SETL() was used to set the LOGINREC for BCP work.
RETCODE bcp_init (DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction)
 Prepare for bulk copy operation on a table.
RETCODE bcp_options (DBPROCESS *dbproc, int option, BYTE *value, int valuelen)
 Set "hints" for uploading a file.
RETCODE bcp_readfmt (DBPROCESS *dbproc, const char filename[])
 Read a format definition file.
RETCODE bcp_sendrow (DBPROCESS *dbproc)
 Write data in host variables to the table.

Detailed Description

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


Function Documentation

DBINT bcp_batch ( DBPROCESS dbproc  ) 

Commit a set of rows to the table.

Parameters:
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.
Returns:
Count of rows saved, or -1 on error.
See also:
bcp_bind(), bcp_done(), bcp_sendrow()
RETCODE bcp_bind ( DBPROCESS dbproc,
BYTE *  varaddr,
int  prefixlen,
DBINT  varlen,
BYTE *  terminator,
int  termlen,
int  vartype,
int  table_column 
)

Bind a program host variable to a database column.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
varaddr address of host variable
prefixlen length of any prefix found at the beginning of varaddr, in bytes. Use zero for fixed-length datatypes.
varlen bytes of data in varaddr. Zero for NULL, -1 for fixed-length datatypes.
terminator byte sequence that marks the end of the data in varaddr
termlen length of terminator
vartype datatype of the host variable
table_column Nth 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()
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:
dbproc contains all information needed by db-lib to manage communications with the server.
host_colnum datafile column number (starting with 1, not zero).
host_type dataype token describing the data type in host_colnum. E.g. SYBCHAR for character data.
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.
host_collen maximum 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_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:

  • '\0' terminator is an ASCII NUL.
  • '\t' terminator is an ASCII TAB.
  • '\n' terminator is an ASCII NL.
host_termlen the length of host_term, in bytes.
table_colnum Nth 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
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:
dbproc contains all information needed by db-lib to manage communications with the server.
host_colnum datafile column number (starting with 1, not zero).
host_type dataype token describing the data type in host_colnum. E.g. SYBCHAR for character data.
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.
host_collen maximum 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_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:

  • '\0' terminator is an ASCII NUL.
  • '\t' terminator is an ASCII TAB.
  • '\n' terminator is an ASCII NL.
host_termlen the length of host_term, in bytes.
table_colnum Nth 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.
typeinfo something
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
RETCODE bcp_collen ( DBPROCESS dbproc,
DBINT  varlen,
int  table_column 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
varlen size 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.)
table_column the number of the column in the table (starting with 1, not zero).
Returns:
SUCCEED or FAIL.
See also:
bcp_bind(), bcp_colptr(), bcp_sendrow()
RETCODE bcp_colptr ( DBPROCESS dbproc,
BYTE *  colptr,
int  table_column 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
colptr The pointer, the address of your variable.
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.
Returns:
SUCCEED or FAIL.
See also:
bcp_bind(), bcp_collen(), bcp_sendrow()
RETCODE bcp_columns ( DBPROCESS dbproc,
int  host_colcount 
)

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

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
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.
Returns:
SUCCEED or FAIL. It's hard to see how it could fail.
See also:
bcp_colfmt()
RETCODE bcp_control ( DBPROCESS dbproc,
int  field,
DBINT  value 
)

Set BCP options for uploading a datafile.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
field symbolic 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.
value The 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()
DBINT bcp_done ( DBPROCESS dbproc  ) 

Conclude the transfer of data from program variables.

Parameters:
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".
Returns:
As with bcp_batch(), the count of rows saved, or -1 on error.
See also:
bcp_batch(), bcp_bind(), bcp_moretext(), bcp_sendrow()
RETCODE bcp_exec ( DBPROCESS dbproc,
DBINT *  rows_copied 
)

Write a datafile to a table.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
rows_copied bcp_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()
DBBOOL bcp_getl ( LOGINREC login  ) 

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

Parameters:
login Address of the LOGINREC variable to be passed to dbopen().
Returns:
TRUE or FALSE.
See also:
BCP_SETL(), bcp_init(), dblogin(), dbopen()
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:
dbproc contains all information needed by db-lib to manage communications with the server.
tblname the name of the table receiving or providing the data.
hfile the data file opposite the table, if any.
errfile the "error file" captures messages and, if errors are encountered, copies of any rows that could not be written to the table.
direction one 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()
RETCODE bcp_options ( DBPROCESS dbproc,
int  option,
BYTE *  value,
int  valuelen 
)

Set "hints" for uploading a file.

A FreeTDS-only function.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
option symbolic constant indicating the option to be set, one of:

  • BCPLABELED Not implemented.
  • BCPHINTS The hint to be passed when the bulk-copy begins.
value The 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
valuelen The strlen of value.
Returns:
SUCCEED or FAIL.
See also:
bcp_control(), bcp_exec(),
Todo:
Simplify. Remove valuelen, and dbproc->bcpinfo->hint = strdup(hints[i])
RETCODE bcp_readfmt ( DBPROCESS dbproc,
const char  filename[] 
)

Read a format definition file.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
filename Name 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()
RETCODE bcp_sendrow ( DBPROCESS dbproc  ) 

Write data in host variables to the table.

Parameters:
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().
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()
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00289.html100664 001750 000144 00000114257 11623073547 0015623 FreeTDS API: Internal bcp functions

Internal bcp functions
[Bulk copy functions]

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

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 int _bcp_get_col_data (TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset)
 For a bcp in from program variables, get the data from the host variable.
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.
static offset_type _bcp_measure_terminated_field (FILE *hostfile, BYTE *terminator, int term_len)
static RETCODE _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

Detailed Description

Static functions internal to the bcp library.


Function Documentation

static RETCODE _bcp_exec_in ( DBPROCESS dbproc,
DBINT *  rows_copied 
) [static]
Parameters:
dbproc contains 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()
static RETCODE _bcp_exec_out ( DBPROCESS dbproc,
DBINT *  rows_copied 
) [static]
Parameters:
dbproc contains 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()
static char* _bcp_fgets ( char *  buffer,
int  size,
FILE *  f 
) [static]
static void _bcp_free_columns ( DBPROCESS dbproc  )  [static]
Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
static void _bcp_free_storage ( DBPROCESS dbproc  )  [static]
Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
bcp_done(), bcp_exec(), bcp_init()
static int _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:
dbproc contains all information needed by db-lib to manage communications with the server.
bindcol 
Returns:
TDS_SUCCEED or TDS_FAIL.
See also:
_bcp_add_fixed_columns, _bcp_add_variable_columns, _bcp_send_bcp_record
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.
static offset_type _bcp_measure_terminated_field ( FILE *  hostfile,
BYTE *  terminator,
int  term_len 
) [static]
Parameters:
hostfile 
terminator 
term_len 
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()
static RETCODE _bcp_read_hostfile ( DBPROCESS dbproc,
FILE *  hostfile,
int *  row_error 
) [static]
Parameters:
dbproc contains 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()
static int _bcp_readfmt_colinfo ( DBPROCESS dbproc,
char *  buf,
BCP_HOSTCOLINFO ci 
) [static]
Parameters:
dbproc contains 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()
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:
str pointer to a character buffer (not null-terminated)
len size of the str in bytes
Returns:
modified length
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00290.html100664 001750 000144 00000134306 11623073547 0015610 FreeTDS API: Money functions

Money functions
[The db-lib API]

Functions to manipulate the MONEY datatype. More...

Functions

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

Detailed Description

Functions to manipulate the MONEY datatype.


Function Documentation

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

Add two DBMONEY4 values.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
m1 first operand.
m2 other operand.
sum output: result of computation.
Return values:
SUCCEED usually.
FAIL on overflow.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
int dbmny4cmp ( DBPROCESS dbproc,
DBMONEY4 m1,
DBMONEY4 m2 
)

Compare two DBMONEY4 values.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
m1 some money.
m2 some other money.
Return values:
0 m1 == m2.
-1 m1 < m2.
1 m1 > m2.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmny4copy ( DBPROCESS dbproc,
DBMONEY4 src,
DBMONEY4 dest 
)

Copy a DBMONEY4 value.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
src address of a DBMONEY4 structure.
dest output: new money.
Return values:
SUCCEED or FAIL if src/dest NULL.
See also:
dbmnycopy(), dbmnyminus(), dbmny4minus().
RETCODE dbmny4minus ( DBPROCESS dbproc,
DBMONEY4 src,
DBMONEY4 dest 
)

Negate a DBMONEY4 value.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
src address of a DBMONEY4 structure.
dest output: result of negation.
Return values:
SUCCEED usually.
FAIL on overflow.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmny4sub ( DBPROCESS dbproc,
DBMONEY4 m1,
DBMONEY4 m2,
DBMONEY4 diff 
)

Subtract two DBMONEY4 values.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
m1 first operand.
m2 other operand, subtracted from m1.
diff output: result of computation.
Return values:
SUCCEED usually.
FAIL on overflow.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmny4zero ( DBPROCESS dbproc,
DBMONEY4 dest 
)

Zero a DBMONEY4 value.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
dest address of a DBMONEY structure.
Return values:
SUCCEED usually.
FAIL dest is NULL.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
int dbmnycmp ( DBPROCESS dbproc,
DBMONEY m1,
DBMONEY m2 
)

Compare two DBMONEY values.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
m1 some money.
m2 some other money.
Return values:
0 m1 == m2.
-1 m1 < m2.
1 m1 > m2.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmnycopy ( DBPROCESS dbproc,
DBMONEY src,
DBMONEY dest 
)

Copy a DBMONEY value.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
src address of a DBMONEY structure.
dest output: new money.
Return values:
SUCCEED always, unless src or dest is NULL.
See also:
RETCODE dbmnydec ( DBPROCESS dbproc,
DBMONEY amount 
)

Subtract $0.0001 from a DBMONEY value.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
amount address of a DBMONEY structure.
Return values:
SUCCEED or FAIL if overflow or amount NULL.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmnyinc ( DBPROCESS dbproc,
DBMONEY amount 
)

Add $0.0001 to a DBMONEY value.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
amount address of a DBMONEY structure.
Return values:
SUCCEED or FAIL if overflow or amount NULL.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmnymaxneg ( DBPROCESS dbproc,
DBMONEY amount 
)

Get maximum negative DBMONEY value supported.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
amount address of a DBMONEY structure.
Return values:
SUCCEED Always.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmnymaxpos ( DBPROCESS dbproc,
DBMONEY amount 
)

Get maximum positive DBMONEY value supported.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
amount address of a DBMONEY structure.
Return values:
SUCCEED Always.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmnyminus ( DBPROCESS dbproc,
DBMONEY src,
DBMONEY dest 
)

Negate a DBMONEY value.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
src address of a DBMONEY structure.
dest output: result of negation.
Return values:
SUCCEED or FAIL if overflow or src/dest NULL.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
RETCODE dbmnyzero ( DBPROCESS dbproc,
DBMONEY dest 
)

Set a DBMONEY value to zero.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
dest address of a DBMONEY structure.
Return values:
SUCCEED unless amount is NULL.
See also:
dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00291.html100664 001750 000144 00000025223 11623073547 0015606 FreeTDS API: Datetime functions

Datetime functions
[The db-lib API]

Functions to manipulate DBDATETIME structures. More...

Functions

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

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

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

Compare DBDATETIME values, similar to strcmp(3).

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
d1 a DBDATETIME structure address
d2 another DBDATETIME structure address
Return values:
0 d1 = d2.
-1 d1 < d2.
1 d1 > d2.
See also:
dbdate4cmp(), dbmnycmp(), dbmny4cmp().
const char* dbmonthname ( DBPROCESS dbproc,
char *  language,
int  monthnum,
DBBOOL  shortform 
)

Get name of a month, in some human language.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
language ignored.
monthnum number of the month, starting with 1.
shortform set 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().
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00292.html100664 001750 000144 00000164465 11623073547 0015623 FreeTDS API: Internals

Internals
[The db-lib API]

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

Classes

struct  _dblib_error_message

Defines

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

Typedefs

typedef struct _dblib_error_message DBLIB_ERROR_MESSAGE

Functions

int _dblib_check_and_handle_interrupt (void *vdbproc)
 check interrupts for libtds.
RETCODE dbcmdrow (DBPROCESS *dbproc)
 See if the current command can return rows.
int dbcurcmd (DBPROCESS *dbproc)
 Get number of the row just returned.
DBINT dbcurrow (DBPROCESS *dbproc)
 Get number of the row currently being read.
DBBOOL dbdead (DBPROCESS *dbproc)
 Check if dbproc is an ex-parrot.
DBINT dbfirstrow (DBPROCESS *dbproc)
 See if a server response has arrived.
int dbiordesc (DBPROCESS *dbproc)
 Get file descriptor of the socket used by a DBPROCESS to read data coming from the server. (!).
int dbiowdesc (DBPROCESS *dbproc)
 Get file descriptor of the socket used by a DBPROCESS to write data coming to the server. (!).
DBINT dblastrow (DBPROCESS *dbproc)
 Get number of the last row in the row buffer.
int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum,...)
 Call client-installed error handler.
RETCODE dbrows (DBPROCESS *dbproc)
 Indicate whether a query returned rows.
STATUS dbrowtype (DBPROCESS *dbproc)
 Get returned row's type.
void dbsetavail (DBPROCESS *dbproc)
 Mark a DBPROCESS as "available".
RETCODE dbsetlbool (LOGINREC *login, int value, int which)
 Set a boolean value in a LOGINREC structure.
RETCODE dbsetllong (LOGINREC *login, long value, int which)
 Set an integer value in a LOGINREC structure.
RETCODE dbsetlname (LOGINREC *login, const char *value, int which)
 Set the value of a string in a LOGINREC structure.
int dbtds (DBPROCESS *dbproc)
 Get the TDS version in use for dbproc.
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)
DBPROCESStdsdbopen (LOGINREC *login, const char *server, int msdblib)
 Form a connection with the server.

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.


Define Documentation

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

Alternative way to set login packet fields.

See also:
dbsetllabeled()
DBSETLVERSION ( login,
version   )     dbsetlversion((login), (version))

maps to the Microsoft (lower-case) function.

See also:
dbsetlversion()

Typedef Documentation

For internal use only.

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

Function Documentation

int _dblib_check_and_handle_interrupt ( void *  vdbproc  ) 

check interrupts for libtds.

Parameters:
vdbproc a DBPROCESS pointer, contains all information needed by db-lib to manage communications with the server.
See also:
DBDEAD(), dbsetinterrupt().
RETCODE dbcmdrow ( DBPROCESS dbproc  ) 

See if the current command can return rows.

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
SUCCEED Yes, it can.
FAIL No, it can't.
Remarks:
Use DBCMDROW() macro instead.
See also:
DBCMDROW(), dbnextrow(), dbresults(), DBROWS(), DBROWTYPE().
int dbcurcmd ( DBPROCESS dbproc  ) 

Get number of the row just returned.

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
DBCURROW().
Todo:
Unimplemented.
DBINT dbcurrow ( DBPROCESS dbproc  ) 

Get number of the row currently being read.

For internal use only.

Parameters:
dbproc contains 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:
0 Always.
See also:
DBCURROW(), dbclrbuf(), DBFIRSTROW(), dbgetrow(), DBLASTROW(), dbnextrow(), dbsetopt(),.
Todo:
Unimplemented.
DBBOOL dbdead ( DBPROCESS dbproc  ) 

Check if dbproc is an ex-parrot.

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
Return values:
TRUE process has been marked dead.
FALSE process is OK.
Remarks:
dbdead() does not communicate with the server. Unless a previously db-lib marked dbproc dead, dbdead() returns FALSE.
See also:
dberrhandle().
DBINT dbfirstrow ( DBPROCESS dbproc  ) 

See if a server response has arrived.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
milliseconds how 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_dbproc output: DBPROCESS for which a response arrived, of NULL.
return_reason output:

  • 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:
SUCCEED everything worked.
FAIL a server connection died.
See also:
DBIORDESC(), DBRBUF(), dbresults(), dbreghandle(), dbsqlok().
Todo:
Unimplemented.

For internal use only.

Get number of the first row in the row buffer.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
DBFIRSTROW(), dbclrbuf(), DBCURROW(), dbgetrow(), DBLASTROW(), dbnextrow(), dbsetopt().
int dbiordesc ( DBPROCESS dbproc  ) 

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

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
dbcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbsqlok(), dbsqlsend().
int dbiowdesc ( DBPROCESS dbproc  ) 

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

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
dbcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbsqlok(), dbsqlsend().
DBINT dblastrow ( DBPROCESS dbproc  ) 

Get number of the last row in the row buffer.

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
DBLASTROW(), dbclrbuf(), DBCURROW(), DBFIRSTROW(), dbgetrow(), dbnextrow(), dbsetopt().
int dbperror ( DBPROCESS dbproc,
DBINT  msgno,
long  errnum,
  ... 
)

Call client-installed error handler.

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
msgno identifies the error message to be passed to the client's handler.
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. 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().
RETCODE dbrows ( DBPROCESS dbproc  ) 

Indicate whether a query returned rows.

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
DBROWS(), DBCMDROW(), dbnextrow(), dbresults(), DBROWTYPE().
STATUS dbrowtype ( DBPROCESS dbproc  ) 

Get returned row's type.

For internal use only.

Parameters:
dbproc contains all information needed by db-lib to manage communications with the server.
See also:
DBROWTYPE().
void dbsetavail ( DBPROCESS dbproc  ) 

Mark a DBPROCESS as "available".

For internal use only.

Parameters:
dbproc contains 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().
RETCODE dbsetlbool ( LOGINREC login,
int  value,
int  which 
)

Set a boolean value in a LOGINREC structure.

For internal use only.

Called by various macros to populate login.

Parameters:
login the LOGINREC* to modify.
value the value to set it to.
which the field to set.
Remarks:
Only DBSETBCP is implemented.
Return values:
SUCCEED the value was set.
FAIL invalid value passed for which.
Todo:
DBSETNOSHORT, DBSETENCRYPT, DBSETLABELED
RETCODE dbsetllong ( LOGINREC login,
long  value,
int  which 
)

Set an integer value in a LOGINREC structure.

For internal use only.

Called by various macros to populate login.

Parameters:
login the LOGINREC* to modify.
value the value to set it to.
which the field to set.
Return values:
SUCCEED the value was set.
FAIL anything other than DBSETPACKET was passed for which.
RETCODE dbsetlname ( LOGINREC login,
const char *  value,
int  which 
)

Set the value of a string in a LOGINREC structure.

For internal use only.

Called by various macros to populate login.

Parameters:
login the LOGINREC* to modify.
value the value to set it to.
which the field to set.
Return values:
SUCCEED the value was set.
FAIL DBSETHID or other invalid which was tried.
int dbtds ( DBPROCESS dbproc  ) 

Get the TDS version in use for dbproc.

For internal use only.

Parameters:
dbproc contains 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().
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)

For internal use only.

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().
DBPROCESS* tdsdbopen ( LOGINREC login,
const char *  server,
int  msdblib 
)

Form a connection with the server.

For internal use only.

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:
login LOGINREC* carrying the account information.
server name of the dataserver to connect to.
Returns:
valid pointer on successful login.
Return values:
NULL insufficient 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.

Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00293.html100664 001750 000144 00000011676 11623073547 0015617 FreeTDS API: Unimplemented

Unimplemented
[The db-lib API]

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

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()
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00294.html100664 001750 000144 00000010711 11623073547 0015605 FreeTDS API: ODBC API

ODBC API

Functions callable by ODBC client programs. More...

Modules

 ODBC utility
 

Functions called within ODBC driver.



Detailed Description

Functions callable by ODBC client programs.

Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00295.html100664 001750 000144 00000060704 11623073547 0015615 FreeTDS API: ODBC utility

ODBC utility
[ODBC API]

Functions called within ODBC driver. More...

Defines

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

Functions

int 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.
void odbc_convert_err_set (struct _sql_errors *errs, TDS_INT err)
DSTRodbc_dstr_copy (TDS_DBC *dbc, DSTR *s, int size, 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.
int odbc_get_string_size (int size, ODBC_CHAR *str _WIDE)
void odbc_rdbms_version (TDSSOCKET *tds, char *pversion_string)
 Returns the version of the RDBMS in the ODBC format.
SQLSMALLINT odbc_server_to_sql_type (int col_type, int col_size)
 Convert type from database to ODBC.
SQLRETURN odbc_set_concise_c_type (SQLSMALLINT concise_type, struct _drecord *drec, int check_only)
 Set concise type and all cascading field.
SQLRETURN odbc_set_concise_sql_type (SQLSMALLINT concise_type, struct _drecord *drec, int check_only)
 Set concise type and all cascading field.
void odbc_set_return_params (struct _hstmt *stmt, unsigned int n_row)
void odbc_set_return_status (struct _hstmt *stmt, unsigned int n_row)
void odbc_set_sql_type_info (TDSCOLUMN *col, struct _drecord *drec, SQLINTEGER odbc_ver)
static int odbc_set_stmt (TDS_STMT *stmt, char **dest, const ODBC_CHAR *sql, int sql_len _WIDE)
int odbc_set_stmt_prepared_query (TDS_STMT *stmt, const ODBC_CHAR *sql, int sql_len _WIDE)
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.
int odbc_sql_to_c_type_default (int sql_type)
SQLINTEGER odbc_sql_to_displaysize (int sqltype, TDSCOLUMN *col)
int odbc_sql_to_server_type (TDSSOCKET *tds, int sql_type)
static char * odbc_strndup (const char *s, int len)

Detailed Description

Functions called within ODBC driver.


Define Documentation

#define SQL_TYPES
Value:
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_VERBOSE_START(SQL_DATETIME) \
        TYPE_VERBOSE_DATE(SQL_DATETIME, SQL_CODE_TIMESTAMP, SQL_TYPE_TIMESTAMP, SQL_TIMESTAMP) \
        TYPE_VERBOSE_END(SQL_DATETIME)

Function Documentation

int 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 even if server do not support it

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

Set concise type and all cascading field.

Parameters:
concise_type concise type to set
drec record to set. NULL to test error without setting
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 
)

Set concise type and all cascading field.

Parameters:
concise_type concise type to set
drec record to set. NULL to test error without setting
check_only it <>0 (true) check only, do not set type
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:
dbc database connection. Can be NULL
buffer client buffer
cbBuffer client buffer size (in bytes)
pcbBuffer pointer to SQLSMALLINT to hold string size
s string to copy
len len of string to copy. <0 null terminated
flag set of flag 0x10 SQLINTEGER
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00296.html100664 001750 000144 00000045022 11623073547 0015612 FreeTDS API: Authentication

Authentication
[LibTDS API]

Functions for handling authentication. More...

Classes

struct  names_blob_prefix_t
struct  tds_answer
struct  tds_ntlm_auth

Defines

#define offsetof(st, m)   ((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))

Typedefs

typedef struct tds_answer TDSANSWER
typedef struct tds_ntlm_auth TDSNTLMAUTH

Functions

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 void generate_random_buffer (unsigned char *out, int len)
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 int make_ntlm_hash (TDSSOCKET *tds, const char *passwd, unsigned char ntlm_hash[16])
static int make_ntlm_v2_hash (TDSSOCKET *tds, const char *passwd, unsigned char ntlm_v2_hash[16])
static int tds7_send_auth (TDSSOCKET *tds, const unsigned char *challenge, TDS_UINT flags, const unsigned char *names_blob, TDS_INT names_blob_len)
static int tds_answer_challenge (TDSSOCKET *tds, TDSCONNECTION *connection, 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.
static int tds_answer_challenge_ntlmv2 (TDSSOCKET *tds, TDSCONNECTION *connection, 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 int tds_ntlm_free (TDSSOCKET *tds, TDSAUTHENTICATION *tds_auth)
TDSAUTHENTICATIONtds_ntlm_get_auth (TDSSOCKET *tds)
 Build a NTLMSPP packet to send to server.
static int tds_ntlm_handle_next (TDSSOCKET *tds, struct tds_authentication *auth, size_t len)
static void unix_to_nt_time (TDS_UINT8 *nt, time_t t)
 put a 8 byte filetime from a time_t This takes GMT as input

Variables

static const unsigned char ntlm_id [] = "NTLMSSP"

Detailed Description

Functions for handling authentication.


Function Documentation

static int tds_answer_challenge ( TDSSOCKET tds,
TDSCONNECTION connection,
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:
passwd clear text domain password
challenge challenge data given by server
flags NTLM flags from server side
answer buffer where to store crypted password
TDSAUTHENTICATION* tds_ntlm_get_auth ( TDSSOCKET tds  ) 

Build a NTLMSPP packet to send to server.

Parameters:
tds A pointer to the TDSSOCKET structure managing a client/server operation.
Returns:
authentication info
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00297.html100664 001750 000144 00000077344 11623073547 0015627 FreeTDS API: Configuration

Configuration
[LibTDS API]

Handle reading of configuration. More...

Functions

static int hex2num (char *hex)
static int hexdigit (int c)
static int parse_server_name_for_port (TDSCONNECTION *connection, TDSLOGIN *login)
 Check the server name to find port info first Warning: connection-> & login-> are all modified when needed.
static int search_interface_file (TDSCONNECTION *connection, 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'.
int tds_config_boolean (const char *value)
static void tds_config_encryption (const char *value, TDSCONNECTION *connection)
static void tds_config_env_tdsdump (TDSCONNECTION *connection)
static void tds_config_env_tdshost (TDSCONNECTION *connection)
static void tds_config_env_tdsport (TDSCONNECTION *connection)
static void tds_config_env_tdsver (TDSCONNECTION *connection)
static void tds_config_login (TDSCONNECTION *connection, TDSLOGIN *login)
TDS_USMALLINT tds_config_verstr (const char *tdsver, TDSCONNECTION *connection)
 Set TDS version from given string.
void tds_fix_connection (TDSCONNECTION *connection)
 Fix configuration after reading it.
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.
int tds_lookup_host (const char *servername, char *ip)
 Get the IP address for a hostname.
static int tds_lookup_port (const char *portname)
 Given a portname lookup the port.
void tds_parse_conf_section (const char *option, const char *value, void *param)
int tds_read_conf_file (TDSCONNECTION *connection, const char *server)
 Read configuration info for given server return 0 on error.
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).
static int tds_read_conf_sections (FILE *in, const char *server, TDSCONNECTION *connection)
TDSCONNECTIONtds_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
static int tds_read_interfaces (const char *server, TDSCONNECTION *connection)
 Try to find the IP number and port for a (possibly) logical server name.
int tds_set_interfaces_file_loc (const char *interf)
 Set the full name of interface file.
static int tds_try_conf_file (const char *path, const char *how, const char *server, TDSCONNECTION *connection)

Variables

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

Detailed Description

Handle reading of configuration.


Function Documentation

static int parse_server_name_for_port ( TDSCONNECTION 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
static int search_interface_file ( TDSCONNECTION connection,
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 'connection'

Parameters:
dir name of base directory for interface file
file name of the interface file
host logical host to search for
Returns:
0 if not fount 1 if found
TDS_USMALLINT tds_config_verstr ( const char *  tdsver,
TDSCONNECTION connection 
)

Set TDS version from given string.

Parameters:
tdsver tds string version
connection where to store information
Returns:
as encoded hex value: high nybble major, low nybble minor.
void tds_fix_connection ( TDSCONNECTION connection  ) 

Fix configuration after reading it.

Currently this read some environment variables and replace some options.

static char* tds_get_home_file ( const char *  file  )  [static]

Return filename from HOME directory.

Returns:
allocated string or NULL if error
int tds_lookup_host ( const char *  servername,
char *  ip 
)

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.

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.

int tds_read_conf_file ( TDSCONNECTION connection,
const char *  server 
)

Read configuration info for given server return 0 on error.

Parameters:
connection where to store configuration
server section of file configuration that hold configuration for a server
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:
in configuration file
section section to read
tds_conf_parse callback that receive every entry in section
param parameter to pass to callback function
TDSCONNECTION* 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.

static int tds_read_interfaces ( const char *  server,
TDSCONNECTION connection 
) [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.
int tds_set_interfaces_file_loc ( const char *  interf  ) 

Set the full name of interface file.

Parameters:
interf file name
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00298.html100664 001750 000144 00000123065 11623073550 0015612 FreeTDS API: Conversion

Conversion
[LibTDS API]

Conversions between datatypes. More...

Defines

#define binary_to_result(data, len, cr)   binary_to_result(desttype, data, len, cr)
#define CASE_ALL_BINARY   SYBBINARY: case SYBVARBINARY: case SYBIMAGE: case XSYBBINARY: case XSYBVARBINARY: case TDS_CONVERT_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 int is_alphabetic (const char *)
static int is_ampm (const char *)
static int is_dd_mon_yyyy (char *t)
static int is_numeric (const char *)
static int is_numeric_dateformat (const char *)
static int is_timeformat (const char *)
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.
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, 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
static TDS_INT string_to_int8 (const char *buf, const char *pend, TDS_INT8 *res)
 convert a number in string to TDS_INT8
static int string_to_numeric (const char *instr, const char *pend, CONV_RESULT *cr)
 convert a number in string to a TDSNUMERIC
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 int stringz_to_numeric (const char *instr, CONV_RESULT *cr)
 convert a zero terminated string to NUMERIC
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.
static TDS_INT tds_convert_binary (int srctype, const TDS_UCHAR *src, TDS_INT srclen, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_bit (int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_char (int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_datetime (const TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_datetime4 (const TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_flt8 (int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_int1 (int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_int2 (int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_int4 (int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_int8 (int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_money (int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_money4 (int srctype, const TDS_CHAR *src, int srclen, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_numeric (int srctype, const TDS_NUMERIC *src, TDS_INT srclen, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_real (int srctype, const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
static TDS_INT tds_convert_unique (int srctype, const TDS_CHAR *src, TDS_INT srclen, int desttype, CONV_RESULT *cr)
TDS_INT tds_datecrack (TDS_INT datetype, const void *di, TDSDATEREC *dr)
 Convert from db date format to a structured date format.
TDS_INT tds_get_null_type (int srctype)
 Get same type but nullable.
size_t tds_strftime (char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr)
 format a date string according to an "extended" strftime(3) formatting definition.
unsigned char tds_willconvert (int srctype, int desttype)
 Test if a conversion is possible.

Variables

const char tds_hex_digits [16] = "0123456789abcdef"

Detailed Description

Conversions between datatypes.

Supports, for example, dbconvert().


Function Documentation

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:
datestr string to check
t where to store month (if NULL no store is done)
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.

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
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
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
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_ctx context (used in conversion to data and to return messages)
srctype type of source
src pointer to source data to convert
srclen length in bytes of source (not counting terminator or strings)
desttype type of destination
cr structure to hold result
Returns:
length of result or TDS_CONVERT_* failure code on failure. All TDS_CONVERT_* constants are <0.
TDS_INT tds_datecrack ( TDS_INT  datetype,
const void *  di,
TDSDATEREC dr 
)

Convert from db date format to a structured date format.

Parameters:
datetype source date type. SYBDATETIME or SYBDATETIME4
di source date
dr destination date
Returns:
TDS_FAIL or TDS_SUCCEED
TDS_INT tds_get_null_type ( int  srctype  ) 

Get same type but nullable.

Parameters:
srctype type requires
Returns:
nullable type
size_t tds_strftime ( char *  buf,
size_t  maxsize,
const char *  format,
const TDSDATEREC dr 
)

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

Parameters:
buf output buffer
maxsize size of buffer in bytes (space include terminator)
format format string passed to strftime(3), except that z represents milliseconds
dr date to convert
Returns:
length of string returned, 0 for error
unsigned char tds_willconvert ( int  srctype,
int  desttype 
)

Test if a conversion is possible.

Parameters:
srctype source type
desttype destination type
Returns:
0 if not convertible
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00299.html100664 001750 000144 00000122147 11623073550 0015613 FreeTDS API: Charset conversion

Charset conversion
[LibTDS API]

Convert between different charsets. More...

Defines

#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.
void tds7_srv_charset_changed (TDSSOCKET *tds, int sql_collate, int lcid)
static int tds_canonical_charset (const char *charset_name)
 Determine canonical iconv character set.
const char * tds_canonical_charset_name (const char *charset_name)
 Determine canonical iconv character set name.
size_t tds_iconv (TDSSOCKET *tds, const TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 Wrapper around iconv(3).
void tds_iconv_close (TDSSOCKET *tds)
size_t tds_iconv_fread (iconv_t cd, FILE *stream, size_t field_len, size_t term_len, char *outbuf, size_t *outbytesleft)
 Read a data file, passing the data through iconv().
void tds_iconv_free (TDSSOCKET *tds)
TDSICONVtds_iconv_from_collate (TDSSOCKET *tds, TDS_UCHAR collate[5])
 Get iconv information from a LCID (to support different column encoding under MSSQL2K).
TDSICONVtds_iconv_get (TDSSOCKET *tds, const char *client_charset, const char *server_charset)
static TDSICONVtds_iconv_get_info (TDSSOCKET *tds, 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).
void tds_iconv_open (TDSSOCKET *tds, const char *charset)
void tds_srv_charset_changed (TDSSOCKET *tds, const char *charset)
static void tds_srv_charset_changed_num (TDSSOCKET *tds, int canonic_charset_num)
const char * tds_sybase_charset_name (const char *charset_name)
 Determine the name Sybase uses for a character set, given a canonical iconv name.
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.

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)
  • 2. ISO8859-1 <-> server meta data (iso2server_metadata)

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

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.
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.
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.
size_t tds_iconv ( TDSSOCKET tds,
const 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:
tds state information for the socket and the TDS protocol
io Enumerated value indicating whether the data are being sent to or received from the server.
conv information about the encodings involved, including the iconv(3) conversion descriptors.
inbuf address of pointer to the input buffer of data to be converted.
inbytesleft address of count of bytes in inbuf.
outbuf address of pointer to the output buffer.
outbytesleft address of count of bytes in outbuf.
Return values:
number of 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.

size_t tds_iconv_fread ( iconv_t  cd,
FILE *  stream,
size_t  field_len,
size_t  term_len,
char *  outbuf,
size_t *  outbytesleft 
)

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

Returns:
Count of bytes either not read, or read but not converted. Returns zero on success.
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.
const char* tds_sybase_charset_name ( const char *  charset_name  ) 

Determine the name Sybase uses for a character set, given a canonical iconv name.

Returns:
Sybase name, or NULL if lookup failed.
Remarks:
Returned name can be sent to Sybase a server.
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

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
}
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
}
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,
}
const unsigned char utf8_masks[7] [static]
Initial value:
 {
        0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01
}
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00300.html100664 001750 000144 00000100645 11623073550 0015571 FreeTDS API: Memory allocation

Memory allocation
[LibTDS API]

Allocate or free resources. More...

Defines

#define SQLS_ENTRY(number, state)   case number: p = state; break

Functions

BCPCOLDATAtds_alloc_bcp_column_data (int column_size)
char * tds_alloc_client_sqlstate (int msgno)
static TDSCOMPUTEINFOtds_alloc_compute_result (int num_cols, int by_cols)
 Allocate memory for storing compute info return NULL on out of memory.
TDSCOMPUTEINFO ** tds_alloc_compute_results (TDSSOCKET *tds, int num_cols, int by_cols)
int tds_alloc_compute_row (TDSCOMPUTEINFO *res_info)
TDSCONNECTIONtds_alloc_connection (TDSLOCALE *locale)
 Allocate space for configure structure and initialize with default values.
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 (TDSSOCKET *tds, const char *id)
 Allocate a dynamic statement.
TDSLOCALEtds_alloc_locale (void)
TDSLOGINtds_alloc_login (void)
char * tds_alloc_lookup_sqlstate (TDSSOCKET *tds, int msgno)
void * tds_alloc_param_data (TDSCOLUMN *curparam)
 Allocate data for a parameter.
TDSPARAMINFOtds_alloc_param_result (TDSPARAMINFO *old_param)
 Adds a output parameter to TDSPARAMINFO.
TDSRESULTINFOtds_alloc_results (int num_cols)
int tds_alloc_row (TDSRESULTINFO *res_info)
 Allocate space for row store return NULL on out of memory.
TDSSOCKETtds_alloc_socket (TDSCONTEXT *context, int bufsize)
void tds_cursor_deallocated (TDSSOCKET *tds, TDSCURSOR *cursor)
void tds_free_all_results (TDSSOCKET *tds)
void tds_free_bcp_column_data (BCPCOLDATA *coldata)
static void tds_free_compute_result (TDSCOMPUTEINFO *comp_info)
static void tds_free_compute_results (TDSSOCKET *tds)
void tds_free_connection (TDSCONNECTION *connection)
void tds_free_context (TDSCONTEXT *context)
void tds_free_dynamic (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 Frees dynamic statement and remove from TDS.
static void tds_free_env (TDSSOCKET *tds)
void tds_free_input_params (TDSDYNAMIC *dyn)
 Frees all allocated input parameters of a dynamic statement.
void tds_free_locale (TDSLOCALE *locale)
void tds_free_login (TDSLOGIN *login)
void tds_free_msg (TDSMESSAGE *message)
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 (TDSSOCKET *tds, char *id)
 Get an id for dynamic query based on TDS information.
static void tds_param_free (TDSCOLUMN *col)
TDSSOCKETtds_realloc_socket (TDSSOCKET *tds, size_t bufsize)
void tds_release_cursor (TDSSOCKET *tds, TDSCURSOR *cursor)
static void tds_row_free (TDSRESULTINFO *res_info, unsigned char *row)
static int winsock_initialized (void)

Variables

static const unsigned char defaultcaps []
static volatile int inc_num = 1

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.


Function Documentation

TDSCONNECTION* tds_alloc_connection ( TDSLOCALE locale  ) 

Allocate space for configure structure and initialize with default values.

Parameters:
locale locale information (copied to configuration information)
Returns:
allocated structure or NULL if out of memory
TDSDYNAMIC * tds_alloc_dynamic ( TDSSOCKET tds,
const char *  id 
)

Allocate a dynamic statement.

Parameters:
tds the connection within which to allocate the statement.
id a 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

void* tds_alloc_param_data ( TDSCOLUMN curparam  ) 

Allocate data for a parameter.

Parameters:
curparam parameter to retrieve size information
Returns:
NULL on failure or new data
TDSPARAMINFO * tds_alloc_param_result ( TDSPARAMINFO old_param  ) 

Adds a output parameter to TDSPARAMINFO.

Parameters:
old_param a 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.

void tds_free_dynamic ( TDSSOCKET tds,
TDSDYNAMIC dyn 
)

Frees dynamic statement and remove from TDS.

Parameters:
tds state information for the socket and the TDS protocol
dyn dynamic statement to be freed.
void tds_free_input_params ( TDSDYNAMIC dyn  ) 

Frees all allocated input parameters of a dynamic statement.

Parameters:
dyn the dynamic statement whose input parameter are to be freed

tds_free_input_params frees all parameters for the give dynamic statement

static char* tds_get_dynid ( TDSSOCKET tds,
char *  id 
) [static]

Get an id for dynamic query based on TDS information.

Parameters:
tds state information for the socket and the TDS protocol
Returns:
TDS_FAIL or TDS_SUCCEED

Variable Documentation

const unsigned char defaultcaps[] [static]
Initial value:
 { 
     
        0x01, 0x09, 0x00, 0x08, 0x0E, 0x6D, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE,
        0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x02, 0x68, 0x00, 0x00, 0x00
}
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00301.html100664 001750 000144 00000234670 11623073550 0015600 FreeTDS API: Query

Query
[LibTDS API]

Function to handle query. More...

Defines

#define START_QUERY
#define tds_convert_string_free(original, converted)   do { if (original != converted) free((char*) converted); } while(0)
#define TDS_PUT_N_AS_UCS2(tds, s)

Enumerations

enum  { MUL_STARTED = 1 }

Functions

static char * tds5_fix_dot_query (const char *query, size_t *query_len, TDSPARAMINFO *params)
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+.
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+.
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)
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).
static void tds7_send_execute (TDSSOCKET *tds, TDSDYNAMIC *dyn)
int tds8_submit_prepexec (TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
 tds8_submit_prepexec() creates a temporary stored procedure in the server.
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.
static const char * tds_convert_string (TDSSOCKET *tds, const TDSICONV *char_conv, const char *s, int len, size_t *out_len)
 Convert a string in an allocated buffer.
int tds_count_placeholders (const char *query)
 Count the number of placeholders in query.
static int tds_count_placeholders_ucs2le (const char *query, const char *query_end)
int tds_cursor_close (TDSSOCKET *tds, TDSCURSOR *cursor)
int tds_cursor_dealloc (TDSSOCKET *tds, TDSCURSOR *cursor)
 Send a deallocation request to server libTDS care for all deallocation stuff (memory and server cursor) Caller should not use cursor pointer anymore.
int tds_cursor_declare (TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *something_to_send)
int tds_cursor_fetch (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row)
int tds_cursor_get_cursor_info (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *prow_number, TDS_UINT *prow_count)
int tds_cursor_open (TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *something_to_send)
int tds_cursor_setname (TDSSOCKET *tds, TDSCURSOR *cursor)
int tds_cursor_setrows (TDSSOCKET *tds, TDSCURSOR *cursor, int *something_to_send)
int tds_cursor_update (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO *params)
static size_t tds_fix_column_size (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Get column size for wire.
static int tds_get_column_declaration (TDSSOCKET *tds, TDSCOLUMN *curcol, char *out)
 Return declaration for column (like "varchar(20)").
int tds_multiple_done (TDSSOCKET *tds, TDSMULTIPLE *multiple)
int tds_multiple_execute (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC *dyn)
int tds_multiple_init (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type)
int tds_multiple_query (TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO *params)
int tds_needs_unprepare (TDSSOCKET *tds, TDSDYNAMIC *dyn)
const char * tds_next_placeholder (const char *start)
 Get position of next placeholder.
static const char * tds_next_placeholder_ucs2le (const char *start, const char *end, int named)
static int tds_put_data (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Write data to wire.
static int tds_put_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol, int flags)
 Put data information to wire.
static int tds_put_data_info_length (TDSSOCKET *tds, TDSCOLUMN *curcol, int flags)
 Calc information length in bytes (useful for calculating full packet length).
static int tds_put_param_as_string (TDSSOCKET *tds, TDSPARAMINFO *params, int n)
static void tds_put_params (TDSSOCKET *tds, TDSPARAMINFO *info, int flags)
static int tds_query_flush_packet (TDSSOCKET *tds)
static int tds_quote (TDSSOCKET *tds, char *buffer, char quoting, const char *id, int len)
static void tds_quote_and_put (TDSSOCKET *tds, const char *s, const char *end)
int tds_quote_id (TDSSOCKET *tds, char *buffer, const char *id, int idlen)
 Quote an id.
int tds_quote_string (TDSSOCKET *tds, char *buffer, const char *str, int len)
 Quote a string.
int 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.
static int tds_send_emulated_execute (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params)
 Emulate prepared execute traslating to a normal language.
static int tds_send_emulated_rpc (TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params)
static void tds_set_cur_cursor (TDSSOCKET *tds, TDSCURSOR *cursor)
static const char * tds_skip_comment (const char *s)
static const char * tds_skip_comment_ucs2le (const char *s, const char *end)
const char * tds_skip_quoted (const char *s)
 Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd]).
static const char * tds_skip_quoted_ucs2le (const char *s, const char *end)
static void tds_start_query (TDSSOCKET *tds)
int tds_submit_execdirect (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params)
 Submit a prepared query with parameters.
int tds_submit_execute (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 tds_submit_execute() sends a previously prepared dynamic statement to the server.
int tds_submit_optioncmd (TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size)
int 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.
int tds_submit_query (TDSSOCKET *tds, const char *query)
 tds_submit_query() sends a language string to the database server for processing.
int tds_submit_query_params (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params)
 tds_submit_query_params() sends a language string to the database server for processing.
int tds_submit_queryf (TDSSOCKET *tds, const char *queryf,...)
int tds_submit_rpc (TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params)
 tds_submit_rpc() call a RPC from server.
int tds_submit_unprepare (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 Send a unprepare request for a prepared query.

Variables

static const TDS_UCHAR tds9_query_start []

Detailed Description

Function to handle query.


Define Documentation

#define START_QUERY
Value:
do { \
        if (IS_TDS72_PLUS(tds)) \
                tds_start_query(tds); \
} while(0)
#define TDS_PUT_N_AS_UCS2 ( tds,
 ) 
Value:
do { \
        char buffer[sizeof(s)*2-2]; \
        tds_put_n(tds, buffer, tds_ascii_to_ucs2(buffer, s)); \
} while(0)

Function Documentation

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:
tds state information for the socket and the TDS protocol
params parameters to build declaration
out_len length output buffer in bytes
Returns:
allocated and filled string or NULL on failure (coded in ucs2le charset )
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+.

Parameters:
tds state information for the socket and the TDS protocol
params parameters to build declaration
out_len length output buffer in bytes
Returns:
allocated and filled string or NULL on failure (coded in ucs2le charset )
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:
tds state information for the socket and the TDS protocol
query query (in ucs2le codings)
query_len query length in bytes
int tds8_submit_prepexec ( TDSSOCKET tds,
const char *  query,
const char *  id,
TDSDYNAMIC **  dyn_out,
TDSPARAMINFO params 
)

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

Parameters:
tds state information for the socket and the TDS protocol
query language query with given placeholders (?)
id string to identify the dynamic query. Pass NULL for automatic generation.
dyn_out will receive allocated TDSDYNAMIC*. Any older allocated dynamic won't be freed, Can be NULL.
params parameters to use. It can be NULL even if parameters are present. Used only for TDS7+
Returns:
TDS_FAIL or TDS_SUCCEED
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:
buffer buffer where to store output
buf string to write
Returns:
bytes written
static const char* tds_convert_string ( TDSSOCKET tds,
const TDSICONV char_conv,
const char *  s,
int  len,
size_t *  out_len 
) [static]

Convert a string in an allocated buffer.

Parameters:
tds state information for the socket and the TDS protocol
char_conv information about the encodings involved
s input string
len input string length (in bytes), -1 for null terminated
out_len returned output length (in bytes)
Returns:
string allocated (or input pointer if no conversion required) or NULL if error
static int tds_get_column_declaration ( TDSSOCKET tds,
TDSCOLUMN curcol,
char *  out 
) [static]

Return declaration for column (like "varchar(20)").

Parameters:
tds state information for the socket and the TDS protocol
curcol column
out buffer to hold declaration
Returns:
TDS_FAIL or TDS_SUCCEED
const char* tds_next_placeholder ( const char *  start  ) 

Get position of next placeholder.

Parameters:
start pointer to part of query to search
Returns:
next placeholder or NULL if not found
static int tds_put_data ( TDSSOCKET tds,
TDSCOLUMN curcol 
) [static]

Write data to wire.

Parameters:
tds state information for the socket and the TDS protocol
curcol column where store column information
Returns:
TDS_FAIL on error or TDS_SUCCEED
static int tds_put_data_info ( TDSSOCKET tds,
TDSCOLUMN curcol,
int  flags 
) [static]

Put data information to wire.

Parameters:
tds state information for the socket and the TDS protocol
curcol column where to store information
flags bit flags on how to send data (use TDS_PUT_DATA_USE_NAME for use name information)
Returns:
TDS_SUCCEED or TDS_FAIL
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:
tds state information for the socket and the TDS protocol
curcol column where to store information
flags bit flags on how to send data (use TDS_PUT_DATA_USE_NAME for use name information)
Returns:
TDS_SUCCEED or TDS_FAIL
int tds_quote_id ( TDSSOCKET tds,
char *  buffer,
const char *  id,
int  idlen 
)

Quote an id.

Parameters:
tds state information for the socket and the TDS protocol
buffer buffer to store quoted id. If NULL do not write anything (useful to compute quote length)
id id to quote
idlen id length
Returns:
written chars (not including needed terminator)
int tds_quote_string ( TDSSOCKET tds,
char *  buffer,
const char *  str,
int  len 
)

Quote a string.

Parameters:
tds state information for the socket and the TDS protocol
buffer buffer to store quoted id. If NULL do not write anything (useful to compute quote length)
str string to quote (not necessary null-terminated)
len length of string (-1 for null terminated)
Returns:
written chars (not including needed terminator)
int 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:
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.

const char* tds_skip_quoted ( const char *  s  ) 

Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd]).

Parameters:
s pointer to first quoting character (should be '," or [)
Returns:
character after quoting
int tds_submit_execdirect ( TDSSOCKET tds,
const char *  query,
TDSPARAMINFO params 
)

Submit a prepared query with parameters.

Parameters:
tds state information for the socket and the TDS protocol
query language query with given placeholders (?)
params parameters to send
Returns:
TDS_FAIL or TDS_SUCCEED
int tds_submit_execute ( TDSSOCKET tds,
TDSDYNAMIC dyn 
)

tds_submit_execute() sends a previously prepared dynamic statement to the server.

Parameters:
tds state information for the socket and the TDS protocol
dyn dynamic proc to execute. Must build from same tds.
int 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:
tds state information for the socket and the TDS protocol
query language query with given placeholders (?)
id string to identify the dynamic query. Pass NULL for automatic generation.
dyn_out will receive allocated TDSDYNAMIC*. Any older allocated dynamic won't be freed, Can be NULL.
params parameters to use. It can be NULL even if parameters are present. Used only for TDS7+
Returns:
TDS_FAIL or TDS_SUCCEED
int 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:
tds state information for the socket and the TDS protocol
query language query to submit
Returns:
TDS_FAIL or TDS_SUCCEED
int tds_submit_query_params ( TDSSOCKET tds,
const char *  query,
TDSPARAMINFO params 
)

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:
tds state information for the socket and the TDS protocol
query language query to submit
params parameters of query
Returns:
TDS_FAIL or TDS_SUCCEED
int tds_submit_rpc ( TDSSOCKET tds,
const char *  rpc_name,
TDSPARAMINFO params 
)

tds_submit_rpc() call a RPC from server.

Output parameters will be stored in tds->param_info

Parameters:
tds state information for the socket and the TDS protocol
rpc_name name of RPC
params parameters informations. NULL for no parameters
int tds_submit_unprepare ( TDSSOCKET tds,
TDSDYNAMIC dyn 
)

Send a unprepare request for a prepared query.

Parameters:
tds state information for the socket and the TDS protocol
dyn dynamic query
Returns:
TDS_SUCCEED or TDS_FAIL

Variable Documentation

const TDS_UCHAR tds9_query_start[] [static]
Initial value:
 {
        
        0x16, 0, 0, 0,
        
        0x12, 0, 0, 0,
        
        0x02, 0,
        
        0, 0, 0, 0, 0, 0, 0, 0,
        
        1, 0, 0, 0
}
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00302.html100664 001750 000144 00000104572 11623073550 0015576 FreeTDS API: Network functions

Network functions
[LibTDS API]

Functions for reading or writing from network. More...

Defines

#define TEMP_FREE   ;
#define TEMP_INIT(s)   char temp[s]
#define TEMP_SIZE   sizeof(temp)

Typedefs

typedef unsigned int ioctl_nonblocking_t

Functions

static int goodread (TDSSOCKET *tds, unsigned char *buf, int buflen)
static int read_and_convert (TDSSOCKET *tds, const TDSICONV *char_conv, size_t *wire_size, char **outbuf, size_t *outbytesleft)
int tds7_get_instance_port (const char *ip_addr, const char *instance)
 Get port of given instance.
int tds7_get_instance_ports (FILE *output, const char *ip_addr)
 Get port of all instances.
int tds_close_socket (TDSSOCKET *tds)
int tds_flush_packet (TDSSOCKET *tds)
 Flush packet to server.
unsigned char tds_get_byte (TDSSOCKET *tds)
int tds_get_char_data (TDSSOCKET *tds, char *row_buffer, size_t wire_size, TDSCOLUMN *curcol)
 Fetch character data the wire.
TDS_INT tds_get_int (TDSSOCKET *tds)
 Get an int32 from the server.
TDS_INT8 tds_get_int8 (TDSSOCKET *tds)
void * tds_get_n (TDSSOCKET *tds, void *dest, int need)
 Get N bytes from the buffer and return them in the already allocated space given to us.
TDS_SMALLINT tds_get_smallint (TDSSOCKET *tds)
 Get an int16 from the server.
int tds_get_string (TDSSOCKET *tds, int string_len, char *dest, size_t dest_size)
 Fetch a string from the wire.
static int tds_goodread (TDSSOCKET *tds, unsigned char *buf, int buflen, unsigned char unfinished)
 Loops until we have received buflen characters return -1 on failure.
static int tds_goodwrite (TDSSOCKET *tds, const unsigned char *buffer, size_t len, unsigned char last)
int tds_init_write_buf (TDSSOCKET *tds)
int tds_lastpacket (TDSSOCKET *tds)
TDSERRNO tds_open_socket (TDSSOCKET *tds, const char *ip_addr, unsigned int port, int timeout, int *p_oserr)
unsigned char tds_peek (TDSSOCKET *tds)
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_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.
int tds_read_packet (TDSSOCKET *tds)
 Read in one 'packet' from the server.
static int tds_select (TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds)
 Select on a socket until it's available or the timeout expires.
void tds_unget_byte (TDSSOCKET *tds)
 Unget will always work as long as you don't call it twice in a row.
int tds_write_packet (TDSSOCKET *tds, unsigned char final)

Detailed Description

Functions for reading or writing from network.


Function Documentation

int tds7_get_instance_port ( const char *  ip_addr,
const char *  instance 
)

Get port of given instance.

Returns:
port number or 0 if error
int tds7_get_instance_ports ( FILE *  output,
const char *  ip_addr 
)

Get port of all instances.

Returns:
default port number or 0 if error
Remarks:
experimental, cf. MC-SQLR.pdf.
int tds_flush_packet ( TDSSOCKET tds  ) 

Flush packet to server.

Returns:
TDS_FAIL or TDS_SUCCEED
int 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:
tds state information for the socket and the TDS protocol
row_buffer destination buffer in current_row. Can't be NULL
wire_size size to read from wire (in bytes)
curcol column information
Returns:
TDS_SUCCEED or TDS_FAIL (probably memory error on text data)
Todo:
put a TDSICONV structure in every TDSCOLUMN
void* tds_get_n ( TDSSOCKET tds,
void *  dest,
int  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. (tetherow@nol.org)

int tds_get_string ( TDSSOCKET tds,
int  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:
tds connection information
string_len length of string to read from wire (in server characters, bytes for tds4-tds5, ucs2 for tds7+)
dest destination buffer, if NULL string is read and discarded
dest_size destination buffer size, in bytes
static int tds_goodwrite ( TDSSOCKET tds,
const unsigned char *  buffer,
size_t  len,
unsigned char  last 
) [static]
Parameters:
tds the famous socket
buffer data to send
len bytes in buffer
last 1 if this is the last packet, else 0
Returns:
len on success, <0 on failure
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:
tds state information for the socket and the TDS protocol
s string to write
len length of string in characters, or -1 for null terminated
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
static int tds_select ( TDSSOCKET tds,
unsigned  tds_sel,
int  timeout_seconds 
) [static]

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.
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.

Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00303.html100664 001750 000144 00000042555 11623073550 0015601 FreeTDS API: Dynamic string functions

Dynamic string functions
[LibTDS API]

Handle dynamic string. More...

Defines

#define tds_dstr_buf(s)   ((s)->dstr_s)
#define tds_dstr_cstr(s)   ((const char* ) tds_dstr_buf(s))
#define tds_dstr_init(s)   do { DSTR *_tds_s = (s); _tds_s->dstr_size = 0; _tds_s->dstr_s = (char*) tds_str_empty; } while(0)
 init a string with empty
#define tds_dstr_isempty(s)   ((s)->dstr_size == 0)
 test if string is empty
#define tds_dstr_len(s)   ((s)->dstr_size)

Functions

DSTRtds_dstr_alloc (DSTR *s, size_t length)
 allocate space for length char
DSTRtds_dstr_copy (DSTR *s, const char *src)
 copy a string from another
DSTRtds_dstr_copyn (DSTR *s, const char *src, size_t length)
 Set string to a given buffer of characters.
DSTRtds_dstr_dup (DSTR *s, const DSTR *src)
void tds_dstr_free (DSTR *s)
 free string
DSTRtds_dstr_set (DSTR *s, char *src)
 set a string from another buffer.
DSTRtds_dstr_setlen (DSTR *s, size_t length)
 limit length of string, MUST be <= current length
void tds_dstr_zero (DSTR *s)
 clear all string filling with zeroes (mainly for security reason)

Detailed Description

Handle dynamic string.

In this string are always valid (you don't have NULL pointer, only empty string)


Function Documentation

DSTR * tds_dstr_alloc ( DSTR s,
size_t  length 
)

allocate space for length char

Parameters:
s dynamic string
length new length
Returns:
string allocated or NULL on memory error
DSTR * tds_dstr_copy ( DSTR s,
const char *  src 
)

copy a string from another

Parameters:
s dynamic string
src source buffer
Returns:
string copied or NULL on memory error
DSTR * tds_dstr_copyn ( DSTR s,
const char *  src,
size_t  length 
)

Set string to a given buffer of characters.

Parameters:
s dynamic string
src source buffer
length length of source buffer
Returns:
string copied or NULL on memory error
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:
s dynamic string
src source buffer
Returns:
string copied or NULL on memory error
DSTR * tds_dstr_setlen ( DSTR s,
size_t  length 
)

limit length of string, MUST be <= current length

Parameters:
s dynamic string
length new length
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00304.html100664 001750 000144 00000153226 11623073550 0015600 FreeTDS API: Results processing

Results processing
[LibTDS API]

Handle tokens in packets. More...

Classes

struct  namelist

Functions

static int tds5_process_dyn_result2 (TDSSOCKET *tds)
 New TDS 5.0 token for describing output parameters.
static int tds5_process_optioncmd (TDSSOCKET *tds)
static int tds5_process_result (TDSSOCKET *tds)
 tds5_process_result() is the new TDS 5.0 result set processing routine.
static int tds7_get_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Read data information from wire.
static int tds7_get_variant (TDSSOCKET *tds, TDSCOLUMN *curcol)
static int tds7_process_compute_result (TDSSOCKET *tds)
 tds7_process_compute_result() processes compute result sets for TDS 7/8.
static int tds7_process_result (TDSSOCKET *tds)
 tds7_process_result() is the TDS 7.0 result set processing routine.
static int tds8_read_table_names (TDSSOCKET *tds, int remainder, struct namelist **p_head)
static int tds9_get_varmax (TDSSOCKET *tds, TDSCOLUMN *curcol)
static int tds_alloc_get_string (TDSSOCKET *tds, char **string, int len)
 Read a string from wire in a new allocated buffer.
static void tds_free_namelist (struct namelist *head)
static int tds_get_data (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Read a data from wire.
static int tds_get_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol, int is_param)
 Read data information from wire.
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
TDSDYNAMICtds_lookup_dynamic (TDSSOCKET *tds, const char *id)
 Find a dynamic given string id.
static const char * tds_pr_op (int op)
static int tds_process_auth (TDSSOCKET *tds)
int tds_process_cancel (TDSSOCKET *tds)
static int tds_process_col_fmt (TDSSOCKET *tds)
 tds_process_col_fmt() is the other half of result set processing under TDS 4.2.
static int 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
static int tds_process_colinfo (TDSSOCKET *tds, char **names, int num_names)
static int tds_process_compute (TDSSOCKET *tds, TDS_INT *pcomputeid)
 tds_process_compute() processes compute rows and places them in the row buffer.
static int tds_process_compute_names (TDSSOCKET *tds)
 tds_process_compute_names() processes compute result sets.
static int tds_process_compute_result (TDSSOCKET *tds)
 tds_process_compute_result() processes compute result sets.
static int tds_process_cursor_tokens (TDSSOCKET *tds)
static int 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
static int tds_process_dyn_result (TDSSOCKET *tds)
static TDSDYNAMICtds_process_dynamic (TDSSOCKET *tds)
 tds_process_dynamic() finds the element of the dyns array for the id
static int tds_process_end (TDSSOCKET *tds, int marker, int *flags_parm)
 tds_process_end() processes any of the DONE, DONEPROC, or DONEINPROC tokens.
static int 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.
int tds_process_login_tokens (TDSSOCKET *tds)
 tds_process_login_tokens() is called after sending the login packet to the server.
static int tds_process_msg (TDSSOCKET *tds, int marker)
 tds_process_msg() is called for MSG, ERR, or EED tokens and is responsible for calling the CLI's message handling routine returns TDS_SUCCEED if informational, TDS_FAIL if error.
static int tds_process_param_result (TDSSOCKET *tds, TDSPARAMINFO **pinfo)
 process output parameters of a stored procedure.
static int tds_process_param_result_tokens (TDSSOCKET *tds)
static int tds_process_params_result_token (TDSSOCKET *tds)
 tds_process_params_result_token() processes params on TDS5.
static int tds_process_result (TDSSOCKET *tds)
 tds_process_result() is the TDS 5.0 result set processing routine.
static int tds_process_row (TDSSOCKET *tds)
 tds_process_row() processes rows and places them in the row buffer.
int 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.
static int tds_process_tabname (TDSSOCKET *tds)
int tds_process_tokens (TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
 process all streams.
const char * tds_prtype (int token)
static int tds_read_namelist (TDSSOCKET *tds, int remainder, struct namelist **p_head, int large)
static int tds_set_spid (TDSSOCKET *tds)
void tds_swap_numeric (TDS_NUMERIC *num)

Detailed Description

Handle tokens in packets.

Many PDU (packets data unit) contain tokens. (like result description, rows, data, errors and many other).


Function Documentation

static int tds5_process_result ( TDSSOCKET tds  )  [static]

tds5_process_result() 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

static int tds7_get_data_info ( TDSSOCKET tds,
TDSCOLUMN curcol 
) [static]

Read data information from wire.

Parameters:
tds state information for the socket and the TDS protocol
curcol column where to store information
static int 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.

static int 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

static int tds_alloc_get_string ( TDSSOCKET tds,
char **  string,
int  len 
) [static]

Read a string from wire in a new allocated buffer.

Parameters:
tds state information for the socket and the TDS protocol
len length of string to read
static int tds_get_data ( TDSSOCKET tds,
TDSCOLUMN curcol 
) [static]

Read a data from wire.

Parameters:
tds state information for the socket and the TDS protocol
curcol column where store column information
Returns:
TDS_FAIL on error or TDS_SUCCEED
static int tds_get_data_info ( TDSSOCKET tds,
TDSCOLUMN curcol,
int  is_param 
) [static]

Read data information from wire.

Parameters:
tds state information for the socket and the TDS protocol
curcol column where to store information
TDSDYNAMIC* tds_lookup_dynamic ( TDSSOCKET tds,
const char *  id 
)

Find a dynamic given string id.

Returns:
dynamic or NULL is not found
Parameters:
tds state information for the socket and the TDS protocol
id dynamic id to search
int 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.
static int 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

static int 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.

static int tds_process_end ( TDSSOCKET tds,
int  marker,
int *  flags_parm 
) [static]

tds_process_end() processes any of the DONE, DONEPROC, or DONEINPROC tokens.

Parameters:
tds state information for the socket and the TDS protocol
marker TDS token number
flags_parm filled with bit flags (see TDS_DONE_ constants). Is NULL nothing is returned
static int 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.

int 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

static int 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.

static int tds_process_result ( TDSSOCKET tds  )  [static]

tds_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

int 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)
int 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:
tds A pointer to the TDSSOCKET structure managing a client/server operation.
result_type A 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:
flag Flags to select token type to stop/return
Todo:
Complete TDS_DESCRIBE_RESULT description
Return values:
TDS_SUCCEED if a result set is available for processing.
TDS_FAIL on error.
TDS_NO_MORE_RESULTS if all results have been completely processed.
anything returned by one of the many functions it calls. :-(
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00305.html100664 001750 000144 00000016011 11623073550 0015567 FreeTDS API: LibTDS API

LibTDS API

Callable functions in libtds. More...

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.

Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00306.html100664 001750 000144 00000023611 11623073547 0015602 FreeTDS API: Todo List

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 (DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen)

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 dbuse (DBPROCESS *dbproc, const char *name)
name should be quoted.

Member tds_get_char_data (TDSSOCKET *tds, char *row_buffer, size_t wire_size, TDSCOLUMN *curcol)
put a TDSICONV structure in every TDSCOLUMN

Member tds_iconv (TDSSOCKET *tds, const 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)
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.

Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00307.html100664 001750 000144 00000010307 11623073547 0015601 FreeTDS API: Bug List

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.
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00309.html100664 001750 000144 00000011133 11623073550 0015573 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00310.html100664 001750 000144 00000011043 11623073550 0015563 FreeTDS API: Member List

_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
con (defined in _cs_blkdesc)_cs_blkdesc
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00311.html100664 001750 000144 00000014017 11623073550 0015570 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00312.html100664 001750 000144 00000020241 11623073550 0015565 FreeTDS API: Member List

_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
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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00313.html100664 001750 000144 00000011076 11623073550 0015574 FreeTDS API: Member List

_cs_command_list Member List

This is the complete list of members for _cs_command_list, including all inherited members.
cmd (defined in _cs_command_list)_cs_command_list
next (defined in _cs_command_list)_cs_command_list
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00314.html100664 001750 000144 00000010570 11623073550 0015573 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00315.html100664 001750 000144 00000014337 11623073550 0015601 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00316.html100664 001750 000144 00000016163 11623073550 0015601 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00317.html100664 001750 000144 00000014200 11623073550 0015570 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00318.html100664 001750 000144 00000013746 11623073550 0015607 FreeTDS API: Member List

_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
datesecond (defined in _cs_daterec)_cs_daterec
datetzone (defined in _cs_daterec)_cs_daterec
dateyear (defined in _cs_daterec)_cs_daterec
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00319.html100664 001750 000144 00000011053 11623073550 0015575 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00320.html100664 001750 000144 00000011060 11623073550 0015563 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00321.html100664 001750 000144 00000011611 11623073550 0015566 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00322.html100664 001750 000144 00000014743 11623073550 0015600 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00323.html100664 001750 000144 00000011605 11623073550 0015573 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00324.html100664 001750 000144 00000011032 11623073550 0015566 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00325.html100664 001750 000144 00000010553 11623073550 0015576 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00326.html100664 001750 000144 00000011332 11623073550 0015573 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00327.html100664 001750 000144 00000012116 11623073550 0015575 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00328.html100664 001750 000144 00000013730 11623073550 0015601 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00329.html100664 001750 000144 00000014676 11623073550 0015614 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00330.html100664 001750 000144 00000015042 11623073550 0015570 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00331.html100664 001750 000144 00000011055 11623073550 0015571 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00332.html100664 001750 000144 00000011037 11623073550 0015572 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00333.html100664 001750 000144 00000011364 11623073550 0015576 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00334.html100664 001750 000144 00000010564 11623073550 0015600 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00335.html100664 001750 000144 00000011443 11623073550 0015576 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00336.html100664 001750 000144 00000011654 11623073550 0015603 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00337.html100664 001750 000144 00000013063 11623073550 0015600 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00338.html100664 001750 000144 00000012741 11623073550 0015603 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00339.html100664 001750 000144 00000024703 11623073550 0015605 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00340.html100664 001750 000144 00000015734 11623073550 0015601 FreeTDS API: Member List

_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
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
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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00341.html100664 001750 000144 00000010776 11623073550 0015603 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00342.html100664 001750 000144 00000014304 11623073550 0015573 FreeTDS API: Member List

_hdbc Member List

This is the complete list of members for _hdbc, including all inherited members.
attr (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
server (defined in _hdbc)_hdbc
stmt_list_hdbc
tds_socket (defined in _hdbc)_hdbc
uad_hdbc
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00343.html100664 001750 000144 00000012253 11623073550 0015575 FreeTDS API: Member List

_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
parent (defined in _hdesc)_hdesc
records (defined in _hdesc)_hdesc
type (defined in _hdesc)_hdesc
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00344.html100664 001750 000144 00000011575 11623073550 0015604 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00345.html100664 001750 000144 00000011515 11623073551 0015600 FreeTDS API: Member List

_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
tds_ctx (defined in _henv)_henv
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00346.html100664 001750 000144 00000016217 11623073551 0015605 FreeTDS API: Member List

_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
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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00347.html100664 001750 000144 00000023446 11623073551 0015610 FreeTDS API: Member List

_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
cancel_sent (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
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 (defined in _hstmt)_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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00348.html100664 001750 000144 00000011131 11623073551 0015575 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00349.html100664 001750 000144 00000015147 11623073551 0015611 FreeTDS API: Member List

_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
servername (defined in _options)_options
verbose (defined in _options)_options
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00350.html100664 001750 000144 00000011034 11623073551 0015570 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00351.html100664 001750 000144 00000012631 11623073551 0015575 FreeTDS API: Member List

_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
server (defined in _sql_error)_sql_error
state2 (defined in _sql_error)_sql_error
state3 (defined in _sql_error)_sql_error
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00352.html100664 001750 000144 00000011617 11623073551 0015601 FreeTDS API: Member List

_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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00353.html100664 001750 000144 00000013611 11623073551 0015576 FreeTDS API: Member List

BCP_HOSTCOLINFO Member List

This is the complete list of members for BCP_HOSTCOLINFO, including all inherited members.
bcp_column_data (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00354.html100664 001750 000144 00000013622 11623073551 0015601 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00355.html100664 001750 000144 00000015667 11623073551 0015615 FreeTDS API: Member List

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
c (defined in conv_result)conv_result
cb (defined in conv_result)conv_result
cc (defined in conv_result)conv_result
dt (defined in conv_result)conv_result
dt4 (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
u (defined in conv_result)conv_result
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00356.html100664 001750 000144 00000011102 11623073551 0015572 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00357.html100664 001750 000144 00000011101 11623073551 0015572 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00358.html100664 001750 000144 00000011040 11623073551 0015575 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00359.html100664 001750 000144 00000011120 11623073551 0015575 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00360.html100664 001750 000144 00000011076 11623073551 0015577 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00361.html100664 001750 000144 00000011236 11623073551 0015576 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00362.html100664 001750 000144 00000014776 11623073551 0015613 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00363.html100664 001750 000144 00000011037 11623073551 0015577 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00364.html100664 001750 000144 00000011044 11623073551 0015576 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00365.html100664 001750 000144 00000011652 11623073551 0015604 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00366.html100664 001750 000144 00000014110 11623073551 0015575 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:33 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00367.html100664 001750 000144 00000011016 11623073552 0015601 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00368.html100664 001750 000144 00000010543 11623073552 0015606 FreeTDS API: Member List

DBMONEY4 Member List

This is the complete list of members for DBMONEY4, including all inherited members.
mny4 (defined in DBMONEY4)DBMONEY4
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00369.html100664 001750 000144 00000011312 11623073552 0015602 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00370.html100664 001750 000144 00000011277 11623073552 0015604 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00371.html100664 001750 000144 00000011306 11623073552 0015576 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00372.html100664 001750 000144 00000011041 11623073552 0015573 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00373.html100664 001750 000144 00000011025 11623073552 0015576 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00374.html100664 001750 000144 00000011031 11623073552 0015574 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00375.html100664 001750 000144 00000011533 11623073552 0015604 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00376.html100664 001750 000144 00000011307 11623073552 0015604 FreeTDS API: Member List

DSNINFO Member List

This is the complete list of members for DSNINFO, including all inherited members.
connectionDSNINFO
dsnDSNINFO
origdsnDSNINFO
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00377.html100664 001750 000144 00000011575 11623073552 0015614 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00378.html100664 001750 000144 00000012360 11623073552 0015606 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00379.html100664 001750 000144 00000011310 11623073552 0015601 FreeTDS API: Member List

MD4Context Member List

This is the complete list of members for MD4Context, including all inherited members.
bits (defined in MD4Context)MD4Context
buf (defined in MD4Context)MD4Context
in (defined in MD4Context)MD4Context
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00380.html100664 001750 000144 00000011310 11623073552 0015571 FreeTDS API: Member List

MD5Context Member List

This is the complete list of members for MD5Context, including all inherited members.
bits (defined in MD5Context)MD5Context
buf (defined in MD5Context)MD5Context
in (defined in MD5Context)MD5Context
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00381.html100664 001750 000144 00000013576 11623073552 0015612 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00382.html100664 001750 000144 00000011017 11623073552 0015577 FreeTDS API: Member List

namelist Member List

This is the complete list of members for namelist, including all inherited members.
name (defined in namelist)namelist
next (defined in namelist)namelist
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00383.html100664 001750 000144 00000013421 11623073552 0015601 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00384.html100664 001750 000144 00000011040 11623073552 0015575 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00385.html100664 001750 000144 00000032344 11623073552 0015610 FreeTDS API: Member List

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
dbobject (defined in pd)pd
ddb (defined in pd)pd
ddbobject (defined in pd)pd
Dflag (defined in pd)pd
direction (defined in pd)pd
dpass (defined in pd)pd
dserver (defined in pd)pd
duser (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
sdb (defined in pd)pd
sdbobject (defined in pd)pd
server (defined in pd)pd
Sflag (defined in pd)pd
spass (defined in pd)pd
sserver (defined in pd)pd
suser (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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00386.html100664 001750 000144 00000011256 11623073552 0015610 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00387.html100664 001750 000144 00000012120 11623073552 0015600 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:34 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00388.html100664 001750 000144 00000011712 11623073553 0015610 FreeTDS API: Member List

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_
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00389.html100664 001750 000144 00000011044 11623073553 0015607 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00390.html100664 001750 000144 00000011027 11623073553 0015600 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00391.html100664 001750 000144 00000011112 11623073553 0015574 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00392.html100664 001750 000144 00000012510 11623073553 0015600 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00393.html100664 001750 000144 00000011367 11623073553 0015612 FreeTDS API: Member List

TDS8_COLLATION Member List

This is the complete list of members for TDS8_COLLATION, including all inherited members.
charset_id (defined in TDS8_COLLATION)TDS8_COLLATION
flags (defined in TDS8_COLLATION)TDS8_COLLATION
locale_id (defined in TDS8_COLLATION)TDS8_COLLATION
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00394.html100664 001750 000144 00000011071 11623073553 0015603 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00395.html100664 001750 000144 00000011041 11623073553 0015601 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00396.html100664 001750 000144 00000011732 11623073553 0015611 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00397.html100664 001750 000144 00000011361 11623073553 0015610 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00398.html100664 001750 000144 00000013745 11623073553 0015621 FreeTDS API: Member List

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
var_cols (defined in tds_bcpinfo)tds_bcpinfo
xfer_init (defined in tds_bcpinfo)tds_bcpinfo
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00399.html100664 001750 000144 00000011310 11623073553 0015604 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00400.html100664 001750 000144 00000026730 11623073553 0015577 FreeTDS API: Member List

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_namelentds_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
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
table_namelen (defined in tds_column)tds_column
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00402.html100664 001750 000144 00000014404 11623073553 0015574 FreeTDS API: Member List

tds_compiletime_settings Member List

This is the complete list of members for tds_compiletime_settings, including all inherited members.
freetds_version (defined in tds_compiletime_settings)tds_compiletime_settings
iodbc (defined in tds_compiletime_settings)tds_compiletime_settings
last_update (defined in tds_compiletime_settings)tds_compiletime_settings
libiconv (defined in tds_compiletime_settings)tds_compiletime_settings
msdblib (defined in tds_compiletime_settings)tds_compiletime_settings
sybase_compat (defined in tds_compiletime_settings)tds_compiletime_settings
sysconfdir (defined in tds_compiletime_settings)tds_compiletime_settings
tdsver (defined in tds_compiletime_settings)tds_compiletime_settings
threadsafe (defined in tds_compiletime_settings)tds_compiletime_settings
unixodbc (defined in tds_compiletime_settings)tds_compiletime_settings
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00403.html100664 001750 000144 00000023747 11623073553 0015607 FreeTDS API: Member List

tds_connection Member List

This is the complete list of members for tds_connection, including all inherited members.
app_name (defined in tds_connection)tds_connection
block_size (defined in tds_connection)tds_connection
broken_dates (defined in tds_connection)tds_connection
bulk_copy (defined in tds_connection)tds_connection
capabilities (defined in tds_connection)tds_connection
client_charset (defined in tds_connection)tds_connection
client_host_name (defined in tds_connection)tds_connection
connect_timeout (defined in tds_connection)tds_connection
database (defined in tds_connection)tds_connection
debug_flags (defined in tds_connection)tds_connection
dump_file (defined in tds_connection)tds_connection
emul_little_endian (defined in tds_connection)tds_connection
encryption_level (defined in tds_connection)tds_connection
gssapi_use_delegation (defined in tds_connection)tds_connection
instance_name (defined in tds_connection)tds_connection
ip_addrtds_connection
language (defined in tds_connection)tds_connection
library (defined in tds_connection)tds_connection
option_flag2 (defined in tds_connection)tds_connection
passwordtds_connection
porttds_connection
query_timeout (defined in tds_connection)tds_connection
server_charsettds_connection
server_host_name (defined in tds_connection)tds_connection
server_nametds_connection
server_realm_nametds_connection
suppress_language (defined in tds_connection)tds_connection
tds_version (defined in tds_connection)tds_connection
text_size (defined in tds_connection)tds_connection
use_ntlmv2 (defined in tds_connection)tds_connection
user_nametds_connection
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00404.html100664 001750 000144 00000012120 11623073553 0015567 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00405.html100664 001750 000144 00000015531 11623073553 0015601 FreeTDS API: Member List
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00406.html100664 001750 000144 00000012513 11623073553 0015577 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00407.html100664 001750 000144 00000023506 11623073553 0015604 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00408.html100664 001750 000144 00000010620 11623073553 0015576 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00409.html100664 001750 000144 00000011026 11623073553 0015600 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:35 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00410.html100664 001750 000144 00000012646 11623073554 0015602 FreeTDS API: Member List

tds_dynamic Member List

This is the complete list of members for tds_dynamic, including all inherited members.
emulatedtds_dynamic
idtds_dynamic
nexttds_dynamic
num_idtds_dynamic
paramstds_dynamic
querytds_dynamic
res_infotds_dynamic
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00411.html100664 001750 000144 00000011656 11623073554 0015603 FreeTDS API: Member List

tds_encoding Member List

This is the complete list of members for tds_encoding, including all inherited members.
canonic (defined in tds_encoding)tds_encoding
max_bytes_per_char (defined in tds_encoding)tds_encoding
min_bytes_per_char (defined in tds_encoding)tds_encoding
name (defined in tds_encoding)tds_encoding
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00412.html100664 001750 000144 00000011556 11623073554 0015603 FreeTDS API: Member List

tds_env Member List

This is the complete list of members for tds_env, including all inherited members.
block_size (defined in tds_env)tds_env
charset (defined in tds_env)tds_env
database (defined in tds_env)tds_env
language (defined in tds_env)tds_env
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00413.html100664 001750 000144 00000011470 11623073554 0015577 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00414.html100664 001750 000144 00000011413 11623073554 0015575 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00415.html100664 001750 000144 00000011335 11623073554 0015601 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00416.html100664 001750 000144 00000017051 11623073554 0015603 FreeTDS API: Member List

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_copy (defined in tds_login)tds_login
capabilities (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
database (defined in tds_login)tds_login
encryption_level (defined in tds_login)tds_login
language (defined in tds_login)tds_login
library (defined in tds_login)tds_login
password (defined in tds_login)tds_login
port (defined in tds_login)tds_login
query_timeout (defined in tds_login)tds_login
server_charset (defined in tds_login)tds_login
server_name (defined in tds_login)tds_login
suppress_language (defined in tds_login)tds_login
tds_version (defined in tds_login)tds_login
user_name (defined in tds_login)tds_login
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00417.html100664 001750 000144 00000013727 11623073554 0015612 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00418.html100664 001750 000144 00000015144 11623073554 0015606 FreeTDS API: Member List
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00419.html100664 001750 000144 00000011050 11623073554 0015577 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00420.html100664 001750 000144 00000010573 11623073554 0015600 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00421.html100664 001750 000144 00000011343 11623073554 0015575 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00422.html100664 001750 000144 00000011073 11623073554 0015576 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00423.html100664 001750 000144 00000011276 11623073554 0015604 FreeTDS API: Member List

tds_pbcb Member List

This is the complete list of members for tds_pbcb, including all inherited members.
cb (defined in tds_pbcb)tds_pbcb
from_malloc (defined in tds_pbcb)tds_pbcb
pb (defined in tds_pbcb)tds_pbcb
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00424.html100664 001750 000144 00000014651 11623073554 0015605 FreeTDS API: Member List

tds_pool Member List

This is the complete list of members for tds_pool, including all inherited members.
database (defined in tds_pool)tds_pool
max_member_age (defined in tds_pool)tds_pool
max_open_conn (defined in tds_pool)tds_pool
max_users (defined in tds_pool)tds_pool
members (defined in tds_pool)tds_pool
min_open_conn (defined in tds_pool)tds_pool
name (defined in tds_pool)tds_pool
num_members (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
users (defined in tds_pool)tds_pool
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00425.html100664 001750 000144 00000012776 11623073554 0015614 FreeTDS API: Member List

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
fragment (defined in tds_pool_member)tds_pool_member
last_used_tm (defined in tds_pool_member)tds_pool_member
need_more (defined in tds_pool_member)tds_pool_member
num_bytes_left (defined in tds_pool_member)tds_pool_member
state (defined in tds_pool_member)tds_pool_member
tds (defined in tds_pool_member)tds_pool_member
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00426.html100664 001750 000144 00000011363 11623073554 0015604 FreeTDS API: Member List

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
tds (defined in tds_pool_user)tds_pool_user
user_state (defined in tds_pool_user)tds_pool_user
Generated on Wed Aug 17 22:22:36 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00427.html100664 001750 000144 00000014670 11623073555 0015612 FreeTDS API: Member List

tds_result_info Member List

This is the complete list of members for tds_result_info, including all inherited members.
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_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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00428.html100664 001750 000144 00000012170 11623073555 0015604 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00429.html100664 001750 000144 00000011337 11623073555 0015611 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00430.html100664 001750 000144 00000011046 11623073555 0015576 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00431.html100664 001750 000144 00000031060 11623073555 0015575 FreeTDS API: Member List

tds_socket Member List

This is the complete list of members for tds_socket, including all inherited members.
authentication (defined in tds_socket)tds_socket
broken_dates (defined in tds_socket)tds_socket
capabilities (defined in tds_socket)tds_socket
char_conv_count (defined in tds_socket)tds_socket
char_convs (defined in tds_socket)tds_socket
collation (defined in tds_socket)tds_socket
comp_info (defined in tds_socket)tds_socket
connectiontds_socket
cur_cursortds_socket
cur_dyntds_socket
current_resultstds_socket
cursorstds_socket
dynstds_socket
emul_little_endian (defined in tds_socket)tds_socket
env (defined in tds_socket)tds_socket
env_chg_func (defined in tds_socket)tds_socket
has_statustds_socket
in_buftds_socket
in_buf_maxtds_socket
in_canceltds_socket
in_flagtds_socket
in_lentds_socket
in_postds_socket
internal_sp_called (defined in tds_socket)tds_socket
num_comp_info (defined in tds_socket)tds_socket
option_value (defined in tds_socket)tds_socket
out_buftds_socket
out_flagtds_socket
out_postds_socket
param_info (defined in tds_socket)tds_socket
parent (defined in tds_socket)tds_socket
product_name (defined in tds_socket)tds_socket
product_versiontds_socket
query_timeout (defined in tds_socket)tds_socket
res_info (defined in tds_socket)tds_socket
ret_statustds_socket
rows_affectedtds_socket
stds_socket
spid (defined in tds_socket)tds_socket
state (defined in tds_socket)tds_socket
tds71rev1 (defined in tds_socket)tds_socket
tds9_transaction (defined in tds_socket)tds_socket
tds_ctx (defined in tds_socket)tds_socket
tds_version (defined in tds_socket)tds_socket
tls_credentials (defined in tds_socket)tds_socket
tls_session (defined in tds_socket)tds_socket
use_iconv (defined in tds_socket)tds_socket
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00432.html100664 001750 000144 00000015067 11623073555 0015607 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00433.html100664 001750 000144 00000012620 11623073555 0015600 FreeTDS API: Member List

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_mstds_time
tm_sectds_time
tm_yeartds_time
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00434.html100664 001750 000144 00000011342 11623073555 0015601 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00435.html100664 001750 000144 00000012100 11623073555 0015573 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00436.html100664 001750 000144 00000014435 11623073555 0015611 FreeTDS API: Member List
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00437.html100664 001750 000144 00000011045 11623073555 0015604 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00438.html100664 001750 000144 00000011052 11623073555 0015603 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00439.html100664 001750 000144 00000013212 11623073555 0015604 FreeTDS API: Member List

tdsiconvinfo Member List

This is the complete list of members for tdsiconvinfo, including all inherited members.
client_charset (defined in tdsiconvinfo)tdsiconvinfo
flags (defined in tdsiconvinfo)tdsiconvinfo
from_wire (defined in tdsiconvinfo)tdsiconvinfo
from_wire2 (defined in tdsiconvinfo)tdsiconvinfo
server_charset (defined in tdsiconvinfo)tdsiconvinfo
suppress (defined in tdsiconvinfo)tdsiconvinfo
to_wire (defined in tdsiconvinfo)tdsiconvinfo
to_wire2 (defined in tdsiconvinfo)tdsiconvinfo
Generated on Wed Aug 17 22:22:37 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00440.html100664 001750 000144 00000011025 11623073556 0015575 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00441.html100664 001750 000144 00000010547 11623073556 0015606 FreeTDS API: Member List

tdsmoney4 Member List

This is the complete list of members for tdsmoney4, including all inherited members.
mny4 (defined in tdsmoney4)tdsmoney4
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00442.html100664 001750 000144 00000011322 11623073556 0015577 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00443.html100664 001750 000144 00000011046 11623073556 0015603 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00444.html100664 001750 000144 00000011565 11623073556 0015612 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00445.html100664 001750 000144 00000011047 11623073556 0015606 FreeTDS API: Member List

tdsvarbinary Member List

This is the complete list of members for tdsvarbinary, including all inherited members.
array (defined in tdsvarbinary)tdsvarbinary
len (defined in tdsvarbinary)tdsvarbinary
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00446.html100664 001750 000144 00000011033 11623073556 0015602 FreeTDS API: Member List

tdsvarchar Member List

This is the complete list of members for tdsvarchar, including all inherited members.
array (defined in tdsvarchar)tdsvarchar
len (defined in tdsvarchar)tdsvarchar
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/a00447.html100664 001750 000144 00000011072 11623073556 0015606 FreeTDS API: Member List

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
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/annotated.html100664 001750 000144 00000050046 11623073550 0016742 FreeTDS API: Class List

Class List

Here are the classes, structs, unions and interfaces with brief descriptions:
_character_set_alias
_cs_blkdesc
_cs_clientmsg
_cs_command
_cs_command_list
_cs_config
_cs_connection
_cs_context
_cs_datafmt
_cs_daterec
_cs_datetime
_cs_datetime4
_cs_dynamic
_cs_iodesc
_cs_locale
_cs_money
_cs_money4
_cs_numeric
_cs_objdata
_cs_objname
_cs_param
_cs_servermsg
_cs_varbinary
_cs_varchar
_csremote_proc
_ct_colinfo
_dblib_error_message
_DBREMOTE_PROC
_DBREMOTE_PROC_PARAM
_dheader
_drecord
_hcattr
_hchk
_hdbc
_hdesc
_heattr
_henv
_hsattr
_hstmt
_null_representation
_options
_procedure
_sql_error
_sql_errors
BCP_HOSTCOLINFO
BCP_HOSTFILEINFO
conv_result::cb_t
conv_result::cc_t
conv_result
cs_diag_msg
cs_diag_msg_client
cs_diag_msg_svr
DATA
DBCOL
DBDATETIME
DBDATETIME4
dblib_buffer_row
dblib_context
DBMONEY
DBMONEY4
DBNUMERIC
dboption
dbstring
dbtypeinfo
DBVARYBIN
DBVARYCHAR
des_key
DSNINFO
func_info
LOGINREC
MD4Context
MD5Context
METADATA
namelist
names_blob_prefix_t
native_info
pd
pollfd
ProfileParam
ptw32_mcs_node_t_
s_SqlMsgMap
s_v3to2map
string_linked_list
tag_DBPROC_ROWBUF
TDS8_COLLATIONTDS 8.0 collation informations
tds_align_struct
tds_answer
tds_authentication
tds_bcpcoldata
tds_bcpinfo
tds_blobInformation about blobs (e.g
tds_columnMetadata about columns in regular and compute rows
tds_compiletime_settingsA structure to hold all the compile-time settings
tds_connection
tds_context
tds_cursorHolds informations about a cursor
tds_cursor_status
tds_dblib_dbprocess
tds_dblib_loginrec
tds_dstr
tds_dynamicHolds information for a dynamic (also called prepared) query
tds_encodingInformation relevant to libiconv
tds_envCurrent environment as reported by the server
tds_errno_message_flags
tds_error_message
tds_locale
tds_login
tds_message
tds_microsoft_dbdaterec
tds_multiple
tds_ntlm_auth
tds_option_arg
TDS_PARSED_PARAM
tds_pbcb
tds_pool
tds_pool_member
tds_pool_user
tds_result_infoHold information for any results
tds_save_context
tds_save_env
tds_save_msg
tds_socketInformation for a server connection
tds_sybase_dbdaterec
tds_time
tds_upd_col
tds_variantStore variant informations
tdsdaterecUsed by tds_datecrack
tdsdatetime
tdsdatetime4
tdsiconvinfo
tdsmoney
tdsmoney4
tdsnumeric
tdsoldmoney
tdsunique
tdsvarbinary
tdsvarchar
tmp_col_struct
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/classes.html100664 001750 000144 00000042667 11623073550 0016434 FreeTDS API: Alphabetical List

Class Index

B | C | D | F | L | M | N | P | S | T | _
  B  
LOGINREC   tds_context   tds_upd_col   _cs_money   
BCP_HOSTCOLINFO   
  M  
tds_cursor   tds_variant   _cs_money4   
BCP_HOSTFILEINFO   MD4Context   tds_cursor_status   tdsdaterec   _cs_numeric   
  C  
MD5Context   tds_dblib_dbprocess   tdsdatetime   _cs_objdata   
conv_result::cb_t   METADATA   tds_dblib_loginrec   tdsdatetime4   _cs_objname   
conv_result::cc_t   
  N  
tds_dstr   tdsiconvinfo   _cs_param   
conv_result   namelist   tds_dynamic   tdsmoney   _cs_servermsg   
cs_diag_msg   names_blob_prefix_t   tds_encoding   tdsmoney4   _cs_varbinary   
cs_diag_msg_client   native_info   tds_env   tdsnumeric   _cs_varchar   
cs_diag_msg_svr   
  P  
tds_errno_message_flags   tdsoldmoney   _csremote_proc   
  D  
pd   tds_error_message   tdsunique   _ct_colinfo   
DATA   pollfd   tds_locale   tdsvarbinary   _dblib_error_message   
DBCOL   ProfileParam   tds_login   tdsvarchar   _DBREMOTE_PROC   
DBDATETIME   ptw32_mcs_node_t_   tds_message   tmp_col_struct   _DBREMOTE_PROC_PARAM   
DBDATETIME4   
  S  
tds_microsoft_dbdaterec   
  _  
_dheader   
dblib_buffer_row   s_SqlMsgMap   tds_multiple   _character_set_alias   _drecord   
dblib_context   s_v3to2map   tds_ntlm_auth   _cs_blkdesc   _hcattr   
DBMONEY   string_linked_list   tds_option_arg   _cs_clientmsg   _hchk   
DBMONEY4   
  T  
TDS_PARSED_PARAM   _cs_command   _hdbc   
DBNUMERIC   tag_DBPROC_ROWBUF   tds_pbcb   _cs_command_list   _hdesc   
dboption   TDS8_COLLATION   tds_pool   _cs_config   _heattr   
dbstring   tds_align_struct   tds_pool_member   _cs_connection   _henv   
dbtypeinfo   tds_answer   tds_pool_user   _cs_context   _hsattr   
DBVARYBIN   tds_authentication   tds_result_info   _cs_datafmt   _hstmt   
DBVARYCHAR   tds_bcpcoldata   tds_save_context   _cs_daterec   _null_representation   
des_key   tds_bcpinfo   tds_save_env   _cs_datetime   _options   
DSNINFO   tds_blob   tds_save_msg   _cs_datetime4   _procedure   
  F  
tds_column   tds_socket   _cs_dynamic   _sql_error   
func_info   tds_compiletime_settings   tds_sybase_dbdaterec   _cs_iodesc   _sql_errors   
  L  
tds_connection   tds_time   _cs_locale   
B | C | D | F | L | M | N | P | S | T | _
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/doxygen.css100664 001750 000144 00000017347 11623073545 0016301/* The standard CSS for doxygen */ body, table, div, p, dl { font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; font-size: 12px; } /* @group Heading Levels */ h1 { text-align: center; font-size: 150%; } h2 { font-size: 120%; } h3 { font-size: 100%; } 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, p.starttd { margin-top: 2px; } 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: #e8eef2; border: 1px solid #84b0c7; text-align: center; margin: 2px; padding: 2px; } div.qindex, div.navpath { width: 100%; line-height: 140%; } div.navtab { margin-right: 15px; } /* @group Link Styling */ a { color: #153788; font-weight: normal; text-decoration: none; } .contents a:visited { color: #1b77c5; } a:hover { text-decoration: underline; } a.qindex { font-weight: bold; } a.qindexHL { font-weight: bold; background-color: #6666cc; color: #ffffff; border: 1px double #9295C2; } .contents a.qindexHL:visited { color: #ffffff; } a.el { font-weight: bold; } a.elRef { } a.code { color: #3030f0; } a.codeRef { color: #3030f0; } /* @end */ dl.el { margin-left: -1cm; } .fragment { font-family: monospace, fixed; font-size: 105%; } pre.fragment { border: 1px solid #CCCCCC; background-color: #f5f5f5; padding: 4px 6px; margin: 4px 8px 4px 2px; overflow: auto; word-wrap: break-word; font-size: 9pt; line-height: 125%; } div.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } div.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold; } div.groupText { margin-left: 16px; font-style: italic; } body { background: white; color: black; margin-right: 20px; margin-left: 20px; } td.indexkey { background-color: #e8eef2; font-weight: bold; border: 1px solid #CCCCCC; margin: 2px 0px 2px 0; padding: 2px 10px; } td.indexvalue { background-color: #e8eef2; border: 1px solid #CCCCCC; padding: 2px 10px; margin: 2px 0px; } tr.memlist { background-color: #f0f0f0; } 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; } 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 } /* @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 #84b0c7; } th.dirtab { background: #e8eef2; font-weight: bold; } hr { height: 0px; border: none; border-top: 1px solid #666; } hr.footer { height: 1px; } /* @group Member Descriptions */ .mdescLeft, .mdescRight, .memItemLeft, .memItemRight, .memTemplItemLeft, .memTemplItemRight, .memTemplParams { background-color: #FAFAFA; border: none; margin: 4px; padding: 1px 0 0 8px; } .mdescLeft, .mdescRight { padding: 0px 8px 4px 8px; color: #555; } .memItemLeft, .memItemRight, .memTemplParams { border-top: 1px solid #ccc; } .memItemLeft, .memTemplItemLeft { white-space: nowrap; } .memTemplParams { color: #606060; white-space: nowrap; } /* @end */ /* @group Member Details */ /* Styles for detailed member documentation */ .memtemplate { font-size: 80%; color: #606060; font-weight: normal; margin-left: 3px; } .memnav { background-color: #e8eef2; border: 1px solid #84b0c7; text-align: center; margin: 2px; margin-right: 15px; padding: 2px; } .memitem { padding: 0; margin-bottom: 10px; } .memname { white-space: nowrap; font-weight: bold; margin-left: 6px; } .memproto { border-top: 1px solid #84b0c7; border-left: 1px solid #84b0c7; border-right: 1px solid #84b0c7; padding: 0; background-color: #d5e1e8; font-weight: bold; /* firefox specific markup */ background-image: -moz-linear-gradient(rgba(228, 233, 245, 1.0) 0%, rgba(193, 205, 232, 1.0) 100%); -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; -moz-border-radius-topright: 8px; -moz-border-radius-topleft: 8px; /* webkit specific markup */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(228, 233, 245, 1.0)), to(rgba(193, 205, 232, 1.0))); -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); -webkit-border-top-right-radius: 8px; -webkit-border-top-left-radius: 8px; } .memdoc { border-bottom: 1px solid #84b0c7; border-left: 1px solid #84b0c7; border-right: 1px solid #84b0c7; padding: 2px 5px; background-color: #eef3f5; border-top-width: 0; /* firefox specific markup */ -moz-border-radius-bottomleft: 8px; -moz-border-radius-bottomright: 8px; -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; /* webkit specific markup */ -webkit-border-bottom-left-radius: 8px; -webkit-border-bottom-right-radius: 8px; -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); } .paramkey { text-align: right; } .paramtype { white-space: nowrap; } .paramname { color: #602020; white-space: nowrap; } .paramname em { font-style: normal; } /* @end */ /* @group Directory (tree) */ /* for the tree view */ .ftvtree { font-family: sans-serif; margin: 0.5em; } /* these are for tree view when used as main index */ .directory { font-size: 9pt; font-weight: bold; } .directory h3 { margin: 0px; margin-top: 1em; font-size: 11pt; } /* The following two styles can be used to replace the root node title with an image of your choice. Simply uncomment the next two styles, specify the name of your image and be sure to set 'height' to the proper pixel height of your image. */ /* .directory h3.swap { height: 61px; background-repeat: no-repeat; background-image: url("yourimage.gif"); } .directory h3.swap span { display: none; } */ .directory > h3 { margin-top: 0; } .directory p { margin: 0px; white-space: nowrap; } .directory div { display: none; margin: 0px; } .directory img { vertical-align: -30%; } /* these are for tree view when not used as main index */ .directory-alt { font-size: 100%; font-weight: bold; } .directory-alt h3 { margin: 0px; margin-top: 1em; font-size: 11pt; } .directory-alt > h3 { margin-top: 0; } .directory-alt p { margin: 0px; white-space: nowrap; } .directory-alt div { display: none; margin: 0px; } .directory-alt img { vertical-align: -30%; } /* @end */ address { font-style: normal; color: #333; } table.doxtable { border-collapse:collapse; } table.doxtable td, table.doxtable th { border: 1px solid #153788; padding: 3px 7px 2px; } table.doxtable th { background-color: #254798; color: #FFFFFF; font-size: 110%; padding-bottom: 4px; padding-top: 5px; text-align:left; } freetds-0.91/doc/doc/freetds-0.91/reference/doxygen.png100664 001750 000144 00000002401 11623073545 0016256‰PNG  IHDRd-ok>ÂgAMAÖØÔOX2tEXtSoftwareAdobe ImageReadyqÉe<]PLTEǾÏ"&©ÈÎï¶»ÖÓÚú“¢Þ ¬à¶Âõ‡§ÕÙêÉÊÎáâæ{ŽÔ¡ëˆ™× ²ø§¬¹ÀÀ±ÝÝÎùùéõõçëëåED9×ÖËhg]_X<@:#mhUÿÿÿÝÀ1tRNSÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÍvÿIDATxÚbC£: d#„„………h` @¡X",***LKˆ.–], ºX@t± €èb @ÑÅ€BµD„6–š%""´° € ˜% ˆ™B:H¢ˆ²Áf@• ˆRPy"K`\PbC(!II!h©…ëƒ(ñ„Ä!ꈬC„Ä…àl!0[X\J\$TMˆ(’>a$S„ Ù@ Ш@R.$‚¬LJBR¢‰AÌG1 ¬ Â(FȃÔPhhÁTÀ¢„%!`€&q°%u P ¹¢ ¬ € ¹CT$B¢à|‚ºW„¤Àl £!B`R$( …Ĉ‘’ž@AÅ%ĤÄ%@,(—ʂڱ%$ÁââRPmB U`1IˆYB  99€\1 yCCCÿf"[N 'Ü=TGÈ’øl8˜^Kû5<êSæRɤ”%î@@ à›Ê b1 qÅAXHˆ¸&ØB’R y n˜P„Ìã–4A €€j¹€€>Ü ˜ t!˜+(.ÈÅWQ±A2ÜÜMUÜ‚’’‚‚â `1 %`19€F< 3cZÄ`óe!\ˆ DÈ+. 83‹³Àä¸!lYYA -6‚EJŠ¢V €@©žXXX 4„å Ê@86Ð`RdB´€4I "Ý "–@xrÊŒ‚H€AÊ`—f ÉȰCŒ"XV0ɲ³C b@2…¬H ¬È“ p)!(ì‚ 0Ž4ˆ)(%RÁÎ ¶$€TÊ€¥Àþb‡b,säÐ@7À üѰ‚Òî?f¥Ö—\PIx!I´¦"”Ȉ’3¨ QY˜ÿt^^ÛØgv- }>WJOAV`$&#”¦8ùøø8€\FF ›SFJ$ÂÆ€ÐƊС䈉ÀÀ 4ª…Èäå -Á§‡ €H²…—ŸŸŸf ?ðâ5„ €k1Âd‰,ŒÃ ³ƒ“€.€"­F™ËË€àñ‚½ÁIÈ€"±Ù4ÉH gx|‚f©m)))9´. aMDƒ& ºX@t± €èb @ÑÅ€¢‹%DKˆ.–], ºX@t± €èb @€d`‚ɽSµOIEND®B`‚freetds-0.91/doc/doc/freetds-0.91/reference/files.html100664 001750 000144 00000031434 11623073556 0016075 FreeTDS API: File Index

File List

Here is a list of all documented files with brief descriptions:
/home/jklowden/releases/freetds-0.91/include/bkpublic.h [code]
/home/jklowden/releases/freetds-0.91/include/cspublic.h [code]
/home/jklowden/releases/freetds-0.91/include/cstypes.h [code]
/home/jklowden/releases/freetds-0.91/include/ctlib.h [code]
/home/jklowden/releases/freetds-0.91/include/ctpublic.h [code]
/home/jklowden/releases/freetds-0.91/include/dblib.h [code]
/home/jklowden/releases/freetds-0.91/include/des.h [code]
/home/jklowden/releases/freetds-0.91/include/fakepoll.h [code]
/home/jklowden/releases/freetds-0.91/include/hmac_md5.h [code]
/home/jklowden/releases/freetds-0.91/include/md4.h [code]
/home/jklowden/releases/freetds-0.91/include/md5.h [code]
/home/jklowden/releases/freetds-0.91/include/odbcss.h [code]
/home/jklowden/releases/freetds-0.91/include/replacements.h [code]
/home/jklowden/releases/freetds-0.91/include/sqldb.h [code]
/home/jklowden/releases/freetds-0.91/include/sqlfront.h [code]
/home/jklowden/releases/freetds-0.91/include/sybdb.dox.h [code]
/home/jklowden/releases/freetds-0.91/include/sybdb.h [code]Primary include file for db-lib applications
/home/jklowden/releases/freetds-0.91/include/syberror.h [code]
/home/jklowden/releases/freetds-0.91/include/sybfront.h [code]
/home/jklowden/releases/freetds-0.91/include/tds.h [code]Main include file for libtds
/home/jklowden/releases/freetds-0.91/include/tds_configs.h [code]
/home/jklowden/releases/freetds-0.91/include/tds_sysdep_private.h [code]
/home/jklowden/releases/freetds-0.91/include/tdsbytes.h [code]
/home/jklowden/releases/freetds-0.91/include/tdsconvert.h [code]
/home/jklowden/releases/freetds-0.91/include/tdsiconv.h [code]
/home/jklowden/releases/freetds-0.91/include/tdsodbc.h [code]
/home/jklowden/releases/freetds-0.91/include/tdssrv.h [code]
/home/jklowden/releases/freetds-0.91/include/tdsstring.h [code]
/home/jklowden/releases/freetds-0.91/include/tdsthread.h [code]
/home/jklowden/releases/freetds-0.91/include/replacements/readpassphrase.h [code]
/home/jklowden/releases/freetds-0.91/src/apps/freebcp.h [code]
/home/jklowden/releases/freetds-0.91/src/apps/fisql/edit.h [code]
/home/jklowden/releases/freetds-0.91/src/apps/fisql/handlers.h [code]
/home/jklowden/releases/freetds-0.91/src/apps/fisql/interrupt.h [code]
/home/jklowden/releases/freetds-0.91/src/apps/fisql/terminal.h [code]
/home/jklowden/releases/freetds-0.91/src/dblib/bcp.cImplementation of db-lib bulk copy functions
/home/jklowden/releases/freetds-0.91/src/dblib/buffering.h [code]
/home/jklowden/releases/freetds-0.91/src/dblib/dblib.cMain implementation file for db-lib
/home/jklowden/releases/freetds-0.91/src/dblib/error_table.h [code]
/home/jklowden/releases/freetds-0.91/src/odbc/sqlwparams.h [code]
/home/jklowden/releases/freetds-0.91/src/pool/pool.h [code]
/home/jklowden/releases/freetds-0.91/src/tds/alternative_character_sets.h [code]
/home/jklowden/releases/freetds-0.91/src/tds/character_sets.h [code]
/home/jklowden/releases/freetds-0.91/src/tds/enum_cap.h [code]
/home/jklowden/releases/freetds-0.91/src/tds/sybase_character_sets.h [code]
/home/jklowden/releases/freetds-0.91/src/tds/tds_checks.h [code]
/home/jklowden/releases/freetds-0.91/vms/vargdefs.h [code]
/home/jklowden/releases/freetds-0.91/win32/config.h [code]
/home/jklowden/releases/freetds-0.91/win32/freetds_sysconfdir.h [code]
/home/jklowden/releases/freetds-0.91/win32/resource.h [code]
/home/jklowden/releases/freetds-0.91/win32/tds_sysdep_public.h [code]
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/functions.html100664 001750 000144 00000040604 11623073550 0016774 FreeTDS API: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- b -

- c -

- d -

- e -

- h -

- i -

- l -

- m -

- n -

- o -

- p -

- q -

- r -

- s -

- t -

- u -

- w -

- y -

Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/functions_vars.html100664 001750 000144 00000040461 11623073550 0020030 FreeTDS API: Class Members - Variables
 

- b -

- c -

- d -

- e -

- h -

- i -

- l -

- m -

- n -

- o -

- p -

- q -

- r -

- s -

- t -

- u -

- w -

- y -

Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals.html100664 001750 000144 00000014423 11623073556 0016415 FreeTDS API: Class Members
Here is a list of all documented file members with links to the documentation:

- _ -

  • _bcp_exec_in() : bcp.c
  • _bcp_exec_out() : bcp.c
  • _bcp_fgets() : bcp.c
  • _bcp_free_columns() : bcp.c
  • _bcp_free_storage() : bcp.c
  • _bcp_get_col_data() : bcp.c
  • _bcp_get_term_var() : bcp.c
  • _bcp_measure_terminated_field() : bcp.c
  • _bcp_read_hostfile() : bcp.c
  • _bcp_readfmt_colinfo() : bcp.c
  • _TDS_STATE : tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_0x62.html100664 001750 000144 00000017634 11623073556 0017203 FreeTDS API: Class Members
Here is a list of all documented file members with links to the documentation:

- b -

Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_0x64.html100664 001750 000144 00000101270 11623073556 0017173 FreeTDS API: Class Members
Here is a list of all documented file members with links to the documentation:

- d -

Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_0x72.html100664 001750 000144 00000012305 11623073556 0017172 FreeTDS API: Class Members
Here is a list of all documented file members with links to the documentation:

- r -

Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_0x74.html100664 001750 000144 00000041157 11623073556 0017203 FreeTDS API: Class Members
Here is a list of all documented file members with links to the documentation:

- t -

  • tds7_crypt_pass() : tds.h
  • tds7_get_instance_port() : tds.h
  • tds7_get_instance_ports() : tds.h
  • tds8_submit_prepexec() : tds.h
  • tds_alloc_connection() : tds.h
  • tds_alloc_dynamic() : tds.h
  • tds_alloc_param_data() : tds.h
  • tds_alloc_param_result() : tds.h
  • tds_alloc_row() : tds.h
  • tds_bcp_directions : tds.h
  • tds_bcp_send_record() : tds.h
  • TDS_COMPILETIME_SETTINGS : tds.h
  • tds_config_verstr() : tds.h
  • tds_count_placeholders() : tds.h
  • tds_cursor_dealloc() : tds.h
  • tds_datecrack() : tds.h
  • TDS_DEAD : tds.h
  • TDS_DONE_CANCELLED : tds.h
  • TDS_DONE_COUNT : tds.h
  • TDS_DONE_ERROR : tds.h
  • TDS_DONE_FINAL : tds.h
  • TDS_DONE_INXACT : tds.h
  • TDS_DONE_MORE_RESULTS : tds.h
  • TDS_DONE_PROC : tds.h
  • TDS_DONE_SRVERROR : tds.h
  • TDS_ENCODING : tds.h
  • tds_end : tds.h
  • tds_fix_connection() : tds.h
  • tds_flush_packet() : tds.h
  • tds_free_dynamic() : tds.h
  • tds_free_input_params() : tds.h
  • tds_free_param_result() : tds.h
  • tds_get_char_data() : tds.h
  • tds_get_compiletime_settings() : tds.h
  • tds_get_homedir() : tds.h
  • tds_get_int() : tds.h
  • tds_get_locale() : tds.h
  • tds_get_n() : tds.h
  • tds_get_smallint() : tds.h
  • tds_get_string() : tds.h
  • tds_get_token_size() : tds.h
  • tds_iconv_alloc() : tds.h
  • tds_iconv_from_collate() : tds.h
  • TDS_IDLE : tds.h
  • TDS_IS_MSSQL : tds.h
  • TDS_IS_SYBASE : tds.h
  • tds_lookup_dynamic() : tds.h
  • tds_lookup_host() : tds.h
  • TDS_MS_VER : tds.h
  • tds_next_placeholder() : tds.h
  • tds_ntlm_get_auth() : tds.h
  • tds_numeric_bytes_per_prec : tds.h
  • TDS_OPTION_CMD : tds.h
  • TDS_PENDING : tds.h
  • tds_process_cancel() : tds.h
  • tds_process_login_tokens() : tds.h
  • tds_process_simple_query() : tds.h
  • tds_process_tokens() : tds.h
  • tds_put_string() : tds.h
  • tds_put_tinyint : tds.h
  • TDS_QUERYING : tds.h
  • tds_quote_id() : tds.h
  • tds_quote_string() : tds.h
  • TDS_RCSID() : dblib.c
  • tds_read_conf_file() : tds.h
  • tds_read_conf_section() : tds.h
  • tds_read_config_info() : tds.h
  • tds_read_packet() : tds.h
  • TDS_READING : tds.h
  • tds_send_cancel() : tds.h
  • tds_set_column_type() : tds.h
  • tds_set_interfaces_file_loc() : tds.h
  • tds_set_param_type() : tds.h
  • tds_set_server() : tds.h
  • tds_set_state() : tds.h
  • tds_skip_quoted() : tds.h
  • TDS_STATE : tds.h
  • tds_submit_execdirect() : tds.h
  • tds_submit_execute() : tds.h
  • tds_submit_prepare() : tds.h
  • tds_submit_query() : tds.h
  • tds_submit_query_params() : tds.h
  • tds_submit_rpc() : tds.h
  • tds_submit_unprepare() : tds.h
  • TDS_SYB_VER : tds.h
  • tds_timestamp_str() : tds.h
  • tds_unget_byte() : tds.h
  • tds_version() : tds.h
  • TDSBLOB : tds.h
  • TDSCOLUMN : tds.h
  • TDSCURSOR : tds.h
  • TDSDATEREC : tds.h
  • tdsdbopen() : dblib.c , sybdb.h
  • tdsdump_close() : tds.h
  • tdsdump_col() : tds.h
  • tdsdump_dump_buf() : tds.h
  • tdsdump_log() : tds.h
  • tdsdump_off() : tds.h
  • tdsdump_on() : tds.h
  • tdsdump_open() : tds.h
  • TDSDYNAMIC : tds.h
  • TDSENV : tds.h
  • tdserror() : tds.h
  • TDSRESULTINFO : tds.h
  • TDSVARIANT : tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_defs.html100664 001750 000144 00000020566 11623073556 0017423 FreeTDS API: Class Members
 

- b -

- d -

- t -

Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_enum.html100664 001750 000144 00000011747 11623073556 0017447 FreeTDS API: Class Members
 
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_eval.html100664 001750 000144 00000014475 11623073556 0017433 FreeTDS API: Class Members
 
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_func.html100664 001750 000144 00000014200 11623073556 0017421 FreeTDS API: Class Members
 

- _ -

  • _bcp_exec_in() : bcp.c
  • _bcp_exec_out() : bcp.c
  • _bcp_fgets() : bcp.c
  • _bcp_free_columns() : bcp.c
  • _bcp_free_storage() : bcp.c
  • _bcp_get_col_data() : bcp.c
  • _bcp_get_term_var() : bcp.c
  • _bcp_measure_terminated_field() : bcp.c
  • _bcp_read_hostfile() : bcp.c
  • _bcp_readfmt_colinfo() : bcp.c
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_func_0x62.html100664 001750 000144 00000017410 11623073556 0020206 FreeTDS API: Class Members
 

- b -

Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_func_0x64.html100664 001750 000144 00000073132 11623073556 0020213 FreeTDS API: Class Members
 

- d -

Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_func_0x72.html100664 001750 000144 00000012226 11623073556 0020207 FreeTDS API: Class Members
 

- r -

Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_func_0x74.html100664 001750 000144 00000031524 11623073556 0020213 FreeTDS API: Class Members
 

- t -

  • tds7_crypt_pass() : tds.h
  • tds7_get_instance_port() : tds.h
  • tds7_get_instance_ports() : tds.h
  • tds8_submit_prepexec() : tds.h
  • tds_alloc_connection() : tds.h
  • tds_alloc_dynamic() : tds.h
  • tds_alloc_param_data() : tds.h
  • tds_alloc_param_result() : tds.h
  • tds_alloc_row() : tds.h
  • tds_bcp_send_record() : tds.h
  • tds_config_verstr() : tds.h
  • tds_count_placeholders() : tds.h
  • tds_cursor_dealloc() : tds.h
  • tds_datecrack() : tds.h
  • tds_fix_connection() : tds.h
  • tds_flush_packet() : tds.h
  • tds_free_dynamic() : tds.h
  • tds_free_input_params() : tds.h
  • tds_free_param_result() : tds.h
  • tds_get_char_data() : tds.h
  • tds_get_compiletime_settings() : tds.h
  • tds_get_homedir() : tds.h
  • tds_get_int() : tds.h
  • tds_get_locale() : tds.h
  • tds_get_n() : tds.h
  • tds_get_smallint() : tds.h
  • tds_get_string() : tds.h
  • tds_get_token_size() : tds.h
  • tds_iconv_alloc() : tds.h
  • tds_iconv_from_collate() : tds.h
  • tds_lookup_dynamic() : tds.h
  • tds_lookup_host() : tds.h
  • tds_next_placeholder() : tds.h
  • tds_ntlm_get_auth() : tds.h
  • tds_process_cancel() : tds.h
  • tds_process_login_tokens() : tds.h
  • tds_process_simple_query() : tds.h
  • tds_process_tokens() : tds.h
  • tds_put_string() : tds.h
  • tds_quote_id() : tds.h
  • tds_quote_string() : tds.h
  • TDS_RCSID() : dblib.c
  • tds_read_conf_file() : tds.h
  • tds_read_conf_section() : tds.h
  • tds_read_config_info() : tds.h
  • tds_read_packet() : tds.h
  • tds_send_cancel() : tds.h
  • tds_set_column_type() : tds.h
  • tds_set_interfaces_file_loc() : tds.h
  • tds_set_param_type() : tds.h
  • tds_set_server() : tds.h
  • tds_set_state() : tds.h
  • tds_skip_quoted() : tds.h
  • tds_submit_execdirect() : tds.h
  • tds_submit_execute() : tds.h
  • tds_submit_prepare() : tds.h
  • tds_submit_query() : tds.h
  • tds_submit_query_params() : tds.h
  • tds_submit_rpc() : tds.h
  • tds_submit_unprepare() : tds.h
  • tds_timestamp_str() : tds.h
  • tds_unget_byte() : tds.h
  • tds_version() : tds.h
  • tdsdbopen() : dblib.c , sybdb.h
  • tdsdump_close() : tds.h
  • tdsdump_col() : tds.h
  • tdsdump_dump_buf() : tds.h
  • tdsdump_log() : tds.h
  • tdsdump_off() : tds.h
  • tdsdump_on() : tds.h
  • tdsdump_open() : tds.h
  • tdserror() : tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/index.html100664 001750 000144 00000012731 11623073546 0016100 FreeTDS API: FreeTDS Reference Manual

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.

Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/installdox100775 001750 000144 00000005025 11623073550 0016203#!/usr/bin/perl %subst = ( ); $quiet = 0; if (open(F,"search.cfg")) { $_= ; s/[ \t\n]*$//g ; $subst{"_doc"} = $_; $_= ; s/[ \t\n]*$//g ; $subst{"_cgi"} = $_; } while ( @ARGV ) { $_ = shift @ARGV; if ( s/^-// ) { if ( /^l(.*)/ ) { $v = ($1 eq "") ? shift @ARGV : $1; ($v =~ /\/$/) || ($v .= "/"); $_ = $v; if ( /(.+)\@(.+)/ ) { if ( exists $subst{$1} ) { $subst{$1} = $2; } else { print STDERR "Unknown tag file $1 given with option -l\n"; &usage(); } } else { print STDERR "Argument $_ is invalid for option -l\n"; &usage(); } } elsif ( /^q/ ) { $quiet = 1; } elsif ( /^\?|^h/ ) { &usage(); } else { print STDERR "Illegal option -$_\n"; &usage(); } } else { push (@files, $_ ); } } foreach $sub (keys %subst) { if ( $subst{$sub} eq "" ) { print STDERR "No substitute given for tag file `$sub'\n"; &usage(); } elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" ) { print "Substituting $subst{$sub} for each occurence of tag file $sub\n"; } } if ( ! @files ) { if (opendir(D,".")) { foreach $file ( readdir(D) ) { $match = ".html"; next if ( $file =~ /^\.\.?$/ ); ($file =~ /$match/) && (push @files, $file); ($file =~ "tree.js") && (push @files, $file); } closedir(D); } } if ( ! @files ) { print STDERR "Warning: No input files given and none found!\n"; } foreach $f (@files) { if ( ! $quiet ) { print "Editing: $f...\n"; } $oldf = $f; $f .= ".bak"; unless (rename $oldf,$f) { print STDERR "Error: cannot rename file $oldf\n"; exit 1; } if (open(F,"<$f")) { unless (open(G,">$oldf")) { print STDERR "Error: opening file $oldf for writing\n"; exit 1; } if ($oldf ne "tree.js") { while () { s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g; print G "$_"; } } else { while () { s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g; print G "$_"; } } } else { print STDERR "Warning file $f does not exist\n"; } unlink $f; } sub usage { print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n"; print STDERR "Options:\n"; print STDERR " -l tagfile\@linkName tag file + URL or directory \n"; print STDERR " -q Quiet mode\n\n"; exit 1; } freetds-0.91/doc/doc/freetds-0.91/reference/globals_type.html100664 001750 000144 00000013573 11623073556 0017463 FreeTDS API: Class Members
 
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/globals_vars.html100664 001750 000144 00000011302 11623073556 0017441 FreeTDS API: Class Members
 
  • tds_numeric_bytes_per_prec : tds.h
Generated on Wed Aug 17 22:22:38 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/modules.html100664 001750 000144 00000012314 11623073550 0016431 FreeTDS API: Module Index
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/pages.html100664 001750 000144 00000010017 11623073546 0016063 FreeTDS API: Page Index

Related Pages

Here is a list of all related documentation pages:
Generated on Wed Aug 17 22:22:30 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/tab_b.gif100664 001750 000144 00000000043 11623073545 0015631GIF89a€„°Ç,D;freetds-0.91/doc/doc/freetds-0.91/reference/tab_l.gif100664 001750 000144 00000001302 11623073545 0015642GIF89a ,Õö÷ùñô÷öøúüýþúûüùúûøùúêïóïóöÆÕßÒÞæØâéÞçíÝæìåìñèîòô÷ùóöø³ÈÕÁÒÝËÙâÏÜäÖá薴ŹɯÂÍ»ÎÙÃÔÞÂÓÝÈ×àÌÚâÕáèÙäê×âèåìðëðó„°ÇÑÞåÜæëãëïëñôîóõ÷úûûüüÿÿÿþþþ, ,ÿ@–P±É`H$!%CqVe2X­ŠÌJ(“Ä +€˜3 2$ÀÆ ¼kvŠä-Ëçõu*…"}ã|}|~q(" $f„ 'Žl(Œ&&$r‘™ › & ! )¢¤›{¨£¥r­ª°©¯„±¯¬´¦·»º³®«§¾¶ÃÂÀ¿²¹ÇÄËÆ²ÌÉεҽͼ„ÔÈÓ×иÙÝÕÏÙÊâÜßãçæê¾äÛÅëÇíáîÖìéïøñ÷õüÑðåùü¤Pß?‚ƒœÇÛBm åAœÎáÀ†%V܈î!Çk÷Ø/áÄ;^¤¨²$Æ–#Mf)f͇(WÎL‰“æKçÒ„° ’I)L:eD ¡Cµ´x*4 U¨h  %A«£^ÁNKb¬Ùe§X±‚´k»x!ÁÖí—2tÝÖ !¯š5tÛæé—À]$¬´%ƒXíâ.i[¬]Y­•ÊfžEëõkg`µ††:zëçÒž;£}ºµj×aa‹–Mš¶é׸cçž½»vïÛºƒóî›8ðáÈ‹'?®¼9óç©G_>Ýyuè¬_ßž]zwêß­‡Ç¾º¼mîæµG~½ûôÞთ/ž>ùööÙ«Ïÿ¿ÿýÿÅà|ÖWà}v;freetds-0.91/doc/doc/freetds-0.91/reference/tab_r.gif100664 001750 000144 00000005031 11623073545 0015653GIF89a,Õö÷ùñô÷öøúüýþúûüùúûøùúêïóïóöÆÕßÒÞæØâéÞçíÝæìåìñèîòô÷ùóöø³ÈÕÁÒÝËÙâÏÜäÖá薴ŹɯÂÍ»ÎÙÃÔÞÂÓÝÈ×àÌÚâÕáèÙäê×âèåìðëðó„°ÇÑÞåÜæëãëïëñôîóõ÷úûûüüÿÿÿþþþ,,ÿ@’pH,ȤrÉl:ŸÐ¨tJ­Z¯Ø¬v •h<¬pkL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~ÏwVa+‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ “*)^,*ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂö)'ÆÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæÚ¥(" ðñòóôõö÷øùúûüýþÿ H° ÁƒòK"ƒRHœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\éÅu&@€ Á²¦Í›8sêÜɳ§Oÿ–(±€DУH“*]Ê´©Ó§P£JJµªÕ«X³jÝʵ«×¯S84± ‰hÓª]˶­Û·pãÊK·®Ý»xóêÝË·¯ß¿€Ó} âDÌf(^̸±ãÇ#KžL¹²å˘3kÞ̹³çÏ C‹m¹ðCÄHœXͺµë×°cËžM»¶íÛ¸sëÞÍ»·ïßÀƒ N÷ÃJ” Á®¹óçУKŸN½ºõëØ³kßν»÷ïàËO¾úñ€ dÇ@€‚‚L¤"ÉÈF:ò‘Œ¤$9† (8…&ÉÉNzò“  ¥(G©FB^²!˨)WÉÊVºò•°l¤)1™ wÄò–¸Ì¥.wÊYºäƒà¥0‡IÌbó¾|ÉHpÌf:ó™Ðìe pJ±ˆ€}Ȧ6·ÉÍnzó›à §8û0Â%"¸æ8×ÉÎvºóðŒ§<ÉPÎQ`ò%×$€>÷ÉÏ~úóŸ ¨@JЂô M¨BÊІ:ô¡¨D'ZPKF Ö¼&16ÊÑŽzô£ ©HGJRb ÷Lç5ÏÁÒ–ºô¥ÿ0©LgJÓšš#(e>¯‰Óžúô§@ ªP‡JÔ¢õ¨HMªR—ÊÔ¦:õ©PªT§JÕª&5;%U·ÊÕ®zõ«` «XÇJV«ÂC§‹ÑjY×ÊÖ¶ºõ­p«\ŠU´À¦xÍ«^÷Ê×¾úõ¯ÐÀi)$‚”ô°ˆM¬bËØÆ:vˆ, ಘͬf7ËÙÎzö³  ­hGKÚÒšö´¨M­jWËÚÖºöµ°­*$ÛSPô¶¸Í­nwËÛÞúö·ÀÅm +„â¸ÈM®r—ËÜæ:÷¹ÐE®?±9ÏêZ÷ºØÍ®v¿9€î"‚ºÛ ¯xÇKÞòb—™ÑLÿ¯z×Ë^A¢·½ð¯|ç†÷Ò÷¾øÍ¯0í«ßþú÷¿¡ä/€Là»×ÀN°‚ï(à;øÁ n0„'LaýJ¸ÂÎ0{/¬á{ؘþ°ˆG|Ë“øÄ(¥‰SÌâCrÅ.ޱŒ ãÛøÆv¬1ŽwÌc6ê¸Ç@ÞñƒLd¹ÈHNñ‘“Ìd/¹ÉPÎð“£LeO¹ÊXŽp–·|â+sùËýõ2˜ÇL_1“ùÌí53š×M5³ùÍÇt3œç¼_:ÛÙÂwÎs™õÌgøÊ¹Ï€p ýÌ?úÐ/F´¢ë¼èFãÒÐŽŽt!-éJã‘Ò–Îô1­éN»‘ÓžuÿA-êP“ºÔ>5ª3­êUWºÕ®Ž4¬cÝèYÓZѶ¾õ¡s­ëAóº×€þ5°ù,ìaç¹ØÆ¶3²“=çe3ûÍÎ~öš£-í3S»Úc¾6¶¿¬ímo¹ÛÞÆ2¸ÃMåq“Êæ>7“Ó­n$³»ÝD~7¼,ïyó¸ÞöÆ1¾ómã}óÛÈÿvµ¿Þâ\É/µÁNâ…3ÜÉ÷´Ã#Þá‰S\ÊguÆ-mñO¸ã0ÈC¾à‘“\Ë'_´ÉS^à•³|À.ùc.ó0לÐ4¿9~s®ó=÷¼Ï<ÿy|ƒ.ô4]ÏD?ºz“®ô67]ÙO§3Ó£ÞÌ©SÄW‡vÖÙl>õ­3Úëdî:Øu)ö±?ÚìÙF;˜Ë®öW²½í­|;ÜW)÷¹²îvtÞ˽w¾÷Ý|à×=xÂÞÝA;freetds-0.91/doc/doc/freetds-0.91/reference/a00001.html100664 001750 000144 00000012130 11623073550 0015556 FreeTDS API: _character_set_alias Struct Reference

_character_set_alias Struct Reference

List of all members.

Public Attributes

const char * alias
int canonic

The documentation for this struct was generated from the following file:
  • /home/jklowden/releases/freetds-0.91/include/tdsiconv.h
Generated on Wed Aug 17 22:22:32 2011 for FreeTDS API by  doxygen 1.6.3
freetds-0.91/doc/doc/freetds-0.91/reference/tabs.css100664 001750 000144 00000003464 11623073545 0015550/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ DIV.tabs { float : left; width : 100%; background : url("tab_b.gif") repeat-x bottom; margin-bottom : 4px; } DIV.tabs UL { margin : 0px; padding-left : 10px; list-style : none; } DIV.tabs LI, DIV.tabs FORM { display : inline; margin : 0px; padding : 0px; } DIV.tabs FORM { float : right; } DIV.tabs A { float : left; background : url("tab_r.gif") no-repeat right top; border-bottom : 1px solid #84B0C7; font-size : 80%; font-weight : bold; text-decoration : none; } DIV.tabs A:hover { background-position: 100% -150px; } DIV.tabs A:link, DIV.tabs A:visited, DIV.tabs A:active, DIV.tabs A:hover { color: #1A419D; } DIV.tabs SPAN { float : left; display : block; background : url("tab_l.gif") no-repeat left top; padding : 5px 9px; white-space : nowrap; } DIV.tabs #MSearchBox { float : right; display : inline; font-size : 1em; } DIV.tabs TD { font-size : 80%; font-weight : bold; text-decoration : none; } /* Commented Backslash Hack hides rule from IE5-Mac \*/ DIV.tabs SPAN {float : none;} /* End IE5-Mac hack */ DIV.tabs A:hover SPAN { background-position: 0% -150px; } DIV.tabs LI.current A { background-position: 100% -150px; border-width : 0px; } DIV.tabs LI.current SPAN { background-position: 0% -150px; padding-bottom : 6px; } DIV.navpath { background : none; border : none; border-bottom : 1px solid #84B0C7; text-align : center; margin : 2px; padding : 2px; } freetds-0.91/doc/Makefile.am100644 001750 000144 00000023322 11550062746 0011406 # Converting DocBook to HTML (several small files) # http://www.freebsd.org/tutorials/docproj-primer/x3132.html#AEN3140 # $Id: Makefile.am,v 1.65.4.1 2011/04/09 13:57:58 jklowden Exp $ SHELL = /bin/sh TXT2MAN = $(srcdir)/txt2man DOCDIR = doc/freetds-$(VERSION) PRODUCT = FreeTDS TARGET_DOCDIR = $(DESTDIR)$(datadir)/$(DOCDIR) IMAGES = images/important.gif \ images/note.gif \ images/tip.gif \ images/caution.gif \ images/warning.gif CALLOUTS = images/callouts/1.gif \ images/callouts/2.gif \ images/callouts/3.gif \ images/callouts/4.gif \ images/callouts/5.gif \ images/callouts/6.gif \ images/callouts/7.gif \ images/callouts/8.gif \ images/callouts/9.gif \ images/callouts/10.gif 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) freebcp.txt tsql.txt osql.txt fisql.txt \ bsqldb.txt bsqlodbc.txt defncopy.txt datacopy.txt \ $(DOCDIR)/userguide $(DOCDIR)/reference \ images grep_sample_code \ tds_ssl.html dist-hook: find $(distdir)/doc -name CVS -exec rm -rf {} ';' 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: $(mkinstalldirs) $(TARGET_DOCDIR)/userguide \ $(TARGET_DOCDIR)/reference \ $(TARGET_DOCDIR)/images \ $(TARGET_DOCDIR)/images/callouts 2>&1 MANOPTS = -I 'FreeTDS User Guide' -v 'FreeTDS Utilities' -t $(PRODUCT) -r $(VERSION) freebcp.1: freebcp.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/freebcp.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ tsql.1: tsql.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/tsql.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ osql.1: osql.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/osql.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ fisql.1: fisql.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/fisql.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ bsqldb.1: bsqldb.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/bsqldb.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ bsqlodbc.1: bsqlodbc.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/bsqlodbc.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ defncopy.1: defncopy.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/defncopy.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ datacopy.1: datacopy.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/datacopy.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ # If we built the documentation ourselves, install that, # else if we have access to distributed documentation, install that. install-data-local: installdirs $(noinst_DATA) $(mkinstalldirs) $(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_DATA) {} $(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_DATA) {} $(TARGET_DOCDIR)/reference ';' cd $(srcdir) && find images -name \*.gif -exec \ $(INSTALL_DATA) {} $(TARGET_DOCDIR)/{} ';' uninstall-local: rm -rf $(TARGET_DOCDIR) clean-local: rm -rf userguide.dsl doxy.log userguide reference \ 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 # To make the userguide, export DOCBOOK_DSL to point to docbook.dsl. $(DOCDIR)/userguide/index.htm: userguide.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 $(mkinstalldirs) $(DOCDIR)/userguide 2>&1 touch $(DOCDIR)/userguide/t.htm rm -f $(DOCDIR)/userguide/* $(MAKE) dblib.api.sgml ctlib.api.sgml odbc.api.sgml # 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 if test ! -r $@ ; then \ echo '

at www.freetds.org' \ > .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 # for convenience, create a link in the build directory if test -h userguide; then rm userguide; fi ln -sf $(DOCDIR)/userguide userguide userguide: $(DOCDIR)/userguide/index.htm reference: $(DOCDIR)/reference/index.html DISTRIBUTED_REF_DIR = $(srcdir)/$(DOCDIR)/reference $(DOCDIR)/reference/index.html: $(top_srcdir)/ChangeLog $(mkinstalldirs) $(DOCDIR) 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 $(mkinstalldirs) $(DOCDIR)/reference 2>&1 if test ! -r $@ ; then \ cd $(DOCDIR)/reference && \ echo '

at www.freetds.org' \ > .index.html && \ mv .index.html index.html; \ fi # for convenience, create a link in the build directory if test -h reference; then rm reference; fi ln -sf $(DOCDIR)/reference reference # # 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. # dblib.api.sgml: echo 'db-lib API Implementation Summary' > .dblib.api echo '' \ 'Category' \ 'Microsoft name' \ 'Sybase name' \ 'Status' \ 'Comments' \ '' \ '' \ >> .dblib.api grep '^dblib' $(srcdir)/api_status.txt | \ sed -e 's!^dblib[ ]!!; s![ ][ ]*! !g; s!$$!!; ' \ >> .dblib.api echo '
' >> .dblib.api mv .dblib.api $@ ctlib.api.sgml: echo '' \ 'ct-lib API Implementation Summary' \ > .ctlib.api echo '' \ 'Category' \ 'Function' \ 'Status' \ 'Comments' \ '' \ '' \ >> .ctlib.api grep '^ctlib' $(srcdir)/api_status.txt | \ sed -e 's!^ctlib[ ]!!; s![ ]! !g; s!$$!!; ' \ >> .ctlib.api echo '
' \ >> .ctlib.api mv .ctlib.api $@ MSDN_ODBC = http://msdn.microsoft.com/library/en-us/odbc/htm/odbc odbc.api.sgml: echo 'ODBC API Implementation Summary' \ > .odbc.api echo '' \ 'Category' \ 'Function' \ 'Status' \ 'Comments' \ '' \ '' \ >> .odbc.api # The mean RE below (with "ulink" in it) forms a URL to Microsoft's reference page # for the function. It assumes a word starting with "SQL" is an ODBC function. # Let's hope they don't change their site too often. grep '^odbc' $(srcdir)/api_status.txt | \ sed -e' s!^odbc[ ]!!; s![ ][ ]*! !g; s!\(SQL[[:alpha:]]*\)!\1!g; s!$$!!; ' \ >> .odbc.api echo '
' \ >> .odbc.api mv .odbc.api $@ DISTCLEANFILES = $(DOCDIR)/userguide $(DOCDIR)/reference freetds-0.91/doc/Makefile.in100664 001750 000144 00000062061 11623070617 0011421# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 # $Id: Makefile.am,v 1.65.4.1 2011/04/09 13:57:58 jklowden Exp $ VPATH = @srcdir@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = 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' man1dir = $(mandir)/man1 am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)" man5dir = $(mandir)/man5 NROFF = nroff MANS = $(man_MANS) DATA = $(noinst_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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@ TXT2MAN = $(srcdir)/txt2man DOCDIR = doc/freetds-$(VERSION) PRODUCT = FreeTDS TARGET_DOCDIR = $(DESTDIR)$(datadir)/$(DOCDIR) IMAGES = images/important.gif \ images/note.gif \ images/tip.gif \ images/caution.gif \ images/warning.gif CALLOUTS = images/callouts/1.gif \ images/callouts/2.gif \ images/callouts/3.gif \ images/callouts/4.gif \ images/callouts/5.gif \ images/callouts/6.gif \ images/callouts/7.gif \ images/callouts/8.gif \ images/callouts/9.gif \ images/callouts/10.gif 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) freebcp.txt tsql.txt osql.txt fisql.txt \ bsqldb.txt bsqlodbc.txt defncopy.txt datacopy.txt \ $(DOCDIR)/userguide $(DOCDIR)/reference \ images grep_sample_code \ tds_ssl.html 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 MANOPTS = -I 'FreeTDS User Guide' -v 'FreeTDS Utilities' -t $(PRODUCT) -r $(VERSION) DISTRIBUTED_UG_DIR = $(srcdir)/$(DOCDIR)/userguide DISTRIBUTED_REF_DIR = $(srcdir)/$(DOCDIR)/reference MSDN_ODBC = http://msdn.microsoft.com/library/en-us/odbc/htm/odbc DISTCLEANFILES = $(DOCDIR)/userguide $(DOCDIR)/reference 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 .PRECIOUS: 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 install-man1: $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" @list=''; test -n "$(man1dir)" || exit 0; \ { 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'; \ } | 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,.,'`; \ test -z "$$files" || { \ echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(man1dir)" && rm -f $$files; } install-man5: $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man5dir)" || $(MKDIR_P) "$(DESTDIR)$(man5dir)" @list=''; test -n "$(man5dir)" || exit 0; \ { 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'; \ } | 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,.,'`; \ test -z "$$files" || { \ echo " ( cd '$(DESTDIR)$(man5dir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(man5dir)" && rm -f $$files; } tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi @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 $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook check-am: all-am check: check-am all-am: Makefile $(MANS) $(DATA) 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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 clean-local 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-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 dist-hook distclean distclean-generic \ distclean-libtool 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 \ uninstall uninstall-am uninstall-local uninstall-man \ uninstall-man1 uninstall-man5 dist-hook: find $(distdir)/doc -name CVS -exec rm -rf {} ';' $(DOCDIR)/userguide: $(DOCDIR)/userguide/index.htm $(DOCDIR)/reference: $(DOCDIR)/reference/index.html doc: $(DOCDIR)/userguide $(DOCDIR)/reference dist: man man: $(man_MANS) installdirs: $(mkinstalldirs) $(TARGET_DOCDIR)/userguide \ $(TARGET_DOCDIR)/reference \ $(TARGET_DOCDIR)/images \ $(TARGET_DOCDIR)/images/callouts 2>&1 freebcp.1: freebcp.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/freebcp.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ tsql.1: tsql.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/tsql.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ osql.1: osql.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/osql.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ fisql.1: fisql.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/fisql.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ bsqldb.1: bsqldb.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/bsqldb.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ bsqlodbc.1: bsqlodbc.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/bsqlodbc.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ defncopy.1: defncopy.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/defncopy.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ datacopy.1: datacopy.txt $(TXT2MAN) $(MANOPTS) $(srcdir)/datacopy.txt >.$@ if test ! -s .$@; then echo 'unable to generate $@'; fi test -s .$@ mv .$@ $@ # If we built the documentation ourselves, install that, # else if we have access to distributed documentation, install that. install-data-local: installdirs $(noinst_DATA) $(mkinstalldirs) $(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_DATA) {} $(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_DATA) {} $(TARGET_DOCDIR)/reference ';' cd $(srcdir) && find images -name \*.gif -exec \ $(INSTALL_DATA) {} $(TARGET_DOCDIR)/{} ';' uninstall-local: rm -rf $(TARGET_DOCDIR) clean-local: rm -rf userguide.dsl doxy.log userguide reference \ dblib.api.sgml \ ctlib.api.sgml \ odbc.api.sgml # To make the userguide, export DOCBOOK_DSL to point to docbook.dsl. $(DOCDIR)/userguide/index.htm: userguide.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 $(mkinstalldirs) $(DOCDIR)/userguide 2>&1 touch $(DOCDIR)/userguide/t.htm rm -f $(DOCDIR)/userguide/* $(MAKE) dblib.api.sgml ctlib.api.sgml odbc.api.sgml # 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 if test ! -r $@ ; then \ echo '

at www.freetds.org' \ > .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 # for convenience, create a link in the build directory if test -h userguide; then rm userguide; fi ln -sf $(DOCDIR)/userguide userguide userguide: $(DOCDIR)/userguide/index.htm reference: $(DOCDIR)/reference/index.html $(DOCDIR)/reference/index.html: $(top_srcdir)/ChangeLog $(mkinstalldirs) $(DOCDIR) 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 $(mkinstalldirs) $(DOCDIR)/reference 2>&1 if test ! -r $@ ; then \ cd $(DOCDIR)/reference && \ echo '

at www.freetds.org' \ > .index.html && \ mv .index.html index.html; \ fi # for convenience, create a link in the build directory if test -h reference; then rm reference; fi ln -sf $(DOCDIR)/reference reference # # 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. # dblib.api.sgml: echo 'db-lib API Implementation Summary' > .dblib.api echo '' \ 'Category' \ 'Microsoft name' \ 'Sybase name' \ 'Status' \ 'Comments' \ '' \ '' \ >> .dblib.api grep '^dblib' $(srcdir)/api_status.txt | \ sed -e 's!^dblib[ ]!!; s![ ][ ]*! !g; s!$$!!; ' \ >> .dblib.api echo '
' >> .dblib.api mv .dblib.api $@ ctlib.api.sgml: echo '' \ 'ct-lib API Implementation Summary' \ > .ctlib.api echo '' \ 'Category' \ 'Function' \ 'Status' \ 'Comments' \ '' \ '' \ >> .ctlib.api grep '^ctlib' $(srcdir)/api_status.txt | \ sed -e 's!^ctlib[ ]!!; s![ ]! !g; s!$$!!; ' \ >> .ctlib.api echo '
' \ >> .ctlib.api mv .ctlib.api $@ odbc.api.sgml: echo 'ODBC API Implementation Summary' \ > .odbc.api echo '' \ 'Category' \ 'Function' \ 'Status' \ 'Comments' \ '' \ '' \ >> .odbc.api # The mean RE below (with "ulink" in it) forms a URL to Microsoft's reference page # for the function. It assumes a word starting with "SQL" is an ODBC function. # Let's hope they don't change their site too often. grep '^odbc' $(srcdir)/api_status.txt | \ sed -e' s!^odbc[ ]!!; s![ ][ ]*! !g; s!\(SQL[[:alpha:]]*\)!\1!g; s!$$!!; ' \ >> .odbc.api echo '
' \ >> .odbc.api mv .odbc.api $@ # 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-0.91/doc/api_status.txt100664 001750 000144 00000054772 11507403007 0012275#!/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-0.91/doc/bcp.txt100664 001750 000144 00000001053 07361702255 0010657Bulk 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-0.91/doc/cap.txt100664 001750 000144 00000012326 07511640510 0010653Capabilities ------------ 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-0.91/doc/getting_started.txt100664 001750 000144 00000010315 11144435366 0013303Introduction ------------ 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 which so far is not implemented (but can still be accessed with 4.2). No version of MS SQL uses 5.0 and Sybase does not use 7.0, but both still support 4.2. TDS 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| <10.x | >11.0 |<5.5.03|5.5*|>6.0| +-----+----+----+----+-----------+------------+-------+----+----+ | 4.2 | X | X | X | X | X | | | | | 5.0 | | | | | X | | X | X | | 7.0 | | X | X | | | | | | | 8.0 | | | 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. These two directories may eventually be merged. 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 is the most robust CLI we have, followed by ctlib, which is quite usable none-the-less. ODBC is a late starter, but has been improved recently. 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. Misc ---- Please send fixes and updates to this document to Brian Bruns (brian@bruns.org) I realize it's a little rough right now but I wanted to at least put something out. freetds-0.91/doc/policy.txt100664 001750 000144 00000006345 11144435366 0011423Documentation 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-0.91/doc/CodingStyle100664 001750 000144 00000017225 07557451753 0011544The 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 CVS 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-0.91/doc/userguide.dsl.in100664 001750 000144 00000006467 11123105073 0012457 ]> ;; 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-0.91/doc/userguide.sgml100644 001750 000144 00001136600 11566002411 0012225 FreeTDS"> DB-Library'> CT-Library'> ODBC'> freetds.conf"> ]> $Date: 2011/05/21 18:31:37 $ $Revision: 1.139.2.1 $ &freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; Brian Bruns James K. Lowden 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 Brian Bruns and James K. Lowden 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: $Revision: 1.139.2.1 $ $Date: 2011/05/21 18:31:37 $ CVS control number $Id: userguide.sgml,v 1.139.2.1 2011/05/21 18:31:37 jklowden Exp $. 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 CVS tree. 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. 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;. Your humble author 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 two projects. The &freetds; C libraries and &freetds;/ JDBC. The &freetds; C 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. 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. 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.0 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 and Java 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 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.65 automake (GNU automake) 1.11.1 ltmain.sh (GNU libtool) 2.2.6b 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>CVS</productname> repository The latest &freetds; package is always available from iBiblio and its mirrors. Code changes by the developers are immediately available in the CVS repository. If you've run into a problem, you may want to check out from CVS to see if it's fixed there. No password is needed to obtain the current CVS copy of FreeTDS; you need only have a CVS client installed on your machine. Then: $ cvs -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds login $ cvs -z3 -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds checkout -P freetds Password: $ For those behind firewalls or otherwise unable to access CVS, nightly snapshots of CVS are rolled up into tarballs for your convenience. They can be downloaded from ibiblio.org. Tarballs are generated around 3am EST (GMT-5). In general, the CVS HEAD revision (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 CVS HEAD. As with any project of this sort, if you want to use the CVS HEAD revision, 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 CVS is described in the file INSTALL.CVS. 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. 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 and 7.2. 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. 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. Enable SSPI support. SSPI is a Micrsoft library that allows you to use your current logged-in account for authentication. With this option enabled, FreeTDS supports "trusted logins" for Win32/64, just as Microsoft's own implementations do. 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 :) 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 CVS CVS 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 Building for Windows using Microsoft's compiler is supported via the NMakefile included in the distribution. Set up the command-line build environment per Microsoft's instructions, and run e.g. $ nmake -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=debug The assumed availability of standard .h files is captured in win32/config.h. If you encounter difficulties related to missing include files, examine the indicated file for an include guard, and compare it to win32/config.h. For example, you get an error like this: Missing include file in Windows … asprintf.c include\tds_sysdep_private.h(239) : fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory src/replacements/asprintf.c includes include/tds_sysdep_private.h, where you find 238 #ifdef HAVE_INTTYPES_H 239 #include <inttypes.h> 240 #endif and, sure enough, asprintf.c earlier includes win32/config.h, which says 91 /* Define to 1 if you have the <inttypes.h> header file. */ 92 #define HAVE_INTTYPES_H 1 Which shouldn't be defined unless inttypes.h exists on your system. Let's review: config.h has preprocessor definitions that (try to) describe the build environment to the compiler. In this example, it got one wrong, causing the compiler to look for a file that isn't present, creating the error. The solution is not to change the &freetds; source code, but merely to comment out line 92 in config.h. Perhaps you're shaking your head at such an old school approach. Over the years, Microsoft's proprietary project-configuration files have proved difficult to support. Every version is different, and there are a great many versions in use in the wild at any one time. As the project changes, it becomes impossible to maintain these kinds of files. For Windows applications that use &freetds; the hard-won wisdom is just use the NMakefile, please, thanks! If you like a visual environment and visual debugging, no problem: Microsoft's tools support Makefile projects. The author has direct knowledge of developers for whom that arrangement works quite well. Other ways to build under Windows® Visual Studio. Project files are included in the win32 directory. See above note for why these might be out of date. Dev-C++ MingW gcc under cygwin. The Borland Builder 6.0 compiler is also reported to work, but requires some tweaking of the #include statements. We would apply any patches that make this work cleanly. From the Department of Double Emulation: &freetds; builds as a .dll under WINE and as a .a under Interix. See the mailing list archives (second half of 2003) for details. 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 in the source distribution. OS X® As of this writing ($Date: 2011/05/21 18:31:37 $), the regular distribution compiles on OS X. Alternative build procedure On 11 March 2004, Dmitri Fedortchenko offered the following approach, using a local libtool. It is included here as a source of clues, in case you encounter trouble. Installing with libtool 1.5.2 Install the latest libtool from GNU into /usr/local, so as not to interfere with the Apple-original. Make sure /usr/local/bin is in your PATH and /usr/local/lib is in your LIBRARY_PATH. Go to the &freetds; source directory and generate the Makefiles $ ./configure --disable-libiconv --disable-odbc Overwrite FreeTDS's libtool with a symbolic link to your (better) one If you run configure again, you'll need to perform this step again, because libtool will have been regenerated in its fossilized state. $ ln -sf /usr/local/bin/libtool To check that you've done everything correctly up to this point, $ ./libtool --version libtool should report version 1.5.2 (or whatever version you downloaded, and not 1.4). And finally, of course $ make && make install ]]> 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.63RC9.tar.gz 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. &freetds; does not support MARS.. Microsoft SQL Server 2008 7.2 (unchanged)
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.
<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, 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. 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/required off Specify if encryption is desidered. Supported for Microsoft servers. off disables encryption (only if needed); request means use if available; required means create and allow encrypted connections only. enable gssapi delegation on/off off Enable delegation flag using Kerberos.
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, 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 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: locale is "C" locale charset is "646" Compile-time settings (established with the "configure" script): Version: freetds &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 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/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 three 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 table defines 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.
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=FreeTDSrefers to the [FreeTDS] entry in odbcinst.ini.;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. $ make odbctest.o $ 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 or 7.2). 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) 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, and UCS-2. 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 replacment). 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 infomation. 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, It works because much of Active Directory is based on Kerberos. From each according to his ability; to each according to his needs. Kerberos can be used to authenticate to Microsoft SQL Servers. 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. SybSQL SybSQL is a Qt-based GUI interface to Sybase databases that uses the &dblib; API. SybSQL has a fairly basic build process that simply uses a Makefile. In order for SybSQL to find Qt and &freetds; you need to define QTDIR and SYBASE environment variables. If you have Qt installed, you may have QTDIR defined already. To verify, type echo $QTDIR at the shell prompt. This example uses my own installation path of qt-2.3.1 (from RedHat 7.2), YMMV. $ export QTDIR=/usr/lib/qt-2.3.1 $ export SYBASE=/usr/local $ make When finished you'll have an executable named sybsql that you can run. One caveat to the way in which SybSQL and &freetds; interact is that SybSQL expects to be running under OpenClient, and makes the assumption that a valid $SYBASE/interfaces file exists. Since &freetds; has deprecated use of the interfaces file in favor of the &freetdsconf; config file, you may have to create a interfaces file just to satisfy SybSQL. By defining SYBASE to the parent directory of the interfaces file, you may put it wherever you like; it does not have to be in /usr/local. When using &freetdsconf;, &freetds; does not rely on the SYBASE variable for finding its own components, so it is safe to point it elsewhere. Python Your humble author is not enlightened enough to use Python, and the information contained in this section is a little rough. Please contact the list for more assistance or (better yet) to improve these instructions. Install distutils if you haven't already. $ tar xvfz distutils-latest.tgz $ cd distutils $ python setup.py install You can obtain the Python Sybase module here. This example uses version 0.34, the most current at the time of this writing, please adjust accordingly if using a different version. $ tar xvfz sybase-0.34.tgz $ cd sybase-0.34 $ 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 Qt has two drivers to access SQL Server databases: QTDS and QODBC. At the time of writing (January 2010) QTDS has a performance problem because rather than maintaining a connection, it instead re-connects for every query. So use QODBC. There are however 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 by [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 A related problem is that some people have reported problems with text field using TDS version 7.0. One known workaround is to convert long strings to varchar(8000) in your query text with CAST( variable_name as varchar(8000) ) as variable_name. Text datatype handling is fixed in &freetds; 0.60, except for bcp operations. 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. The usual manifestation is some sort of spurious out of memory error or segment fault. To avoid this, 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;. 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;. Give particular attention to reverse DNS lookups, if you were forced (or thought you were forced) to identify the server by number, instead of by name, as Vint intended. You can defeat &freetds;'s automatic reverse-DNS lookup feature by inserting #define NOREVERSELOOKUPS in src/tds/config.c, rebuilding, and reinstalling. Reverse lookup code has been removed as of version 0.62 because it was poorly implemented. 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.83.dev.20110124 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. 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) 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 &freetds; FAQ Master, or post a message to the 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 your friendly project maintainer, James K. Lowden. 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 sample 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 db-lib 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. Broadly, that entails providing buffers to &dblib; to fill, and iterating 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 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. nextrow() 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; 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. <function>db-lib</> 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 more 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 = dbwillconvert(pcol->type, SYBCHAR); } 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, which FreeTDS's dbwillconvert() returns (for fixed-length datatypes). For IMAGE data, we need to multiply by 2, because dbbind() will convert each byte to a hexadecimal pair. The example program will report an error with IMAGE data. 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 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 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.
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. 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 czyborra.com is offline at the time of this writing (December 2003). It contained good information, so it's still included here, in case it comes back to life. 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 is the system employed by Microsoft NT-based systems. Microsoft database servers store UCS-2 strings in nchar and nvarchar datatypes. Microsoft also designed version 7.0 (and up) of the TDS protocol around UCS-2: all metadata (table names and such) are encoded according to UCS-2 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. 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-0.91/doc/userguide.css100664 001750 000144 00000000447 10320116355 0012053/* * $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-0.91/doc/freebcp.1100664 001750 000144 00000014167 11563461455 0011057." Text automatically generated by txt2man-1.4.7 .TH FreeTDS "May 14, 2011" "0.91RC2" "FreeTDS Utilities" .SH NAME \fBfreebcp \fP- bulk loading utility for Sybase and Microsoft databases .SH SYNOPSIS .nf .fam C \fBfreebcp\fP [[database.]owner.]object_name {in | [query]out} \fIdatafile\fP { \fB-c\fP | \fB-n\fP | \fB-f\fP \fIformatfile\fP } [\fB-b\fP \fIbatchsize\fP] [\fB-F\fP \fIfirstrow\fP] [\fB-L\fP \fIlastrow\fP] [\fB-e\fP \fIerrfile\fP] [\fB-I\fP \fIinterfaces\fP] [\fB-m\fP \fImaxerrors\fP] [\fB-t\fP \fIfield_term\fP] [\fB-r\fP \fIrow_term\fP] [\fB-h\fP \fIhints\fP] [\fB-T\fP \fItextsize\fP] [\fB-A\fP \fIpacket_size\fP] [\fB-O\fP \fIoptions\fP] [\fB-S\fP \fIservername\fP] [\fB-U\fP \fIusername\fP] [\fB-P\fP \fIpassword\fP] [\fB-EdVv\fP] .fam T .fi .SH DESCRIPTION \fBfreebcp\fP is a utility program distributed with FreeTDS. \fBfreebcp\fP replicates (in part at least) the functionality of the "bcp" utility programs distributed by Sybase and Microsoft. .PP \fBfreebcp\fP makes use of the db-lib 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 .TP .B database The database of the object being copied. Optional if the table/view is in the default database for \fIusername\fP. .TP .B owner The owner of the object being copied. Optional if \fIusername\fP or the database owner is the owner of the table. .TP .B object_name Usually, object_name is the name of the database table you wish to access. It can also be a view (and, subject to constraints, it is sometimes possible to load a view). It can also be an SQL query, cf. queryout, below. .TP .B in | [query]out The direction of the bulk copy operation. 'in' indicates data are to be copied from a host file into a database table; 'out' indicates data are to be copied from a database table to a host file. 'queryout' indicates that table_name is in fact a query, rather than a database object. \fBfreebcp\fP 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.) .TP .B \fIdatafile\fP The name of an operating system file. .SH OPTIONS .TP .B \fB-c\fP 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 freetds.conf. .TP .B \fB-n\fP The host data file is in "native" format. This is a format that \fBfreebcp\fP will be able to process, but is not portable or readable. .TP .B \fB-f\fP \fIformatfile\fP The format of the host data file is described by \fIformatfile\fP. The layout of \fIformatfile\fP is identical to that understood by the Sybase and Microsoft bcp utilities, but is too complicated to describe here. .TP .B \fB-b\fP \fIbatchsize\fP 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 'committed' into the database. The default value for \fIbatchsize\fP is 1000. .TP .B \fB-F\fP \fIfirstrow\fP The first row to copy from the input file or database table. The default is the first row, row 1. .TP .B \fB-L\fP \fIlastrow\fP The last row to copy from an input file or database table. The default is the last row. .TP .B \fB-r\fP \fIrow_term\fP The row terminator for a character file. May be more than one character. Default is newline ('\\n'). Cf. \fB-c\fP, above. .TP .B \fB-t\fP \fIfield_term\fP The field terminator for character file. Also known as a column delimiter. May be more than one character. Default is tab ('\\t'). Cf. \fB-c\fP, above. .TP .B \fB-m\fP \fImaxerrors\fP Stop after encountering maxerror errors. Default 10. .TP .B \fB-e\fP \fIerrfile\fP Write errors to error_file. For uploads. Includes line and column information, and the row data. .TP .B \fB-S\fP \fIservername\fP The name of the Database Server to which to connect. .TP .B \fB-U\fP \fIusername\fP A database login name. If \fIusername\fP is not provided, a domain login is attempted for TDS 7+ connections. .TP .B \fB-P\fP \fIpassword\fP A database \fIpassword\fP. .TP .B \fB-E\fP Write the data in \fIdatafile\fP to the table's IDENTITY column. Without this flag, the identity data present in the \fIdatafile\fP will be ignored, and new IDENTITY values will be generated for the imported rows. .TP .B \fB-d\fP Turn off any logging. (Unintuitive, perhaps.) .TP .B \fB-O\fP \fIoptions\fP SQL text to set connection \fIoptions\fP prior to the bcp operation. If \fIoptions\fP is a valid filename, the SQL is read from the file instead. Sometimes needed for queryout. Example: "\fB-O\fP 'SET QUOTED_IDENTIFIER ON'" .TP .B \fB-I\fP \fIinterfaces\fP The name and location of the \fIinterfaces\fP file to search when connecting to servername. Overrides freetds.conf. .TP .B \fB-h\fP \fIhints\fP Set bcp \fIhints\fP. For valid values, cf. \fBbcp_options\fP() in the FreeTDS Reference Manual. .TP .B \fB-T\fP \fItextsize\fP For text or image columns, set the maximum number of characters to request from the server. Defaults to the setting in freetds.conf. If not specified anywhere, defaults to the full size of the data. .TP .B \fB-A\fP \fIpacket_size\fP Set the size of a TDS packet to \fIpacket_size\fP. Not sure why you would want to do this, except as an experiment. .TP .B \fB-v\fP \fB-V\fP Print the version information and exit. .SH ENVIRONMENT .TP .B DSQUERY default \fIservername\fP .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.1 protocol is required. .PP Theoretically both Sybase and Microsoft support the TDS 4.2 protocol, but in reality they implement the bcp portion of TDS 4.2 differently. FreeTDS has no way of knowing which type of server it's connected to, hence TDS protocol 4.2 is not supported. .SH HISTORY \fBfreebcp\fP first appeared in FreeTDS 0.60 .SH AUTHORS The \fBfreebcp\fP utility was written by Bill Thompson (thompbil@exchange.uk.ml.com) .SH BUGS Currently, there is no support for text data types in \fBfreebcp\fP, when SQL Server 2000 is the target database. freetds-0.91/doc/tsql.1100664 001750 000144 00000006673 11563461455 0010437." Text automatically generated by txt2man-1.4.7 .TH FreeTDS "May 14, 2011" "0.91RC2" "FreeTDS Utilities" .SH NAME \fBtsql \fP- utility to test FreeTDS connections and queries .SH SYNOPSIS .nf .fam C .TP .B \fBtsql\fP { \fB-S\fP \fIservername\fP [\fB-I\fP \fIinterface\fP] | \fB-H\fP \fIhostname\fP \fB-p\fP \fIport\fP } \fB-U\fP \fIusername\fP [\fB-P\fP \fIpassword\fP] [\fB-o\fP \fIoptions\fP] .TP .B \fBtsql\fP \fB-C\fP .fam T .fi .SH DESCRIPTION \fBtsql\fP is a diagnostic tool provided as part of FreeTDS. It uses the TDS protocol directly to connect to Sybase or Microsoft SQL Servers, and allows the user to issue queries that test the capabilities of FreeTDS. .PP \fBtsql\fP is *not* a replacement for a complete isql, such as sqsh (www.sqsh.org). It is designed to rely on the lowest level FreeTDS library, tdslib, as a way to isolate potential bugs in the protocol implementation. .PP \fBtsql\fP can be run in two ways, one which uses the freetds.conf and one which connects directly using the server's \fIhostname\fP and \fIport\fP. .PP When \fB-S\fP is used, FreeTDS uses the freetds.conf (or equivalent) and environment variables in the normal way to determine the server's ip address and \fIport\fP. You can use \fB-I\fP to specify a filename, overriding FreeTDS's configuration file search algorithm. .PP The \fB-H\fP and \fB-p\fP parameters are provided especially for troubleshooting new configurations (or servers). Use of these parameters causes FreeTDS to ignore any freetds.conf and environment variables. .RE .PP .SH OPTIONS .TP .B \fB-S\fP \fIservername\fP the Database Server to which to connect. .TP .B \fB-I\fP \fIinterface\fP a freetds.conf or interfaces file describing \fIservername\fP .TP .B \fB-H\fP \fIhostname\fP the DNS \fIhostname\fP of the server .TP .B \fB-p\fP \fIport\fP the \fIport\fP at which SQL Server is listening .TP .B \fB-U\fP \fIusername\fP database login name. If \fIusername\fP is not provided, a domain login is attempted for TDS 7+ connections. .TP .B \fB-P\fP \fIpassword\fP database \fIpassword\fP. .PP \fB-L\fP list server "instances" (with \fB-H\fP) .TP .B \fB-C\fP prints some of the compile-time configuration parameters. .TP .B \fB-o\fP \fIoptions\fP apply the \fIoptions\fP specified to every command. .RS .TP .B f No footer [result count] .TP .B h No header [titles] .TP .B t Print time .TP .B v Print version .TP .B q Quiet .SH NOTES Typing "exit", "quit", or "bye" (or ^D) exits \fBtsql\fP. .PP Typing "version" displays the TDS protocol version. .PP Command batches may be separated with "go" or "GO". If "GO", the version string is reported before executing the batch. .PP After prompting for the \fIpassword\fP, \fBtsql\fP will attempt to connect to the remote .TP .B server. \fBtsql\fP displays a counter indicating the number of seconds that .TP .B it is attempting to connect. Typically, \fBtsql\fP should immediately respond .TP .B with a '1>' prompt. If you see the counter (1, 2, 3, \.\.\.), most likely \fBtsql\fP is unable to connect to the indicated server. .PP If you can connect with "\fBtsql\fP \fB-S\fP \fIservername\fP", your basic FreeTDS installation is working. .PP If you have suggestions for ways to make \fBtsql\fP more useful as a diagnostic tool, please recommend them to the FreeTDS mailing list for consideration. .SH HISTORY \fBtsql\fP first appeared in FreeTDS 0.60. .SH AUTHORS The \fBtsql\fP utility was written by Brian Bruns. .SH BUGS Several, to be sure, now that it's documented. :) freetds-0.91/doc/osql.1100664 001750 000144 00000004107 11563461455 0010420." Text automatically generated by txt2man-1.4.7 .TH FreeTDS "May 14, 2011" "0.91RC2" "FreeTDS Utilities" .SH NAME \fBosql \fP- utility to test FreeTDS connections and queries \fB .SH SYNOPSIS .nf .fam C .TP .B \fBosql\fP \fB-S\fP \fIdsn\fP \fB-U\fP \fIusername\fP \fB-P\fP \fIpassword\fP [\fB-I\fP \fIini_dir\fP] .fam T .fi .SH DESCRIPTION \fBosql\fP 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 \fBosql\fP works only with the isql that comes with unixODBC. .SH OPTIONS .TP .B \fB-S\fP \fIdsn\fP the Data Source Name to which to connect, as known to odbc.ini. .TP .B \fB-U\fP \fIusername\fP database login name. .TP .B \fB-P\fP \fIpassword\fP database \fIpassword\fP. .TP .B \fB-I\fP \fIini_dir\fP override odbc.ini file location. .SH EXAMPLE If you have an odbc.ini with a section like this: .PP .nf .fam C [myDSN] servername = myserver TDS_Version = 5.0 .fam T .fi You would invoke \fBosql\fP as: .PP .nf .fam C osql -S myDSN [\.\.\.] .fam T .fi .SH NOTES If you can connect with "\fBosql\fP \fB-S\fP servername \fB-U\fP user \fB-P\fP passwd", your FreeTDS ODBC installation is working. .PP \fBosql\fP guesses where unixODBC might look for its 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 \fBosql\fP cannot intuit your odbc.ini directory, you can force the issue with the \fB-I\fP option. However, you're instructing \fBosql\fP 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 \fBosql\fP more useful as a diagnostic tool, please post them to the FreeTDS mailing list. .SH HISTORY \fBosql\fP first appeared in FreeTDS 0.65. .SH AUTHORS The \fBosql\fP utility was written by James K. Lowden freetds-0.91/doc/bsqldb.1100664 001750 000144 00000006723 11563461455 0010717." Text automatically generated by txt2man-1.4.7 .TH FreeTDS "May 14, 2011" "0.91RC2" "FreeTDS Utilities" .SH NAME \fBbsqldb \fP- batch SQL script processor using DB-Library \fB .SH SYNOPSIS .nf .fam C \fBbsqldb\fP [\fB-U\fP \fIusername\fP] [\fB-P\fP \fIpassword\fP] [\fB-S\fP \fIservername\fP] [\fB-D\fP \fIdatabase\fP] [\fB-i\fP \fIinput_file\fP] [\fB-o\fP \fIoutput_file\fP] [\fB-e\fP \fIerror_file\fP] [\fB-H\fP \fIhostname\fP] [\fB-t\fP \fIfield_term\fP] [\fB-hqv\fP] .fam T .fi .SH DESCRIPTION \fBbsqldb\fP is a utility program distributed with FreeTDS. .PP \fBbsqldb\fP is a non-interactive equivalent of the "isql" utility programs distributed by Sybase and Microsoft. Like them, \fBbsqldb\fP uses the command "go" on a line by itself as a separator between batches. The last batch need not be followed by "go". .PP \fBbsqldb\fP makes use of the DB-Library API provided by FreeTDS. This API is of course also available to application developers. .SH OPTIONS .TP .B \fB-U\fP \fIusername\fP Database server login name. If \fIusername\fP is not provided, a domain login is attempted for TDS 7+ connections. .TP .B \fB-P\fP \fIpassword\fP Database server \fIpassword\fP. .PP \fB-S\fP \fIservername\fP Database server to which to connect. .TP .B \fB-D\fP \fIdatabase\fP Database to use. .TP .B \fB-i\fP \fIinput_file\fP Name of script file, containing SQL. .TP .B \fB-o\fP \fIoutput_file\fP Name of output file, holding result data. .TP .B \fB-e\fP \fIerror_file\fP Name of file for errors. .TP .B \fB-t\fP \fIfield_term\fP Specifies the field terminator. Default is two spaces (' '). Recognized escape sequences are tab ('\\t'), carriage return ('\\r'), newline ('\\n'), and backslash ('\\\\'). .TP .B \fB-h\fP Print column headers with the data to the same file. .TP .B \fB-H\fP \fIhostname\fP Override name of client sent to server. .TP .B \fB-q\fP Do not print column metadata, return status, or rowcount. Overrides \fB-h\fP. .TP .B \fB-v\fP Verbose mode, for more information about the DB-Libraryrary interaction. This also reports the result set metadata, including and return code. All verbose data are written to standard error (or \fB-e\fP), so as not to interfere with the data stream. .SH ENVIRONMENT .TP .B DSQUERY default \fIservername\fP .SH NOTES \fBbsqldb\fP is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The \fB-i\fP, \fB-o\fP, and \fB-e\fP options override these, of course. .PP The source code for \fBbsqldb\fP 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 are using it in this way and find something unclear, you are encouraged to email the author your comments. .SH EXIT STATUS \fBbsqldb\fP exits 0 on success, and >0 if the server cannot process the query. .PP \fBbsqldb\fP 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 \fBexit\fP(3). .SH HISTORY \fBbsqldb\fP first appeared in FreeTDS 0\.63. .SH AUTHORS The \fBbsqldb\fP utility was written by James K. Lowden .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 \fBbsqldb\fP cannot return output parameters for stored procedures with these servers. freetds-0.91/doc/bsqlodbc.1100664 001750 000144 00000004702 11563461455 0011234." Text automatically generated by txt2man-1.4.7 .TH FreeTDS "May 14, 2011" "0.91RC2" "FreeTDS Utilities" .SH NAME \fBbsqlodbc \fP- batch SQL script processor using ODBC \fB .SH SYNOPSIS .nf .fam C \fBbsqlodbc\fP [\fB-U\fP \fIusername\fP] [\fB-P\fP \fIpassword\fP] [\fB-S\fP \fIserver\fP] [\fB-D\fP \fIdatabase\fP] [\fB-i\fP \fIinput_file\fP] [\fB-o\fP \fIoutput_file\fP] [\fB-e\fP \fIerror_file\fP] [\fB-t\fP \fIfield_term\fP] [\fB-qv\fP] .fam T .fi .SH DESCRIPTION \fBbsqlodbc\fP is a utility program distributed with FreeTDS. .PP \fBbsqlodbc\fP is a non-interactive equivalent of the "isql" utility programs distributed by Sybase and Microsoft. Like them, \fBbsqlodbc\fP uses the command "go" on a line by itself as a separator between batches. The last batch need not be followed by "go". .PP \fBbsqlodbc\fP makes use of the ODBC API provided by FreeTDS. This API is of course also available to application developers. .SH OPTIONS .TP .B \fB-U\fP \fIusername\fP Database \fIserver\fP login name. .TP .B \fB-P\fP \fIpassword\fP Database \fIserver\fP \fIpassword\fP. .TP .B \fB-S\fP \fIserver\fP Database \fIserver\fP to which to connect. .TP .B \fB-D\fP \fIdatabase\fP Database to use. .TP .B \fB-i\fP \fIinput_file\fP Name of script file, containing SQL. .TP .B \fB-o\fP \fIoutput_file\fP Name of output file, holding result data. .TP .B \fB-e\fP \fIerror_file\fP Name of file for errors. .TP .B \fB-t\fP \fIfield_term\fP Specifies the field terminator. Default is two spaces (' '). Recognized escape sequences are tab ('\\t'), carriage return ('\\r'), newline ('\\n'), and backslash ('\\\\'). .TP .B \fB-h\fP Print column headers with the data to the same file. .TP .B \fB-q\fP Do not print column metadata, return status, or rowcount. Overrides \fB-h\fP. .TP .B \fB-v\fP 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 \fB-e\fP), so as not to interfere with the data stream. .SH NOTES \fBbsqlodbc\fP is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The \fB-i\fP, \fB-o\fP, and \fB-e\fP options override these, of course. .SH EXIT STATUS \fBbsqlodbc\fP exits 0 on success, and >0 if the \fIserver\fP cannot process the query. .SH HISTORY \fBbsqlodbc\fP first appeared in FreeTDS 0.65. .SH AUTHORS The \fBbsqlodbc\fP utility was written by James K. Lowden .RE .PP freetds-0.91/doc/defncopy.1100664 001750 000144 00000005314 11563461456 0011253." Text automatically generated by txt2man-1.4.7 .TH FreeTDS "May 14, 2011" "0.91RC2" "FreeTDS Utilities" .SH NAME \fBdefncopy \fP- extract procedures and views from a Microsoft server. \fB .SH SYNOPSIS .nf .fam C \fBdefncopy\fP [\fB-U\fP \fIusername\fP] [\fB-P\fP \fIpassword\fP] [\fB-S\fP \fIserver\fP] [\fB-D\fP \fIdatabase\fP] [\fB-i\fP \fIinput_file\fP] [\fB-o\fP \fIoutput_file\fP] [\fB-v\fP] [owner.]object_name [[owner.]object_name\.\.\.] .fam T .fi .SH DESCRIPTION \fBdefncopy\fP is a utility program distributed with FreeTDS. It replaces a similar program of the same name distributed by Sybase. .PP \fBdefncopy\fP 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. .SH OBJECTS .TP .B owner is optional if you or the \fIdatabase\fP owner is the owner of the procedure/view being copied. .TP .B object_name is the name of the system object you wish to extract. .SH OPTIONS .TP .B \fB-U\fP \fIusername\fP \fIdatabase\fP \fIserver\fP login name. .TP .B \fB-P\fP \fIpassword\fP \fIdatabase\fP \fIserver\fP \fIpassword\fP. .TP .B \fB-S\fP \fIserver\fP \fIdatabase\fP \fIserver\fP to which to connect. .TP .B \fB-D\fP \fIdatabase\fP \fIdatabase\fP to use. Optional if the procedure/view being extracted is in your default \fIdatabase\fP. .TP .B \fB-i\fP \fIinput_file\fP a script to apply to the \fIdatabase\fP. Not currently implemented. .TP .B \fB-o\fP \fIoutput_file\fP a file to hold the script, defaults to standard output. .TP .B \fB-v\fP Show version information and copyright notice. .SH NOTES \fBdefncopy\fP is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The \fB-i\fP and \fB-o\fP options override these, of course. .PP \fBdefncopy\fP makes use of the db-lib API provided by FreeTDS. This API is of course also available to application developers. .SH EXIT STATUS \fBdefncopy\fP exits 0 on success, and >0 if the \fIserver\fP cannot process the query. .PP \fBdefncopy\fP will report any errors returned by the \fIserver\fP, but will continue processing. .SH HISTORY \fBdefncopy\fP first appeared in FreeTDS 0.63. .SH AUTHORS The \fBdefncopy\fP utility was written by James K. Lowden .SH BUGS Works only with Microsoft servers and ancient Sybase servers. .PP Does not create primary keys. .PP Many options are defined by Sybase that this version does not implement. Feel free to correct this situation. .PP In theory, \fBdefncopy\fP could apply/produce DDL for any system object, but at present only tables, procedures and views are supported, and only for extraction. freetds-0.91/doc/datacopy.1100664 001750 000144 00000004766 11563461456 0011262." Text automatically generated by txt2man-1.4.7 .TH FreeTDS "May 14, 2011" "0.91RC2" "FreeTDS Utilities" .SH NAME \fBdatacopy \fP- move table data between two servers .SH SYNOPSIS .nf .fam C \fBdatacopy\fP { \fB-t\fP | \fB-a\fP | \fB-c\fP \fIowner\fP } [\fB-b\fP \fIbatchsize\fP] [\fB-p\fP \fIpacketsize\fP] [\fB-v\fP] [\fB-d\fP] [\fB-S\fP \fIserver/username/password/database/table_or_view\fP] [\fB-D\fP \fIserver/username/password/database/table\fP] .fam T .fi .SH DESCRIPTION \fBdatacopy\fP is a utility distributed with FreeTDS. \fBdatacopy\fP will move table data from one server to another without the need for intermediate files. \fBdatacopy\fP is much faster and more efficient than is freebcp out/in. .PP \fBdatacopy\fP makes use of the db-lib bcp API built into FreeTDS. This API is also available to application developers. .PP \fBdatacopy\fP can be used to migrate data between Sybase ASE and SQL Server or vice versa. .SH OPTIONS .TP .B \fB-t\fP Truncate target table before loading data. .TP .B \fB-a\fP Append data to target table. .TP .B \fB-c\fP \fIowner\fP Create the target table with the same schema as the source table. \fBdatacopy\fP will submit a 'create table' command on the target server/database using the specified \fIowner\fP in .RS .TP .B the command, e.g. CREATE TABLE \fIowner\fP\.table (\.\.\.). .RE .TP .B \fB-b\fP \fIbatchsize\fP The number of rows per batch of data copied. Each batch of data is effectively 'committed' to the database. The default is 1000. .TP .B \fB-p\fP \fIpacketsize\fP The number of bytes, per network packet, sent to and from the servers. Increased packet size can enhance performance. .TP .B \fB-v\fP Produce verbose output, including diagnostic timings. .TP .B \fB-d\fP Produce freetds TDSDUMP output. (Serious debug only!) .TP .B \fB-S\fP \fIserver/username/password/database/table_or_view\fP The connection information for the source server and the location/name of the table (or view) to be copied. If not specified, \fBdatacopy\fP will prompt the user for the information. .TP .B \fB-D\fP \fIserver/username/password/database/table\fP The connection information for the destination server and the location/name of the target table. If not specified, \fBdatacopy\fP will prompt the user for the information. .SH SEE ALSO \fBfreebcp\fP(1), \fBdefncopy\fP(1), \fBbsqldb\fP(1), \fBtsql\fP(1), \fIFreeTDS User Guide\fP. .SH HISTORY \fBdatacopy\fP first appeared in FreeTDS 0.64. .SH AUTHORS The \fBdatacopy\fP utility was written by Bill Thompson (thompbil@exchange.uk.ml.com). freetds-0.91/doc/fisql.1100664 001750 000144 00000011046 11563461456 0010561." Text automatically generated by txt2man-1.4.7 .TH FreeTDS "May 14, 2011" "0.91RC2" "FreeTDS Utilities" .SH NAME \fBfisql \fP- interactive SQL shell \fB .SH SYNOPSIS .nf .fam C \fBfisql\fP [\fB-e\fP] [\fB-F\fP] [\fB-g\fP] [\fB-p\fP] [\fB-n\fP] [\fB-v\fP] [\fB-X\fP] [\fB-Y\fP] \[a] [\fB-a\fP \fIdisplay_charset\fP] [\fB-c\fP \fIcmdend\fP] \[a] [\fB-D\fP \fIdatabase\fP] [\fB-E\fP \fIeditor\fP] \[a] [\fB-h\fP \fIheaders\fP] [\fB-H\fP \fIhostname\fP] [\fB-i\fP \fIinputfile\fP] \[a] [\fB-I\fP \fIinterfaces_file\fP] [\fB-J\fP \fIclient_charset\fP] \[a] [\fB-l\fP \fIlogin_timeout\fP] [\fB-m\fP \fIerrorlevel\fP] \[a] [\fB-o\fP \fIoutputfile\fP] \[a] [\fB-P\fP \fIpassword\fP] [\fB-s\fP \fIcolseparator\fP] [\fB-S\fP \fIserver\fP] \[a] [\fB-t\fP \fItimeout\fP] [\fB-U\fP \fIusername\fP] [\fB-w\fP \fIwidth\fP] \[a] [\fB-y\fP \fIsybase_dir\fP] [\fB-z\fP \fIlanguage\fP] .fam T .fi .SH DESCRIPTION \fBfisql\fP is very similar to the "isql" utility programs distributed by Sybase and Microsoft. Like them, \fBfisql\fP uses the command "go" on a line by itself as a separator between batches. .SH OPTIONS .TP .B \fB-a\fP \fIdisplay_charset\fP The client charset name. Not implemented. .TP .B \fB-c\fP \fIcmdend\fP Command terminator, defaults to go. .TP .B \fB-D\fP Database name on the \fIserver\fP to use. .TP .B \fB-e\fP Echo SQL input (usually in \fIoutputfile\fP) .TP .B \fB-E\fP \fIeditor\fP Specify an \fIeditor\fP to invoke. Defaults to vi. .TP .B \fB-F\fP FIPS mode ON. Server returns a message (but processes the query anyway) when it encounters a non-standard SQL command. .TP .B \fB-g\fP Display a brief help message .TP .B \fB-h\fP \fIheaders\fP Number of rows after which to repeat the column \fIheaders\fP. Default is once per resultset. .TP .B \fB-H\fP \fIhostname\fP Hostname of the client machine as it will be told to the \fIserver\fP. .TP .B \fB-I\fP \fIinterfaces_file\fP Name of the interfaces or freetds.conf file to use. .TP .B \fB-i\fP \fIinputfile\fP Name of script file, containing SQL. .TP .B \fB-J\fP \fIclient_charset\fP Not implemented. .TP .B \fB-l\fP \fIlogin_timeout\fP How long to wait for the \fIserver\fP to acknowledge a login attempt. .TP .B \fB-m\fP \fIerrorlevel\fP For errors of the severity level specified or higher, print only the message number, state, and error level. Below that level, print nothing. .TP .B \fB-n\fP Suppress line numbers in echoed output. .TP .B \fB-o\fP \fIoutputfile\fP Name of output file, holding result data. .TP .B \fB-p\fP Prints performance statistics. Not implemented. .TP .B \fB-P\fP \fIpassword\fP Database \fIserver\fP \fIpassword\fP. .TP .B \fB-s\fP \fIcolseparator\fP The column separator. Default is space. Shell metacharacters require quoting. .TP .B \fB-S\fP \fIserver\fP Database \fIserver\fP to which to connect. .TP .B \fB-t\fP \fItimeout\fP The query \fItimeout\fP, in seconds. How long to wait for a query to be processed. The default is indefinitely, or as determined by freetds.conf. .TP .B \fB-U\fP \fIusername\fP Database \fIserver\fP login name. .TP .B \fB-v\fP Display version and copyright. .TP .B \fB-w\fP \fIwidth\fP How many characters wide to print the output. Defaults to 80. .TP .B \fB-X\fP Use encrypted login. Not implemented in FreeTDS. .TP .B \fB-y\fP \fIsybase_dir\fP Sets the SYBASE environment variable. Not used by FreeTDS. .TP .B \fB-Y\fP Use chained transactions. .TP .B \fB-z\fP \fIlanguage\fP Name of a \fIlanguage\fP for \fBfisql\fP's prompts and messages. Cf. DBSETLNATLANG. .SH NOTES \fBfisql\fP is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The \fB-i\fP, \fB-o\fP, and \fB-e\fP options override these, of course. .PP \fBfisql\fP uses the db-lib 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. .SH EXIT STATUS \fBfisql\fP exits 0 on success, and >0 if the \fIserver\fP cannot process the query. .PP \fBfisql\fP will report any errors returned by the \fIserver\fP, 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 \fBexit\fP(3). .SH HISTORY \fBfisql\fP first appeared in FreeTDS 0.65. .SH AUTHORS The \fBfisql\fP utility was written by Nicholas S. Castellano , who contributed it to the FreeTDS project under the terms of the GPL. .SH BUGS Requires the GNU readline library. freetds-0.91/doc/freetds.conf.5100664 001750 000144 00000014474 11311307243 0012017.\" $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 5 . .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 .Rs .%B FreeTDS User Guide .Re . .Sh HISTORY \.conf files first appeared with version 0.53 of FreeTDS. freetds-0.91/doc/freebcp.txt100664 001750 000144 00000013264 11537233770 0011531NAME freebcp - bulk loading utility for Sybase and Microsoft databases SYNOPSIS freebcp [[database.]owner.]object_name {in | [query]out} datafile { -c | -n | -f formatfile } [-b batchsize] [-F firstrow] [-L lastrow] [-e errfile] [-I interfaces] [-m maxerrors] [-t field_term] [-r row_term] [-h hints] [-T textsize] [-A packet_size] [-O options] [-S servername] [-U username] [-P password] [-EdVv] DESCRIPTION freebcp is a utility program distributed with FreeTDS. freebcp replicates (in part at least) the functionality of the "bcp" utility programs distributed by Sybase and Microsoft. freebcp makes use of the db-lib bcp API provided by FreeTDS. This API is also available to application developers. The manual pages or online help for Sybase or SQL Server can be referenced for more detailed information on "bcp" functionality. TABLES AND FILES database The database of the object being copied. Optional if the table/view is in the default database for username. owner The owner of the object being copied. Optional if username or the database owner is the owner of the table. object_name Usually, object_name is the name of the database table you wish to access. It can also be a view (and, subject to constraints, it is sometimes possible to load a view). It can also be an SQL query, cf. queryout, below. in | [query]out The direction of the bulk copy operation. 'in' indicates data are to be copied from a host file into a database table; 'out' indicates data are to be copied from a database table to a host file. 'queryout' indicates that table_name is in fact a query, rather than a database object. freebcp 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.) datafile The name of an operating system file. OPTIONS -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 freetds.conf. -n The host data file is in "native" format. This is a format that freebcp will be able to process, but is not portable or readable. -f formatfile The format of the host data file is described by formatfile. The layout of formatfile is identical to that understood by the Sybase and Microsoft bcp utilities, but is too complicated to describe here. -b 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 'committed' into the database. The default value for batchsize is 1000. -F firstrow The first row to copy from the input file or database table. The default is the first row, row 1. -L lastrow The last row to copy from an input file or database table. The default is the last row. -r row_term The row terminator for a character file. May be more than one character. Default is newline ('\\n'). Cf. -c, above. -t 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. -c, above. -m maxerrors Stop after encountering maxerror errors. Default 10. -e errfile Write errors to error_file. For uploads. Includes line and column information, and the row data. -S servername The name of the Database Server to which to connect. -U username A database login name. If username is not provided, a domain login is attempted for TDS 7+ connections. -P password A database password. -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. -d Turn off any logging. (Unintuitive, perhaps.) -O options SQL text to set connection options prior to the bcp operation. If options is a valid filename, the SQL is read from the file instead. Sometimes needed for queryout. Example: "-O 'SET QUOTED_IDENTIFIER ON'" -I interfaces The name and location of the interfaces file to search when connecting to servername. Overrides freetds.conf. -h hints Set bcp hints. For valid values, cf. bcp_options() in the FreeTDS Reference Manual. -T textsize For text or image columns, set the maximum number of characters to request from the server. Defaults to the setting in freetds.conf. If not specified anywhere, defaults to the full size of the data. -A 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. -v -V Print the version information and exit. ENVIRONMENT DSQUERY default servername 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.1 protocol is required. Theoretically both Sybase and Microsoft support the TDS 4.2 protocol, but in reality they implement the bcp portion of TDS 4.2 differently. FreeTDS has no way of knowing which type of server it's connected to, hence TDS protocol 4.2 is not supported. HISTORY freebcp first appeared in FreeTDS 0.60 AUTHORS The freebcp utility was written by Bill Thompson (thompbil@exchange.uk.ml.com) BUGS Currently, there is no support for text data types in freebcp, when SQL Server 2000 is the target database. freetds-0.91/doc/tsql.txt100664 001750 000144 00000005506 11537233770 0011106NAME tsql - utility to test FreeTDS connections and queries SYNOPSIS tsql { -S servername [-I interface] | -H hostname -p port } -U username [-P password] [-o options] tsql -C DESCRIPTION tsql is a diagnostic tool provided as part of FreeTDS. It uses the TDS protocol directly to connect to Sybase or Microsoft SQL Servers, and allows the user to issue queries that test the capabilities of FreeTDS. tsql is *not* a replacement for a complete isql, such as sqsh (www.sqsh.org). It is designed to rely on the lowest level FreeTDS library, tdslib, as a way to isolate potential bugs in the protocol implementation. tsql can be run in two ways, one which uses the freetds.conf and one which connects directly using the server's hostname and port. When -S is used, FreeTDS uses the freetds.conf (or equivalent) and environment variables in the normal way to determine the server's ip address and port. You can use -I to specify a filename, overriding FreeTDS's configuration file search algorithm. The -H and -p parameters are provided especially for troubleshooting new configurations (or servers). Use of these parameters causes FreeTDS to ignore any freetds.conf and environment variables. OPTIONS -S servername the Database Server to which to connect. -I interface a freetds.conf or interfaces file describing servername -H hostname the DNS hostname of the server -p port the port at which SQL Server is listening -U username database login name. If username is not provided, a domain login is attempted for TDS 7+ connections. -P password database password. -L list server "instances" (with -H) -C prints some of the compile-time configuration parameters. -o options apply the options specified to every command. f No footer [result count] h No header [titles] t Print time v Print version q Quiet NOTES Typing "exit", "quit", or "bye" (or ^D) exits tsql. Typing "version" displays the TDS protocol version. Command batches may be separated with "go" or "GO". If "GO", the version string is reported before executing the batch. After prompting for the password, tsql will attempt to connect to the remote server. tsql displays a counter indicating the number of seconds that it is attempting to connect. Typically, tsql should immediately respond with a '1>' prompt. If you see the counter (1, 2, 3, ...), most likely tsql is unable to connect to the indicated server. If you can connect with "tsql -S servername", your basic FreeTDS installation is working. If you have suggestions for ways to make tsql more useful as a diagnostic tool, please recommend them to the FreeTDS mailing list for consideration. HISTORY tsql first appeared in FreeTDS 0.60. AUTHORS The tsql utility was written by Brian Bruns. BUGS Several, to be sure, now that it's documented. :) freetds-0.91/doc/osql.txt100664 001750 000144 00000003152 10731317746 0011075NAME osql - utility to test FreeTDS connections and queries SYNOPSIS osql -S dsn -U username -P password [-I ini_dir] DESCRIPTION osql 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. osql works only with the isql that comes with unixODBC. OPTIONS -S dsn the Data Source Name to which to connect, as known to odbc.ini. -U username database login name. -P password database password. -I ini_dir override odbc.ini file location. EXAMPLE If you have an odbc.ini with a section like this: [myDSN] servername = myserver TDS_Version = 5.0 You would invoke osql as: osql -S myDSN [...] NOTES If you can connect with "osql -S servername -U user -P passwd", your FreeTDS ODBC installation is working. osql guesses where unixODBC might look for its 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. If osql cannot intuit your odbc.ini directory, you can force the issue with the -I option. However, you're instructing osql 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. If you have suggestions for ways to make osql more useful as a diagnostic tool, please post them to the FreeTDS mailing list. HISTORY osql first appeared in FreeTDS 0.65. AUTHORS The osql utility was written by James K. Lowden freetds-0.91/doc/fisql.txt100664 001750 000144 00000007171 11471366602 0011237NAME fisql - interactive SQL shell SYNOPSIS fisql [-e] [-F] [-g] [-p] [-n] [-v] [-X] [-Y] \[a] [-a display_charset] [-c cmdend] \[a] [-D database] [-E editor] \[a] [-h headers] [-H hostname] [-i inputfile] \[a] [-I interfaces_file] [-J client_charset] \[a] [-l login_timeout] [-m errorlevel] \[a] [-o outputfile] \[a] [-P password] [-s colseparator] [-S server] \[a] [-t timeout] [-U username] [-w width] \[a] [-y sybase_dir] [-z language] DESCRIPTION fisql is very similar to 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. OPTIONS -a display_charset The client charset name. Not implemented. -c cmdend Command terminator, defaults to go. -D Database name on the server to use. -e Echo SQL input (usually in outputfile) -E editor Specify an editor to invoke. Defaults to vi. -F FIPS mode ON. Server returns a message (but processes the query anyway) when it encounters a non-standard SQL command. -g Display a brief help message -h headers Number of rows after which to repeat the column headers. Default is once per resultset. -H hostname Hostname of the client machine as it will be told to the server. -I interfaces_file Name of the interfaces or freetds.conf file to use. -i inputfile Name of script file, containing SQL. -J client_charset Not implemented. -l login_timeout How long to wait for the server to acknowledge a login attempt. -m errorlevel For errors of the severity level specified or higher, print only the message number, state, and error level. Below that level, print nothing. -n Suppress line numbers in echoed output. -o outputfile Name of output file, holding result data. -p Prints performance statistics. Not implemented. -P password Database server password. -s colseparator The column separator. Default is space. Shell metacharacters require quoting. -S server Database server to which to connect. -t 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. -U username Database server login name. -v Display version and copyright. -w width How many characters wide to print the output. Defaults to 80. -X Use encrypted login. Not implemented in FreeTDS. -y sybase_dir Sets the SYBASE environment variable. Not used by FreeTDS. -Y Use chained transactions. -z language Name of a language for fisql's prompts and messages. Cf. DBSETLNATLANG. NOTES fisql is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The -i, -o, and -e options override these, of course. fisql uses the db-lib 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 fisql exits 0 on success, and >0 if the server cannot process the query. fisql 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). HISTORY fisql first appeared in FreeTDS 0.65. AUTHORS The fisql utility was written by Nicholas S. Castellano , who contributed it to the FreeTDS project under the terms of the GPL. BUGS Requires the GNU readline library. freetds-0.91/doc/bsqldb.txt100664 001750 000144 00000005745 11537233770 0011377NAME bsqldb - batch SQL script processor using DB-Library SYNOPSIS bsqldb [-U username] [-P password] [-S servername] [-D database] [-i input_file] [-o output_file] [-e error_file] [-H hostname] [-t field_term] [-hqv] DESCRIPTION bsqldb is a utility program distributed with FreeTDS. bsqldb is 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 DB-Library API provided by FreeTDS. This API is of course also available to application developers. OPTIONS -U username Database server login name. If username is not provided, a domain login is attempted for TDS 7+ connections. -P password Database server password. -S servername Database server to which to connect. -D database Database to use. -i input_file Name of script file, containing SQL. -o output_file Name of output file, holding result data. -e error_file Name of file for errors. -t field_term Specifies the field terminator. Default is two spaces (' '). Recognized escape sequences are tab ('\\t'), carriage return ('\\r'), newline ('\\n'), and backslash ('\\\\'). -h Print column headers with the data to the same file. -H hostname Override name of client sent to server. -q Do not print column metadata, return status, or rowcount. Overrides -h. -v Verbose mode, for more information about the DB-Libraryrary interaction. This also reports the result set metadata, including and return code. All verbose data are written to standard error (or -e), so as not to interfere with the data stream. ENVIRONMENT DSQUERY default servername NOTES bsqldb is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The -i, -o, and -e options override these, of course. The source code for bsqldb 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 are using it in this way and find something unclear, you are encouraged to email the author your comments. EXIT STATUS bsqldb exits 0 on success, and >0 if the server cannot process the query. bsqldb 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). HISTORY bsqldb first appeared in FreeTDS 0\.63. AUTHORS The bsqldb utility was written by James K. Lowden BUGS Microsoft servers as of SQL Server 7.0 SP 3 do not return output parameters unless the RPC functions are used. This means bsqldb cannot return output parameters for stored procedures with these servers. freetds-0.91/doc/bsqlodbc.txt100664 001750 000144 00000003741 10731317746 0011714NAME bsqlodbc - batch SQL script processor using ODBC SYNOPSIS bsqlodbc [-U username] [-P password] [-S server] [-D database] [-i input_file] [-o output_file] [-e error_file] [-t field_term] [-qv] DESCRIPTION bsqlodbc is a utility program distributed with FreeTDS. bsqlodbc is 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". bsqlodbc makes use of the ODBC API provided by FreeTDS. This API is of course also available to application developers. OPTIONS -U username Database server login name. -P password Database server password. -S server Database server to which to connect. -D database Database to use. -i input_file Name of script file, containing SQL. -o output_file Name of output file, holding result data. -e error_file Name of file for errors. -t field_term Specifies the field terminator. Default is two spaces (' '). Recognized escape sequences are tab ('\\t'), carriage return ('\\r'), newline ('\\n'), and backslash ('\\\\'). -h Print column headers with the data to the same file. -q Do not print column metadata, return status, or rowcount. Overrides -h. -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 -e), so as not to interfere with the data stream. NOTES bsqlodbc is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The -i, -o, and -e options override these, of course. EXIT STATUS bsqlodbc exits 0 on success, and >0 if the server cannot process the query. HISTORY bsqlodbc first appeared in FreeTDS 0.65. AUTHORS The bsqlodbc utility was written by James K. Lowden freetds-0.91/doc/defncopy.txt100664 001750 000144 00000004455 10554334064 0011730NAME defncopy - extract procedures and views from a Microsoft server. SYNOPSIS defncopy [-U username] [-P password] [-S server] [-D database] [-i input_file] [-o output_file] [-v] [owner.]object_name [[owner.]object_name...] DESCRIPTION defncopy is a utility program distributed with FreeTDS. It 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. OBJECTS owner is optional if you or the database owner is the owner of the procedure/view being copied. object_name is the name of the system object you wish to extract. OPTIONS -U username database server login name. -P password database server password. -S server database server to which to connect. -D database database to use. Optional if the procedure/view being extracted is in your default database. -i input_file a script to apply to the database. Not currently implemented. -o output_file a file to hold the script, defaults to standard output. -v Show version information and copyright notice. NOTES defncopy is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The -i and -o options override these, of course. defncopy makes use of the db-lib API provided by FreeTDS. This API is of course also available to application developers. EXIT STATUS defncopy exits 0 on success, and >0 if the server cannot process the query. defncopy will report any errors returned by the server, but will continue processing. HISTORY defncopy first appeared in FreeTDS 0.63. AUTHORS The defncopy utility was written by James K. Lowden 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, defncopy could apply/produce DDL for any system object, but at present only tables, procedures and views are supported, and only for extraction. freetds-0.91/doc/datacopy.txt100664 001750 000144 00000004471 10263265316 0011723NAME datacopy - move table data between two servers SYNOPSIS datacopy { -t | -a | -c owner } [-b batchsize] [-p packetsize] [-v] [-d] [-S server/username/password/database/table_or_view] [-D server/username/password/database/table] DESCRIPTION datacopy is a utility distributed with FreeTDS. 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 db-lib bcp API built into FreeTDS. This API is also available to application developers. datacopy can be used to migrate data between Sybase ASE and SQL Server or vice versa. OPTIONS -t Truncate target table before loading data. -a Append data to target table. -c owner Create the target table with the same schema as the source table. datacopy will submit a 'create table' command on the target server/database using the specified owner in the command, e.g. CREATE TABLE owner\.table (...). -b batchsize The number of rows per batch of data copied. Each batch of data is effectively 'committed' to the database. The default is 1000. -p packetsize The number of bytes, per network packet, sent to and from the servers. Increased packet size can enhance performance. -v Produce verbose output, including diagnostic timings. -d Produce freetds TDSDUMP output. (Serious debug only!) -S 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, datacopy will prompt the user for the information. -D server/username/password/database/table The connection information for the destination server and the location/name of the target table. If not specified, datacopy will prompt the user for the information. SEE ALSO freebcp(1), defncopy(1), bsqldb(1), tsql(1), FreeTDS User Guide. HISTORY datacopy first appeared in FreeTDS 0.64. AUTHORS The datacopy utility was written by Bill Thompson (thompbil@exchange.uk.ml.com). freetds-0.91/doc/images/CVS/Root100664 001750 000144 00000000073 11550062420 0012105:ext:jklowden@freetds.cvs.sourceforge.net:/cvsroot/freetds freetds-0.91/doc/images/CVS/Repository100664 001750 000144 00000000023 11550062420 0013334freetds/doc/images freetds-0.91/doc/images/CVS/Entries100664 001750 000144 00000000455 11550062525 0012605/caution.gif/1.1/Mon Dec 10 05:13:11 2007//TBranch-0_91 /important.gif/1.1/Mon Dec 29 13:57:52 2003/-kb/TBranch-0_91 /note.gif/1.1/Mon Dec 29 13:57:52 2003/-kb/TBranch-0_91 /tip.gif/1.1/Mon Dec 29 13:57:52 2003/-kb/TBranch-0_91 /warning.gif/1.1/Mon Dec 10 05:13:11 2007//TBranch-0_91 D/callouts//// D freetds-0.91/doc/images/CVS/Tag100664 001750 000144 00000000015 11550062421 0011672TBranch-0_91 freetds-0.91/doc/images/callouts/CVS/Root100664 001750 000144 00000000073 11550062421 0013734:ext:jklowden@freetds.cvs.sourceforge.net:/cvsroot/freetds freetds-0.91/doc/images/callouts/CVS/Repository100664 001750 000144 00000000034 11550062421 0015165freetds/doc/images/callouts freetds-0.91/doc/images/callouts/CVS/Entries100664 001750 000144 00000000767 11550062422 0014435/1.gif/1.1/Mon Dec 10 05:13:11 2007//TBranch-0_91 /10.gif/1.1/Mon Dec 10 05:13:11 2007//TBranch-0_91 /2.gif/1.1/Mon Dec 10 05:13:12 2007//TBranch-0_91 /3.gif/1.1/Mon Dec 10 05:13:12 2007//TBranch-0_91 /4.gif/1.1/Mon Dec 10 05:13:12 2007//TBranch-0_91 /5.gif/1.1/Mon Dec 10 05:13:12 2007//TBranch-0_91 /6.gif/1.1/Mon Dec 10 05:13:13 2007//TBranch-0_91 /7.gif/1.1/Mon Dec 10 05:13:13 2007//TBranch-0_91 /8.gif/1.1/Mon Dec 10 05:13:13 2007//TBranch-0_91 /9.gif/1.1/Mon Dec 10 05:13:13 2007//TBranch-0_91 D freetds-0.91/doc/images/callouts/CVS/Tag100664 001750 000144 00000000015 11550062422 0013521TBranch-0_91 freetds-0.91/doc/images/callouts/1.gif100664 001750 000144 00000001602 10727145347 0013277GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, _ÿý»G)98Ýøï\ ¤€ãÜÀ‡9ƒ Æ=F•œ»·‘##ŒK•¤ˆ€#N+#¶äÓ%”/cÆI3&£{(Õâè±áD—- ü‚”þ ;freetds-0.91/doc/images/callouts/10.gif100664 001750 000144 00000001646 10727145347 0013367GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, ƒÿ 䔄Œî ü÷. ¤€ÛÀjÕJá­×9))î• ñîŸÆZæxÀHIDgµ¬Íã_ˆÀ¼7†sÂ|×3P.uÖrF@Žb” ”‘5”œ±<Ú‹„^÷¬ÅÉ0Uªp\øF‰”þ ;freetds-0.91/doc/images/callouts/2.gif100664 001750 000144 00000001623 10727145350 0013275GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, pÿý»G)98Ýøï\ R„€ãÜÀ‡!¬{g €÷A,e @ˆ=ÀhDoµ("€HäˆfÒTr®–N+YÞsYS$€5÷ÆÄˆ!彇œÎI=çdà5- #gJ ÿ;freetds-0.91/doc/images/callouts/3.gif100664 001750 000144 00000001632 10727145350 0013276GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///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-0.91/doc/images/callouts/4.gif100664 001750 000144 00000001623 10727145350 0013277GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, pÿ l%%E %¥ ¼§€Ãä8'°¡C%ÿæ8Ìq¯•C(jtHÉ"€V¥ÞƒC-ç Ü[‰Àe•)î1r AÃ1 –rcèG3?2º—㨷5ïý{×ô(€ÞÞã‚K;freetds-0.91/doc/images/callouts/5.gif100664 001750 000144 00000001627 10727145350 0013304GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, tÿ 䔄Œî ü÷.‚)B¤@ÛÀr0|÷N €÷JÈøÁÈ“Œ<’låŒI10ŒÔHHÉ9N#È‚ÐHFïrª„ e$¥s#cˆ„ùOIo”~þÀл>*l˜óe ‹ )9¤˜P`@;freetds-0.91/doc/images/callouts/6.gif100664 001750 000144 00000001635 10727145351 0013305GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, zÿ l%%E %¥ ¼§ )æ8'°!€RïÎC ǽVç¼Ã€á]‡”,+•"G‡108<÷ΙMÈàÍïæä´Ø«”Cg„`°æ]ˆ 2ºw¥{÷’HqïŸÉœ/SxSx“K1¦ ;freetds-0.91/doc/images/callouts/7.gif100664 001750 000144 00000001616 10727145351 0013305GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, kÿ ¬%%E %­î üwO  !@ÈqN ­þ³ ƽ^B†Äpî"J&EÖ2G ‘¤Ü{ÍÖjÁD2Ç?)0cè É蘌þ) YkhÈ ß ù´âBN9 HQT`@;freetds-0.91/doc/images/callouts/8.gif100664 001750 000144 00000001633 10727145351 0013305GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, xÿ l%%E)¥ |§!æ8'PˆÃRÞ¬õ‚ ƽR•ÜãxnŽCJ ‰à݇108Pë\FÈ åž%.s¦,ÕËa«¢A˜óÎà9B'ÿYD@éÜ;J8=þc8sfŽw ÿ•R"„„;freetds-0.91/doc/images/callouts/9.gif100664 001750 000144 00000001637 10727145351 0013312GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, |ÿ l%%E)­î üwO <ÌñN ZY;Wjâ½VçxC€áž–‡”.(€µŽr`x¸gdÉ^I>„Ðëݹsµr:̉5JcÀr/„’92º@«ïÖ>>???@@@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-0.91/doc/images/tip.gif100664 001750 000144 00000002005 07774031340 0012076GIF87a÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///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-0.91/doc/images/warning.gif100664 001750 000144 00000002034 10727145347 0012756GIF87a÷!)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-0.91/doc/images/important.gif100664 001750 000144 00000002071 07774031340 0013322GIF87a÷)))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-0.91/doc/images/caution.gif100664 001750 000144 00000002017 10727145347 0012754GIF87a÷!!11BBZZcckkss{{„„„„sŒŒŒŒsŒŒŒ””””s””{œœœœsœœ{œœ”œœœ¥¥¥¥c¥¥œ¥¥¥µµµµZµµcµµµ½½½½cÎÎÎÎÎÖÖÖÖÎÖÖÖÞÞÞÞ1ÞÞ9ÞÞBçççç1çç9çççïïïïï÷÷÷÷÷÷÷÷1÷÷÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,ôuH° Áƒ_Ä@È ‰6DHB $N$ø¢Á 4>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-0.91/doc/grep_sample_code100775 001750 000144 00000000767 10727145347 0012606#! /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-0.91/doc/tds_ssl.html100664 001750 000144 00000023002 11244772137 0011712 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-0.91/samples/README100664 001750 000144 00000000224 07361702256 0011131The 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-0.91/samples/Makefile.am100664 001750 000144 00000001157 10501770765 0012313# 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-0.91/samples/Makefile.in100664 001750 000144 00000027726 11623070617 0012331# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SCRIPTS = $(noinst_SCRIPTS) SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 .PRECIOUS: 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 TAGS: ctags: CTAGS CTAGS: 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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 \ 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 uninstall uninstall-am 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-0.91/samples/debug.c100664 001750 000144 00000003314 07361702256 0011506/* 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-0.91/samples/dyntest.c100664 001750 000144 00000007516 07400241153 0012106#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-0.91/samples/odbc.ini100664 001750 000144 00000000460 07577433237 0011674; ; 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-0.91/samples/odbctest.php100664 001750 000144 00000001050 07361702256 0012567 freetds-0.91/samples/odbctest.pl100664 001750 000144 00000001020 10224335055 0012377#!/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-0.91/samples/test.php100664 001750 000144 00000000453 07361702256 0011745 \n"; } ?> freetds-0.91/samples/test.pl100664 001750 000144 00000001134 10141722522 0011552#!/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-0.91/samples/unixodbc.freetds.driver.template.in100664 001750 000144 00000002025 10501770765 0017154# # $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-0.91/samples/unixodbc.install.sh100775 001750 000144 00000002607 07551060750 0014074#! /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-0.91/samples/unixodbc.jdbc.datasource.template100664 001750 000144 00000002031 07551060750 0016646# # $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-0.91/win32/initnet.c100664 001750 000144 00000002134 10660767455 0011377#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; break; case DLL_PROCESS_DETACH: #if defined(_MSC_VER) && defined(_DEBUG) _CrtDumpMemoryLeaks(); #endif break; } return TRUE; } #endif freetds-0.91/win32/winlogin.c100664 001750 000144 00000012542 11437410512 0011535/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tds.h" #include "tdsodbc.h" #include "tdsstring.h" #include "tdsconvert.h" #include "replacements.h" #include #ifdef DMALLOC #include #endif /* 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 TDSCONNECTION struct */ static BOOL CALLBACK LoginDlgProc(HWND hDlg, UINT message, WPARAM wParam, /* */ LPARAM lParam) { TDSCONNECTION *connection; char tmp[100]; switch (message) { case WM_INITDIALOG: /* lParam points to the TDSCONNECTION */ connection = (TDSCONNECTION *) lParam; SetWindowUserData(hDlg, lParam); /* copy info from TDSCONNECTION to the dialog */ SendDlgItemMessage(hDlg, IDC_LOGINSERVER, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&connection->server_name)); SendDlgItemMessage(hDlg, IDC_LOGINUID, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&connection->user_name)); SendDlgItemMessage(hDlg, IDC_LOGINPWD, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&connection->password)); SendDlgItemMessage(hDlg, IDC_LOGINDUMP, BM_SETCHECK, !tds_dstr_isempty(&connection->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 TDSCONNECTION */ connection = (TDSCONNECTION *) 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(&connection->user_name, tmp); SendDlgItemMessage(hDlg, IDC_LOGINPWD, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); tds_dstr_copy(&connection->password, tmp); if (SendDlgItemMessage(hDlg, IDC_LOGINDUMP, BM_GETCHECK, 0, 0)) { char * filename = get_desktop_file("FreeTDS.log"); if (filename) { tds_dstr_copy(&connection->dump_file, filename); free(filename); } } else { tds_dstr_copy(&connection->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 TDSCONNECTION * structure and return TRUE. If the user hits [CANCEL] then return FALSE. * \param hwndParent parent for dialog * \param connection where to store login info */ BOOL get_login_info(HWND hwndParent, TDSCONNECTION * connection) { return DialogBoxParam(hinstFreeTDS, MAKEINTRESOURCE(IDD_LOGIN), hwndParent, (DLGPROC) LoginDlgProc, (LPARAM) connection); } freetds-0.91/win32/winsetup.c100664 001750 000144 00000030640 11437410512 0011564/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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 "tds.h" #include "tdsodbc.h" #include "tdsstring.h" #include "tdsconvert.h" #include "replacements.h" #include #ifdef DMALLOC #include #endif typedef struct { DSTR origdsn; /**< original name of the data source */ DSTR dsn; /**< edited name of the data source */ TDSCONNECTION *connection; /**< 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->connection = tds_alloc_connection(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_connection(di->connection); 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->connection, 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->connection->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->connection->port); WRITESTR("Port", tmp); sprintf(tmp, "%d.%d", TDS_MAJOR(di->connection), TDS_MINOR(di->connection)); WRITESTR("TDS_Version", tmp); sprintf(tmp, "%u", di->connection->text_size); WRITESTR("TextSize", tmp); sprintf(tmp, "%u", di->connection->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->connection) && !IS_TDS46(di->connection) && !IS_TDS50(di->connection) && !IS_TDS7_PLUS(di->connection)) return "Bad Protocol version"; if (tds_dstr_isempty(&di->connection->server_name)) return "Address is required"; if (di->connection->port < 1 || di->connection->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", 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->connection), TDS_MINOR(di->connection)); SendDlgItemMessage(hDlg, IDC_PROTOCOL, CB_SELECTSTRING, -1, (LPARAM) tmp); SendDlgItemMessage(hDlg, IDC_ADDRESS, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&di->connection->server_name)); sprintf(tmp, "%u", di->connection->port); SendDlgItemMessage(hDlg, IDC_PORT, WM_SETTEXT, 0, (LPARAM) tmp); SendDlgItemMessage(hDlg, IDC_DATABASE, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&di->connection->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->connection->tds_version = (major << 8) | minor; } SendDlgItemMessage(hDlg, IDC_ADDRESS, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); tds_dstr_copy(&di->connection->server_name, tmp); SendDlgItemMessage(hDlg, IDC_PORT, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); di->connection->port = atoi(tmp); SendDlgItemMessage(hDlg, IDC_DATABASE, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); tds_dstr_copy(&di->connection->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 connection 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-0.91/win32/Makefile.am100664 001750 000144 00000000464 11444375411 0011605SUBDIRS = msvc6 EXTRA_DIST = config.h FreeTDS.def FreeTDS_w.def initnet.c \ tds_sysdep_public.h freetds_sysconfdir.h \ winsetup.c winlogin.c \ setup.rc resource.h \ version.rc version.rc.in \ freetds.nsh freetds.nsh.in \ installfreetds.bat freetds.nsi \ dblib.def CLEANFILES = setup.res freetds-0.91/win32/Makefile.in100664 001750 000144 00000045754 11623070620 0011622# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/freetds.nsh.in $(srcdir)/version.rc.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = version.rc freetds.nsh CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-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 uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) 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@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 = msvc6 EXTRA_DIST = config.h FreeTDS.def FreeTDS_w.def initnet.c \ tds_sysdep_public.h freetds_sysconfdir.h \ winsetup.c winlogin.c \ setup.rc resource.h \ version.rc version.rc.in \ freetds.nsh freetds.nsh.in \ installfreetds.bat freetds.nsi \ dblib.def CLEANFILES = setup.res 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 win32/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu win32/Makefile .PRECIOUS: 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)/$@ 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 # 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. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; 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" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) 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; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" 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 \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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-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: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic clean-libtool \ ctags ctags-recursive 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-recursive \ uninstall uninstall-am # 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-0.91/win32/freetds.nsh.in100664 001750 000144 00000000044 10047747615 0012325!define PRODUCT_VERSION "@VERSION@" freetds-0.91/win32/version.rc.in100664 001750 000144 00000002356 11327324613 0012171 #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-2010 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-0.91/win32/config.h100664 001750 000144 00000017367 11460370275 0011202/* include/config.h. Generated by configure. */ /* include/config.h.in. Generated from configure.ac by autoheader. */ /* 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 */ /* Defined if --enable-krb5 used and library detected */ /* #undef ENABLE_KRB5 */ /* Define to enable ODBC wide string support */ #define ENABLE_ODBC_WIDE 1 /* 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 `atoll' function. */ #define HAVE_ATOLL 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_DLFCN_H */ /* 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 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 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 `gethostname' function. */ #define HAVE_GETHOSTNAME 1 /* 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 the iconv() function. */ /* #undef HAVE_ICONV */ /* Define to 1 if you have a 64-bit integral type. */ #define HAVE_INT64 1 /* 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_LIMITS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LOCALE_H 1 /* 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. */ /* #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_ODBCSS_H */ /* Define to 1 if you have the header file. */ /* #undef HAVE_PATHS_H */ /* Define to 1 if you have the GNU Readline library. */ /* #undef HAVE_READLINE */ /* Define to 1 if you have the SQLGetPrivateProfileString function. */ #define HAVE_SQLGETPRIVATEPROFILESTRING 1 /* Define if sqltypes.h define SQLLEN */ #define HAVE_SQLLEN 1 /* 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 */ /* Defined if --enable-sspi and SSPI detected */ #define HAVE_SSPI 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_STRINGS_H */ /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the `strtok_r' function. */ /* #undef HAVE_STRTOK_R */ /* 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. */ /* #define HAVE_SYS_SOCKET_H 1 */ /* Define to 1 if you have the header file. */ /* #undef HAVE_SYS_STAT_H */ /* Define to 1 if you have the header file. */ #ifdef __GNUC__ # define HAVE_SYS_TIME_H 1 #endif /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_UNISTD_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 `_vsnprintf' function. */ #define HAVE__VSNPRINTF 1 /* Define as const if the declaration of iconv() needs const. */ #define ICONV_CONST const /* 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. */ #define NETDB_REENTRANT 1 /* Name of package */ #define PACKAGE "freetds" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define PACKAGE_NAME "FreeTDS" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "" /* Define to the version of this package. */ #define PACKAGE_VERSION "" /* The size of `char', as computed by sizeof. */ #define SIZEOF_CHAR 1 /* The size of `double', as computed by sizeof. */ #define SIZEOF_DOUBLE 8 /* The size of `float', as computed by sizeof. */ #define SIZEOF_FLOAT 4 /* The size of `int', as computed by sizeof. */ #define SIZEOF_INT 4 /* The size of `long', as computed by sizeof. */ #define SIZEOF_LONG 4 /* The size of `long long', as computed by sizeof. */ #define SIZEOF_LONG_LONG 0 /* The size of `short', as computed by sizeof. */ #define SIZEOF_SHORT 2 /* The size of `SQLWCHAR', as computed by sizeof. */ #define SIZEOF_SQLWCHAR 2 /* The size of `wchar_t', as computed by sizeof. */ #define SIZEOF_WCHAR_T 2 /* The size of `__int64', as computed by sizeof. */ #define SIZEOF___INT64 8 /* Define to 1 if you want to use SSPI for Win32 */ #define HAVE_SSPI 1 /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define to 1 if you can safely include both and . */ #ifdef __GNUC__ # define TIME_WITH_SYS_TIME 1 #else # define TIME_WITH_SYS_TIME 0 #endif /* define to format string used for 64bit integers */ #define TDS_I64_FORMAT "I64d" /* Version number of package */ #define VERSION "0.83.dev" /* 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 # define _GNU_SOURCE 1 #endif #undef HAVE_ODBCSS_H #ifdef _MSC_VER #define HAVE_ODBCSS_H 1 #endif #define TDS42 1 #ifdef _MSC_VER #define inline __inline #endif #include #include typedef SSIZE_T ssize_t; freetds-0.91/win32/FreeTDS.def100664 001750 000144 00000002514 11424513320 0011452EXPORTS 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 DllRegisterServer DllUnregisterServer SQLGetTypeInfoW = SQLGetTypeInfo freetds-0.91/win32/FreeTDS_w.def100664 001750 000144 00000003443 11450327337 0012014EXPORTS 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 DllRegisterServer DllUnregisterServer 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 freetds-0.91/win32/tds_sysdep_public.h100644 001750 000144 00000003716 11623070342 0013434/* 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 _tds_sysdep_public_h_ #define _tds_sysdep_public_h_ static char rcsid_tds_sysdep_public_h[] = "$Id: tds_sysdep_public.h,v 1.8.2.1 2011/08/04 04:38:20 freddy77 Exp $"; static void *no_unused_tds_sysdep_public_h_warn[] = { rcsid_tds_sysdep_public_h, no_unused_tds_sysdep_public_h_warn }; #ifdef __cplusplus extern "C" { #endif #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 #if !defined(MSDBLIB) && !defined(SYBDBLIB) #define SYBDBLIB 1 #endif #if defined(MSDBLIB) && defined(SYBDBLIB) #error MSDBLIB and SYBDBLIB cannot both be defined #endif #ifdef __cplusplus } #endif #endif /* _tds_sysdep_public_h_ */ freetds-0.91/win32/freetds_sysconfdir.h100664 001750 000144 00000000040 07642775776 0013636#define FREETDS_SYSCONFDIR "c:" freetds-0.91/win32/setup.rc100664 001750 000144 00000010123 11330565770 0011233//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-0.91/win32/resource.h100664 001750 000144 00000001644 10047755400 0011550//{{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-0.91/win32/version.rc100664 001750 000144 00000002162 11623073515 0011560 #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 0,91,0,11229 PRODUCTVERSION 0,91,0,11229 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", "0, 91, 0, 11229\0" VALUE "InternalName", "FreeTDS\0" VALUE "LegalCopyright", "Copyright © 2004-2010 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", "0, 91, 0, 11229\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #endif // !_MAC freetds-0.91/win32/freetds.nsh100664 001750 000144 00000000037 11623073515 0011712!define PRODUCT_VERSION "0.91" freetds-0.91/win32/installfreetds.bat100664 001750 000144 00000001235 10045512221 0013245@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% %dest%\ODBCCONF INSTALLDRIVER "FreeTDS|Driver=FreeTDS.dll|Setup=FreeTDS.dll||" %dest%\ODBCCONF CONFIGDRIVER "FreeTDS" "APILevel=1" %dest%\ODBCCONF CONFIGDRIVER "FreeTDS" "ConnectFunctions=YYY" %dest%\ODBCCONF CONFIGDRIVER "FreeTDS" "DriverODBCVer=02.50" %dest%\ODBCCONF CONFIGDRIVER "FreeTDS" "FileUsage=0" %dest%\ODBCCONF CONFIGDRIVER "FreeTDS" "SQLLevel=1" %dest%\ODBCCONF CONFIGDRIVER "FreeTDS" "CPTimeout=60" freetds-0.91/win32/freetds.nsi100664 001750 000144 00000006632 11373073756 0011733; 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" !define ODBC_DRIVER_NAME "FreeTDS ODBC Driver" !define ODBC_REGKEY "SOFTWARE\ODBC\ODBCINST.INI\${ODBC_DRIVER_NAME}" !define ODBC_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 WriteRegStr ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" "Driver" "$SYSDIR\FreeTDS.dll" WriteRegStr ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" "APILevel" "2" WriteRegStr ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" "ConnectFunctions" "YYY" WriteRegStr ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" "CPTimeout" "60" WriteRegStr ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" "DriverODBCVer" "02.50" WriteRegStr ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" "FileUsage" "0" WriteRegStr ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" "Setup" "$SYSDIR\FreeTDS.dll" WriteRegStr ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" "SQLLevel" "1" ; tell that our driver is installed WriteRegStr "HKLM" "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" "${ODBC_DRIVER_NAME}" "Installed" 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 DeleteRegValue "HKLM" "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" "${ODBC_DRIVER_NAME}" DeleteRegKey ${ODBC_ROOT_KEY} "${ODBC_REGKEY}" Delete "$INSTDIR\uninst.exe" Delete "$SYSDIR\FreeTDS.dll" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" SetAutoClose true SectionEnd freetds-0.91/win32/dblib.def100664 001750 000144 00000001506 11444375411 0011303EXPORTS dbbind dbcancel dbcanquery dbclose dbclrbuf dbcmd dbcmdrow dbtablecolinfo dbcolinfo dbcollen dbcolname dbcolsource dbcoltype dbcoltypeinfo dbcolutype dbconvert dbcount dbcurcmd dbcurrow dbdata dbdatecmp dbdatecrack dbdatlen dbdead dberrhandle dbexit dbfcmd dbfirstrow dbfreebuf dbinit dbisavail dbiscount dbisopt dblastrow dblogin dbloginfree dbmorecmds dbmoretext dbmsghandle dbname dbnextrow dbnullbind dbnumalts dbnumcols dbnumcompute dbnumrets tdsdbopen dbopen dbprtype dbresults dbrows dbrowtype dbsetlname dbsetlversion dbsetlogintime dbsetopt dbsetrow dbsettime dbsetuserdata dbsetversion dbservcharset dbsqlexec dbsqlok dbsqlsend dbstrlen dbtds dbvarylen dbuse dbwillconvert freetds-0.91/win32/msvc6/Makefile.am100664 001750 000144 00000000153 11444375411 0012636EXTRA_DIST = FreeTDS.dsp FreeTDS.dsw iconv_replacement.c \ libTDS.dsp dblib.dsp dblib_dll.dsp libct.dsp freetds-0.91/win32/msvc6/Makefile.in100664 001750 000144 00000026561 11623070620 0012653# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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/msvc6 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 = FreeTDS.dsp FreeTDS.dsw iconv_replacement.c \ libTDS.dsp dblib.dsp dblib_dll.dsp libct.dsp 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/msvc6/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu win32/msvc6/Makefile .PRECIOUS: 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 TAGS: ctags: CTAGS CTAGS: 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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 \ 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 uninstall uninstall-am # 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-0.91/win32/msvc6/FreeTDS.dsp100664 001750 000144 00000013107 11432505625 0012550# Microsoft Developer Studio Project File - Name="FreeTDS" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=FreeTDS - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "FreeTDS.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "FreeTDS.mak" CFG="FreeTDS - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "FreeTDS - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "FreeTDS - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "FreeTDS - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "odbc_Release" # PROP BASE Intermediate_Dir "odbc_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "odbc_Release" # PROP Intermediate_Dir "odbc_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /I "../../include" /D "NOCRYPT" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /D "DLL_EXPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "FreeTDS - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "odbc_Debug" # PROP BASE Intermediate_Dir "odbc_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "odbc_Debug" # PROP Intermediate_Dir "odbc_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I ".." /I "../../include" /D "NOCRYPT" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /D "DLL_EXPORT" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tds_debug\libtds.lib /nologo /dll /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "FreeTDS - Win32 Release" # Name "FreeTDS - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\src\odbc\connectparams.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\convert_tds2sql.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\descriptor.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\error.c # End Source File # Begin Source File SOURCE=..\FreeTDS_w.def # End Source File # Begin Source File SOURCE=..\initnet.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\native.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\odbc.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\odbc_checks.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\odbc_util.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\prepare_query.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\sql2tds.c # End Source File # Begin Source File SOURCE=..\..\src\odbc\sqlwchar.c # End Source File # Begin Source File SOURCE=..\winlogin.c # End Source File # Begin Source File SOURCE=..\winsetup.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\..\include\tdsodbc.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File SOURCE=..\setup.rc # End Source File # End Group # End Target # End Project freetds-0.91/win32/msvc6/FreeTDS.dsw100664 001750 000144 00000003155 11444375411 0012562Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "FreeTDS"=".\FreeTDS.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name libTDS End Project Dependency }}} ############################################################################### Project: "dblib"=".\dblib.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name libTDS End Project Dependency }}} ############################################################################### Project: "dblib_dll"=".\dblib_dll.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name libTDS End Project Dependency }}} ############################################################################### Project: "libTDS"=".\libTDS.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "libct"=".\libct.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name libTDS End Project Dependency }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### freetds-0.91/win32/msvc6/iconv_replacement.c100664 001750 000144 00000000052 07733653704 0014453#include "../../src/replacements/iconv.c" freetds-0.91/win32/msvc6/libTDS.dsp100664 001750 000144 00000015443 11432505625 0012442# Microsoft Developer Studio Project File - Name="libTDS" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=libTDS - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "libTDS.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "libTDS.mak" CFG="libTDS - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "libTDS - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "libTDS - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "libTDS - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "tds_Release" # PROP BASE Intermediate_Dir "tds_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "tds_Release" # PROP Intermediate_Dir "tds_Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /I "../../include" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /D "NDEBUG" /D "_LIB" /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "libTDS - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "tds_Debug" # PROP BASE Intermediate_Dir "tds_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "tds_Debug" # PROP Intermediate_Dir "tds_Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I ".." /I "../../include" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /D "_DEBUG" /D "_LIB" /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ENDIF # Begin Target # Name "libTDS - Win32 Release" # Name "libTDS - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\src\tds\bulk.c # End Source File # Begin Source File SOURCE=..\..\src\tds\challenge.c # End Source File # Begin Source File SOURCE=..\..\src\tds\config.c # End Source File # Begin Source File SOURCE=..\..\src\tds\convert.c # End Source File # Begin Source File SOURCE=..\..\src\tds\data.c # End Source File # Begin Source File SOURCE=..\..\src\tds\des.c # End Source File # Begin Source File SOURCE=..\..\src\tds\getmac.c # End Source File # Begin Source File SOURCE=..\..\src\tds\iconv.c # End Source File # Begin Source File SOURCE=..\..\src\tds\locale.c # End Source File # Begin Source File SOURCE=..\..\src\tds\login.c # End Source File # Begin Source File SOURCE=..\..\src\tds\md4.c # End Source File # Begin Source File SOURCE=..\..\src\tds\md5.c # End Source File # Begin Source File SOURCE=..\..\src\tds\hmac_md5.c # End Source File # Begin Source File SOURCE=..\..\src\tds\mem.c # End Source File # Begin Source File SOURCE=..\..\src\tds\net.c # End Source File # Begin Source File SOURCE=..\..\src\tds\numeric.c # End Source File # Begin Source File SOURCE=..\..\src\tds\query.c # End Source File # Begin Source File SOURCE=..\..\src\tds\read.c # End Source File # Begin Source File SOURCE=..\..\src\tds\tdsstring.c # End Source File # Begin Source File SOURCE=..\..\src\tds\threadsafe.c # End Source File # Begin Source File SOURCE=..\..\src\tds\token.c # End Source File # Begin Source File SOURCE=..\..\src\tds\util.c # End Source File # Begin Source File SOURCE=..\..\src\tds\log.c # End Source File # Begin Source File SOURCE=..\..\src\tds\vstrbuild.c # End Source File # Begin Source File SOURCE=..\..\src\tds\write.c # End Source File # Begin Source File SOURCE=..\..\src\tds\sspi.c # End Source File # Begin Source File SOURCE=..\..\src\tds\win_mutex.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\config.h # End Source File # Begin Source File SOURCE=..\..\include\des.h # End Source File # Begin Source File SOURCE=..\freetds_sysconfdir.h # End Source File # Begin Source File SOURCE=..\..\include\md4.h # End Source File # Begin Source File SOURCE=..\..\include\md5.h # End Source File # Begin Source File SOURCE=..\..\include\hmac_md5.h # End Source File # Begin Source File SOURCE=..\..\include\replacements.h # End Source File # Begin Source File SOURCE=..\..\include\tds.h # End Source File # Begin Source File SOURCE=..\..\include\tds_configs.h # End Source File # Begin Source File SOURCE=..\..\include\tds_sysdep_private.h # End Source File # Begin Source File SOURCE=..\tds_sysdep_public.h # End Source File # Begin Source File SOURCE=..\..\src\tds\tds_willconvert.h # End Source File # Begin Source File SOURCE=..\..\include\tdsconvert.h # End Source File # Begin Source File SOURCE=..\..\include\tdsiconv.h # End Source File # Begin Source File SOURCE=..\..\include\tdsstring.h # End Source File # Begin Source File SOURCE=..\..\include\tdsver.h # End Source File # End Group # Begin Group "Replacements" # PROP Default_Filter "" # Begin Source File SOURCE=..\..\src\replacements\asprintf.c # End Source File # Begin Source File SOURCE=.\iconv_replacement.c # End Source File # Begin Source File SOURCE=..\..\src\replacements\fakepoll.c # End Source File # Begin Source File SOURCE=..\..\src\replacements\strlcpy.c # End Source File # Begin Source File SOURCE=..\..\src\replacements\strlcat.c # End Source File # Begin Source File SOURCE=..\..\src\replacements\strtok_r.c # End Source File # Begin Source File SOURCE=..\..\src\replacements\vasprintf.c # End Source File # End Group # End Target # End Project freetds-0.91/win32/msvc6/dblib.dsp100664 001750 000144 00000007230 10175652424 0012373# Microsoft Developer Studio Project File - Name="dblib" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=dblib - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "dblib.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "dblib.mak" CFG="dblib - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "dblib - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "dblib - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "dblib - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "db_Release" # PROP BASE Intermediate_Dir "db_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "db_Release" # PROP Intermediate_Dir "db_Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /I "../../include" /I "../../src" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /FR /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "dblib - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "db_Debug" # PROP BASE Intermediate_Dir "db_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "db_Debug" # PROP Intermediate_Dir "db_Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I ".." /I "../../include" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ENDIF # Begin Target # Name "dblib - Win32 Release" # Name "dblib - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\src\dblib\dblib.c # End Source File # Begin Source File SOURCE=..\..\src\dblib\dbopen.c # End Source File # Begin Source File SOURCE=..\..\src\dblib\dbutil.c # End Source File # Begin Source File SOURCE=..\..\src\dblib\rpc.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\..\src\dblib\error_table.h # End Source File # Begin Source File SOURCE=..\..\include\sybdb.h # End Source File # Begin Source File SOURCE=..\..\include\syberror.h # End Source File # Begin Source File SOURCE=..\..\include\sybfront.h # End Source File # End Group # End Target # End Project freetds-0.91/win32/msvc6/dblib_dll.dsp100664 001750 000144 00000010061 11444375411 0013220# Microsoft Developer Studio Project File - Name="dblib_dll" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=dblib_dll - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "dblib.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "dblib.mak" CFG="dblib_dll - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "dblib_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "dblib_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "dblib_dll - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "dbdll_Release" # PROP BASE Intermediate_Dir "dbdll_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "dbdll_Release" # PROP Intermediate_Dir "dbdll_Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /I "../../include" /I "../../src" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /FR /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /dll /machine:I386 # ADD LINK32 ws2_32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "dblib_dll - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "dbdll_Debug" # PROP BASE Intermediate_Dir "dbdll_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "dbdll_Debug" # PROP Intermediate_Dir "dbdll_Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I ".." /I "../../include" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /dll /machine:I386 # ADD LINK32 ws2_32.lib /nologo /dll /machine:I386 !ENDIF # Begin Target # Name "dblib_dll - Win32 Release" # Name "dblib_dll - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\src\dblib\dblib.c # End Source File # Begin Source File SOURCE=..\..\src\dblib\dbopen.c # End Source File # Begin Source File SOURCE=..\..\src\dblib\dbutil.c # End Source File # Begin Source File SOURCE=..\..\src\dblib\rpc.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\..\src\dblib\error_table.h # End Source File # Begin Source File SOURCE=..\..\include\sybdb.h # End Source File # Begin Source File SOURCE=..\..\include\syberror.h # End Source File # Begin Source File SOURCE=..\..\include\sybfront.h # End Source File # Begin Source File SOURCE=..\dblib.def # End Source File # End Group # End Target # End Project freetds-0.91/win32/msvc6/libct.dsp100664 001750 000144 00000006722 11334033763 0012416# Microsoft Developer Studio Project File - Name="libct" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=libct - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "libct.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "libct.mak" CFG="libct - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "libct - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "libct - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "libct - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "ct_Release" # PROP BASE Intermediate_Dir "ct_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "ct_Release" # PROP Intermediate_Dir "ct_Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Yu"stdafx.h" /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /I "../../include" /I "../../src" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /FR"ct_Release/" /Fp"ct_Release/libct.pch" /YX /Fo"ct_Release/" /Fd"ct_Release/" /FD /c # ADD BASE RSC /l 0xc09 /d "NDEBUG" # ADD RSC /l 0xc09 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "libct - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "ct_Debug" # PROP Intermediate_Dir "ct_Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Yu"stdafx.h" /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I ".." /I "../../include" /D "HAVE_CONFIG_H" /D "UNIXODBC" /D "_FREETDS_LIBRARY_SOURCE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREETDS_EXPORTS" /D "HAVE_SQLGETPRIVATEPROFILESTRING" /FR /Fp"ct_Debug/ctlib.pch" /YX /FD /GZ /c # ADD BASE RSC /l 0xc09 /d "_DEBUG" # ADD RSC /l 0xc09 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ENDIF # Begin Target # Name "libct - Win32 Release" # Name "libct - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\src\ctlib\blk.c # End Source File # Begin Source File SOURCE=..\..\src\ctlib\cs.c # End Source File # Begin Source File SOURCE=..\..\src\ctlib\ct.c # End Source File # Begin Source File SOURCE=..\..\src\ctlib\ctutil.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # End Target # End Project freetds-0.91/vms/Makefile.am100664 001750 000144 00000000500 11411510566 0011433EXTRA_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-0.91/vms/Makefile.in100664 001750 000144 00000027036 11623070620 0011456# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.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/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) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ 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@ 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@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ 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@ 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@ 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_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@ lt_ECHO = @lt_ECHO@ 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 .PRECIOUS: 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 TAGS: ctags: CTAGS CTAGS: 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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 \ 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 uninstall uninstall-am 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-0.91/vms/config_h.vms100664 001750 000144 00000023262 11437763206 0011725/* $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 `atoll' function. */ #ifdef __VAX #undef HAVE_ATOLL #else #define HAVE_ATOLL 1 #endif /* 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 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 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 `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 a 64-bit integral type. */ #define HAVE_INT64 1 /* 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 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 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 format string used for 64bit integers */ #define TDS_I64_FORMAT "lld" /* 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 "." #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 ); #if !HAVE_ASPRINTF #pragma extern_prefix "freetds_" (asprintf) #endif /* !HAVE_ASPRINTF */ #if !HAVE_VASPRINTF #pragma extern_prefix "freetds_" (vasprintf) #endif /* !HAVE_VASPRINTF */ #if !HAVE_SNPRINTF #pragma extern_prefix "portable_" (snprintf) extern int snprintf(char *, size_t, const char *, /*args*/ ...); #endif /* !HAVE_SNPRINTF */ #if !HAVE_STRTOK_R #pragma extern_prefix "freetds_" (strtok_r) #endif /* !HAVE_STRTOK_R */ #pragma extern_prefix restore #define tds_sysdep_intptr_type int /* 32-bit int */ #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 #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[]); #endif /* CONFIG_H_LOADED */ freetds-0.91/vms/configure.com100664 001750 000144 00000021326 10761641522 0012075$! 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 $! $! 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 "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 $! $ 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 "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; $! $ 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-0.91/vms/edit.c100664 001750 000144 00000003444 11375511140 0010500/* 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-0.91/vms/descrip_mms.template100664 001750 000144 00000217736 11411510566 0013466# 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.16 2010/06/26 23:47:02 berryc Exp $ # OpenVMS description file for FreeTDS # To override default TDS version of 5.0 specify /MACRO="TDSVER=TDSxx" # where xx is one of 42, 46, 50, 70, or 80. # 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 .IFDEF TDSVER .ELSE TDSVER = TDS50 .ENDIF 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 .IFDEF ODBC CDEFINE = "$(TDSVER)","HAVE_CONFIG_H"=1,_FREETDS_LIBRARY_SOURCE=1,"UNIXODBC" CODBCFLAGS = /NAMES=(AS_IS,SHORTENED) .ELSE CDEFINE = $(TDSVER),HAVE_CONFIG_H=1,_FREETDS_LIBRARY_SOURCE=1 CODBCFLAGS = /NAMES=SHORTENED .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 = /DEFINE=($(CDEFINE))/PREFIX=($(CPREFIX))/FLOAT=IEEE/IEEE=DENORM/OBJECT=$(MMS$TARGET_NAME)$(OBJ) $(CODBCFLAGS) $(CDBGFLAGS) LINKFLAGS = $(LDBGFLAGS) .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@ 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]log$(OBJ), [.src.replacements]strlcpy$(OBJ), \ $(ASPRINTFOBJ) $(VASPRINTFOBJ) $(SNPRINTFOBJ) $(STRTOK_ROBJ) $(LIBICONVOBJ) \ [.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), $(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 []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) @ 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) @ 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) @ 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]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) @ 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) @ 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) @ 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]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_1$(E) : [.src.tds.unittests]utf8_1$(OBJ) [.src.tds.unittests]common$(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) 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) 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) # 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]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]common$(OBJ) : [.src.dblib.unittests]common.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;* @ 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("*$(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-0.91/vms/getpass.c100664 001750 000144 00000020047 11502563155 0011224/* 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. */ #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #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; static char software_version[] = "$Id: getpass.c,v 1.7 2010/12/17 04:26:21 berryc Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* * 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; 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); } 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-0.91/vms/libodbc.opt100664 001750 000144 00000000022 07662411321 0011522LIBODBC/Shareable freetds-0.91/vms/odbc_driver_axp.opt100664 001750 000144 00000007454 11414573037 0013301! 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,- SQLGetCursorName=PROCEDURE,- SQLGetData=PROCEDURE,- SQLGetDescField=PROCEDURE,- SQLGetDescRec=PROCEDURE,- SQLGetDiagField=PROCEDURE,- SQLGetDiagRec=PROCEDURE,- SQLGetEnvAttr=PROCEDURE,- SQLGetFunctions=PROCEDURE,- SQLGetInfo=PROCEDURE,- SQLGetStmtAttr=PROCEDURE,- SQLGetStmtOption=PROCEDURE,- SQLGetTypeInfo=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,- SQLSetCursorName=PROCEDURE,- SQLSetDescField=PROCEDURE,- SQLSetDescRec=PROCEDURE,- SQLSetEnvAttr=PROCEDURE,- SQLSetParam=PROCEDURE,- SQLSetPos=PROCEDURE,- SQLSetScrollOptions=PROCEDURE,- SQLSetStmtAttr=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-0.91/vms/README.vms100664 001750 000144 00000007550 11250136722 0011076README.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-0.91/vms/vargdefs.h100664 001750 000144 00000004206 11411510566 0011360/* 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-0.91/vms/vmsarg_command_bcp.cld100664 001750 000144 00000005051 11411510566 0013712! 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-0.91/vms/vmsarg_command_defncopy.cld100664 001750 000144 00000003603 11411510566 0014756! 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-0.91/vms/vmsarg_command_isql.cld100664 001750 000144 00000004013 11411510566 0014113! 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-0.91/vms/vmsarg_mapping_bcp.c100664 001750 000144 00000005621 11411510566 0013412/* 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-0.91/vms/vmsarg_mapping_defncopy.c100664 001750 000144 00000003733 11411510566 0014457/* 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-0.91/vms/vmsarg_mapping_isql.c100664 001750 000144 00000005754 11411510566 0013625/* 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-0.91/vms/vmsarg_parse.c100664 001750 000144 00000072436 11411510566 0012255/* 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[2], month_1[2], date_2[3], date_1[2]; char hour_2[3], hour_1[2], 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[1]; 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; }