commit 86f254a56a90ad31b6fcdb0650170aac93c93caf Author: BoHung Chiu Date: Wed Oct 4 21:13:16 2023 +0800 First version with older sync migrate. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e157571 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/db/*.sqlite3-journal +test/dummy/log/*.log +test/dummy/storage/ +test/dummy/tmp/ diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..651f998 --- /dev/null +++ b/Gemfile @@ -0,0 +1,15 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +# Declare your gem's dependencies in sync_fgu_personal_data.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use a debugger +# gem 'byebug', group: [:development, :test] diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..80b49aa --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2019 Eric Tsai + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..276ba0c --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Usage +* set cron job to run `bundle exec rake sync_nccu_personal_plugins:sync` for asia everyday \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..b546eb6 --- /dev/null +++ b/Rakefile @@ -0,0 +1,32 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'SyncNccuPersonalData' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.md') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__) +load 'rails/tasks/engine.rake' + +load 'rails/tasks/statistics.rake' + +require 'bundler/gem_tasks' + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + +task default: :test diff --git a/app/assets/images/sync_fgu_personal_data/.keep b/app/assets/images/sync_fgu_personal_data/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/sync_fgu_personal_data/.keep b/app/assets/stylesheets/sync_fgu_personal_data/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/.keep b/app/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/helpers/.keep b/app/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/.keep b/app/views/.keep new file mode 100644 index 0000000..e69de29 diff --git a/bin/rails b/bin/rails new file mode 100644 index 0000000..4e21e3a --- /dev/null +++ b/bin/rails @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails gems +# installed from the root of your application. + +ENGINE_ROOT = File.expand_path('..', __dir__) +ENGINE_PATH = File.expand_path('../lib/sync_fgu_personal_data/engine', __dir__) +APP_PATH = File.expand_path('../test/dummy/config/application', __dir__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +require 'rails/all' +require 'rails/engine/commands' diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..1daf9a4 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,2 @@ +Rails.application.routes.draw do +end diff --git a/freetds-1.1.24_build/bin/bsqldb b/freetds-1.1.24_build/bin/bsqldb new file mode 100644 index 0000000..d2d53ce Binary files /dev/null and b/freetds-1.1.24_build/bin/bsqldb differ diff --git a/freetds-1.1.24_build/bin/datacopy b/freetds-1.1.24_build/bin/datacopy new file mode 100644 index 0000000..4fb9e1b Binary files /dev/null and b/freetds-1.1.24_build/bin/datacopy differ diff --git a/freetds-1.1.24_build/bin/defncopy b/freetds-1.1.24_build/bin/defncopy new file mode 100644 index 0000000..dc86b59 Binary files /dev/null and b/freetds-1.1.24_build/bin/defncopy differ diff --git a/freetds-1.1.24_build/bin/fisql b/freetds-1.1.24_build/bin/fisql new file mode 100644 index 0000000..f4cb566 Binary files /dev/null and b/freetds-1.1.24_build/bin/fisql differ diff --git a/freetds-1.1.24_build/bin/freebcp b/freetds-1.1.24_build/bin/freebcp new file mode 100644 index 0000000..ed27882 Binary files /dev/null and b/freetds-1.1.24_build/bin/freebcp differ diff --git a/freetds-1.1.24_build/bin/osql b/freetds-1.1.24_build/bin/osql new file mode 100644 index 0000000..71e0c0c --- /dev/null +++ b/freetds-1.1.24_build/bin/osql @@ -0,0 +1,388 @@ +#! /bin/sh +# $Id: osql,v 1.12 2011-05-11 03:08:13 jklowden Exp $ +# +# Check odbc.ini, odbcinst, and, optionally, freetds.conf, +# then execute isql (assume it's unixODBC's isql). +# + +USAGE="Syntax: $(basename $0) -S server -U user -P password" + +while getopts I:S:U:P: OPTION +do + case ${OPTION} in + I) OVER_DIR=${OPTARG} # override + ;; + S) DSN=${OPTARG} + ;; + U) USERNAME=${OPTARG} + ;; + P) PASSWORD=${OPTARG} + ;; + \?) echo $USAGE + exit 1 + ;; + esac +done + +#cho ${DSN} ${USERNAME} ${PASSWORD} +if [ -z "${DSN}" -o -z "${USERNAME}" -o -z "${PASSWORD}" ] +then + + echo $USAGE + exit 1 +fi + +ISQL=$(command -v isql) +if [ -z "${ISQL}" ] +then + echo "$(basename $0): error: no \"isql\" command found. Is unixODBC installed?" + exit 1 +fi + +# Establish ODBC prefix directory + +ISQL_DIR=$(strings ${ISQL} | grep ^/ | grep -v elf | grep -v '\.so\.' | head -1 | sed 's/lib$/etc/' ) + +INI_DIRNAME="/tmp/$(basename $0).$$" +exec 3> ${INI_DIRNAME} + +# Check the libraries, too. +if [ -z "${OVER_DIR}" ] +then + echo "checking shared odbc libraries linked to isql for default directories..." + (echo ${ISQL_DIR}; ldd "${ISQL}" | awk '/libodbc\./ {print $3}') \ + | while read L + do + strings "$L" | grep '^/' | grep -v '/lib' \ + | while read D + do + if [ ! -s "${INI_DIRNAME}" ] + then + printf " trying $D ... " + if [ -d "$D" -a -r "${D}/odbc.ini" ] + then + printf $D >&3 + printf "OK" + else + printf "no" + fi + printf "\n" + fi + done + done +fi + +ODBC_DIR=$(cat ${INI_DIRNAME}) && rm ${INI_DIRNAME} + +if [ -z "${ODBC_DIR}" -a -z "${OVER_DIR}" ] +then + echo "$(basename $0): problem: no potential directory strings in \"$(command -v isql)\"" + echo "$(basename $0): advice: use \"osql -I DIR\" where DIR unixODBC\'s install prefix e.g. /usr/local" + echo "isql strings are:" + strings ${ISQL} | grep ^/ | sed 's/^/+ /' + #xit 1 +fi + +if [ "${OVER_DIR}" ] +then + if [ -d "${ODBC_DIR}" ] + then + echo "\"${ODBC_DIR}\" is a directory, overridden by" + else + echo "\"${ODBC_DIR}\" is NOT a directory, overridden by" + fi + echo "\"${OVER_DIR}\"." + + if [ -d "${OVER_DIR}" ] + then + ODBC_DIR=${OVER_DIR} + else + echo "$(basename $0): error: \"${OVER_DIR}\" is not a directory" + exit 1 + fi +fi + +# Look for server entry in odbc.ini +echo 'checking odbc.ini files' +for F in "${HOME}/.odbc.ini" "${ODBC_DIR}/odbc.ini" +do + if [ ! -d "$(dirname $F)" ] + then + echo "warning: $(dirname $F) is not a directory" + continue + fi + + if [ -r "$F" ] + then + echo " reading $F" + else + echo " cannot read \"$F\"" + continue + fi + + grep -F "[${DSN}]" $F > /dev/null + + if [ $? -eq 0 ] + then + echo "[${DSN}] found in $F" + ODBC_INI=$F + break + else + echo "[${DSN}] not found in $F" + fi +done + +if [ -z "${ODBC_INI}" ] +then + echo "$(basename $0): error: unable to locate ${DSN} in any odbc.ini" + exit 1 +fi + +# Report finding of server entry +echo found this section: +SED_CMD="/^\[${DSN}\]/,/^[[:space:]]*$/ { s/^/ /; p; }" +sed -ne "${SED_CMD}" ${ODBC_INI} + +# +# Examine server entry in odbc.ini +# + +# Find the driver in the servername or default section +for D in "${DSN}" 'default' +do + echo "looking for driver for DSN [$D] in ${ODBC_INI}" + grep "$D" ${ODBC_INI} > /dev/null + if [ $? -eq 0 ] + then + CMD="/^\[$D\]/,/^[[:space:]]*$/ { s/^/ /; p; }" + DRIVER_LINE=$(sed -ne "${CMD}" ${ODBC_INI} \ + | grep -Ei '^[[:space:]]*driver[[:space:]]*=') + if [ -z "${DRIVER_LINE}" ] + then + echo " no driver mentioned for [$D] in $(basename ${ODBC_INI})" + continue + fi + + echo " found driver line: \"${DRIVER_LINE}\"" + DRIVER=$(echo ${DRIVER_LINE} \ + | awk -F ' *= *' '{print $2}' \ + | sed 's/[[:space:]][[:space:]]*//g') + if [ "${DRIVER}" ] + then + echo " driver \"${DRIVER}\" found for [$D] in $(basename ${ODBC_INI})" + break + else + echo " driver line for [$D] incomplete in $(basename ${ODBC_INI})" + continue + fi + fi +done + +if [ -z "${DRIVER}" ] +then + echo "$(basename $0): error: no driver found for [${DSN}] in $(basename ${ODBC_INI})" + exit 1 +fi + +# get filename of driver +echo found driver named \"${DRIVER}\" +if [ -d "${DRIVER}" -o ! -x "${DRIVER}" ] +then + # not a filename, look it up + DRIVERNAME=${DRIVER} + ODBC_INST="${ODBC_DIR}/odbcinst.ini" + echo "\"${DRIVERNAME}\" is not an executable file" + echo "looking for entry named [${DRIVERNAME}] in ${ODBC_INST}" + + grep "${DRIVERNAME}" ${ODBC_INST} > /dev/null + if [ $? -ne 0 ] + then + if [ $? -eq 1 ] + then + echo "$(basename $0): error: no driver entry [${DRIVERNAME}] in ${ODBC_INST}" + fi + exit 1; + fi + + CMD="/^\[${DRIVERNAME}\]/,/^[[:space:]]*$/ { s/^/ /; p; }" + DRIVER_LINE=$(sed -ne "${CMD}" ${ODBC_INST} \ + | grep -Ei '^[[:space:]]*driver[[:space:]]*=') + if [ -z "${DRIVER_LINE}" ] + then + echo "$(basename $0): no driver mentioned for [${DRIVERNAME}] in $(basename ${ODBC_INST})" + exit 1 + fi + + echo " found driver line: \"${DRIVER_LINE}\"" + DRIVER=$(echo ${DRIVER_LINE} | awk -F ' *= *' '{print $2}') + if [ -z "${DRIVER}" ] + then + echo "$(basename $0): driver line incomplete for [${DRIVERNAME}] in $(basename ${ODBC_INST})" + exit 1 + fi + + echo " found driver ${DRIVER} for [${DRIVERNAME}] in $(basename ${ODBC_INST})" +fi + +if [ -z "${DRIVER}" ] +then + echo $(basename $0): 'error: sorry, failed sanity check: ${DRIVER} is null' + exit 1 +fi + +if [ -x "${DRIVER}" ] +then + echo "${DRIVER} is an executable file" +else + echo "${DRIVER} is not an executable file" + echo "$(basename $0): error: no driver found for ${DSN}" + exit 1 +fi + +# find the server/servername +SERVER_LINE=$(sed -ne "${SED_CMD}" ${ODBC_INI} \ + | grep -Ei '^[[:space:]]*server(name)*[[:space:]]*=') + +ATTRIBUTE=$(echo ${SERVER_LINE} | awk -F' *= *' '{print $1}') + +if [ -z "${ATTRIBUTE}" ] +then + echo "$(basename $0): neither \"Server\" nor \"Servername\" found for [${DSN}] in $(basename ${ODBC_INI})" + exit 1 +fi + +echo ${SERVER_LINE} | grep -i servername >/dev/null + +# +# Find the server's hostname +# +if [ $? -eq 0 ] # ODBC-Combined +then + TDS_SERVER=$(echo ${SERVER_LINE} | awk -F ' *= *' '{print $2}') + echo 'Using ODBC-Combined strategy' + echo "DSN [${DSN}] has servername \"${TDS_SERVER}\" (from ${ODBC_INI})" + if [ -z "${TDS_SERVER}" ] + then + exit 1 + fi + + # Look for $TDS_SERVER in freetds.conf + + FREETDS_DIR=$(tsql -C | grep 'freetds.conf directory' | awk -F: '{print $2}' | sed 's/^ *//') + if [ -z "${FREETDS_DIR}" ] + then + echo "$(basename $0): error: unable to locate directory for freetds.conf using \"$(command -v tsql)\"" + exit 1 + fi + + for F in "${HOME}/.freetds.conf" "${FREETDS_DIR}/freetds.conf" + do + if [ -r "$F" ] + then + echo $F is a readable file + else + echo cannot read \"$F\" + continue + fi + + echo "looking for [${TDS_SERVER}] in $F" + grep -F "[${TDS_SERVER}]" $F > /dev/null + + if [ $? -eq 0 ] + then + FREETDS_CONF=$F + break + else + echo "[${TDS_SERVER}]" not found in $F + fi + done + + if [ -z "${FREETDS_CONF}" ] + then + echo "$(basename $0): error: unable to locate ${TDS_SERVER} in any freetds.conf" + exit 1 + fi + + # Examine server entry in freetds.conf + + echo found this section: + SED_CMD="/^\[${TDS_SERVER}\]/,/^[[:space:]]*$/ { s/^/ /; p; }" + sed -ne "${SED_CMD}" ${FREETDS_CONF} + + SERVER_LINE=$(sed -ne "${SED_CMD}" ${FREETDS_CONF} \ + | grep -Ei '^[[:space:]]*host[[:space:]]*=') + + # No character class support in mawk, + # cf. "Mawk does not support Posix character classes in expressions" + # https://bugs.launchpad.net/ubuntu/+source/mawk/+bug/69724 + HOST=$(echo ${SERVER_LINE} | awk -F' *= *' '{print $2}') + + if [ -z "${HOST}" ] + then + echo "$(basename $0): no \"host\" entry found for [${TDS_SERVER}] in $(basename ${FREETDS_CONF})" + exit 1 + fi + +else # odbc.ini contains a "server", a DNS host + HOST=$(echo ${SERVER_LINE} | awk -F ' *= *' '{print $2}') + echo "\"${ATTRIBUTE}\" found, not using freetds.conf" + echo "${ATTRIBUTE} is \"${HOST}\"" + if [ -z "${HOST}" ] + then + echo "$(basename $0): no value found for \"${ATTRIBUTE}\" entry in $(basename ${ODBC_INI})" + exit 1 + fi +fi + +# If the "host" is an ip address, look up the name, for neatness, e.g. +## $ host 10.81.36.39 +## 39.36.81.10.IN-ADDR.ARPA domain name pointer ntc5003.eg.com +if [ "${HOST}" = "$(echo ${HOST} | sed 's/[^.0-9]*//')" ] +then + ADDRESS=${HOST} + echo 'looking up hostname for ip address' ${ADDRESS} + HOST=$(host ${HOST} | awk '/domain/ {print $5}' | sed 's/\.$//') + if [ -z "${HOST}" ] + then + echo "$(basename $0): warning: no DNS hostname found for \"${ADDRESS}\"" + HOST=${ADDRESS} # restore host address string + fi +fi + +# Now we have a DNS hostname for the server in HOST +if [ "${HOST}" != "${ADDRESS}" ] +then + ADDRESS=$(host ${HOST} | awk '/has address/ {print $4}' | head -1) +fi +if [ -z "${ADDRESS}" ] +then + echo "$(basename $0): no IP address found for \"${HOST}\"" + exit 1 +fi + +#cho ${HOST} has address ${ADDRESS} + +# Report what we know and exec isql + +printf "\n" +printf "Configuration looks OK. Connection details:\n\n" +printf "%22s:\t%-30s\n" DSN ${DSN} +printf "%22s:\t%-30s\n" odbc.ini "${ODBC_INI}" +printf "%22s:\t%-30s\n" Driver ${DRIVER} +printf "%22s:\t%-30s\n" "Server hostname" ${HOST} +printf "%22s:\t%-30s\n" Address ${ADDRESS} +printf "\n" + +echo Attempting connection as ${USERNAME} ... + +if [ -z "${TDSDUMP}" ] +then + TDSDUMP_AUTO="/tmp/$(basename $0).dump.$$" + export TDSDUMP=${TDSDUMP_AUTO} +fi + +( set -x; isql ${DSN} ${USERNAME} ${PASSWORD} -v ) \ + || sed -ne 's/Connecting/FAILED &/p' ${TDSDUMP} + +test "${TDSDUMP_AUTO}" && rm -f ${TDSDUMP_AUTO} + diff --git a/freetds-1.1.24_build/bin/tdspool b/freetds-1.1.24_build/bin/tdspool new file mode 100644 index 0000000..c5d2a4a Binary files /dev/null and b/freetds-1.1.24_build/bin/tdspool differ diff --git a/freetds-1.1.24_build/bin/tsql b/freetds-1.1.24_build/bin/tsql new file mode 100644 index 0000000..49fe30d Binary files /dev/null and b/freetds-1.1.24_build/bin/tsql differ diff --git a/freetds-1.1.24_build/etc/freetds.conf b/freetds-1.1.24_build/etc/freetds.conf new file mode 100644 index 0000000..e982ad9 --- /dev/null +++ b/freetds-1.1.24_build/etc/freetds.conf @@ -0,0 +1,41 @@ +# +# This file is installed by FreeTDS if no file by the same +# name is found in the installation directory. +# +# For information about the layout of this file and its settings, +# see the freetds.conf manpage "man freetds.conf". + +# Global settings are overridden by those in a database +# server specific section +[global] + # TDS protocol version + tds version = auto + + # Whether to write a TDSDUMP file for diagnostic purposes + # (setting this to /tmp is insecure on a multi-user system) +; dump file = /tmp/freetds.log +; debug flags = 0xffff + + # Command and connection timeouts +; timeout = 10 +; connect timeout = 10 + + # To reduce data sent from server for BLOBs (like TEXT or + # IMAGE) try setting 'text size' to a reasonable limit +; text size = 64512 + + # If you experience TLS handshake errors and are using openssl, + # try adjusting the cipher list (don't surround in double or single quotes) + # openssl ciphers = HIGH:!SSLv2:!aNULL:-DH + +# A typical Sybase server +[egServer50] + host = symachine.domain.com + port = 5000 + tds version = 5.0 + +# A typical Microsoft server +[egServer73] + host = ntmachine.domain.com + port = 1433 + tds version = 7.3 diff --git a/freetds-1.1.24_build/etc/locales.conf b/freetds-1.1.24_build/etc/locales.conf new file mode 100644 index 0000000..575b19d --- /dev/null +++ b/freetds-1.1.24_build/etc/locales.conf @@ -0,0 +1,23 @@ +[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 + diff --git a/freetds-1.1.24_build/etc/pool.conf b/freetds-1.1.24_build/etc/pool.conf new file mode 100644 index 0000000..6e44b03 --- /dev/null +++ b/freetds-1.1.24_build/etc/pool.conf @@ -0,0 +1,11 @@ +[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 diff --git a/freetds-1.1.24_build/include/bkpublic.h b/freetds-1.1.24_build/include/bkpublic.h new file mode 100644 index 0000000..d43c60c --- /dev/null +++ b/freetds-1.1.24_build/include/bkpublic.h @@ -0,0 +1,69 @@ +/* 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 diff --git a/freetds-1.1.24_build/include/cspublic.h b/freetds-1.1.24_build/include/cspublic.h new file mode 100644 index 0000000..2a6e16a --- /dev/null +++ b/freetds-1.1.24_build/include/cspublic.h @@ -0,0 +1,776 @@ +/* FreeTDS - Library of routines accessing Sybase and Microsoft databases + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _cspublic_h_ +#define _cspublic_h_ + +#include + +#undef TDS_STATIC_CAST +#ifdef __cplusplus +#define TDS_STATIC_CAST(type, a) static_cast(a) +extern "C" +{ +#if 0 +} +#endif +#else +#define TDS_STATIC_CAST(type, a) ((type)(a)) +#endif + +#define CS_PUBLIC +#define CS_STATIC static + +#define CS_SUCCEED 1 +#define CS_FAIL 0 +#define CS_MEM_ERROR -1 +#define CS_PENDING -2 +#define CS_QUIET -3 +#define CS_BUSY -4 +#define CS_INTERRUPT -5 +#define CS_BLK_HAS_TEXT -6 +#define CS_CONTINUE -7 +#define CS_FATAL -8 +#define CS_RET_HAFAILOVER -9 +#define CS_UNSUPPORTED -10 + +#define CS_CANCELED -202 +#define CS_ROW_FAIL -203 +#define CS_END_DATA -204 +#define CS_END_RESULTS -205 +#define CS_END_ITEM -206 +#define CS_NOMSG -207 +#define CS_TIMED_OUT -208 + +#define CS_SIZEOF(x) sizeof(x) + +#define CS_LAYER(x) (((x) >> 24) & 0xFF) +#define CS_ORIGIN(x) (((x) >> 16) & 0xFF) +#define CS_SEVERITY(x) (((x) >> 8) & 0xFF) +#define CS_NUMBER(x) ((x) & 0xFF) + +/* forward declarations */ +typedef CS_RETCODE(*CS_CSLIBMSG_FUNC) (CS_CONTEXT *, CS_CLIENTMSG *); +typedef CS_RETCODE(*CS_CLIENTMSG_FUNC) (CS_CONTEXT *, CS_CONNECTION *, CS_CLIENTMSG *); +typedef CS_RETCODE(*CS_SERVERMSG_FUNC) (CS_CONTEXT *, CS_CONNECTION *, CS_SERVERMSG *); + + +#define CS_IODATA TDS_STATIC_CAST(CS_INT, 1600) +#define CS_SRC_VALUE -2562 + + + +/* status bits for CS_SERVERMSG */ +#define CS_HASEED 0x01 + +typedef struct _cs_blkdesc CS_BLKDESC; + +/* CS_CAP_REQUEST values */ +#define CS_REQ_LANG 1 +#define CS_REQ_RPC 2 +#define CS_REQ_NOTIF 3 +#define CS_REQ_MSTMT 4 +#define CS_REQ_BCP 5 +#define CS_REQ_CURSOR 6 +#define CS_REQ_DYN 7 +#define CS_REQ_MSG 8 +#define CS_REQ_PARAM 9 +#define CS_DATA_INT1 10 +#define CS_DATA_INT2 11 +#define CS_DATA_INT4 12 +#define CS_DATA_BIT 13 +#define CS_DATA_CHAR 14 +#define CS_DATA_VCHAR 15 +#define CS_DATA_BIN 16 +#define CS_DATA_VBIN 17 +#define CS_DATA_MNY8 18 +#define CS_DATA_MNY4 19 +#define CS_DATA_DATE8 20 +#define CS_DATA_DATE4 21 +#define CS_DATA_FLT4 22 +#define CS_DATA_FLT8 23 +#define CS_DATA_NUM 24 +#define CS_DATA_TEXT 25 +#define CS_DATA_IMAGE 26 +#define CS_DATA_DEC 27 +#define CS_DATA_LCHAR 28 +#define CS_DATA_LBIN 29 +#define CS_DATA_INTN 30 +#define CS_DATA_DATETIMEN 31 +#define CS_DATA_MONEYN 32 +#define CS_CSR_PREV 33 +#define CS_CSR_FIRST 34 +#define CS_CSR_LAST 35 +#define CS_CSR_ABS 36 +#define CS_CSR_REL 37 +#define CS_CSR_MULTI 38 +#define CS_CON_OOB 39 +#define CS_CON_INBAND 40 +#define CS_CON_LOGICAL 41 +#define CS_PROTO_TEXT 42 +#define CS_PROTO_BULK 43 +#define CS_REQ_URGNOTIF 44 +#define CS_DATA_SENSITIVITY 45 +#define CS_DATA_BOUNDARY 46 +#define CS_PROTO_DYNAMIC 47 +#define CS_PROTO_DYNPROC 48 +#define CS_DATA_FLTN 49 +#define CS_DATA_BITN 50 +#define CS_OPTION_GET 51 +#define CS_DATA_INT8 52 +#define CS_DATA_VOID 53 + +/* CS_CAP_RESPONSE values */ +#define CS_RES_NOMSG 1 +#define CS_RES_NOEED 2 +#define CS_RES_NOPARAM 3 +#define CS_DATA_NOINT1 4 +#define CS_DATA_NOINT2 5 +#define CS_DATA_NOINT4 6 +#define CS_DATA_NOBIT 7 +#define CS_DATA_NOCHAR 8 +#define CS_DATA_NOVCHAR 9 +#define CS_DATA_NOBIN 10 +#define CS_DATA_NOVBIN 11 +#define CS_DATA_NOMNY8 12 +#define CS_DATA_NOMNY4 13 +#define CS_DATA_NODATE8 14 +#define CS_DATA_NODATE4 15 +#define CS_DATA_NOFLT4 16 +#define CS_DATA_NOFLT8 17 +#define CS_DATA_NONUM 18 +#define CS_DATA_NOTEXT 19 +#define CS_DATA_NOIMAGE 20 +#define CS_DATA_NODEC 21 +#define CS_DATA_NOLCHAR 22 +#define CS_DATA_NOLBIN 23 +#define CS_DATA_NOINTN 24 +#define CS_DATA_NODATETIMEN 25 +#define CS_DATA_NOMONEYN 26 +#define CS_CON_NOOOB 27 +#define CS_CON_NOINBAND 28 +#define CS_PROTO_NOTEXT 29 +#define CS_PROTO_NOBULK 30 +#define CS_DATA_NOSENSITIVITY 31 +#define CS_DATA_NOBOUNDARY 32 +#define CS_RES_NOTDSDEBUG 33 +#define CS_RES_NOSTRIPBLANKS 34 +#define CS_DATA_NOINT8 35 + +/* Properties */ +enum +{ +/* + * These defines looks weird but programs can test support for defines, + * compiler can check enum and there are no define side effecs + */ + CS_USERNAME = 9100, +#define CS_USERNAME CS_USERNAME + CS_PASSWORD = 9101, +#define CS_PASSWORD CS_PASSWORD + CS_APPNAME = 9102, +#define CS_APPNAME CS_APPNAME + CS_HOSTNAME = 9103, +#define CS_HOSTNAME CS_HOSTNAME + CS_LOGIN_STATUS = 9104, +#define CS_LOGIN_STATUS CS_LOGIN_STATUS + CS_TDS_VERSION = 9105, +#define CS_TDS_VERSION CS_TDS_VERSION + CS_CHARSETCNV = 9106, +#define CS_CHARSETCNV CS_CHARSETCNV + CS_PACKETSIZE = 9107, +#define CS_PACKETSIZE CS_PACKETSIZE + CS_USERDATA = 9108, +#define CS_USERDATA CS_USERDATA + CS_NETIO = 9110, +#define CS_NETIO CS_NETIO + CS_TEXTLIMIT = 9112, +#define CS_TEXTLIMIT CS_TEXTLIMIT + CS_HIDDEN_KEYS = 9113, +#define CS_HIDDEN_KEYS CS_HIDDEN_KEYS + CS_VERSION = 9114, +#define CS_VERSION CS_VERSION + CS_IFILE = 9115, +#define CS_IFILE CS_IFILE + CS_LOGIN_TIMEOUT = 9116, +#define CS_LOGIN_TIMEOUT CS_LOGIN_TIMEOUT + CS_TIMEOUT = 9117, +#define CS_TIMEOUT CS_TIMEOUT + CS_MAX_CONNECT = 9118, +#define CS_MAX_CONNECT CS_MAX_CONNECT + CS_EXPOSE_FMTS = 9120, +#define CS_EXPOSE_FMTS CS_EXPOSE_FMTS + CS_EXTRA_INF = 9121, +#define CS_EXTRA_INF CS_EXTRA_INF + CS_ANSI_BINDS = 9123, +#define CS_ANSI_BINDS CS_ANSI_BINDS + CS_BULK_LOGIN = 9124, +#define CS_BULK_LOGIN CS_BULK_LOGIN + CS_LOC_PROP = 9125, +#define CS_LOC_PROP CS_LOC_PROP + CS_PARENT_HANDLE = 9130, +#define CS_PARENT_HANDLE CS_PARENT_HANDLE + CS_EED_CMD = 9131, +#define CS_EED_CMD CS_EED_CMD + CS_DIAG_TIMEOUT = 9132, +#define CS_DIAG_TIMEOUT CS_DIAG_TIMEOUT + CS_DISABLE_POLL = 9133, +#define CS_DISABLE_POLL CS_DISABLE_POLL + CS_SEC_ENCRYPTION = 9135, +#define CS_SEC_ENCRYPTION CS_SEC_ENCRYPTION + CS_SEC_CHALLENGE = 9136, +#define CS_SEC_CHALLENGE CS_SEC_CHALLENGE + CS_SEC_NEGOTIATE = 9137, +#define CS_SEC_NEGOTIATE CS_SEC_NEGOTIATE + CS_CON_STATUS = 9143, +#define CS_CON_STATUS CS_CON_STATUS + CS_VER_STRING = 9144, +#define CS_VER_STRING CS_VER_STRING + CS_SERVERNAME = 9146, +#define CS_SERVERNAME CS_SERVERNAME + CS_SEC_APPDEFINED = 9149, +#define CS_SEC_APPDEFINED CS_SEC_APPDEFINED + CS_STICKY_BINDS = 9151, +#define CS_STICKY_BINDS CS_STICKY_BINDS + CS_SERVERADDR = 9206, +#define CS_SERVERADDR CS_SERVERADDR + CS_PORT = 9300, +#define CS_PORT CS_PORT + CS_CLIENTCHARSET = 9301, +#define CS_CLIENTCHARSET CS_CLIENTCHARSET + CS_DATABASE = 9302 +#define CS_DATABASE CS_DATABASE +}; + +/* Arbitrary precision math operators */ +enum +{ + CS_ADD = 1, + CS_SUB, + CS_MULT, + CS_DIV +}; + +enum +{ +#define CS_TDS_AUTO CS_TDS_AUTO + CS_TDS_AUTO = 0, + CS_TDS_40 = 7360, + CS_TDS_42, + CS_TDS_46, + CS_TDS_495, + CS_TDS_50, + CS_TDS_70, + CS_TDS_71, +#define CS_TDS_71 CS_TDS_71 + CS_TDS_72, +#define CS_TDS_72 CS_TDS_72 + CS_TDS_73, +#define CS_TDS_73 CS_TDS_73 + CS_TDS_74, +#define CS_TDS_74 CS_TDS_74 +}; + +/* bit mask values used by CS_DATAFMT.status */ +#define CS_HIDDEN (1 << 0) +#define CS_KEY (1 << 1) +#define CS_VERSION_KEY (1 << 2) +#define CS_NODATA (1 << 3) +#define CS_UPDATABLE (1 << 4) +#define CS_CANBENULL (1 << 5) +#define CS_DESCIN (1 << 6) +#define CS_DESCOUT (1 << 7) +#define CS_INPUTVALUE (1 << 8) +#define CS_UPDATECOL (1 << 9) +#define CS_RETURN (1 << 10) +#define CS_TIMESTAMP (1 << 13) +#define CS_NODEFAULT (1 << 14) +#define CS_IDENTITY (1 << 15) + +/* + * DBD::Sybase compares indicator to CS_NULLDATA so this is -1 + * (the documentation states -1) + */ +#define CS_GOODDATA 0 +#define CS_NULLDATA (-1) + +/* CS_CON_STATUS read-only property bit mask values */ +#define CS_CONSTAT_CONNECTED 0x01 +#define CS_CONSTAT_DEAD 0x02 + +/* + * Code added for CURSOR support + * types accepted by ct_cursor + */ +#define CS_CURSOR_DECLARE 700 +#define CS_CURSOR_OPEN 701 +#define CS_CURSOR_ROWS 703 +#define CS_CURSOR_UPDATE 704 +#define CS_CURSOR_DELETE 705 +#define CS_CURSOR_CLOSE 706 +#define CS_CURSOR_DEALLOC 707 +#define CS_CURSOR_OPTION 725 + +#define CS_FOR_UPDATE TDS_STATIC_CAST(CS_INT, 0x1) +#define CS_READ_ONLY TDS_STATIC_CAST(CS_INT, 0x2) +#define CS_RESTORE_OPEN TDS_STATIC_CAST(CS_INT, 0x8) +#define CS_IMPLICIT_CURSOR TDS_STATIC_CAST(CS_INT, 0x40) + + +#define CS_CURSTAT_NONE TDS_STATIC_CAST(CS_INT, 0x0) +#define CS_CURSTAT_DECLARED TDS_STATIC_CAST(CS_INT, 0x1) +#define CS_CURSTAT_OPEN TDS_STATIC_CAST(CS_INT, 0x2) +#define CS_CURSTAT_CLOSED TDS_STATIC_CAST(CS_INT, 0x4) +#define CS_CURSTAT_RDONLY TDS_STATIC_CAST(CS_INT, 0x8) +#define CS_CURSTAT_UPDATABLE TDS_STATIC_CAST(CS_INT, 0x10) +#define CS_CURSTAT_ROWCOUNT TDS_STATIC_CAST(CS_INT, 0x20) +#define CS_CURSTAT_DEALLOC TDS_STATIC_CAST(CS_INT, 0x40) + +#define CS_CUR_STATUS TDS_STATIC_CAST(CS_INT, 9126) +#define CS_CUR_ID TDS_STATIC_CAST(CS_INT, 9127) +#define CS_CUR_NAME TDS_STATIC_CAST(CS_INT, 9128) +#define CS_CUR_ROWCOUNT TDS_STATIC_CAST(CS_INT, 9129) + +/* options accepted by ct_options() */ +#define CS_OPT_DATEFIRST 5001 +#define CS_OPT_TEXTSIZE 5002 +#define CS_OPT_STATS_TIME 5003 +#define CS_OPT_STATS_IO 5004 +#define CS_OPT_ROWCOUNT 5005 +#define CS_OPT_DATEFORMAT 5007 +#define CS_OPT_ISOLATION 5008 +#define CS_OPT_AUTHON 5009 +#define CS_OPT_SHOWPLAN 5013 +#define CS_OPT_NOEXEC 5014 +#define CS_OPT_ARITHIGNORE 5015 +#define CS_OPT_TRUNCIGNORE 5016 +#define CS_OPT_ARITHABORT 5017 +#define CS_OPT_PARSEONLY 5018 +#define CS_OPT_GETDATA 5020 +#define CS_OPT_NOCOUNT 5021 +#define CS_OPT_FORCEPLAN 5023 +#define CS_OPT_FORMATONLY 5024 +#define CS_OPT_CHAINXACTS 5025 +#define CS_OPT_CURCLOSEONXACT 5026 +#define CS_OPT_FIPSFLAG 5027 +#define CS_OPT_RESTREES 5028 +#define CS_OPT_IDENTITYON 5029 +#define CS_OPT_CURREAD 5030 +#define CS_OPT_CURWRITE 5031 +#define CS_OPT_IDENTITYOFF 5032 +#define CS_OPT_AUTHOFF 5033 +#define CS_OPT_ANSINULL 5034 +#define CS_OPT_QUOTED_IDENT 5035 +#define CS_OPT_ANSIPERM 5036 +#define CS_OPT_STR_RTRUNC 5037 + +/* options accepted by ct_command() */ +enum ct_command_options +{ + CS_MORE = 16, + CS_END = 32, + CS_RECOMPILE = 188, + CS_NO_RECOMPILE, + CS_BULK_INIT, + CS_BULK_CONT, + CS_BULK_DATA, + CS_COLUMN_DATA +}; + + +/* + * bind formats, should be mapped to TDS types + * can be a combination of bit + */ +enum +{ + CS_FMT_UNUSED = 0, +#define CS_FMT_UNUSED CS_FMT_UNUSED + CS_FMT_NULLTERM = 1, +#define CS_FMT_NULLTERM CS_FMT_NULLTERM + CS_FMT_PADNULL = 2, +#define CS_FMT_PADBLANK CS_FMT_PADBLANK + CS_FMT_PADBLANK = 4, +#define CS_FMT_PADNULL CS_FMT_PADNULL + CS_FMT_JUSTIFY_RT = 8 +#define CS_FMT_JUSTIFY_RT CS_FMT_JUSTIFY_RT +}; + +/* callbacks */ +#define CS_COMPLETION_CB 1 +#define CS_SERVERMSG_CB 2 +#define CS_CLIENTMSG_CB 3 +#define CS_NOTIF_CB 4 +#define CS_ENCRYPT_CB 5 +#define CS_CHALLENGE_CB 6 +#define CS_DS_LOOKUP_CB 7 +#define CS_SECSESSION_CB 8 +#define CS_SIGNAL_CB 100 +#define CS_MESSAGE_CB 9119 + +/* string types */ +#define CS_NULLTERM -9 +#define CS_WILDCARD -99 +#define CS_NO_LIMIT -9999 +#define CS_UNUSED -99999 + +/* other */ +#define CS_GET 33 +#define CS_SET 34 +#define CS_CLEAR 35 +#define CS_INIT 36 +#define CS_STATUS 37 +#define CS_MSGLIMIT 38 +#define CS_SUPPORTED 40 + +#define CS_CMD_DONE 4046 +#define CS_CMD_SUCCEED 4047 +#define CS_CMD_FAIL 4048 + +/* commands */ +#define CS_LANG_CMD 148 +#define CS_RPC_CMD 149 +#define CS_SEND_DATA_CMD 151 +#define CS_SEND_BULK_CMD 153 + +#define CS_VERSION_100 112 +#define CS_VERSION_110 1100 +#define CS_VERSION_120 1100 +#define CS_VERSION_125 12500 +#define CS_VERSION_150 15000 + +#define BLK_VERSION_100 CS_VERSION_100 +#define BLK_VERSION_110 CS_VERSION_110 +#define BLK_VERSION_120 CS_VERSION_120 +#define BLK_VERSION_125 CS_VERSION_125 +#define BLK_VERSION_150 CS_VERSION_150 + +#define CS_FORCE_EXIT 300 +#define CS_FORCE_CLOSE 301 + +#define CS_SYNC_IO 8111 +#define CS_ASYNC_IO 8112 +#define CS_DEFER_IO 8113 + +#define CS_CANCEL_CURRENT 6000 +#define CS_CANCEL_ALL 6001 +#define CS_CANCEL_ATTN 6002 + +#define CS_ROW_COUNT 800 +#define CS_CMD_NUMBER 801 +#define CS_NUM_COMPUTES 802 +#define CS_NUMDATA 803 +#define CS_NUMORDERCOLS 805 +#define CS_MSGTYPE 806 +#define CS_BROWSE_INFO 807 +#define CS_TRANS_STATE 808 + +#define CS_TRAN_UNDEFINED 0 +#define CS_TRAN_IN_PROGRESS 1 +#define CS_TRAN_COMPLETED 2 +#define CS_TRAN_FAIL 3 +#define CS_TRAN_STMT_FAIL 4 + +#define CS_COMP_OP 5350 +#define CS_COMP_ID 5351 +#define CS_COMP_COLID 5352 +#define CS_COMP_BYLIST 5353 +#define CS_BYLIST_LEN 5354 + +#define CS_NO_COUNT -1 + +#define CS_OP_SUM 5370 +#define CS_OP_AVG 5371 +#define CS_OP_COUNT 5372 +#define CS_OP_MIN 5373 +#define CS_OP_MAX 5374 + +#define CS_CAP_REQUEST 1 +#define CS_CAP_RESPONSE 2 + +#define CS_PREPARE 717 +#define CS_EXECUTE 718 +#define CS_DESCRIBE_INPUT 720 +#define CS_DESCRIBE_OUTPUT 721 + +#define CS_DEALLOC 711 + +#define CS_LC_ALL 7 +#define CS_SYB_LANG 8 +#define CS_SYB_CHARSET 9 +#define CS_SYB_SORTORDER 10 +#define CS_SYB_COLLATE CS_SYB_SORTORDER +#define CS_SYB_LANG_CHARSET 11 + +#define CS_BLK_IN 1 +#define CS_BLK_OUT 2 + +#define CS_BLK_BATCH 1 +#define CS_BLK_ALL 2 +#define CS_BLK_CANCEL 3 + +/* to do support these */ + +#define CS_BLK_ARRAY_MAXLEN 0x1000 +#define CS_DEF_PREC 18 + +/* Error Severities */ +#define CS_SV_INFORM TDS_STATIC_CAST(CS_INT, 0) +#define CS_SV_API_FAIL TDS_STATIC_CAST(CS_INT, 1) +#define CS_SV_RETRY_FAIL TDS_STATIC_CAST(CS_INT, 2) +#define CS_SV_RESOURCE_FAIL TDS_STATIC_CAST(CS_INT, 3) +#define CS_SV_CONFIG_FAIL TDS_STATIC_CAST(CS_INT, 4) +#define CS_SV_COMM_FAIL TDS_STATIC_CAST(CS_INT, 5) +#define CS_SV_INTERNAL_FAIL TDS_STATIC_CAST(CS_INT, 6) +#define CS_SV_FATAL TDS_STATIC_CAST(CS_INT, 7) + +/* result_types */ +#define CS_COMPUTE_RESULT 4045 +#define CS_CURSOR_RESULT 4041 +#define CS_PARAM_RESULT 4042 +#define CS_ROW_RESULT 4040 +#define CS_STATUS_RESULT 4043 +#define CS_COMPUTEFMT_RESULT 4050 +#define CS_ROWFMT_RESULT 4049 +#define CS_MSG_RESULT 4044 +#define CS_DESCRIBE_RESULT 4051 + +/* bind types */ +#define CS_ILLEGAL_TYPE TDS_STATIC_CAST(CS_INT, -1) +#define CS_CHAR_TYPE TDS_STATIC_CAST(CS_INT, 0) +#define CS_BINARY_TYPE TDS_STATIC_CAST(CS_INT, 1) +#define CS_LONGCHAR_TYPE TDS_STATIC_CAST(CS_INT, 2) +#define CS_LONGBINARY_TYPE TDS_STATIC_CAST(CS_INT, 3) +#define CS_TEXT_TYPE TDS_STATIC_CAST(CS_INT, 4) +#define CS_IMAGE_TYPE TDS_STATIC_CAST(CS_INT, 5) +#define CS_TINYINT_TYPE TDS_STATIC_CAST(CS_INT, 6) +#define CS_SMALLINT_TYPE TDS_STATIC_CAST(CS_INT, 7) +#define CS_INT_TYPE TDS_STATIC_CAST(CS_INT, 8) +#define CS_REAL_TYPE TDS_STATIC_CAST(CS_INT, 9) +#define CS_FLOAT_TYPE TDS_STATIC_CAST(CS_INT, 10) +#define CS_BIT_TYPE TDS_STATIC_CAST(CS_INT, 11) +#define CS_DATETIME_TYPE TDS_STATIC_CAST(CS_INT, 12) +#define CS_DATETIME4_TYPE TDS_STATIC_CAST(CS_INT, 13) +#define CS_MONEY_TYPE TDS_STATIC_CAST(CS_INT, 14) +#define CS_MONEY4_TYPE TDS_STATIC_CAST(CS_INT, 15) +#define CS_NUMERIC_TYPE TDS_STATIC_CAST(CS_INT, 16) +#define CS_DECIMAL_TYPE TDS_STATIC_CAST(CS_INT, 17) +#define CS_VARCHAR_TYPE TDS_STATIC_CAST(CS_INT, 18) +#define CS_VARBINARY_TYPE TDS_STATIC_CAST(CS_INT, 19) +#define CS_LONG_TYPE TDS_STATIC_CAST(CS_INT, 20) +#define CS_SENSITIVITY_TYPE TDS_STATIC_CAST(CS_INT, 21) +#define CS_BOUNDARY_TYPE TDS_STATIC_CAST(CS_INT, 22) +#define CS_VOID_TYPE TDS_STATIC_CAST(CS_INT, 23) +#define CS_USHORT_TYPE TDS_STATIC_CAST(CS_INT, 24) +#define CS_UNICHAR_TYPE TDS_STATIC_CAST(CS_INT, 25) +#define CS_BLOB_TYPE TDS_STATIC_CAST(CS_INT, 26) +#define CS_DATE_TYPE TDS_STATIC_CAST(CS_INT, 27) +#define CS_TIME_TYPE TDS_STATIC_CAST(CS_INT, 28) +#define CS_UNITEXT_TYPE TDS_STATIC_CAST(CS_INT, 29) +#define CS_BIGINT_TYPE TDS_STATIC_CAST(CS_INT, 30) +#define CS_USMALLINT_TYPE TDS_STATIC_CAST(CS_INT, 31) +#define CS_UINT_TYPE TDS_STATIC_CAST(CS_INT, 32) +#define CS_UBIGINT_TYPE TDS_STATIC_CAST(CS_INT, 33) +#define CS_XML_TYPE TDS_STATIC_CAST(CS_INT, 34) +#define CS_BIGDATETIME_TYPE TDS_STATIC_CAST(CS_INT, 35) +#define CS_BIGTIME_TYPE TDS_STATIC_CAST(CS_INT, 36) +#define CS_UNIQUE_TYPE TDS_STATIC_CAST(CS_INT, 40) + +#define CS_USER_TYPE TDS_STATIC_CAST(CS_INT, 100) +/* cs_dt_info type values */ +enum +{ + CS_MONTH = 7340, +#define CS_MONTH CS_MONTH + CS_SHORTMONTH, +#define CS_SHORTMONTH CS_SHORTMONTH + CS_DAYNAME, +#define CS_DAYNAME CS_DAYNAME + CS_DATEORDER, +#define CS_DATEORDER CS_DATEORDER + CS_12HOUR, +#define CS_12HOUR CS_12HOUR + CS_DT_CONVFMT +#define CS_DT_CONVFMT CS_DT_CONVFMT +}; + +/* DT_CONVFMT types */ +enum +{ + CS_DATES_SHORT = 0, +#define CS_DATES_SHORT CS_DATES_SHORT + CS_DATES_MDY1, +#define CS_DATES_MDY1 CS_DATES_MDY1 + CS_DATES_YMD1, +#define CS_DATES_YMD1 CS_DATES_YMD1 + CS_DATES_DMY1, +#define CS_DATES_DMY1 CS_DATES_DMY1 + CS_DATES_DMY2, +#define CS_DATES_DMY2 CS_DATES_DMY2 + CS_DATES_DMY3, +#define CS_DATES_DMY3 CS_DATES_DMY3 + CS_DATES_DMY4, +#define CS_DATES_DMY4 CS_DATES_DMY4 + CS_DATES_MDY2, +#define CS_DATES_MDY2 CS_DATES_MDY2 + CS_DATES_HMS, +#define CS_DATES_HMS CS_DATES_HMS + CS_DATES_LONG, +#define CS_DATES_LONG CS_DATES_LONG + CS_DATES_MDY3, +#define CS_DATES_MDY3 CS_DATES_MDY3 + CS_DATES_YMD2, +#define CS_DATES_YMD2 CS_DATES_YMD2 + CS_DATES_YMD3, +#define CS_DATES_YMD3 CS_DATES_YMD3 + CS_DATES_YDM1, +#define CS_DATES_YDM1 CS_DATES_YDM1 + CS_DATES_MYD1, +#define CS_DATES_MYD1 CS_DATES_MYD1 + CS_DATES_DYM1, +#define CS_DATES_DYM1 CS_DATES_DYM1 + CS_DATES_MDY1_YYYY = 101, +#define CS_DATES_MDY1_YYYY CS_DATES_MDY1_YYYY + CS_DATES_YMD1_YYYY, +#define CS_DATES_YMD1_YYYY CS_DATES_YMD1_YYYY + CS_DATES_DMY1_YYYY, +#define CS_DATES_DMY1_YYYY CS_DATES_DMY1_YYYY + CS_DATES_DMY2_YYYY, +#define CS_DATES_DMY2_YYYY CS_DATES_DMY2_YYYY + CS_DATES_DMY3_YYYY, +#define CS_DATES_DMY3_YYYY CS_DATES_DMY3_YYYY + CS_DATES_DMY4_YYYY, +#define CS_DATES_DMY4_YYYY CS_DATES_DMY4_YYYY + CS_DATES_MDY2_YYYY, +#define CS_DATES_MDY2_YYYY CS_DATES_MDY2_YYYY + CS_DATES_MDY3_YYYY = 110, +#define CS_DATES_MDY3_YYYY CS_DATES_MDY3_YYYY + CS_DATES_YMD2_YYYY, +#define CS_DATES_YMD2_YYYY CS_DATES_YMD2_YYYY + CS_DATES_YMD3_YYYY +#define CS_DATES_YMD3_YYYY CS_DATES_YMD3_YYYY +}; + +typedef CS_RETCODE(*CS_CONV_FUNC) (CS_CONTEXT * context, CS_DATAFMT * srcfmt, CS_VOID * src, CS_DATAFMT * detsfmt, CS_VOID * dest, + CS_INT * destlen); + +typedef struct _cs_objname +{ + CS_BOOL thinkexists; + CS_INT object_type; + CS_CHAR last_name[CS_MAX_NAME]; + CS_INT lnlen; + CS_CHAR first_name[CS_MAX_NAME]; + CS_INT fnlen; + CS_VOID *scope; + CS_INT scopelen; + CS_VOID *thread; + CS_INT threadlen; +} CS_OBJNAME; + +typedef struct _cs_objdata +{ + CS_BOOL actuallyexists; + CS_CONNECTION *connection; + CS_COMMAND *command; + CS_VOID *buffer; + CS_INT buflen; +} CS_OBJDATA; + +/* Eventually, these should be in terms of TDS values */ +enum +{ + CS_OPT_MONDAY = 1, + CS_OPT_TUESDAY, + CS_OPT_WEDNESDAY, + CS_OPT_THURSDAY, + CS_OPT_FRIDAY, + CS_OPT_SATURDAY, + CS_OPT_SUNDAY +}; +enum +{ + CS_OPT_FMTMDY = 1, + CS_OPT_FMTDMY, + CS_OPT_FMTYMD, + CS_OPT_FMTYDM, + CS_OPT_FMTMYD, + CS_OPT_FMTDYM +}; +enum +{ + CS_OPT_LEVEL0 = 0, + CS_OPT_LEVEL1, + CS_OPT_LEVEL2, + CS_OPT_LEVEL3 +}; + +#define CS_FALSE 0 +#define CS_TRUE 1 + +#define SRV_PROC CS_VOID + +/* constants required for ct_diag (not jet implemented) */ +#define CS_CLIENTMSG_TYPE 4700 +#define CS_SERVERMSG_TYPE 4701 +#define CS_ALLMSG_TYPE 4702 + +CS_RETCODE cs_convert(CS_CONTEXT * ctx, CS_DATAFMT * srcfmt, CS_VOID * srcdata, CS_DATAFMT * destfmt, CS_VOID * destdata, + CS_INT * resultlen); +CS_RETCODE cs_ctx_alloc(CS_INT version, CS_CONTEXT ** ctx); +CS_RETCODE cs_ctx_global(CS_INT version, CS_CONTEXT ** ctx); +CS_RETCODE cs_ctx_drop(CS_CONTEXT * ctx); +CS_RETCODE cs_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); +CS_RETCODE cs_strbuild(CS_CONTEXT * ctx, CS_CHAR * buffer, CS_INT buflen, CS_INT * resultlen, CS_CHAR * text, CS_INT textlen, + CS_CHAR * formats, CS_INT formatlen, ...); +#undef cs_dt_crack +CS_RETCODE cs_dt_crack(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec); +CS_RETCODE cs_dt_crack_v2(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec); +#define cs_dt_crack cs_dt_crack_v2 +CS_RETCODE cs_loc_alloc(CS_CONTEXT * ctx, CS_LOCALE ** locptr); +CS_RETCODE cs_loc_drop(CS_CONTEXT * ctx, CS_LOCALE * locale); +CS_RETCODE cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_VOID * buffer, CS_INT buflen, + CS_INT * outlen); +CS_RETCODE cs_dt_info(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_INT item, CS_VOID * buffer, + CS_INT buflen, CS_INT * outlen); + +CS_RETCODE cs_calc(CS_CONTEXT * ctx, CS_INT op, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_VOID * dest); +CS_RETCODE cs_cmp(CS_CONTEXT * ctx, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_INT * result); +CS_RETCODE cs_conv_mult(CS_CONTEXT * ctx, CS_LOCALE * srcloc, CS_LOCALE * destloc, CS_INT * conv_multiplier); +CS_RETCODE cs_diag(CS_CONTEXT * ctx, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer); +CS_RETCODE cs_manage_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_CHAR * srcname, CS_INT srcnamelen, CS_INT desttype, + CS_CHAR * destname, CS_INT destnamelen, CS_INT * conv_multiplier, CS_CONV_FUNC * func); +CS_RETCODE cs_objects(CS_CONTEXT * ctx, CS_INT action, CS_OBJNAME * objname, CS_OBJDATA * objdata); +CS_RETCODE cs_set_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_INT desttype, CS_CONV_FUNC * func); +CS_RETCODE cs_setnull(CS_CONTEXT * ctx, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT buflen); +CS_RETCODE cs_strcmp(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_INT type, CS_CHAR * str1, CS_INT len1, CS_CHAR * str2, CS_INT len2, + CS_INT * result); +CS_RETCODE cs_time(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen, CS_DATEREC * daterec); +CS_RETCODE cs_will_convert(CS_CONTEXT * ctx, CS_INT srctype, CS_INT desttype, CS_BOOL * result); + +const char * cs_prretcode(int retcode); + +#ifdef __cplusplus +#if 0 +{ +#endif +} +#endif + +#endif diff --git a/freetds-1.1.24_build/include/cstypes.h b/freetds-1.1.24_build/include/cstypes.h new file mode 100644 index 0000000..b656bbd --- /dev/null +++ b/freetds-1.1.24_build/include/cstypes.h @@ -0,0 +1,214 @@ +/* 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 + +typedef int32_t CS_INT; +typedef uint32_t CS_UINT; +typedef int64_t CS_BIGINT; +typedef uint64_t CS_UBIGINT; +typedef int16_t CS_SMALLINT; +typedef uint16_t 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 int32_t 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 uint16_t CS_USHORT; +typedef unsigned char CS_BIT; + +typedef CS_INT CS_RETCODE; + +#define CS_MAX_NAME 132 +#define CS_MAX_SCALE 77 +#define CS_MAX_PREC 77 /* used by php */ +#define CS_MAX_NUMLEN 33 /* used by roguewave */ +#define CS_MAX_MSG 1024 +#define CS_SQLSTATE_SIZE 8 +#define CS_OBJ_NAME 400 +#define CS_TP_SIZE 16 /* text pointer */ +#define CS_TS_SIZE 8 /* length of timestamp */ + + +typedef struct _cs_numeric +{ + unsigned char precision; + unsigned char scale; + unsigned char array[CS_MAX_NUMLEN]; +} CS_NUMERIC; + +typedef CS_NUMERIC CS_DECIMAL; + +typedef struct _cs_varbinary +{ + CS_SMALLINT len; + CS_CHAR array[256]; +} CS_VARBINARY; + +typedef struct _cs_varchar +{ + CS_SMALLINT len; /* length of the string */ + CS_CHAR str[256]; /* string, no NULL terminator */ +} CS_VARCHAR; + +typedef struct _cs_config CS_CONFIG; +typedef struct _cs_context CS_CONTEXT; +typedef struct _cs_connection CS_CONNECTION; +typedef struct _cs_locale CS_LOCALE; +typedef struct _cs_command CS_COMMAND; +typedef struct _cs_blk_row CS_BLK_ROW; + +typedef struct _cs_iodesc +{ + CS_INT iotype; + CS_INT datatype; + CS_LOCALE *locale; + CS_INT usertype; + CS_INT total_txtlen; + CS_INT offset; + CS_BOOL log_on_update; + CS_CHAR name[CS_OBJ_NAME]; + CS_INT namelen; + CS_BYTE timestamp[CS_TS_SIZE]; + CS_INT timestamplen; + CS_BYTE textptr[CS_TP_SIZE]; + CS_INT textptrlen; +} CS_IODESC; + +typedef struct _cs_datafmt +{ + CS_CHAR name[CS_MAX_NAME]; + CS_INT namelen; + CS_INT datatype; + CS_INT format; + CS_INT maxlength; + CS_INT scale; + CS_INT precision; + CS_INT status; + CS_INT count; + CS_INT usertype; + CS_LOCALE *locale; +} CS_DATAFMT; + +typedef struct _cs_money +{ + CS_INT mnyhigh; + CS_UINT mnylow; +} CS_MONEY; + +typedef struct _cs_money4 +{ + CS_INT mny4; +} CS_MONEY4; + +typedef CS_INT CS_DATE; + +typedef CS_INT CS_TIME; + +typedef CS_UBIGINT CS_BIGDATETIME; +typedef CS_UBIGINT CS_BIGTIME; + +typedef struct _cs_datetime +{ + CS_INT dtdays; + CS_INT dttime; +} CS_DATETIME; + +typedef struct _cs_datetime4 +{ + CS_USHORT days; + CS_USHORT minutes; +} CS_DATETIME4; + +typedef struct _cs_daterec +{ + CS_INT dateyear; + CS_INT datemonth; + CS_INT datedmonth; + CS_INT datedyear; + CS_INT datedweek; + CS_INT datehour; + CS_INT dateminute; + CS_INT datesecond; + CS_INT datemsecond; + CS_INT datetzone; + CS_INT datesecfrac; + CS_INT datesecprec; +} CS_DATEREC; + +typedef CS_INT CS_MSGNUM; + +typedef struct _cs_clientmsg +{ + CS_INT severity; + CS_MSGNUM msgnumber; + CS_CHAR msgstring[CS_MAX_MSG]; + CS_INT msgstringlen; + CS_INT osnumber; + CS_CHAR osstring[CS_MAX_MSG]; + CS_INT osstringlen; + CS_INT status; + CS_BYTE sqlstate[CS_SQLSTATE_SIZE]; + CS_INT sqlstatelen; +} CS_CLIENTMSG; + +typedef struct _cs_servermsg +{ + CS_MSGNUM msgnumber; + CS_INT state; + CS_INT severity; + CS_CHAR text[CS_MAX_MSG]; + CS_INT textlen; + CS_CHAR svrname[CS_MAX_NAME]; + CS_INT svrnlen; + CS_CHAR proc[CS_MAX_NAME]; + CS_INT proclen; + CS_INT line; + CS_INT status; + CS_BYTE sqlstate[CS_SQLSTATE_SIZE]; + CS_INT sqlstatelen; +} CS_SERVERMSG; + +#ifdef __cplusplus +#if 0 +{ +#endif +} +#endif + +#endif diff --git a/freetds-1.1.24_build/include/ctpublic.h b/freetds-1.1.24_build/include/ctpublic.h new file mode 100644 index 0000000..0f79952 --- /dev/null +++ b/freetds-1.1.24_build/include/ctpublic.h @@ -0,0 +1,140 @@ +/* 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 diff --git a/freetds-1.1.24_build/include/odbcss.h b/freetds-1.1.24_build/include/odbcss.h new file mode 100644 index 0000000..f643510 --- /dev/null +++ b/freetds-1.1.24_build/include/odbcss.h @@ -0,0 +1,373 @@ +/* FreeTDS - Library of routines accessing Sybase and Microsoft databases + * Copyright (C) 2008 Frediano Ziglio + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _odbcss_h_ +#define _odbcss_h_ + +#ifdef TDSODBC_BCP +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define SQL_DIAG_SS_MSGSTATE (-1150) +#define SQL_DIAG_SS_LINE (-1154) + +#define SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT 1233 +#define SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT 1234 +#define SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS 1235 + +#ifndef SQL_SS_LENGTH_UNLIMITED +#define SQL_SS_LENGTH_UNLIMITED 0 +#endif + +#ifndef SQL_COPT_SS_BASE +#define SQL_COPT_SS_BASE 1200 +#endif + +#ifndef SQL_COPT_SS_MARS_ENABLED +#define SQL_COPT_SS_MARS_ENABLED (SQL_COPT_SS_BASE+24) +#endif + +#ifndef SQL_COPT_SS_OLDPWD +#define SQL_COPT_SS_OLDPWD (SQL_COPT_SS_BASE+26) +#endif + +#define SQL_INFO_FREETDS_TDS_VERSION 1300 +#define SQL_INFO_FREETDS_SOCKET 1301 + +#ifndef SQL_MARS_ENABLED_NO +#define SQL_MARS_ENABLED_NO 0 +#endif + +#ifndef SQL_MARS_ENABLED_YES +#define SQL_MARS_ENABLED_YES 1 +#endif + +#ifndef SQL_SS_VARIANT +#define SQL_SS_VARIANT (-150) +#endif + +#ifndef SQL_SS_UDT +#define SQL_SS_UDT (-151) +#endif + +#ifndef SQL_SS_XML +#define SQL_SS_XML (-152) +#endif + +#ifndef SQL_SS_TABLE +#define SQL_SS_TABLE (-153) +#endif + +#ifndef SQL_SS_TIME2 +#define SQL_SS_TIME2 (-154) +#endif + +#ifndef SQL_SS_TIMESTAMPOFFSET +#define SQL_SS_TIMESTAMPOFFSET (-155) +#endif + +/* + * these types are used from conversion from client to server + */ +#ifndef SQL_C_SS_TIME2 +#define SQL_C_SS_TIME2 (0x4000) +#endif + +#ifndef SQL_C_SS_TIMESTAMPOFFSET +#define SQL_C_SS_TIMESTAMPOFFSET (0x4001) +#endif + +#ifndef SQL_CA_SS_BASE +#define SQL_CA_SS_BASE 1200 +#endif + +#ifndef SQL_CA_SS_UDT_CATALOG_NAME +#define SQL_CA_SS_UDT_CATALOG_NAME (SQL_CA_SS_BASE+18) +#endif + +#ifndef SQL_CA_SS_UDT_SCHEMA_NAME +#define SQL_CA_SS_UDT_SCHEMA_NAME (SQL_CA_SS_BASE+19) +#endif + +#ifndef SQL_CA_SS_UDT_TYPE_NAME +#define SQL_CA_SS_UDT_TYPE_NAME (SQL_CA_SS_BASE+20) +#endif + +#ifndef SQL_CA_SS_UDT_ASSEMBLY_TYPE_NAME +#define SQL_CA_SS_UDT_ASSEMBLY_TYPE_NAME (SQL_CA_SS_BASE+21) +#endif + +#ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_CATALOG_NAME +#define SQL_CA_SS_XML_SCHEMACOLLECTION_CATALOG_NAME (SQL_CA_SS_BASE+22) +#endif + +#ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_SCHEMA_NAME +#define SQL_CA_SS_XML_SCHEMACOLLECTION_SCHEMA_NAME (SQL_CA_SS_BASE+23) +#endif + +#ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_NAME +#define SQL_CA_SS_XML_SCHEMACOLLECTION_NAME (SQL_CA_SS_BASE+24) +#endif + +typedef struct tagSS_TIME2_STRUCT { + SQLUSMALLINT hour; + SQLUSMALLINT minute; + SQLUSMALLINT second; + SQLUINTEGER fraction; +} SQL_SS_TIME2_STRUCT; + +typedef struct tagSS_TIMESTAMPOFFSET_STRUCT { + SQLSMALLINT year; + SQLUSMALLINT month; + SQLUSMALLINT day; + SQLUSMALLINT hour; + SQLUSMALLINT minute; + SQLUSMALLINT second; + SQLUINTEGER fraction; + SQLSMALLINT timezone_hour; + SQLSMALLINT timezone_minute; +} SQL_SS_TIMESTAMPOFFSET_STRUCT; + + +#ifdef TDSODBC_BCP + +#ifndef SUCCEED +#define SUCCEED 1 +#endif +#ifndef FAIL +#define FAIL 0 +#endif + +#ifndef BCPKEEPIDENTITY +#define BCPKEEPIDENTITY 8 +#endif +#ifndef BCPHINTS +#define BCPHINTS 6 +#endif + +#define BCP_DIRECTION_IN 1 + +#define SQL_COPT_SS_BCP (SQL_COPT_SS_BASE+19) +#define SQL_BCP_OFF 0 +#define SQL_BCP_ON 1 + +#define SQL_COPT_TDSODBC_IMPL_BASE 1500 +#define SQL_COPT_TDSODBC_IMPL_BCP_INITA (SQL_COPT_TDSODBC_IMPL_BASE) +#define SQL_COPT_TDSODBC_IMPL_BCP_CONTROL (SQL_COPT_TDSODBC_IMPL_BASE+1) +#define SQL_COPT_TDSODBC_IMPL_BCP_COLPTR (SQL_COPT_TDSODBC_IMPL_BASE+2) +#define SQL_COPT_TDSODBC_IMPL_BCP_SENDROW (SQL_COPT_TDSODBC_IMPL_BASE+3) +#define SQL_COPT_TDSODBC_IMPL_BCP_BATCH (SQL_COPT_TDSODBC_IMPL_BASE+4) +#define SQL_COPT_TDSODBC_IMPL_BCP_DONE (SQL_COPT_TDSODBC_IMPL_BASE+5) +#define SQL_COPT_TDSODBC_IMPL_BCP_BIND (SQL_COPT_TDSODBC_IMPL_BASE+6) +#define SQL_COPT_TDSODBC_IMPL_BCP_INITW (SQL_COPT_TDSODBC_IMPL_BASE+7) + +#define SQL_VARLEN_DATA -10 + +/* copied from sybdb.h which was copied from tds.h */ +/* TODO find a much better way... */ +enum +{ + BCP_TYPE_SQLCHAR = 47, /* 0x2F */ +#define BCP_TYPE_SQLCHAR BCP_TYPE_SQLCHAR + BCP_TYPE_SQLVARCHAR = 39, /* 0x27 */ +#define BCP_TYPE_SQLVARCHAR BCP_TYPE_SQLVARCHAR + BCP_TYPE_SQLINTN = 38, /* 0x26 */ +#define BCP_TYPE_SQLINTN BCP_TYPE_SQLINTN + BCP_TYPE_SQLINT1 = 48, /* 0x30 */ +#define BCP_TYPE_SQLINT1 BCP_TYPE_SQLINT1 + BCP_TYPE_SQLINT2 = 52, /* 0x34 */ +#define BCP_TYPE_SQLINT2 BCP_TYPE_SQLINT2 + BCP_TYPE_SQLINT4 = 56, /* 0x38 */ +#define BCP_TYPE_SQLINT4 BCP_TYPE_SQLINT4 + BCP_TYPE_SQLINT8 = 127, /* 0x7F */ +#define BCP_TYPE_SQLINT8 BCP_TYPE_SQLINT8 + BCP_TYPE_SQLFLT8 = 62, /* 0x3E */ +#define BCP_TYPE_SQLFLT8 BCP_TYPE_SQLFLT8 + BCP_TYPE_SQLDATETIME = 61, /* 0x3D */ +#define BCP_TYPE_SQLDATETIME BCP_TYPE_SQLDATETIME + BCP_TYPE_SQLBIT = 50, /* 0x32 */ +#define BCP_TYPE_SQLBIT BCP_TYPE_SQLBIT + BCP_TYPE_SQLBITN = 104, /* 0x68 */ +#define BCP_TYPE_SQLBITN BCP_TYPE_SQLBITN + BCP_TYPE_SQLTEXT = 35, /* 0x23 */ +#define BCP_TYPE_SQLTEXT BCP_TYPE_SQLTEXT + BCP_TYPE_SQLNTEXT = 99, /* 0x63 */ +#define BCP_TYPE_SQLNTEXT BCP_TYPE_SQLNTEXT + BCP_TYPE_SQLIMAGE = 34, /* 0x22 */ +#define BCP_TYPE_SQLIMAGE BCP_TYPE_SQLIMAGE + BCP_TYPE_SQLMONEY4 = 122, /* 0x7A */ +#define BCP_TYPE_SQLMONEY4 BCP_TYPE_SQLMONEY4 + BCP_TYPE_SQLMONEY = 60, /* 0x3C */ +#define BCP_TYPE_SQLMONEY BCP_TYPE_SQLMONEY + BCP_TYPE_SQLDATETIME4 = 58, /* 0x3A */ +#define BCP_TYPE_SQLDATETIME4 BCP_TYPE_SQLDATETIME4 + BCP_TYPE_SQLREAL = 59, /* 0x3B */ + BCP_TYPE_SQLFLT4 = 59, /* 0x3B */ +#define BCP_TYPE_SQLREAL BCP_TYPE_SQLREAL +#define BCP_TYPE_SQLFLT4 BCP_TYPE_SQLFLT4 + BCP_TYPE_SQLBINARY = 45, /* 0x2D */ +#define BCP_TYPE_SQLBINARY BCP_TYPE_SQLBINARY + BCP_TYPE_SQLVOID = 31, /* 0x1F */ +#define BCP_TYPE_SQLVOID BCP_TYPE_SQLVOID + BCP_TYPE_SQLVARBINARY = 37, /* 0x25 */ +#define BCP_TYPE_SQLVARBINARY BCP_TYPE_SQLVARBINARY + BCP_TYPE_SQLNUMERIC = 108, /* 0x6C */ +#define BCP_TYPE_SQLNUMERIC BCP_TYPE_SQLNUMERIC + BCP_TYPE_SQLDECIMAL = 106, /* 0x6A */ +#define BCP_TYPE_SQLDECIMAL BCP_TYPE_SQLDECIMAL + BCP_TYPE_SQLFLTN = 109, /* 0x6D */ +#define BCP_TYPE_SQLFLTN BCP_TYPE_SQLFLTN + BCP_TYPE_SQLMONEYN = 110, /* 0x6E */ +#define BCP_TYPE_SQLMONEYN BCP_TYPE_SQLMONEYN + BCP_TYPE_SQLDATETIMN = 111, /* 0x6F */ +#define BCP_TYPE_SQLDATETIMN BCP_TYPE_SQLDATETIMN + BCP_TYPE_SQLNVARCHAR = 103, /* 0x67 */ +#define BCP_TYPE_SQLNVARCHAR BCP_TYPE_SQLNVARCHAR + BCP_TYPE_SQLUNIQUEID = 36, /* 0x24 */ +#define BCP_TYPE_SQLUNIQUEID BCP_TYPE_SQLUNIQUEID + BCP_TYPE_SQLDATETIME2 = 42, /* 0x2a */ +#define BCP_TYPE_SQLDATETIME2 BCP_TYPE_SQLDATETIME2 +}; + +typedef struct +{ + int dtdays; + int dttime; +} DBDATETIME; + +#ifdef _MSC_VER +#define TDSODBC_INLINE __inline +#else +#define TDSODBC_INLINE __inline__ +#endif + +struct tdsodbc_impl_bcp_init_params +{ + const void *tblname; + const void *hfile; + const void *errfile; + int direction; +}; + +static TDSODBC_INLINE RETCODE SQL_API +bcp_initA(HDBC hdbc, const char *tblname, const char *hfile, const char *errfile, int direction) +{ + struct tdsodbc_impl_bcp_init_params params = {tblname, hfile, errfile, direction}; + return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_INITA, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; +} + +static TDSODBC_INLINE RETCODE SQL_API +bcp_initW(HDBC hdbc, const SQLWCHAR *tblname, const SQLWCHAR *hfile, const SQLWCHAR *errfile, int direction) +{ + struct tdsodbc_impl_bcp_init_params params = {tblname, hfile, errfile, direction}; + return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_INITW, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; +} + +struct tdsodbc_impl_bcp_control_params +{ + int field; + void *value; +}; + +static TDSODBC_INLINE RETCODE SQL_API +bcp_control(HDBC hdbc, int field, void *value) +{ + struct tdsodbc_impl_bcp_control_params params = {field, value}; + return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_CONTROL, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; +} + +struct tdsodbc_impl_bcp_colptr_params +{ + const unsigned char * colptr; + int table_column; +}; + +static TDSODBC_INLINE RETCODE SQL_API +bcp_colptr(HDBC hdbc, const unsigned char * colptr, int table_column) +{ + struct tdsodbc_impl_bcp_colptr_params params = {colptr, table_column}; + return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_COLPTR, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; +} + +static TDSODBC_INLINE RETCODE SQL_API +bcp_sendrow(HDBC hdbc) +{ + return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_SENDROW, NULL, SQL_IS_POINTER)) ? SUCCEED : FAIL; +} + +struct tdsodbc_impl_bcp_batch_params +{ + int rows; +}; + +static TDSODBC_INLINE int SQL_API +bcp_batch(HDBC hdbc) +{ + struct tdsodbc_impl_bcp_batch_params params = {-1}; + return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_BATCH, ¶ms, SQL_IS_POINTER)) ? params.rows : -1; +} + +struct tdsodbc_impl_bcp_done_params +{ + int rows; +}; + +static TDSODBC_INLINE int SQL_API +bcp_done(HDBC hdbc) +{ + struct tdsodbc_impl_bcp_done_params params = {-1}; + return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_DONE, ¶ms, SQL_IS_POINTER)) ? params.rows : -1; +} + +struct tdsodbc_impl_bcp_bind_params +{ + const unsigned char * varaddr; + int prefixlen; + int varlen; + const unsigned char * terminator; + int termlen; + int vartype; + int table_column; +}; + +static TDSODBC_INLINE RETCODE SQL_API +bcp_bind(HDBC hdbc, const unsigned char * varaddr, int prefixlen, int varlen, + const unsigned char * terminator, int termlen, int vartype, int table_column) +{ + struct tdsodbc_impl_bcp_bind_params params = {varaddr, prefixlen, varlen, terminator, termlen, vartype, table_column}; + return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_BIND, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; +} + +#ifdef UNICODE +#define bcp_init bcp_initW +#else +#define bcp_init bcp_initA +#endif + +#endif /* TDSODBC_BCP */ + +#ifdef __cplusplus +} +#endif + +#endif /* _odbcss_h_ */ diff --git a/freetds-1.1.24_build/include/sqldb.h b/freetds-1.1.24_build/include/sqldb.h new file mode 100644 index 0000000..55e9195 --- /dev/null +++ b/freetds-1.1.24_build/include/sqldb.h @@ -0,0 +1,180 @@ +/* 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 diff --git a/freetds-1.1.24_build/include/sqlfront.h b/freetds-1.1.24_build/include/sqlfront.h new file mode 100644 index 0000000..d351f88 --- /dev/null +++ b/freetds-1.1.24_build/include/sqlfront.h @@ -0,0 +1,57 @@ +/* FreeTDS - Library of routines accessing Sybase and Microsoft databases + * Copyright (C) 1998-1999 Brian Bruns + * Copyright (C) 2011 Frediano Ziglio + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef SQLFRONT_h +#define SQLFRONT_h + +#include "./sybfront.h" + +static const char rcsid_sqlfront_h[] = "$Id: sqlfront.h,v 1.10 2011-07-13 11:06:31 freddy77 Exp $"; +static const void *const no_unused_sqlfront_h_warn[] = { rcsid_sqlfront_h, no_unused_sqlfront_h_warn }; + +typedef DBPROCESS * PDBPROCESS; +typedef LOGINREC * PLOGINREC; +typedef DBCURSOR * PDBCURSOR; + +typedef int * LPINT; +typedef char * LPSTR; +#if !defined(PHP_MSSQL_H) || !defined(PHP_MSSQL_API) +typedef BYTE * LPBYTE; +#endif +typedef void * LPVOID; +typedef const char * LPCSTR; + +typedef const LPINT LPCINT; +#ifndef _LPCBYTE_DEFINED +#define _LPCBYTE_DEFINED +typedef const BYTE * LPCBYTE; +#endif +typedef USHORT * LPUSHORT; +typedef const LPUSHORT LPCUSHORT; +typedef DBINT * LPDBINT; +typedef const LPDBINT LPCDBINT; +typedef DBBINARY * LPDBBINARY; +typedef const LPDBBINARY LPCDBBINARY; +typedef DBDATEREC * LPDBDATEREC; +typedef const LPDBDATEREC LPCDBDATEREC; +typedef DBDATETIME * LPDBDATETIME; +typedef const LPDBDATETIME LPCDBDATETIME; + +#endif diff --git a/freetds-1.1.24_build/include/sybdb.h b/freetds-1.1.24_build/include/sybdb.h new file mode 100644 index 0000000..8e99c8f --- /dev/null +++ b/freetds-1.1.24_build/include/sybdb.h @@ -0,0 +1,1323 @@ +/* FreeTDS - Library of routines accessing Sybase and Microsoft databases + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns + * Copyright (C) 2010, 2011 Frediano Ziglio + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/** \file ../include/sybdb.h + * \brief Primary include file for db-lib applications. + * + * Declares macros, functions, enumerated types, and defined tokens + * used by the db-lib API. + */ + +#ifndef _sybdb_h_ +#define _sybdb_h_ + +#include "tds_sysdep_public.h" + +#undef TDS_STATIC_CAST +#ifdef __cplusplus +#define TDS_STATIC_CAST(type, a) static_cast(a) +extern "C" +{ +#if 0 +} +#endif +#else +#define TDS_STATIC_CAST(type, a) ((type)(a)) +#endif + +#ifdef FALSE +#undef FALSE +#endif +#ifdef TRUE +#undef TRUE +#endif +#define FALSE 0 +#define TRUE 1 + +#define DBSAVE 1 +#define DBNOSAVE 0 +#define DBNOERR -1 + +#define INT_EXIT 0 +#define INT_CONTINUE 1 +#define INT_CANCEL 2 +#define INT_TIMEOUT 3 + +#define DBMAXNUMLEN 33 +/* https://msdn.microsoft.com/en-us/library/ms176061.aspx */ +#define DBMAXNAME 128 + +/** + * DBVERSION_xxx are used with dbsetversion() + */ +#define DBVERSION_UNKNOWN 0 +#define DBVERSION_46 1 +#define DBVERSION_100 2 +#define DBVERSION_42 3 +#define DBVERSION_70 4 +#define DBVERSION_71 5 +#define DBVERSION_72 6 +#define DBVERSION_73 7 +#define DBVERSION_74 8 + +/* these two are defined by Microsoft for dbsetlversion() */ +#define DBVER42 DBVERSION_42 +#define DBVER60 DBVERSION_70 /* our best approximation */ + +/** + * DBTDS_xxx are returned by DBTDS() + * The integer values of the constants are poorly chosen. + */ +#define DBTDS_UNKNOWN 0 +#define DBTDS_2_0 1 /* pre 4.0 SQL Server */ +#define DBTDS_3_4 2 /* Microsoft SQL Server (3.0) */ +#define DBTDS_4_0 3 /* 4.0 SQL Server */ +#define DBTDS_4_2 4 /* 4.2 SQL Server */ +#define DBTDS_4_6 5 /* 2.0 OpenServer and 4.6 SQL Server. */ +#define DBTDS_4_9_5 6 /* 4.9.5 (NCR) SQL Server */ +#define DBTDS_5_0 7 /* 5.0 SQL Server */ +#define DBTDS_7_0 8 /* Microsoft SQL Server 7.0 */ +#define DBTDS_8_0 9 /* Microsoft SQL Server 2000 */ +#define DBTDS_9_0 10 /* Microsoft SQL Server 2005 */ +#define DBTDS_7_1 9 /* Microsoft SQL Server 2000 */ +#define DBTDS_7_2 10 /* Microsoft SQL Server 2005 */ +#define DBTDS_7_3 11 /* Microsoft SQL Server 2008 */ +#define DBTDS_7_4 12 /* Microsoft SQL Server 2012/2014 */ + +#define DBTXPLEN 16 + +#define BCPMAXERRS 1 +#define BCPFIRST 2 +#define BCPLAST 3 +#define BCPBATCH 4 +#define BCPKEEPIDENTITY 8 + +#define BCPLABELED 5 +#define BCPHINTS 6 + +#define DBCMDNONE 0 +#define DBCMDPEND 1 +#define DBCMDSENT 2 + +typedef int RETCODE; + +typedef void DBCURSOR; +typedef void DBXLATE; +typedef void DBSORTORDER; +typedef void DBLOGINFO; +typedef void *DBVOIDPTR; +typedef short SHORT; +typedef unsigned short USHORT; +typedef int (*INTFUNCPTR) (void *, ...); +typedef int (*DBWAITFUNC) (void); +typedef DBWAITFUNC(*DB_DBBUSY_FUNC) (void *dbproc); +typedef void (*DB_DBIDLE_FUNC) (DBWAITFUNC dfunc, void *dbproc); +typedef int (*DB_DBCHKINTR_FUNC) (void *dbproc); +typedef int (*DB_DBHNDLINTR_FUNC) (void *dbproc); + +#ifndef __INCvxWorksh +/* VxWorks already defines STATUS and BOOL. Compiler gets mad if you +** redefine them. */ +/* __INCvxWorksh will get #defined by std. include files included from tds.h +*/ +#ifdef STATUS +/* On DU4.0d we get a conflicting STATUS definition from arpa/nameser.h + when _REENTRANT is defined. +*/ +#undef STATUS +#endif +typedef int STATUS; +#if !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(DOS32X) +typedef int BOOL; +#endif +#endif + +#ifndef _tds_h_ +/* copied from tds.h */ +/* TODO find a best way... */ +enum +{ + SYBCHAR = 47, /* 0x2F */ +#define SYBCHAR SYBCHAR + SYBVARCHAR = 39, /* 0x27 */ +#define SYBVARCHAR SYBVARCHAR + SYBINTN = 38, /* 0x26 */ +#define SYBINTN SYBINTN + SYBINT1 = 48, /* 0x30 */ +#define SYBINT1 SYBINT1 + SYBINT2 = 52, /* 0x34 */ +#define SYBINT2 SYBINT2 + SYBINT4 = 56, /* 0x38 */ +#define SYBINT4 SYBINT4 + SYBINT8 = 127, /* 0x7F */ +#define SYBINT8 SYBINT8 + SYBFLT8 = 62, /* 0x3E */ +#define SYBFLT8 SYBFLT8 + SYBDATETIME = 61, /* 0x3D */ +#define SYBDATETIME SYBDATETIME + SYBBIT = 50, /* 0x32 */ +#define SYBBIT SYBBIT + SYBBITN = 104, /* 0x68 */ +#define SYBBITN SYBBITN + SYBTEXT = 35, /* 0x23 */ +#define SYBTEXT SYBTEXT + SYBNTEXT = 99, /* 0x63 */ +#define SYBNTEXT SYBNTEXT + SYBIMAGE = 34, /* 0x22 */ +#define SYBIMAGE SYBIMAGE + SYBMONEY4 = 122, /* 0x7A */ +#define SYBMONEY4 SYBMONEY4 + SYBMONEY = 60, /* 0x3C */ +#define SYBMONEY SYBMONEY + SYBDATETIME4 = 58, /* 0x3A */ +#define SYBDATETIME4 SYBDATETIME4 + SYBREAL = 59, /* 0x3B */ +#define SYBREAL SYBREAL + SYBBINARY = 45, /* 0x2D */ +#define SYBBINARY SYBBINARY + SYBVOID = 31, /* 0x1F */ +#define SYBVOID SYBVOID + SYBVARBINARY = 37, /* 0x25 */ +#define SYBVARBINARY SYBVARBINARY + SYBNUMERIC = 108, /* 0x6C */ +#define SYBNUMERIC SYBNUMERIC + SYBDECIMAL = 106, /* 0x6A */ +#define SYBDECIMAL SYBDECIMAL + SYBFLTN = 109, /* 0x6D */ +#define SYBFLTN SYBFLTN + SYBMONEYN = 110, /* 0x6E */ +#define SYBMONEYN SYBMONEYN + SYBDATETIMN = 111, /* 0x6F */ +#define SYBDATETIMN SYBDATETIMN + SYBNVARCHAR = 103, /* 0x67 */ +#define SYBNVARCHAR SYBNVARCHAR + SYBDATE = 49, /* 0x31 */ +#define SYBDATE SYBDATE + SYBTIME = 51, /* 0x33 */ +#define SYBTIME SYBTIME + SYBBIGDATETIME = 187, /* 0xBB */ +#define SYBBIGDATETIME SYBBIGDATETIME + SYBBIGTIME = 188, /* 0xBC */ +#define SYBBIGTIME SYBBIGTIME + SYBMSDATE = 40, /* 0x28 */ +#define SYBMSDATE SYBMSDATE + SYBMSTIME = 41, /* 0x29 */ +#define SYBMSTIME SYBMSTIME + SYBMSDATETIME2 = 42, /* 0x2A */ +#define SYBMSDATETIME2 SYBMSDATETIME2 + SYBMSDATETIMEOFFSET = 43, /* 0x2B */ +#define SYBMSDATETIMEOFFSET SYBMSDATETIMEOFFSET +}; + +#define SYBAOPCNT 0x4b +#define SYBAOPCNTU 0x4c +#define SYBAOPSUM 0x4d +#define SYBAOPSUMU 0x4e +#define SYBAOPAVG 0x4f +#define SYBAOPAVGU 0x50 +#define SYBAOPMIN 0x51 +#define SYBAOPMAX 0x52 + +/* mssql2k compute operator */ +#define SYBAOPCNT_BIG 0x09 +#define SYBAOPSTDEV 0x30 +#define SYBAOPSTDEVP 0x31 +#define SYBAOPVAR 0x32 +#define SYBAOPVARP 0x33 +#define SYBAOPCHECKSUM_AGG 0x72 + +#endif + +typedef unsigned char DBBOOL; +typedef char DBCHAR; +typedef unsigned char DBBIT; +typedef unsigned char DBTINYINT; +typedef int16_t DBSMALLINT; +typedef int32_t DBINT; +typedef int64_t DBBIGINT; +typedef unsigned char DBBINARY; +typedef tds_sysdep_real32_type DBREAL; +typedef tds_sysdep_real64_type DBFLT8; +typedef uint16_t DBUSMALLINT; +typedef uint32_t DBUINT; +typedef uint64_t DBUBIGINT; + +typedef struct +{ + DBSMALLINT len; + char str[256]; +} DBVARYCHAR; + +typedef struct +{ + DBSMALLINT len; + unsigned char array[256]; +} DBVARYBIN; + +typedef struct +{ + unsigned char precision; + unsigned char scale; + unsigned char array[33]; +} DBNUMERIC; + +typedef DBNUMERIC DBDECIMAL; + +typedef struct +{ + DBINT mnyhigh; + DBUINT mnylow; +} DBMONEY; + +typedef struct +{ + DBINT mny4; +} DBMONEY4; + +typedef struct +{ + DBINT dtdays; + DBINT dttime; +} DBDATETIME; + +typedef struct +{ + DBUSMALLINT days; /* days since Jan-1-1900 */ + DBUSMALLINT minutes; /* minutes since midnight */ +} DBDATETIME4; + +typedef struct +{ + DBUBIGINT time; /**< time, 7 digit precision */ + DBINT date; /**< date, 0 = 1900-01-01 */ + DBSMALLINT offset; /**< time offset */ + DBUSMALLINT time_prec:3; +// fix a problem with some public headers defining _res +#undef _res + DBUSMALLINT _res:10; + DBUSMALLINT has_time:1; + DBUSMALLINT has_date:1; + DBUSMALLINT has_offset:1; +} DBDATETIMEALL; + +#ifdef MSDBLIB +# define SQLCHAR SYBCHAR + typedef struct + { + DBUSMALLINT numdays; + DBUSMALLINT nummins; + } DBDATETIM4; +#endif + +typedef struct tds_dblib_loginrec LOGINREC; + +#ifndef DOS32X +typedef unsigned char BYTE; +#endif + +typedef struct dbtypeinfo +{ + DBINT precision; + DBINT scale; +} DBTYPEINFO; + +struct dbstring +{ + BYTE *strtext; + DBINT strtotlen; + struct dbstring *strnext; +}; +typedef struct dbstring DBSTRING; + +/* Used by dbcolinfo */ +enum +{ MAXCOLNAMELEN = 512 }; /* duplicates TDS_SYSNAME_SIZE */ +typedef enum { CI_REGULAR=1, CI_ALTERNATE=2, CI_CURSOR=3 } CI_TYPE; + +typedef struct +{ + DBINT SizeOfStruct; + DBCHAR Name[MAXCOLNAMELEN+2]; + DBCHAR ActualName[MAXCOLNAMELEN+2]; + DBCHAR TableName[MAXCOLNAMELEN+2]; + SHORT Type; + DBINT UserType; + DBINT MaxLength; + BYTE Precision; + BYTE Scale; + BOOL VarLength; + BYTE Null; + BYTE CaseSensitive; + BYTE Updatable; + BOOL Identity; + +} DBCOL; + +typedef struct +{ + DBINT SizeOfStruct; + DBCHAR Name[MAXCOLNAMELEN+2]; + DBCHAR ActualName[MAXCOLNAMELEN+2]; + DBCHAR TableName[MAXCOLNAMELEN+2]; + SHORT Type; + DBINT UserType; + DBINT MaxLength; + BYTE Precision; + BYTE Scale; + BOOL VarLength; + BYTE Null; + BYTE CaseSensitive; + BYTE Updatable; + BOOL Identity; + SHORT ServerType; + DBINT ServerMaxLength; + DBCHAR ServerTypeDeclaration[256]; +} DBCOL2; +/* end dbcolinfo stuff */ + + + +/* a large list of options, DBTEXTSIZE is needed by sybtcl */ +#define DBPARSEONLY 0 +#define DBESTIMATE 1 +#define DBSHOWPLAN 2 +#define DBNOEXEC 3 +#define DBARITHIGNORE 4 +#define DBNOCOUNT 5 +#define DBARITHABORT 6 +#define DBTEXTLIMIT 7 +#define DBBROWSE 8 +#define DBOFFSET 9 +#define DBSTAT 10 +#define DBERRLVL 11 +#define DBCONFIRM 12 +#define DBSTORPROCID 13 +#define DBBUFFER 14 +#define DBNOAUTOFREE 15 +#define DBROWCOUNT 16 +#define DBTEXTSIZE 17 +#define DBNATLANG 18 +#define DBDATEFORMAT 19 +#define DBPRPAD 20 +#define DBPRCOLSEP 21 +#define DBPRLINELEN 22 +#define DBPRLINESEP 23 +#define DBLFCONVERT 24 +#define DBDATEFIRST 25 +#define DBCHAINXACTS 26 +#define DBFIPSFLAG 27 +#define DBISOLATION 28 +#define DBAUTH 29 +#define DBIDENTITY 30 +#define DBNOIDCOL 31 +#define DBDATESHORT 32 +#define DBCLIENTCURSORS 33 +#define DBSETTIME 34 +#define DBQUOTEDIDENT 35 + +#define DBNUMOPTIONS 36 + +#define DBPADOFF 0 +#define DBPADON 1 + +#define OFF 0 +#define ON 1 + +#define NOSUCHOPTION 2 + +#define MAXOPTTEXT 32 + +typedef struct tds_dblib_dbprocess DBPROCESS; + +/* + * Sybase & Microsoft use different names for the dbdaterec members. + * Keep these two structures physically identical in memory. + * dbdatecrack() casts one to the other for ease of implementation. + * + * Giving credit where credit is due, we can acknowledge that + * Microsoft chose the better names here, hands down. ("datedmonth"?!) + */ +struct tds_microsoft_dbdaterec +{ + DBINT year; /* 1753 - 9999 */ + DBINT quarter; /* 1 - 4 */ + DBINT month; /* 1 - 12 */ + DBINT day; /* 1 - 31 */ + DBINT dayofyear; /* 1 - 366 */ + DBINT week; /* 1 - 54 (for leap years) */ + DBINT weekday; /* 1 - 7 (Mon. - Sun.) */ + DBINT hour; /* 0 - 23 */ + DBINT minute; /* 0 - 59 */ + DBINT second; /* 0 - 59 */ + DBINT millisecond; /* 0 - 999 */ + DBINT tzone; /* -840 - 840 */ +}; + +struct tds_sybase_dbdaterec +{ + DBINT dateyear; /* 1900 and counting */ + DBINT quarter; /* 0 - 3 (Microsoft only) */ + DBINT datemonth; /* 0 - 11 */ + DBINT datedmonth; /* 1 - 31 */ + DBINT datedyear; /* 1 - 366 */ + DBINT week; /* 1 - 54 (Microsoft only) */ + DBINT datedweek; /* 0 - 6 */ + DBINT datehour; /* 0 - 23 */ + DBINT dateminute; /* 0 - 59 */ + DBINT datesecond; /* 0 - 59 */ + DBINT datemsecond; /* 0 - 999 */ + DBINT datetzone; /* -840 - 840 */ +}; + +struct tds_microsoft_dbdaterec2 +{ + DBINT year; /* 1753 - 9999 */ + DBINT quarter; /* 1 - 4 */ + DBINT month; /* 1 - 12 */ + DBINT day; /* 1 - 31 */ + DBINT dayofyear; /* 1 - 366 */ + DBINT week; /* 1 - 54 (for leap years) */ + DBINT weekday; /* 1 - 7 (Mon. - Sun.) */ + DBINT hour; /* 0 - 23 */ + DBINT minute; /* 0 - 59 */ + DBINT second; /* 0 - 59 */ + DBINT nanosecond; /* 0 - 999999999 */ + DBINT tzone; /* 0 - 127 (Sybase only) */ +}; + +struct tds_sybase_dbdaterec2 +{ + DBINT dateyear; /* 1900 and counting */ + DBINT quarter; /* 0 - 3 (Microsoft only) */ + DBINT datemonth; /* 0 - 11 */ + DBINT datedmonth; /* 1 - 31 */ + DBINT datedyear; /* 1 - 366 */ + DBINT week; /* 1 - 54 (Microsoft only) */ + DBINT datedweek; /* 0 - 6 */ + DBINT datehour; /* 0 - 23 */ + DBINT dateminute; /* 0 - 59 */ + DBINT datesecond; /* 0 - 59 */ + DBINT datensecond; /* 0 - 999999999 */ + DBINT datetzone; /* 0 - 127 */ +}; + + +#ifdef MSDBLIB +typedef struct tds_microsoft_dbdaterec DBDATEREC; +typedef struct tds_microsoft_dbdaterec2 DBDATEREC2; +#else +typedef struct tds_sybase_dbdaterec DBDATEREC; +typedef struct tds_sybase_dbdaterec2 DBDATEREC2; +#endif + +typedef int (*EHANDLEFUNC) (DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); + +typedef int (*MHANDLEFUNC) (DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, + char *proc, int line); + +/* dbpoll() result codes, sybtcl needs DBRESULT */ +#define DBRESULT 1 +#define DBNOTIFICATION 2 +#define DBTIMEOUT 3 +#define DBINTERRUPT 4 + +/* more sybtcl needs: */ +#define DBTXTSLEN 8 + +/* bind types */ +#define CHARBIND 0 +#define STRINGBIND 1 +#define NTBSTRINGBIND 2 +#define VARYCHARBIND 3 +#define VARYBINBIND 4 +#define TINYBIND 6 +#define SMALLBIND 7 +#define INTBIND 8 +#define FLT8BIND 9 +#define REALBIND 10 +#define DATETIMEBIND 11 +#define SMALLDATETIMEBIND 12 +#define MONEYBIND 13 +#define SMALLMONEYBIND 14 +#define BINARYBIND 15 +#define BITBIND 16 +#define NUMERICBIND 17 +#define DECIMALBIND 18 +#define SRCNUMERICBIND 19 +#define SRCDECIMALBIND 20 +#define DATEBIND 21 +#define TIMEBIND 22 +#define BIGDATETIMEBIND 23 +#define BIGTIMEBIND 24 +#define BIGINTBIND 30 +#define DATETIME2BIND 31 +#define MAXBINDTYPES 32 /* keep last */ + +#define DBPRCOLSEP 21 +#define DBPRLINELEN 22 +#define DBRPCRETURN 1 +#define DBRPCDEFAULT 2 + +#define REG_ROW -1 +#define MORE_ROWS -1 +#define NO_MORE_ROWS -2 +#define BUF_FULL -3 +#define NO_MORE_RESULTS 2 +#define SUCCEED 1 +#define FAIL 0 + +#define DB_IN 1 +#define DB_OUT 2 +#define DB_QUERYOUT 3 + +#define DBSINGLE 0 +#define DBDOUBLE 1 +#define DBBOTH 2 + +/* remote procedure call (rpc) options */ +#define DBRPCRECOMPILE TDS_STATIC_CAST(DBSMALLINT, 0x0001) +#define DBRPCRESET TDS_STATIC_CAST(DBSMALLINT, 0x0002) +#define DBRPCCURSOR TDS_STATIC_CAST(DBSMALLINT, 0x0008) + +#if defined(DBLIB_UNIMPLEMENTED) +DBBOOL db12hour(DBPROCESS * dbprocess, const char language[]); + +DBBOOL dbcolbrowse(DBPROCESS * dbprocess, int colnum); + +RETCODE dbcursor(DBCURSOR * hc, DBINT optype, DBINT bufno, BYTE * table, BYTE * values); +RETCODE dbcursorbind(DBCURSOR * hc, int col, int vartype, DBINT varlen, DBINT * poutlen, BYTE * pvaraddr, DBTYPEINFO * typeinfo); +void dbcursorclose(DBCURSOR * hc); +RETCODE dbcursorcolinfo(DBCURSOR * hc, DBINT column, DBCHAR * colname, DBINT * coltype, DBINT * collen, DBINT * usertype); +RETCODE dbcursorfetch(DBCURSOR * hc, DBINT fetchtype, DBINT rownum); +RETCODE dbcursorinfo(DBCURSOR * hc, DBINT * ncols, DBINT * nrows); +DBCURSOR *dbcursoropen(DBPROCESS * dbprocess, BYTE * stmt, SHORT scollopt, SHORT concuropt, USHORT nrows, DBINT * pstatus); + +int dbdate4cmp(DBPROCESS * dbprocess, DBDATETIME4 * d1, DBDATETIME4 * d2); +RETCODE dbdate4zero(DBPROCESS * dbprocess, DBDATETIME4 * d1); +RETCODE dbdatechar(DBPROCESS * dbprocess, char *buf, int datepart, int value); +int dbdatename(DBPROCESS * dbprocess, char *buf, int date, DBDATETIME * datetime); +char *dateorder(DBPROCESS * dbprocess, char *language); +DBINT dbdatepart(DBPROCESS * dbprocess, int datepart, DBDATETIME * datetime); +RETCODE dbdatezero(DBPROCESS * dbprocess, DBDATETIME * d1); +char *dbdayname(DBPROCESS * dbprocess, char *language, int daynum); + +int dbgetoff(DBPROCESS * dbprocess, DBUSMALLINT offtype, int startfrom); + +char *dbqual(DBPROCESS * dbprocess, int tabnum, char *tabname); +void dbfreequal(char *qualptr); + +DBSORTORDER *dbloadsort(DBPROCESS * dbprocess); +RETCODE dbfreesort(DBPROCESS * dbprocess, DBSORTORDER * sortorder); + +RETCODE dbload_xlate(DBPROCESS * dbprocess, char *srv_charset, char *clt_name, DBXLATE ** xlt_tosrv, DBXLATE ** xlt_todisp); + +RETCODE dbmny4divide(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * quotient); +RETCODE dbmny4mul(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * prod); +RETCODE dbmnyadd(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * sum); +RETCODE dbmnydivide(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * quotient); +RETCODE dbmnydown(DBPROCESS * dbproc, DBMONEY * mnyptr, int divisor, int *remainder); +RETCODE dbmnyinit(DBPROCESS * dbproc, DBMONEY * mnyptr, int trim, DBBOOL * negative); +RETCODE dbmnyndigit(DBPROCESS * dbproc, DBMONEY * mnyptr, DBCHAR * value, DBBOOL * zero); +RETCODE dbmnymul(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * prod); +RETCODE dbmnydigit(DBPROCESS * dbprocess, DBMONEY * m1, DBCHAR * value, DBBOOL * zero); +RETCODE dbmnyscale(DBPROCESS * dbproc, DBMONEY * dest, int multiplier, int addend); + + +RETCODE dbnpcreate(DBPROCESS * dbprocess); +RETCODE dbnpdefine(DBPROCESS * dbprocess, DBCHAR * procedure_name, DBSMALLINT namelen); + +int DBNUMORDERS(DBPROCESS * dbprocess); + +RETCODE dbpoll(DBPROCESS * dbproc, long milliseconds, DBPROCESS ** ready_dbproc, int *return_reason); +int dbordercol(DBPROCESS * dbprocess, int order); + +RETCODE dbregdrop(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen); +RETCODE dbregexec(DBPROCESS * dbproc, DBUSMALLINT options); +RETCODE dbreghandle(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen, INTFUNCPTR handler); +RETCODE dbreginit(DBPROCESS * dbproc, DBCHAR * procedure_name, DBSMALLINT namelen); +RETCODE dbreglist(DBPROCESS * dbproc); +RETCODE dbregnowatch(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen); +RETCODE dbregparam(DBPROCESS * dbproc, char *param_name, int type, DBINT datalen, BYTE * data); +RETCODE dbregwatch(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen, DBUSMALLINT options); +RETCODE dbregwatchlist(DBPROCESS * dbprocess); + +void dbrpwclr(LOGINREC * login); +RETCODE dbrpwset(LOGINREC * login, char *srvname, char *password, int pwlen); + +DBINT dbreadpage(DBPROCESS * dbprocess, char *p_dbname, DBINT pageno, BYTE * buf); +RETCODE dbwritepage(DBPROCESS * dbprocess, char *p_dbname, DBINT pageno, DBINT size, BYTE * buf); + +RETCODE dbsetdeflang(char *language); + +int dbstrcmp(DBPROCESS * dbprocess, char *s1, int l1, char *s2, int l2, DBSORTORDER * sort); +int dbstrsort(DBPROCESS * dbprocess, char *s1, int l1, char *s2, int l2, DBSORTORDER * sort); + +DBBOOL dbtabbrowse(DBPROCESS * dbprocess, int tabnum); +int dbtabcount(DBPROCESS * dbprocess); +char *dbtabname(DBPROCESS * dbprocess, int tabnum); +char *dbtabsource(DBPROCESS * dbprocess, int colnum, int *tabnum); + +RETCODE dbsendpassthru(DBPROCESS * dbprocess, DBVOIDPTR bufp); +RETCODE dbrecvpassthru(DBPROCESS * dbprocess, DBVOIDPTR * bufp); + +RETCODE dbgetloginfo(DBPROCESS * dbprocess, DBLOGINFO ** loginfo); +RETCODE dbsetloginfo(LOGINREC * loginrec, DBLOGINFO * loginfo); + +int dbtsnewlen(DBPROCESS * dbprocess); +DBBINARY *dbtsnewval(DBPROCESS * dbprocess); +RETCODE dbtsput(DBPROCESS * dbprocess, DBBINARY * newts, int newtslen, int tabnum, char *tabname); + +RETCODE dbfree_xlate(DBPROCESS * dbprocess, DBXLATE * xlt_tosrv, DBXLATE * clt_todisp); +int dbxlate(DBPROCESS * dbprocess, char *src, int srclen, char *dest, int destlen, DBXLATE * xlt, int *srcbytes_used, + DBBOOL srcend, int status); + +RETCODE bcp_moretext(DBPROCESS * dbproc, DBINT size, BYTE * text); +RETCODE bcp_writefmt(DBPROCESS * dbproc, const char filename[]); + +void build_xact_string(char *xact_name, char *service_name, DBINT commid, char *result); +RETCODE remove_xact(DBPROCESS * connect, DBINT commid, int n); +RETCODE abort_xact(DBPROCESS * connect, DBINT commid); +void close_commit(DBPROCESS * connect); +RETCODE commit_xact(DBPROCESS * connect, DBINT commid); +DBPROCESS *open_commit(LOGINREC * login, char *servername); +RETCODE scan_xact(DBPROCESS * connect, DBINT commid); +DBINT start_xact(DBPROCESS * connect, char *application_name, char *xact_name, int site_count); +DBINT stat_xact(DBPROCESS * connect, DBINT commid); + +#endif /* define unimplemented */ + +BYTE *dbadata(DBPROCESS * dbproc, int computeid, int column); +DBINT dbadlen(DBPROCESS * dbproc, int computeid, int column); +RETCODE dbaltbind(DBPROCESS * dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr); +RETCODE dbaltbind_ps(DBPROCESS * dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr, + DBTYPEINFO * typeinfo); +int dbaltcolid(DBPROCESS * dbproc, int computeid, int column); +DBINT dbaltlen(DBPROCESS * dbproc, int computeid, int column); +int dbaltop(DBPROCESS * dbproc, int computeid, int column); +int dbalttype(DBPROCESS * dbproc, int computeid, int column); +DBINT dbaltutype(DBPROCESS * dbproc, int computeid, int column); +RETCODE dbanullbind(DBPROCESS * dbprocess, int computeid, int column, DBINT * indicator); +RETCODE dbbind(DBPROCESS * dbproc, int column, int vartype, DBINT varlen, BYTE * varaddr); +RETCODE dbbind_ps(DBPROCESS * dbprocess, int column, int vartype, DBINT varlen, BYTE * varaddr, DBTYPEINFO * typeinfo); +int dbbufsize(DBPROCESS * dbprocess); +BYTE *dbbylist(DBPROCESS * dbproc, int computeid, int *size); +RETCODE dbcancel(DBPROCESS * dbproc); +RETCODE dbcanquery(DBPROCESS * dbproc); +char *dbchange(DBPROCESS * dbprocess); +DBBOOL dbcharsetconv(DBPROCESS * dbprocess); +void dbclose(DBPROCESS * dbproc); +void dbclrbuf(DBPROCESS * dbproc, DBINT n); +RETCODE dbclropt(DBPROCESS * dbproc, int option, const char param[]); +RETCODE dbcmd(DBPROCESS * dbproc, const char cmdstring[]); +RETCODE dbcmdrow(DBPROCESS * dbproc); + +#define DBCMDROW(x) dbcmdrow((x)) +RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol ); +RETCODE dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol); +DBINT dbcollen(DBPROCESS * dbproc, int column); +char *dbcolname(DBPROCESS * dbproc, int column); +const char *dbacolname(DBPROCESS * dbproc, int computeid, int column); +char *dbcolsource(DBPROCESS * dbproc, int colnum); +int dbcoltype(DBPROCESS * dbproc, int column); +DBTYPEINFO *dbcoltypeinfo(DBPROCESS * dbproc, int column); +DBINT dbcolutype(DBPROCESS * dbprocess, int column); +DBINT dbconvert(DBPROCESS * dbproc, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen); +DBINT dbconvert_ps(DBPROCESS * dbprocess, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen, + DBTYPEINFO * typeinfo); +BOOL dbiscount(DBPROCESS * dbproc); +DBINT dbcount(DBPROCESS * dbproc); + +#define DBCOUNT(x) dbcount((x)) +int dbcurcmd(DBPROCESS * dbproc); + +#define DBCURCMD(x) dbcurcmd((x)) +DBINT dbcurrow(DBPROCESS * dbproc); + +#define DBCURROW(x) dbcurrow((x)) +BYTE *dbdata(DBPROCESS * dbproc, int column); +int dbdatecmp(DBPROCESS * dbproc, DBDATETIME * d1, DBDATETIME * d2); +RETCODE dbdatecrack(DBPROCESS * dbproc, DBDATEREC * di, DBDATETIME * dt); +RETCODE dbanydatecrack(DBPROCESS * dbproc, DBDATEREC2 * di, int type, const void *data); +DBINT dbdatlen(DBPROCESS * dbproc, int column); +DBBOOL dbdead(DBPROCESS * dbproc); + +#define DBDEAD(x) dbdead((x)) +EHANDLEFUNC dberrhandle(EHANDLEFUNC handler); +void dbexit(void); +RETCODE dbfcmd(DBPROCESS * dbproc, const char *fmt, ...); +DBINT dbfirstrow(DBPROCESS * dbproc); + +#define DBFIRSTROW(x) dbfirstrow((x)) +void dbfreebuf(DBPROCESS * dbproc); +char *dbgetchar(DBPROCESS * dbprocess, int n); +char *dbgetcharset(DBPROCESS * dbprocess); +int dbgetlusername(LOGINREC * login, BYTE * name_buffer, int buffer_len); +int dbgetmaxprocs(void); +char *dbgetnatlanf(DBPROCESS * dbprocess); +int dbgetpacket(DBPROCESS * dbproc); +RETCODE dbgetrow(DBPROCESS * dbproc, DBINT row); +int dbgettime(void); +#define DBGETTIME dbgettime +BYTE *dbgetuserdata(DBPROCESS * dbproc); +DBBOOL dbhasretstat(DBPROCESS * dbproc); +RETCODE dbinit(void); +int dbiordesc(DBPROCESS * dbproc); + +#define DBIORDESC(x) dbiordesc((x)) +int dbiowdesc(DBPROCESS * dbproc); + +#define DBIOWDESC(x) dbiowdesc((x)) +DBBOOL dbisavail(DBPROCESS * dbprocess); + +#define DBISAVAIL(x) dbisavail((x)) +DBBOOL dbisopt(DBPROCESS * dbproc, int option, const char param[]); +DBINT dblastrow(DBPROCESS * dbproc); + +#define DBLASTROW(x) dblastrow((x)) +LOGINREC *dblogin(void); +void dbloginfree(LOGINREC * login); + +int dbmny4cmp(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2); +int dbmnycmp(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2); + +RETCODE dbmny4add(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * sum); +RETCODE dbmnydec(DBPROCESS * dbproc, DBMONEY * mnyptr); +RETCODE dbmnyinc(DBPROCESS * dbproc, DBMONEY * mnyptr); +RETCODE dbmnymaxpos(DBPROCESS * dbproc, DBMONEY * dest); +RETCODE dbmnymaxneg(DBPROCESS * dbproc, DBMONEY * dest); +RETCODE dbmny4minus(DBPROCESS * dbproc, DBMONEY4 * src, DBMONEY4 * dest); +RETCODE dbmnyminus(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest); +RETCODE dbmny4sub(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * diff); +RETCODE dbmnysub(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * diff); + +RETCODE dbmny4copy(DBPROCESS * dbprocess, DBMONEY4 * m1, DBMONEY4 * m2); +RETCODE dbmnycopy(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest); + +RETCODE dbmny4zero(DBPROCESS * dbproc, DBMONEY4 * dest); +RETCODE dbmnyzero(DBPROCESS * dbproc, DBMONEY * dest); + +const char *dbmonthname(DBPROCESS * dbproc, char *language, int monthnum, DBBOOL shortform); +RETCODE dbmorecmds(DBPROCESS * dbproc); + +#define DBMORECMDS(x) dbmorecmds((x)) +RETCODE dbmoretext(DBPROCESS * dbproc, DBINT size, const BYTE text[]); +MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler); +char *dbname(DBPROCESS * dbproc); +STATUS dbnextrow(DBPROCESS * dbproc); +RETCODE dbnullbind(DBPROCESS * dbproc, int column, DBINT * indicator); +int dbnumalts(DBPROCESS * dbproc, int computeid); +int dbnumcols(DBPROCESS * dbproc); +int dbnumcompute(DBPROCESS * dbprocess); +int dbnumrets(DBPROCESS * dbproc); +DBPROCESS *tdsdbopen(LOGINREC * login, const char *server, int msdblib); +DBPROCESS *dbopen(LOGINREC * login, const char *server); + +/* pivot functions */ +struct col_t; +void dbpivot_count (struct col_t *output, const struct col_t *input); +void dbpivot_sum (struct col_t *output, const struct col_t *input); +void dbpivot_min (struct col_t *output, const struct col_t *input); +void dbpivot_max (struct col_t *output, const struct col_t *input); + +struct pivot_t; +typedef void (*DBPIVOT_FUNC)(struct col_t *output, const struct col_t *input); +struct pivot_t * dbrows_pivoted(DBPROCESS *dbproc); +STATUS dbnextrow_pivoted(DBPROCESS *dbproc, struct pivot_t *pp); +RETCODE dbpivot(DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, DBPIVOT_FUNC func, int val); + +DBPIVOT_FUNC dbpivot_lookup_name( const char name[] ); + +#ifdef MSDBLIB +#define dbopen(x,y) tdsdbopen((x),(y), 1) +#else +#define dbopen(x,y) tdsdbopen((x),(y), 0) +#endif + +/* fix PHP problem */ +#ifdef PHP_SYBASE_DBOPEN +#undef PHP_SYBASE_DBOPEN +#define PHP_SYBASE_DBOPEN dbopen +#endif + +void dbprhead(DBPROCESS * dbproc); +DBINT dbprcollen(DBPROCESS * dbproc, int column); +RETCODE dbprrow(DBPROCESS * dbproc); +const char *dbprtype(int token); +DBBOOL DRBUF(DBPROCESS * dbprocess); +STATUS dbreadtext(DBPROCESS * dbproc, void *buf, DBINT bufsize); +void dbrecftos(const char filename[]); +RETCODE dbresults(DBPROCESS * dbproc); +RETCODE dbresults_r(DBPROCESS * dbproc, int recursive); +BYTE *dbretdata(DBPROCESS * dbproc, int retnum); +int dbretlen(DBPROCESS * dbproc, int retnum); +char *dbretname(DBPROCESS * dbproc, int retnum); +DBINT dbretstatus(DBPROCESS * dbproc); +int dbrettype(DBPROCESS * dbproc, int retnum); +RETCODE dbrows(DBPROCESS * dbproc); + +#define DBROWS(x) dbrows((x)) +STATUS dbrowtype(DBPROCESS * dbprocess); + +#define DBROWTYPE(x) dbrowtype((x)) +RETCODE dbrpcinit(DBPROCESS * dbproc, const char rpcname[], DBSMALLINT options); +RETCODE dbrpcparam(DBPROCESS * dbproc, const char paramname[], BYTE status, int type, DBINT maxlen, DBINT datalen, BYTE * value); +RETCODE dbrpcsend(DBPROCESS * dbproc); +RETCODE dbsafestr(DBPROCESS * dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype); +RETCODE *dbsechandle(DBINT type, INTFUNCPTR handler); +char *dbservcharset(DBPROCESS * dbprocess); +void dbsetavail(DBPROCESS * dbprocess); +void dbsetbusy(DBPROCESS * dbprocess, DB_DBBUSY_FUNC busyfunc); +RETCODE dbsetdefcharset(char *charset); +void dbsetidle(DBPROCESS * dbprocess, DB_DBIDLE_FUNC idlefunc); +void dbsetifile(char *filename); +void dbsetinterrupt(DBPROCESS * dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr); +RETCODE dbsetlogintime(int seconds); +RETCODE dbsetmaxprocs(int maxprocs); +RETCODE dbsetnull(DBPROCESS * dbprocess, int bindtype, int bindlen, BYTE * bindval); +RETCODE dbsetopt(DBPROCESS * dbproc, int option, const char *char_param, int int_param); +STATUS dbsetrow(DBPROCESS * dbprocess, DBINT row); +RETCODE dbsettime(int seconds); +void dbsetuserdata(DBPROCESS * dbproc, BYTE * ptr); +RETCODE dbsetversion(DBINT version); + +int dbspid(DBPROCESS * dbproc); +RETCODE dbspr1row(DBPROCESS * dbproc, char *buffer, DBINT buf_len); +DBINT dbspr1rowlen(DBPROCESS * dbproc); +RETCODE dbsprhead(DBPROCESS * dbproc, char *buffer, DBINT buf_len); +RETCODE dbsprline(DBPROCESS * dbproc, char *buffer, DBINT buf_len, DBCHAR line_char); +RETCODE dbsqlexec(DBPROCESS * dbproc); +RETCODE dbsqlok(DBPROCESS * dbproc); +RETCODE dbsqlsend(DBPROCESS * dbproc); +int dbstrbuild(DBPROCESS * dbproc, char *charbuf, int bufsize, char *text, char *formats, ...); +RETCODE dbstrcpy(DBPROCESS * dbproc, int start, int numbytes, char *dest); +int dbstrlen(DBPROCESS * dbproc); +DBINT dbvarylen(DBPROCESS * dbproc, int column); + +#define SYBEVERDOWN 100 /* TDS version downgraded . */ +#define SYBEICONVIU 2400 /* Some character(s) could not be converted into client's character set. */ +#define SYBEICONVAVAIL 2401 /* Character set conversion is not available between client character set '%.*s' and server character set '%.*s'.*/ +#define SYBEICONVO 2402 /* Error converting characters into server's character set. Some character(s) could not be converted.*/ +#define SYBEICONVI 2403 /* Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?').*/ +#define SYBEICONV2BIG 2404 /* Buffer overflow converting characters from client into server's character set.*/ + /* cf. doc/dblib_errors.txt for more iconv error values. */ + /* Reserve a few slots for other iconv-related issues. */ +#define SYBETDSVER 2410 /* Cannot bcp with TDSVER < 5.0 */ +#define SYBEPORT 2500 /* Both port and instance specified */ +#define SYBESYNC 20001 /* Read attempted while out of synchronization with SQL Server. */ +#define SYBEFCON 20002 /* SQL Server connection failed. */ +#define SYBETIME 20003 /* SQL Server connection timed out. */ +#define SYBEREAD 20004 /* Read from SQL Server failed. */ +#define SYBEBUFL 20005 /* DB-LIBRARY internal error - send buffer length corrupted. */ +#define SYBEWRIT 20006 /* Write to SQL Server failed. */ +#define SYBEVMS 20007 /* Sendflush: VMS I/O error. */ +#define SYBESOCK 20008 /* Unable to open socket */ +#define SYBECONN 20009 /* Unable to connect socket -- SQL Server is unavailable or does not exist. */ +#define SYBEMEM 20010 /* Unable to allocate sufficient memory */ +#define SYBEDBPS 20011 /* Maximum number of DBPROCESSes already allocated. */ +#define SYBEINTF 20012 /* Server name not found in interface file */ +#define SYBEUHST 20013 /* Unknown host machine name */ +#define SYBEPWD 20014 /* Incorrect password. */ +#define SYBEOPIN 20015 /* Could not open interface file. */ +#define SYBEINLN 20016 /* Interface file: unexpected end-of-line. */ +#define SYBESEOF 20017 /* Unexpected EOF from SQL Server. */ +#define SYBESMSG 20018 /* General SQL Server error: Check messages from the SQL Server. */ +#define SYBERPND 20019 /* Attempt to initiate a new SQL Server operation with results pending. */ +#define SYBEBTOK 20020 /* Bad token from SQL Server: Data-stream processing out of sync. */ +#define SYBEITIM 20021 /* Illegal timeout value specified. */ +#define SYBEOOB 20022 /* Error in sending out-of-band data to SQL Server. */ +#define SYBEBTYP 20023 /* Unknown bind type passed to DB-LIBRARY function. */ +#define SYBEBNCR 20024 /* Attempt to bind user variable to a non-existent compute row. */ +#define SYBEIICL 20025 /* Illegal integer column length returned by SQL Server. Legal integer lengths are 1, 2, and 4 bytes. */ +#define SYBECNOR 20026 /* Column number out of range. */ +#define SYBENPRM 20027 /* NULL parameter not allowed for this dboption. */ +#define SYBEUVDT 20028 /* Unknown variable-length datatype encountered. */ +#define SYBEUFDT 20029 /* Unknown fixed-length datatype encountered. */ +#define SYBEWAID 20030 /* DB-LIBRARY internal error: ALTFMT following ALTNAME has wrong id. */ +#define SYBECDNS 20031 /* Datastream indicates that a compute column is derived from a non-existent select-list member. */ +#define SYBEABNC 20032 /* Attempt to bind to a non-existent column. */ +#define SYBEABMT 20033 /* User attempted a dbbind() with mismatched column and variable types. */ +#define SYBEABNP 20034 /* Attempt to bind using NULL pointers. */ +#define SYBEAAMT 20035 /* User attempted a dbaltbind() with mismatched column and variable types. */ +#define SYBENXID 20036 /* The Server did not grant us a distributed-transaction ID. */ +#define SYBERXID 20037 /* The Server did not recognize our distributed-transaction ID. */ +#define SYBEICN 20038 /* Invalid computeid or compute column number. */ +#define SYBENMOB 20039 /* No such member of 'order by' clause. */ +#define SYBEAPUT 20040 /* Attempt to print unknown token. */ +#define SYBEASNL 20041 /* Attempt to set fields in a null loginrec. */ +#define SYBENTLL 20042 /* Name too long for loginrec field. */ +#define SYBEASUL 20043 /* Attempt to set unknown loginrec field. */ +#define SYBERDNR 20044 /* Attempt to retrieve data from a non-existent row. */ +#define SYBENSIP 20045 /* Negative starting index passed to dbstrcpy(). */ +#define SYBEABNV 20046 /* Attempt to bind to a NULL program variable. */ +#define SYBEDDNE 20047 /* DBPROCESS is dead or not enabled. */ +#define SYBECUFL 20048 /* Data-conversion resulted in underflow. */ +#define SYBECOFL 20049 /* Data-conversion resulted in overflow. */ +#define SYBECSYN 20050 /* Attempt to convert data stopped by syntax error in source field. */ +#define SYBECLPR 20051 /* Data-conversion resulted in loss of precision. */ +#define SYBECNOV 20052 /* Attempt to set variable to NULL resulted in overflow. */ +#define SYBERDCN 20053 /* Requested data-conversion does not exist. */ +#define SYBESFOV 20054 /* dbsafestr() overflowed its destination buffer. */ +#define SYBEUNT 20055 /* Unknown network type found in interface file. */ +#define SYBECLOS 20056 /* Error in closing network connection. */ +#define SYBEUAVE 20057 /* Unable to allocate VMS event flag. */ +#define SYBEUSCT 20058 /* Unable to set communications timer. */ +#define SYBEEQVA 20059 /* Error in queueing VMS AST routine. */ +#define SYBEUDTY 20060 /* Unknown datatype encountered. */ +#define SYBETSIT 20061 /* Attempt to call dbtsput() with an invalid timestamp. */ +#define SYBEAUTN 20062 /* Attempt to update the timestamp of a table which has no timestamp column. */ +#define SYBEBDIO 20063 /* Bad bulk-copy direction. Must be either IN or OUT. */ +#define SYBEBCNT 20064 /* Attempt to use Bulk Copy with a non-existent Server table. */ +#define SYBEIFNB 20065 /* Illegal field number passed to bcp_control(). */ +#define SYBETTS 20066 /* The table which bulk-copy is attempting to copy to a host-file is shorter than the number of rows which bulk-copy was instructed to skip. */ +#define SYBEKBCO 20067 /* 1000 rows successfully bulk-copied to host-file. */ +#define SYBEBBCI 20068 /* Batch successfully bulk-copied to SQL Server. */ +#define SYBEKBCI 20069 /* Bcp: 1000 rows sent to SQL Server. */ +#define SYBEBCRE 20070 /* I/O error while reading bcp data-file. */ +#define SYBETPTN 20071 /* Syntax error: only two periods are permitted in table names. */ +#define SYBEBCWE 20072 /* I/O error while writing bcp data-file. */ +#define SYBEBCNN 20073 /* Attempt to bulk-copy a NULL value into Server column %d, which does not accept NULL values. */ +#define SYBEBCOR 20074 /* Attempt to bulk-copy an oversized row to the SQL Server. */ +#define SYBEBCIS 20075 /* Attempt to bulk-copy an illegally-sized column value to the SQL Server. */ +#define SYBEBCPI 20076 /* bcp_init() must be called before any other bcp routines. */ +#define SYBEBCPN 20077 /* bcp_bind(), bcp_collen(), bcp_colptr(), bcp_moretext() and bcp_sendrow() may be used only after bcp_init() has been called with the copy direction set to DB_IN. */ +#define SYBEBCPB 20078 /* bcp_bind(), bcp_moretext() and bcp_sendrow() may NOT be used after bcp_init() has been passed a non-NULL input file name. */ +#define SYBEVDPT 20079 /* For bulk copy, all variable-length data must have either a length-prefix or a terminator specified. */ +#define SYBEBIVI 20080 /* bcp_columns(), bcp_colfmt() and bcp_colfmt_ps() may be used only after bcp_init() has been passed a valid input file. */ +#define SYBEBCBC 20081 /* bcp_columns() must be called before bcp_colfmt() and bcp_colfmt_ps(). */ +#define SYBEBCFO 20082 /* Bcp host-files must contain at least one column. */ +#define SYBEBCVH 20083 /* bcp_exec() may be called only after bcp_init() has been passed a valid host file. */ +#define SYBEBCUO 20084 /* Bcp: Unable to open host data-file. */ +#define SYBEBCUC 20085 /* Bcp: Unable to close host data-file. */ +#define SYBEBUOE 20086 /* Bcp: Unable to open error-file. */ +#define SYBEBUCE 20087 /* Bcp: Unable to close error-file. */ +#define SYBEBWEF 20088 /* I/O error while writing bcp error-file. */ +#define SYBEASTF 20089 /* VMS: Unable to setmode for control_c ast. */ +#define SYBEUACS 20090 /* VMS: Unable to assign channel to sys$command. */ +#define SYBEASEC 20091 /* Attempt to send an empty command buffer to the SQL Server. */ +#define SYBETMTD 20092 /* Attempt to send too much TEXT data via the dbmoretext() call. */ +#define SYBENTTN 20093 /* Attempt to use dbtxtsput() to put a new text-timestamp into a non-existent data row. */ +#define SYBEDNTI 20094 /* Attempt to use dbtxtsput() to put a new text-timestamp into a column whose datatype is neither SYBTEXT nor SYBIMAGE. */ +#define SYBEBTMT 20095 /* Attempt to send too much TEXT data via the bcp_moretext() call. */ +#define SYBEORPF 20096 /* Attempt to set remote password would overflow the login-record's remote-password field. */ +#define SYBEUVBF 20097 /* Attempt to read an unknown version of BCP format-file. */ +#define SYBEBUOF 20098 /* Bcp: Unable to open format-file. */ +#define SYBEBUCF 20099 /* Bcp: Unable to close format-file. */ +#define SYBEBRFF 20100 /* I/O error while reading bcp format-file. */ +#define SYBEBWFF 20101 /* I/O error while writing bcp format-file. */ +#define SYBEBUDF 20102 /* Bcp: Unrecognized datatype found in format-file. */ +#define SYBEBIHC 20103 /* Incorrect host-column number found in bcp format-file. */ +#define SYBEBEOF 20104 /* Unexpected EOF encountered in BCP data-file. */ +#define SYBEBCNL 20105 /* Negative length-prefix found in BCP data-file. */ +#define SYBEBCSI 20106 /* Host-file columns may be skipped only when copying INto the Server. */ +#define SYBEBCIT 20107 /* It's illegal to use BCP terminators with program variables other than SYBCHAR, SYBBINARY, SYBTEXT, or SYBIMAGE. */ +#define SYBEBCSA 20108 /* The BCP hostfile '%s' contains only %ld rows. Skipping all of these rows is not allowed. */ +#define SYBENULL 20109 /* NULL DBPROCESS pointer passed to DB-Library. */ +#define SYBEUNAM 20110 /* Unable to get current username from operating system. */ +#define SYBEBCRO 20111 /* The BCP hostfile '%s' contains only %ld rows. It was impossible to read the requested %ld rows. */ +#define SYBEMPLL 20112 /* Attempt to set maximum number of DBPROCESSes lower than 1. */ +#define SYBERPIL 20113 /* It is illegal to pass -1 to dbrpcparam() for the datalen of parameters which are of type SYBCHAR, SYBVARCHAR, SYBBINARY, or SYBVARBINARY. */ +#define SYBERPUL 20114 /* When passing a SYBINTN, SYBDATETIMN, SYBMONEYN, or SYBFLTN parameter via dbrpcparam(), it's necessary to specify the parameter's maximum or actual length, so that DB-Library can recognize it as a SYBINT1, SYBINT2, SYBINT4, SYBMONEY, or SYBMONEY4, etc. */ +#define SYBEUNOP 20115 /* Unknown option passed to dbsetopt(). */ +#define SYBECRNC 20116 /* The current row is not a result of compute clause %d, so it is illegal to attempt to extract that data from this row. */ +#define SYBERTCC 20117 /* dbreadtext() may not be used to receive the results of a query which contains a COMPUTE clause. */ +#define SYBERTSC 20118 /* dbreadtext() may only be used to receive the results of a query which contains a single result column. */ +#define SYBEUCRR 20119 /* Internal software error: Unknown connection result reported by * dbpasswd(). */ +#define SYBERPNA 20120 /* The RPC facility is available only when using a SQL Server whose version number is 4.0 or greater. */ +#define SYBEOPNA 20121 /* The text/image facility is available only when using a SQL Server whose version number is 4.0 or greater. */ +#define SYBEFGTL 20122 /* Bcp: Row number of the first row to be copied cannot be greater than the row number for the last row to be copied. */ +#define SYBECWLL 20123 /* Attempt to set column width less than 1. */ +#define SYBEUFDS 20124 /* Unrecognized format encountered in dbstrbuild(). */ +#define SYBEUCPT 20125 /* Unrecognized custom-format parameter-type encountered in dbstrbuild(). */ +#define SYBETMCF 20126 /* Attempt to install too many custom formats via dbfmtinstall(). */ +#define SYBEAICF 20127 /* Error in attempting to install custom format. */ +#define SYBEADST 20128 /* Error in attempting to determine the size of a pair of translation tables. */ +#define SYBEALTT 20129 /* Error in attempting to load a pair of translation tables. */ +#define SYBEAPCT 20130 /* Error in attempting to perform a character-set translation. */ +#define SYBEXOCI 20131 /* A character-set translation overflowed its destination buffer while using bcp to copy data from a host-file to the SQL Server. */ +#define SYBEFSHD 20132 /* Error in attempting to find the Sybase home directory. */ +#define SYBEAOLF 20133 /* Error in attempting to open a localization file. */ +#define SYBEARDI 20134 /* Error in attempting to read datetime information from a localization file. */ +#define SYBEURCI 20135 /* Unable to read copyright information from the dblib localization file. */ +#define SYBEARDL 20136 /* Error in attempting to read the dblib.loc localization file. */ +#define SYBEURMI 20137 /* Unable to read money-format information from the dblib localization file. */ +#define SYBEUREM 20138 /* Unable to read error mnemonic from the dblib localization file. */ +#define SYBEURES 20139 /* Unable to read error string from the dblib localization file. */ +#define SYBEUREI 20140 /* Unable to read error information from the dblib localization file. */ +#define SYBEOREN 20141 /* Warning: an out-of-range error-number was encountered in dblib.loc. The maximum permissible error-number is defined as DBERRCOUNT in sybdb.h. */ +#define SYBEISOI 20142 /* Invalid sort-order information found. */ +#define SYBEIDCL 20143 /* Illegal datetime column length returned by DataServer. Legal datetime lengths are 4 and 8 bytes. */ +#define SYBEIMCL 20144 /* Illegal money column length returned by DataServer. Legal money lengths are 4 and 8 bytes. */ +#define SYBEIFCL 20145 /* Illegal floating-point column length returned by DataServer. Legal floating-point lengths are 4 and 8 bytes. */ +#define SYBEUTDS 20146 /* Unrecognized TDS version received from SQL Server. */ +#define SYBEBUFF 20147 /* Bcp: Unable to create format-file. */ +#define SYBEACNV 20148 /* Attemp to do conversion with NULL destination variable. */ +#define SYBEDPOR 20149 /* Out-of-range datepart constant. */ +#define SYBENDC 20150 /* Cannot have negative component in date in numeric form. */ +#define SYBEMVOR 20151 /* Month values must be between 1 and 12. */ +#define SYBEDVOR 20152 /* Day values must be between 1 and 7. */ +#define SYBENBVP 20153 /* Cannot pass dbsetnull() a NULL bindval pointer. */ +#define SYBESPID 20154 /* Called dbspid() with a NULL dbproc. */ +#define SYBENDTP 20155 /* Called dbdatecrack() with a NULL datetime parameter. */ +#define SYBEXTN 20156 /* The xlt_todisp and xlt_tosrv parameters to dbfree_xlate() were NULL. */ +#define SYBEXTDN 20157 /* Warning: the xlt_todisp parameter to dbfree_xlate() was NULL. The space associated with the xlt_tosrv parameter has been freed. */ +#define SYBEXTSN 20158 /* Warning: the xlt_tosrv parameter to dbfree_xlate() was NULL. The space associated with the xlt_todisp parameter has been freed. */ +#define SYBENUM 20159 /* Incorrect number of arguments given to DB-Library. */ +#define SYBETYPE 20160 /* Invalid argument type given to DB-Library. */ +#define SYBEGENOS 20161 /* General Operating System Error. */ +#define SYBEPAGE 20162 /* wrong resource type or length given for dbpage() operation. */ +#define SYBEOPTNO 20163 /* Option is not allowed or is unreconized */ +#define SYBEETD 20164 /* Failure to send the expected amount of TEXT or IMAGE data via dbmoretext(). */ +#define SYBERTYPE 20165 /* Invalid resource type given to DB-Library. */ +#define SYBERFILE 20166 /* "Can not open resource file." */ +#define SYBEFMODE 20167 /* Read/Write/Append mode denied on file. */ +#define SYBESLCT 20168 /* Could not select or copy field specified */ +#define SYBEZTXT 20169 /* Attempt to send zero length TEXT or IMAGE to dataserver via dbwritetext(). */ +#define SYBENTST 20170 /* The file being opened must be a stream_lf. */ +#define SYBEOSSL 20171 /* Operating system login level not in range of Secure SQL Server */ +#define SYBEESSL 20172 /* Login security level entered does not agree with operating system level */ +#define SYBENLNL 20173 /* Program not linked with specified network library. */ +#define SYBENHAN 20174 /* called dbrecvpassthru() with a NULL handler parameter. */ +#define SYBENBUF 20175 /* called dbsendpassthru() with a NULL buf pointer. */ +#define SYBENULP 20176 /* Called %s with a NULL %s parameter. */ +#define SYBENOTI 20177 /* No event handler installed. */ +#define SYBEEVOP 20178 /* Called dbregwatch() with a bad options parameter. */ +#define SYBENEHA 20179 /* Called dbreghandle() with a NULL handler parameter. */ +#define SYBETRAN 20180 /* DBPROCESS is being used for another transaction. */ +#define SYBEEVST 20181 /* Must initiate a transaction before calling dbregparam(). */ +#define SYBEEINI 20182 /* Must call dbreginit() before dbregraise(). */ +#define SYBEECRT 20183 /* Must call dbregdefine() before dbregcreate(). */ +#define SYBEECAN 20184 /* Attempted to cancel unrequested event notification. */ +#define SYBEEUNR 20185 /* Unsolicited event notification received. */ +#define SYBERPCS 20186 /* Must call dbrpcinit() before dbrpcparam(). */ +#define SYBETPAR 20187 /* No SYBTEXT or SYBIMAGE parameters were defined. */ +#define SYBETEXS 20188 /* Called dbmoretext() with a bad size parameter. */ +#define SYBETRAC 20189 /* Attempted to turn off a trace flag that was not on. */ +#define SYBETRAS 20190 /* DB-Library internal error - trace structure not found. */ +#define SYBEPRTF 20191 /* dbtracestring() may only be called from a printfunc(). */ +#define SYBETRSN 20192 /* Bad numbytes parameter passed to dbtracestring(). */ +#define SYBEBPKS 20193 /* In DBSETLPACKET(), the packet size parameter must be between 0 and 999999. */ +#define SYBEIPV 20194 /* %1! is an illegal value for the %2! parameter of %3!. */ +#define SYBEMOV 20195 /* Money arithmetic resulted in overflow in function %1!. */ +#define SYBEDIVZ 20196 /* Attempt to divide by $0.00 in function %1!. */ +#define SYBEASTL 20197 /* Synchronous I/O attempted at AST level. */ +#define SYBESEFA 20198 /* DBSETNOTIFS cannot be called if connections are present. */ +#define SYBEPOLL 20199 /* Only one dbpoll() can be active at a time. */ +#define SYBENOEV 20200 /* dbpoll() cannot be called if registered procedure notifications have been disabled. */ +#define SYBEBADPK 20201 /* Packet size of %1! not supported. -- size of %2! used instead. */ +#define SYBESECURE 20202 /* Secure Server function not supported in this version. */ +#define SYBECAP 20203 /* DB-Library capabilities not accepted by the Server. */ +#define SYBEFUNC 20204 /* Functionality not supported at the specified version level. */ +#define SYBERESP 20205 /* Response function address passed to dbresponse() must be non-NULL. */ +#define SYBEIVERS 20206 /* Illegal version level specified. */ +#define SYBEONCE 20207 /* Function can be called only once. */ +#define SYBERPNULL 20208 /* value parameter for dbprcparam() can be NULL, only if the datalen parameter is 0 */ +#define SYBERPTXTIM 20209 /* RPC parameters cannot be of type Text/Image. */ +#define SYBENEG 20210 /* Negotiated login attempt failed. */ +#define SYBELBLEN 20211 /* Security labels should be less than 256 characters long. */ +#define SYBEUMSG 20212 /* Unknown message-id in MSG datastream. */ +#define SYBECAPTYP 20213 /* Unexpected capability type in CAPABILITY datastream. */ +#define SYBEBNUM 20214 /* Bad numbytes parameter passed to dbstrcpy() */ +#define SYBEBBL 20215 /* Bad bindlen parameter passed to dbsetnull() */ +#define SYBEBPREC 20216 /* Illegal precision specified */ +#define SYBEBSCALE 20217 /* Illegal scale specified */ +#define SYBECDOMAIN 20218 /* Source field value is not within the domain of legal values. */ +#define SYBECINTERNAL 20219 /* Internal Conversion error. */ +#define SYBEBTYPSRV 20220 /* Datatype is not supported by the server. */ +#define SYBEBCSET 20221 /* Unknown character-set encountered." */ +#define SYBEFENC 20222 /* Password Encryption failed." */ +#define SYBEFRES 20223 /* Challenge-Response function failed.", */ +#define SYBEISRVPREC 20224 /* Illegal precision value returned by the server. */ +#define SYBEISRVSCL 20225 /* Illegal scale value returned by the server. */ +#define SYBEINUMCL 20226 /* Invalid numeric column length returned by the server. */ +#define SYBEIDECCL 20227 /* Invalid decimal column length returned by the server. */ +#define SYBEBCMTXT 20228 /* bcp_moretext() may be used only when there is at least one text or image column in the server table. */ +#define SYBEBCPREC 20229 /* Column %1!: Illegal precision value encountered. */ +#define SYBEBCBNPR 20230 /* bcp_bind(): if varaddr is NULL, prefixlen must be 0 and no terminator should be specified. */ +#define SYBEBCBNTYP 20231 /* bcp_bind(): if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY. */ +#define SYBEBCSNTYP 20232 /* column number %1!: if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY. */ +#define SYBEBCPCTYP 20233 /* bcp_colfmt(): If table_colnum is 0, host_type cannot be 0. */ +#define SYBEBCVLEN 20234 /* varlen should be greater than or equal to -1. */ +#define SYBEBCHLEN 20235 /* host_collen should be greater than or equal to -1. */ +#define SYBEBCBPREF 20236 /* Illegal prefix length. Legal values are 0, 1, 2 or 4. */ +#define SYBEBCPREF 20237 /* Illegal prefix length. Legal values are -1, 0, 1, 2 or 4. */ +#define SYBEBCITBNM 20238 /* bcp_init(): tblname parameter cannot be NULL. */ +#define SYBEBCITBLEN 20239 /* bcp_init(): tblname parameter is too long. */ +#define SYBEBCSNDROW 20240 /* bcp_sendrow() may NOT be called unless all text data for the previous row has been sent using bcp_moretext(). */ +#define SYBEBPROCOL 20241 /* bcp protocol error: returned column count differs from the actual number of columns received. */ +#define SYBEBPRODEF 20242 /* bcp protocol error: expected default information and got none. */ +#define SYBEBPRONUMDEF 20243 /* bcp protocol error: expected number of defaults differs from the actual number of defaults received. */ +#define SYBEBPRODEFID 20244 /* bcp protocol error: default column id and actual column id are not same */ +#define SYBEBPRONODEF 20245 /* bcp protocol error: default value received for column that does not have default. */ +#define SYBEBPRODEFTYP 20246 /* bcp protocol error: default value datatype differs from column datatype. */ +#define SYBEBPROEXTDEF 20247 /* bcp protocol error: more than one row of default information received. */ +#define SYBEBPROEXTRES 20248 /* bcp protocol error: unexpected set of results received. */ +#define SYBEBPROBADDEF 20249 /* bcp protocol error: illegal default column id received. */ +#define SYBEBPROBADTYP 20250 /* bcp protocol error: unknown column datatype. */ +#define SYBEBPROBADLEN 20251 /* bcp protocol error: illegal datatype length received. */ +#define SYBEBPROBADPREC 20252 /* bcp protocol error: illegal precision value received. */ +#define SYBEBPROBADSCL 20253 /* bcp protocol error: illegal scale value received. */ +#define SYBEBADTYPE 20254 /* Illegal value for type parameter given to %1!. */ +#define SYBECRSNORES 20255 /* Cursor statement generated no results. */ +#define SYBECRSNOIND 20256 /* One of the tables involved in the cursor statement does not have a unique index. */ +#define SYBECRSVIEW 20257 /* A view cannot be joined with another table or a view in a cursor statement. */ +#define SYBECRSVIIND 20258 /* The view used in the cursor statement does not include all the unique index columns of the underlying tables. */ +#define SYBECRSORD 20259 /* Only fully keyset driven cursors can have 'order by', ' group by', or 'having' phrases. */ +#define SYBECRSBUFR 20260 /* Row buffering should not be turned on when using cursor APIs. */ +#define SYBECRSNOFREE 20261 /* The DBNOAUTOFREE option should not be turned on when using cursor APIs. */ +#define SYBECRSDIS 20262 /* Cursor statement contains one of the disallowed phrases 'compute', 'union', 'for browse', or 'select into'. */ +#define SYBECRSAGR 20263 /* Aggregate functions are not allowed in a cursor statement. */ +#define SYBECRSFRAND 20264 /* Fetch types RANDOM and RELATIVE can only be used within the keyset of keyset driven cursors. */ +#define SYBECRSFLAST 20265 /* Fetch type LAST requires fully keyset driven cursors. */ +#define SYBECRSBROL 20266 /* Backward scrolling cannot be used in a forward scrolling cursor. */ +#define SYBECRSFROWN 20267 /* Row number to be fetched is outside valid range. */ +#define SYBECRSBSKEY 20268 /* Keyset cannot be scrolled backward in mixed cursors with a previous fetch type. */ +#define SYBECRSRO 20269 /* Data locking or modifications cannot be made in a READONLY cursor. */ +#define SYBECRSNOCOUNT 20270 /* The DBNOCOUNT option should not be turned on when doing updates or deletes with dbcursor(). */ +#define SYBECRSTAB 20271 /* Table name must be determined in operations involving data locking or modifications. */ +#define SYBECRSUPDNB 20272 /* Update or insert operations cannot use bind variables when binding type is NOBIND. */ +#define SYBECRSNOWHERE 20273 /* A WHERE clause is not allowed in a cursor update or insert. */ +#define SYBECRSSET 20274 /* A SET clause is required for a cursor update or insert. */ +#define SYBECRSUPDTAB 20275 /* Update or insert operations using bind variables require single table cursors. */ +#define SYBECRSNOUPD 20276 /* Update or delete operation did not affect any rows. */ +#define SYBECRSINV 20277 /* Invalid cursor statement. */ +#define SYBECRSNOKEYS 20278 /* The entire keyset must be defined for KEYSET cursors. */ +#define SYBECRSNOBIND 20279 /* Cursor bind must be called prior to updating cursor */ +#define SYBECRSFTYPE 20280 /* Unknown fetch type. */ +#define SYBECRSINVALID 20281 /* The cursor handle is invalid. */ +#define SYBECRSMROWS 20282 /* Multiple rows are returned, only one is expected. */ +#define SYBECRSNROWS 20283 /* No rows returned, at least one is expected. */ +#define SYBECRSNOLEN 20284 /* No unique index found. */ +#define SYBECRSNOPTCC 20285 /* No OPTCC was found. */ +#define SYBECRSNORDER 20286 /* The order of clauses must be from, where, and order by. */ +#define SYBECRSNOTABLE 20287 /* Table name is NULL. */ +#define SYBECRSNUNIQUE 20288 /* No unique keys associated with this view. */ +#define SYBECRSVAR 20289 /* There is no valid address associated with this bind. */ +#define SYBENOVALUE 20290 /* Security labels require both a name and a value */ +#define SYBEVOIDRET 20291 /* Parameter of type SYBVOID cannot be a return parameter. */ +#define SYBECLOSEIN 20292 /* Unable to close interface file. */ +#define SYBEBOOL 20293 /* Boolean parameters must be TRUE or FALSE. */ +#define SYBEBCPOPT 20294 /* The option cannot be called while a bulk copy operation is progress. */ +#define SYBEERRLABEL 20295 /* An illegal value was returned from the security label handler. */ +#define SYBEATTNACK 20296 /* Timed out waiting for server to acknowledge attention." */ +#define SYBEBBFL 20297 /* -001- Batch failed in bulk-copy to SQL Server */ +#define SYBEDCL 20298 /* -004- DCL Error */ +#define SYBECS 20299 /* -004- cs context Error */ +#define SYBEBULKINSERT 20599 /* cannot build bulk insert statement */ +#define SYBECOLSIZE 22000 /* Invalid column information structure size */ + +int dbtds(DBPROCESS * dbprocess); + +#define DBTDS(a) dbtds(a) +DBINT dbtextsize(DBPROCESS * dbprocess); +DBBINARY *dbtxptr(DBPROCESS * dbproc, int column); +DBBINARY *dbtxtimestamp(DBPROCESS * dbproc, int column); +DBBINARY *dbtxtsnewval(DBPROCESS * dbprocess); +RETCODE dbtxtsput(DBPROCESS * dbprocess, DBBINARY newtxts, int colnum); +RETCODE dbuse(DBPROCESS * dbproc, const char *name); +const char *dbversion(void); +DBBOOL dbwillconvert(int srctype, int desttype); +RETCODE dbwritetext(DBPROCESS * dbproc, char *objname, DBBINARY * textptr, DBTINYINT textptrlen, DBBINARY * timestamp, + DBBOOL log, DBINT size, BYTE * text); + +/* LOGINREC manipulation */ +RETCODE dbsetlname(LOGINREC * login, const char *value, int which); +RETCODE dbsetlbool(LOGINREC * login, int value, int which); +RETCODE dbsetlshort(LOGINREC * login, int value, int which); +RETCODE dbsetllong(LOGINREC * login, long value, int which); +RETCODE dbsetlversion (LOGINREC * login, BYTE version); + +#define DBSETHOST 1 +#define DBSETLHOST(x,y) dbsetlname((x), (y), DBSETHOST) +#define dbsetlhost(x,y) dbsetlname((x), (y), DBSETHOST) +#define DBSETUSER 2 +#define DBSETLUSER(x,y) dbsetlname((x), (y), DBSETUSER) +#define dbsetluser(x,y) dbsetlname((x), (y), DBSETUSER) +#define DBSETPWD 3 +#define DBSETLPWD(x,y) dbsetlname((x), (y), DBSETPWD) +#define dbsetlpwd(x,y) dbsetlname((x), (y), DBSETPWD) +#if defined(DBLIB_UNIMPLEMENTED) +# define DBSETHID 4 /* not implemented */ +# define DBSETLHID(x,y) dbsetlname((x), (y), DBSETHID) +#endif +#define DBSETAPP 5 +#define DBSETLAPP(x,y) dbsetlname((x), (y), DBSETAPP) +#define dbsetlapp(x,y) dbsetlname((x), (y), DBSETAPP) +#define DBSETBCP 6 +#define BCP_SETL(x,y) dbsetlbool((x), (y), DBSETBCP) +#define DBSETLSECURE(x) dbsetlbool((x), (1), DBSETBCP) +#define DBSETNATLANG 7 +#define DBSETLNATLANG(x,y) dbsetlname((x), (y), DBSETNATLANG) +#define dbsetlnatlang(x,y) dbsetlname((x), (y), DBSETNATLANG) +#if defined(DBLIB_UNIMPLEMENTED) +# define DBSETNOSHORT 8 /* not implemented */ +# define DBSETLNOSHORT(x,y) dbsetlbool((x), (y), DBSETNOSHORT) +# define DBSETHIER 9 /* not implemented */ +# define DBSETLHIER(x,y) dbsetlshort((x), (y), DBSETHIER) +#endif +#define DBSETCHARSET 10 +#define DBSETLCHARSET(x,y) dbsetlname((x), (y), DBSETCHARSET) +#define DBSETPACKET 11 +#define DBSETLPACKET(x,y) dbsetllong((x), (y), DBSETPACKET) +#define dbsetlpacket(x,y) dbsetllong((x), (y), DBSETPACKET) +#define DBSETENCRYPT 12 +#define DBSETLENCRYPT(x,y) dbsetlbool((x), (y), DBSETENCRYPT) +#define DBSETLABELED 13 +#define DBSETLLABELED(x,y) dbsetlbool((x), (y), DBSETLABELED) +#define BCP_SETLABELED(x,y) dbsetlbool((x), (y), DBSETLABELED) +#define DBSETDBNAME 14 +#define DBSETLDBNAME(x,y) dbsetlname((x), (y), DBSETDBNAME) +#define DBSETLVERSION(login, version) dbsetlversion((login), (version)) +/* settings from here are purely FreeTDS extensions */ +#define DBSETUTF16 1001 +#define DBSETLUTF16(x,y) dbsetlbool((x), (y), DBSETUTF16) +#define DBSETNTLMV2 1002 +#define DBSETLNTLMV2(x,y) dbsetlbool((x), (y), DBSETNTLMV2) +#define DBSETREADONLY 1003 +#define DBSETLREADONLY(x,y) dbsetlbool((x), (y), DBSETREADONLY) + +RETCODE bcp_init(DBPROCESS * dbproc, const char *tblname, const char *hfile, const char *errfile, int direction); +DBINT bcp_done(DBPROCESS * dbproc); + +DBINT bcp_batch(DBPROCESS * dbproc); +RETCODE bcp_bind(DBPROCESS * dbproc, BYTE * varaddr, int prefixlen, DBINT varlen, BYTE * terminator, int termlen, int type, + int table_column); +RETCODE bcp_collen(DBPROCESS * dbproc, DBINT varlen, int table_column); +RETCODE bcp_columns(DBPROCESS * dbproc, int host_colcount); +RETCODE bcp_colfmt(DBPROCESS * dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, + const BYTE * host_term, int host_termlen, int colnum); +RETCODE bcp_colfmt_ps(DBPROCESS * dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, + BYTE * host_term, int host_termlen, int colnum, DBTYPEINFO * typeinfo); +RETCODE bcp_colptr(DBPROCESS * dbproc, BYTE * colptr, int table_column); +RETCODE bcp_control(DBPROCESS * dbproc, int field, DBINT value); +int bcp_getbatchsize(DBPROCESS * dbproc); /* FreeTDS only */ +RETCODE bcp_exec(DBPROCESS * dbproc, DBINT * rows_copied); +DBBOOL bcp_getl(LOGINREC * login); +RETCODE bcp_options(DBPROCESS * dbproc, int option, BYTE * value, int valuelen); +RETCODE bcp_readfmt(DBPROCESS * dbproc, const char filename[]); +RETCODE bcp_sendrow(DBPROCESS * dbproc); + +#ifdef __cplusplus +#if 0 +{ +#endif +} +#endif + +#endif diff --git a/freetds-1.1.24_build/include/syberror.h b/freetds-1.1.24_build/include/syberror.h new file mode 100644 index 0000000..0a6780b --- /dev/null +++ b/freetds-1.1.24_build/include/syberror.h @@ -0,0 +1,54 @@ +/* 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 diff --git a/freetds-1.1.24_build/include/sybfront.h b/freetds-1.1.24_build/include/sybfront.h new file mode 100644 index 0000000..8af0fbf --- /dev/null +++ b/freetds-1.1.24_build/include/sybfront.h @@ -0,0 +1,46 @@ +/* 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 diff --git a/freetds-1.1.24_build/include/tds_sysdep_public.h b/freetds-1.1.24_build/include/tds_sysdep_public.h new file mode 100644 index 0000000..787173c --- /dev/null +++ b/freetds-1.1.24_build/include/tds_sysdep_public.h @@ -0,0 +1,121 @@ +/* FreeTDS - Library of routines accessing Sybase and Microsoft databases + * Copyright (C) 1998-2011 Brian Bruns + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _tds_sysdep_public_h_ +#define _tds_sysdep_public_h_ + +/* + * This file is publicly installed. + * MUST not include config.h + */ + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# include +#elif defined(__sun) && defined(__SVR4) +# include +#else +typedef signed char int8_t; /* 8-bit int */ +typedef unsigned char uint8_t; /* 8-bit int */ +/* + * This is where platform-specific changes need to be made. + */ +# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +# include +# include +# include + typedef signed short int16_t; /* 16-bit int */ + typedef unsigned short uint16_t; /* 16-bit int */ + typedef signed int int32_t; /* 32-bit int */ + typedef unsigned int uint32_t; /* 32-bit int */ + typedef signed __int64 int64_t; /* 64-bit int */ + typedef unsigned __int64 uint64_t; /* 64-bit int */ +# if !defined(WIN64) && !defined(_WIN64) + typedef signed int intptr_t; /* 32-bit int */ + typedef unsigned int uintptr_t; /* 32-bit int */ +# else + typedef signed __int64 intptr_t; /* 64-bit int */ + typedef unsigned __int64 uintptr_t; /* 64-bit int */ +# endif +# else /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */ + typedef signed short int16_t; /* 16-bit int */ + typedef unsigned short uint16_t; /* 16-bit int */ + typedef signed int int32_t; /* 32-bit int */ + typedef unsigned int uint32_t; /* 32-bit int */ + typedef signed long int64_t; /* 64-bit int */ + typedef unsigned long uint64_t; /* 64-bit int */ + typedef signed long intptr_t; + typedef unsigned long uintptr_t; +# endif +#endif + +#include + +/* try to understand float sizes using float.h constants */ +#if FLT_RADIX == 2 +# if FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 +# define tds_sysdep_real32_type float /* 32-bit real */ +# elif DBL_MANT_DIG == 24 && DBL_MAX_EXP == 128 +# define tds_sysdep_real32_type double /* 32-bit real */ +# elif LDBL_MANT_DIG == 24 && LDBL_MAX_EXP == 128 +# define tds_sysdep_real32_type long double /* 32-bit real */ +# endif +# if FLT_MANT_DIG == 53 && FLT_MAX_EXP == 1024 +# define tds_sysdep_real64_type float /* 64-bit real */ +# elif DBL_MANT_DIG == 53 && DBL_MAX_EXP == 1024 +# define tds_sysdep_real64_type double /* 64-bit real */ +# elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +# define tds_sysdep_real64_type long double /* 64-bit real */ +# endif +# if !defined(tds_sysdep_real32_type) || !defined(tds_sysdep_real64_type) +# error Some float type was not found! +# endif +#else +# if FLT_DIG == 6 && FLT_MAX_10_EXP == 38 +# define tds_sysdep_real32_type float /* 32-bit real */ +# elif DBL_DIG == 6 && DBL_MAX_10_EXP == 38 +# define tds_sysdep_real32_type double /* 32-bit real */ +# elif LDBL_DIG == 6 && LDBL_MAX_10_EXP == 38 +# define tds_sysdep_real32_type long double /* 32-bit real */ +# endif +# if FLT_DIG == 15 && FLT_MAX_10_EXP == 308 +# define tds_sysdep_real64_type float /* 64-bit real */ +# elif DBL_DIG == 15 && DBL_MAX_10_EXP == 308 +# define tds_sysdep_real64_type double /* 64-bit real */ +# elif LDBL_DIG == 15 && LDBL_MAX_10_EXP == 308 +# define tds_sysdep_real64_type long double /* 64-bit real */ +# endif +#endif + +/* fall back to configure.ac types */ +#ifndef tds_sysdep_real32_type +#define tds_sysdep_real32_type float /* 32-bit real */ +#endif /* !tds_sysdep_real32_type */ + +#ifndef tds_sysdep_real64_type +#define tds_sysdep_real64_type double /* 64-bit real */ +#endif /* !tds_sysdep_real64_type */ + +#if !defined(MSDBLIB) && !defined(SYBDBLIB) +#define SYBDBLIB 1 +#endif +#if defined(MSDBLIB) && defined(SYBDBLIB) +#error MSDBLIB and SYBDBLIB cannot both be defined +#endif + +#endif /* _tds_sysdep_public_h_ */ diff --git a/freetds-1.1.24_build/lib/libct.a b/freetds-1.1.24_build/lib/libct.a new file mode 100644 index 0000000..1b63914 Binary files /dev/null and b/freetds-1.1.24_build/lib/libct.a differ diff --git a/freetds-1.1.24_build/lib/libct.la b/freetds-1.1.24_build/lib/libct.la new file mode 100644 index 0000000..7baae8f --- /dev/null +++ b/freetds-1.1.24_build/lib/libct.la @@ -0,0 +1,41 @@ +# libct.la - a libtool library file +# Generated by libtool (GNU libtool) 2.4.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libct.so.4' + +# Names of this library. +library_names='libct.so.4.0.0 libct.so.4 libct.so' + +# The name of the static archive. +old_library='libct.a' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags=' -pthread' + +# Libraries that this one depends upon. +dependency_libs=' -lssl -lcrypto -lpthread' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libct. +current=4 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/home/rulingcom/orbit_sites/test_client/sync_personal_data_task_for_nccu/freetds-1.1.24/build/lib' diff --git a/freetds-1.1.24_build/lib/libct.so b/freetds-1.1.24_build/lib/libct.so new file mode 100644 index 0000000..46e38df Binary files /dev/null and b/freetds-1.1.24_build/lib/libct.so differ diff --git a/freetds-1.1.24_build/lib/libct.so.4 b/freetds-1.1.24_build/lib/libct.so.4 new file mode 100644 index 0000000..46e38df Binary files /dev/null and b/freetds-1.1.24_build/lib/libct.so.4 differ diff --git a/freetds-1.1.24_build/lib/libct.so.4.0.0 b/freetds-1.1.24_build/lib/libct.so.4.0.0 new file mode 100644 index 0000000..46e38df Binary files /dev/null and b/freetds-1.1.24_build/lib/libct.so.4.0.0 differ diff --git a/freetds-1.1.24_build/lib/libsybdb.a b/freetds-1.1.24_build/lib/libsybdb.a new file mode 100644 index 0000000..df130c5 Binary files /dev/null and b/freetds-1.1.24_build/lib/libsybdb.a differ diff --git a/freetds-1.1.24_build/lib/libsybdb.la b/freetds-1.1.24_build/lib/libsybdb.la new file mode 100644 index 0000000..0aa1bf4 --- /dev/null +++ b/freetds-1.1.24_build/lib/libsybdb.la @@ -0,0 +1,41 @@ +# libsybdb.la - a libtool library file +# Generated by libtool (GNU libtool) 2.4.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libsybdb.so.5' + +# Names of this library. +library_names='libsybdb.so.5.1.0 libsybdb.so.5 libsybdb.so' + +# The name of the static archive. +old_library='libsybdb.a' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags=' -pthread' + +# Libraries that this one depends upon. +dependency_libs=' -lssl -lcrypto -lpthread' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libsybdb. +current=6 +age=1 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/home/rulingcom/orbit_sites/test_client/sync_personal_data_task_for_nccu/freetds-1.1.24/build/lib' diff --git a/freetds-1.1.24_build/lib/libsybdb.so b/freetds-1.1.24_build/lib/libsybdb.so new file mode 100644 index 0000000..72d8d7a Binary files /dev/null and b/freetds-1.1.24_build/lib/libsybdb.so differ diff --git a/freetds-1.1.24_build/lib/libsybdb.so.5 b/freetds-1.1.24_build/lib/libsybdb.so.5 new file mode 100644 index 0000000..72d8d7a Binary files /dev/null and b/freetds-1.1.24_build/lib/libsybdb.so.5 differ diff --git a/freetds-1.1.24_build/lib/libsybdb.so.5.1.0 b/freetds-1.1.24_build/lib/libsybdb.so.5.1.0 new file mode 100644 index 0000000..72d8d7a Binary files /dev/null and b/freetds-1.1.24_build/lib/libsybdb.so.5.1.0 differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/1.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/1.gif new file mode 100644 index 0000000..a85c6c1 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/1.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/10.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/10.gif new file mode 100644 index 0000000..11bab0e Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/10.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/2.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/2.gif new file mode 100644 index 0000000..6f1ca23 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/2.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/3.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/3.gif new file mode 100644 index 0000000..12bb607 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/3.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/4.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/4.gif new file mode 100644 index 0000000..be50ce8 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/4.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/5.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/5.gif new file mode 100644 index 0000000..dbaf5f6 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/5.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/6.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/6.gif new file mode 100644 index 0000000..b5d3926 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/6.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/7.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/7.gif new file mode 100644 index 0000000..76d761a Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/7.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/8.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/8.gif new file mode 100644 index 0000000..27a4c26 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/8.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/callouts/9.gif b/freetds-1.1.24_build/share/doc/freetds/images/callouts/9.gif new file mode 100644 index 0000000..1f01d88 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/callouts/9.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/caution.gif b/freetds-1.1.24_build/share/doc/freetds/images/caution.gif new file mode 100644 index 0000000..9cc2e15 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/caution.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/important.gif b/freetds-1.1.24_build/share/doc/freetds/images/important.gif new file mode 100644 index 0000000..25e40c7 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/important.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/note.gif b/freetds-1.1.24_build/share/doc/freetds/images/note.gif new file mode 100644 index 0000000..7322e8e Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/note.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/tip.gif b/freetds-1.1.24_build/share/doc/freetds/images/tip.gif new file mode 100644 index 0000000..f062955 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/tip.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/images/warning.gif b/freetds-1.1.24_build/share/doc/freetds/images/warning.gif new file mode 100644 index 0000000..a587079 Binary files /dev/null and b/freetds-1.1.24_build/share/doc/freetds/images/warning.gif differ diff --git a/freetds-1.1.24_build/share/doc/freetds/reference/index.html b/freetds-1.1.24_build/share/doc/freetds/reference/index.html new file mode 100644 index 0000000..6b5d19c --- /dev/null +++ b/freetds-1.1.24_build/share/doc/freetds/reference/index.html @@ -0,0 +1 @@ +

at www.freetds.org diff --git a/freetds-1.1.24_build/share/doc/freetds/userguide/index.html b/freetds-1.1.24_build/share/doc/freetds/userguide/index.html new file mode 100644 index 0000000..cd168cd --- /dev/null +++ b/freetds-1.1.24_build/share/doc/freetds/userguide/index.html @@ -0,0 +1 @@ +

at www.freetds.org diff --git a/freetds-1.1.24_build/share/man/man1/bsqldb.1 b/freetds-1.1.24_build/share/man/man1/bsqldb.1 new file mode 100644 index 0000000..1dc38cf --- /dev/null +++ b/freetds-1.1.24_build/share/man/man1/bsqldb.1 @@ -0,0 +1,131 @@ +.\" cf. groff_mdoc +.Dd March 26, 2015 +.Dt BSQLDB 1 +.Os FreeTDS 1.1.24 +.Sh NAME +.Nm bsqldb +.Nd batch SQL script processor using DB-Library +.Sh SYNOPSIS +.Nm +.Op Fl hqv +.Op Fl S Ar servername +.Op Fl D Ar database +.Op Fl U Ar username +.Op Fl P Ar password +.Op Fl i Ar input_file +.Op Fl o Ar output_file +.Op Fl e Ar error_file +.Op Fl H Ar hostname +.Op Fl t Ar field_term +.Op Fl R Ar pivot_description +.\" +.Sh DESCRIPTION +.Nm +is a utility program distributed with FreeTDS. +.Nm +is a non-interactive equivalent of the "isql" utility programs +distributed by Sybase and Microsoft. Like them, +.Nm +uses the command "go" on a line by itself as a separator between +batches. The last batch need not be followed by "go". +.Nm +makes use of the DB-Library API provided by FreeTDS. This API is of +course also available to application developers. + +.Sh OPTIONS +.Bl -tag -width indent +.It Fl D Ar database +Database to use. +.It Fl H Ar hostname +hostname Override name of client sent to server. +.It Fl P Ar password +Database server password. +.It Fl S Ar servername +Database server to which to connect. +.It Fl U Ar username +Database server login name. If username is not provided, a domain +login is attempted for TDS 7+ connections. +.It Fl e Ar error_file +Name of file for errors. +.It Fl h +Print column headers with the data to the same file. +.It Fl i Ar input_file +Name of script file, containing SQL. +.It Fl o Ar output_file +Name of output file, holding result data. +.It Fl q +Do not print column metadata, return status, or rowcount. Overrides +.Fl h Ns . +.It Fl t Ar field_term +Specifies the field terminator. Default is two spaces (' '). +Recognized escape sequences are tab ('\\t'), carriage return ('\\r'), +newline ('\\n'), and backslash ('\\\\'). +.It Fl v +Verbose mode, for more information about the DB-Library interaction. +This also reports the result set metadata, including and return code. All +verbose data are written to standard error (or +.Fl e Ns ), so as not to interfere with the data stream. +.It Fl R Ar pivot_description +Specify pivot trasformation. The format is +.Ao Ar down\ columns Ac +.Ao Ar across\ columns Ac +.Ao Ar function Ac +.Ao Ar value Ac . +Columns are specified but numbers. +The format of +.Ar down columns +and +.Ar across columns +is a comma separated list of columns. +.Ar function +is either count, sum, min or max. +.El +.\" +.Sh ENVIRONMENT +.Ev DSQUERY +default +.Ar servername +.\" +.Sh NOTES +.Nm +is a filter; it reads from standard input, writes to standard output, +and writes errors to standard error. The +.Fl i Ns , Fl o Ns , and Fl e +options override these defaults. +.Pp +The source code for +.Nm +is intended as a model for DB-Library users. DB-Library has a rich set +of functions, and it can be hard sometimes to understand how to use +them, particularly the first time. If you find something about the +source code unclear, you are encouraged to email the author your +comments. +.\" +.Sh EXIT STATUS +.Nm +exits 0 on success, and >0 if the server cannot process the query. +.Pp +For messages with severity > 10, +.Nm +calls exit(3) with the severity level. For example, if the severity +level is 16, +.Nm +will return an exit status of 16 to the shell. +.\" +.Sh HISTORY +.Nm +first appeared in FreeTDS 0.63. +.\" +.Sh AUTHORS +The +.Nm +utility was written by +.An "James K. Lowden" Aq jklowden@freetds.org . +.\" +.Sh BUGS +Microsoft servers as of SQL Server 7.0 SP 3 do not return output +parameters unless the RPC functions are used. This means +.Nm +cannot return output parameters for stored procedures with these +servers. + diff --git a/freetds-1.1.24_build/share/man/man1/bsqlodbc.1 b/freetds-1.1.24_build/share/man/man1/bsqlodbc.1 new file mode 100644 index 0000000..f4e1691 --- /dev/null +++ b/freetds-1.1.24_build/share/man/man1/bsqlodbc.1 @@ -0,0 +1,113 @@ +.\" cf. groff_mdoc +.Dd March 25, 2015 +.Os FreeTDS 1.1.24 +.Dt BSQLODBC FreeTDS "FreeTDS Reference Manual" +.\" +.Sh NAME +.Nm bsqlodbc +.Nd batch SQL script processor using ODBC +.\" +.Sh SYNOPSIS +.Pp +.Nm +.Op Fl hqv +.Op Fl U Ar username +.Op Fl P Ar password +.Op Fl S Ar server +.Op Fl D Ar database +.Op Fl i Ar input_file +.Op Fl o Ar output_file +.Op Fl e Ar error_file +.Op Fl t Ar field_term +.Op Fl V Ar odbc_version +.\" +.Sh DESCRIPTION +.Pp +.Nm +is a utility program distributed with FreeTDS. +.Pp +.Nm +is a non-interactive equivalent of the +.Ql isql +utility programs distributed by Sybase and Microsoft. Like them, +.Nm +uses the command +.Ql go +on a line by itself as a separator between batches. The last +batch need not be followed by +.Ql go . +.Pp +.Nm +makes use of the ODBC API provided by FreeTDS. This +API is of course also available to application developers. +.\" +.Sh OPTIONS +.Bl -tag -width indent +.It Fl U Ar username +Database server login name. +.It Fl P Ar password +Database server password. +.It Fl S Ar server +Database server to which to connect. +.It Fl D Ar database +Database to use. +.It Fl i Ar input_file +Name of script file, containing SQL. +.It Fl o Ar output_file +Name of output file, holding result data. +.It Fl e Ar error_file +Name of file for errors. +.It Fl t Ar field_term +Specifies the field terminator. Default is two spaces ( +.Ql \ \ +.Ns ). +Recognized escape sequences are tab ( +.Ql \et +.Ns ), +carriage return ( +.Ql \er +.Ns ), +newline ( +.Ql \en +.Ns ), +and backslash ( +.Ql \e\e +.Ns ). +.It Fl h +Print column headers with the data to the same file. +.It Fl q +Do not print column metadata, return status, or rowcount. Overrides +.Fl h . +.It Fl v +Verbose mode, for more information about the ODBC interaction. +This also reports the result set metadata, including and return code. All +verbose data are written to standard error (or +.Fl e Ns ), +so as not to interfere with the data stream. +.It Fl V Ar odbc_version +Specify ODBC version (2 or 3). +.El +.\" +.Sh NOTES +.Pp +.Nm +is a filter; it reads from standard input, writes to standard output, +and writes errors to standard error. The +.Fl i , +.Fl o , +and +.Fl e +options override these defaults. +.Sh EXIT STATUS +.Nm +exits 0 on success, and >0 if the server cannot process the query. +.\" +.Sh HISTORY +.Nm +first appeared in FreeTDS 0.65. +.\" +.Sh AUTHORS +The +.Nm +utility was written by +.An James K. Lowden Aq jklowden@freetds.org . diff --git a/freetds-1.1.24_build/share/man/man1/datacopy.1 b/freetds-1.1.24_build/share/man/man1/datacopy.1 new file mode 100644 index 0000000..3da7861 --- /dev/null +++ b/freetds-1.1.24_build/share/man/man1/datacopy.1 @@ -0,0 +1,97 @@ +.\" cf. groff_mdoc +.Dd March 25, 2015 +.Os FreeTDS 1.1.24 +.Dt DATACOPY FreeTDS "FreeTDS Reference Manual" +.\" +.Sh NAME +.Nm datacopy +.Nd move table data between two servers +.\" +.Sh SYNOPSIS +.Nm +.Op Fl vdE +.Bro +.Fl t +| +.Fl a +| +.Fl c +.Ar owner +.Brc +.Op Fl b Ar batchsize +.Op Fl p Ar packetsize +.Op Fl S Ar server/username/password/database/table_or_view +.Op Fl D Ar server/username/password/database/table +.Op Fl T Ar textsize +.\" +.Sh DESCRIPTION +.Nm +is a utility distributed with FreeTDS. +.Nm +will move table data from one server to another without the need for +intermediate files. +.Nm +is much faster and more efficient than is freebcp out/in. +.Pp +.Nm +makes use of the db-lib bcp API built into FreeTDS. This API is also +available to application developers. +.Pp +.Nm +can be used to migrate data between Sybase ASE and SQL Server or vice +versa. +.\" +.Sh OPTIONS +.Bl -tag -width indent +.It Fl t +Truncate target table before loading data. +.It Fl a +Append data to target table. +.It Fl c Ar owner +Create the target table with the same schema as the source table. +.Nm +will submit a +.Ql CREATE TABLE +command on the target server using the specified owner in +the command, e.g. +.Ql CREATE TABLE owner.table (.\|.\|.\&). +.It Fl b Ar batchsize +The number of rows per batch of data copied. Each batch of data is +effectively 'committed' to the database. The default is 1000. +.It Fl p Ar packetsize +The number of bytes, per network packet, sent to and from the +servers. Increased packet size can enhance performance. +.It Fl T Ar textsize +Specify size of TEXT/IMAGE column from network. +.It Fl v +Produce verbose output, including diagnostic timings. +.It Fl d +Produce freetds TDSDUMP output. (Serious debug only!) +.It Fl S Ar server/username/password/database/table_or_view +The connection information for the source server +and the location/name of the table (or view) to be copied. +If not specified, +.Nm +prompts the user for the information. +.It Fl D Ar server/username/password/database/table +The connection information for the destination server and the +location/name of the target table. +If not specified, +.Nm +prompts the user for the information. +.It Fl E +Keep identity values. +.Sh SEE ALSO +.Xr freebcp 1 , Xr defncopy 1 , Xr bsqldb 1 , Xr tsql 1 , +.%B FreeTDS User Guide. +.\" +.Sh HISTORY +.Pp +.Nm +first appeared in FreeTDS 0.64. +.\" +.Sh AUTHORS + The +.Nm +utility was written by +.An Bill Thompson Aq thompbil@exchange.uk.ml.com . diff --git a/freetds-1.1.24_build/share/man/man1/defncopy.1 b/freetds-1.1.24_build/share/man/man1/defncopy.1 new file mode 100644 index 0000000..781fd40 --- /dev/null +++ b/freetds-1.1.24_build/share/man/man1/defncopy.1 @@ -0,0 +1,110 @@ +.\" cf. groff_mdoc +.Dd April 26, 2012 +.Os FreeTDS 1.1.24 +.Dt DEFNCOPY FreeTDS "FreeTDS Reference Manual" +.\" +.Sh NAME +.Nm defncopy +.Nd extract procedures and views from a Microsoft server. +.\" +.Sh SYNOPSIS +.Pp +.Nm +.Op Fl v +.Op Fl U Ar username +.Op Fl P Ar password +.Op Fl S Ar server +.Op Fl D Ar database +.Op Fl i Ar input_file +.Op Fl o Ar output_file +.Bo +.Ar owner.object_name +.\" Elipsis according to Werner Lemberg: +.\" http://www.mail-archive.com/groff@gnu.org/msg03122.html +.Op Ar owner.object_name .\|.\|.\& +.Bc +.\" +.Sh DESCRIPTION +.Pp +.Nm +is a utility program distributed with FreeTDS. It replaces +a similar program of the same name distributed by Sybase. +.Pp +.Nm +reads the text of a stored procedure or view, and writes a script +suitable for recreating the procedure or view. For tables, it reads +the output of sp_help and constructs a +.Ql CREATE TABLE +statement, complete +with +.Ql CREATE INDEX Ns , +too. +.\" +.Ar owner +is optional if you or the database owner is the owner +of the procedure/view being copied. +.Ar object_name +is the name of the system object you wish to extract. +.\" +.Sh OPTIONS +.Bl -tag -width indent +.It Fl U Ar username +database server login name. +.It Fl P Ar password +database server password. +.It Fl S Ar server +database server to which to connect. +.It Fl D Ar database +database to use. Optional if the procedure/view being extracted is in your +default database. +.It Fl i Ar input_file +a script to apply to the database. Not currently implemented. +.It Fl o Ar output_file +a file to hold the script, defaults to standard output. +.It Fl v +Show version information and copyright notice. +.El +.\" +.Sh NOTES +.Nm +is a filter; it reads from standard input, writes to standard output, +and writes errors to standard error. The +.Fl i , +.Fl o , +and +.Fl e +options override these defaults. +.Pp +.Nm +makes use of the db-lib API provided by FreeTDS. This +API is of course also available to application developers. +.Sh EXIT STATUS +.Pp +.Nm +exits 0 on success, and >0 if the server cannot process the query. +.Pp +.Nm +will report any errors returned by the server, but will continue +processing. +.\" +.Sh HISTORY +.Pp +.Nm +first appeared in FreeTDS 0.63. +.\" +.Sh AUTHORS +The +.Nm +utility was written by +.An James K. Lowden Aq jklowden@schemamania.org. +.\" +.Sh BUGS +Works only with Microsoft servers and ancient Sybase servers. +Does not create primary keys. +Many options are defined by Sybase that this version does not implement. Feel +free to correct this situation. +In theory, +.Nm +could apply/produce DDL for any system object, +but at present only tables, procedures and views are supported, +and only for extraction. diff --git a/freetds-1.1.24_build/share/man/man1/fisql.1 b/freetds-1.1.24_build/share/man/man1/fisql.1 new file mode 100644 index 0000000..af53cab --- /dev/null +++ b/freetds-1.1.24_build/share/man/man1/fisql.1 @@ -0,0 +1,172 @@ +.\" cf. groff_mdoc +.Dd March 25, 2015 +.Os FreeTDS 1.1.24 +.Dt FISQL FreeTDS "FreeTDS Reference Manual" +.\" +.Sh NAME +.Nm fisql +.Nd interactive SQL shell +.\" +.Sh SYNOPSIS +.Pp +.Nm +.Op Fl eFgpnvXY +.Op Fl a Ar display_charset +.Op Fl A Ar packet_size +.Op Fl c Ar cmdend +.Op Fl D Ar database +.Op Fl E Ar editor +.Op Fl h Ar headers +.Op Fl H Ar hostname +.Op Fl i Ar inputfile +.Op Fl I Ar interfaces_file +.Op Fl J Ar client_charset +.Op Fl l Ar login_timeout +.Op Fl m Ar errorlevel +.Op Fl o Ar outputfile +.Op Fl P Ar password +.Op Fl s Ar colseparator +.Op Fl S Ar server +.Op Fl t Ar timeout +.Op Fl U Ar username +.Op Fl w Ar width +.Op Fl y Ar sybase_dir +.Op Fl z Ar language +.\" +.Sh DESCRIPTION +.Pp +.Nm +is very similar to the +.Ql isql +utility programs distributed by Sybase and Microsoft. Like them, +.Nm +uses the command +.Ql go +on a line by itself as a separator between batches. +.\" +.Sh OPTIONS +.Bl -tag -width indent +.It Fl a Ar display_charset +The client charset name. Not implemented. +.It Fl A Ar packet_size +Set protocol packet size. You should not need to set this parameter. +.It Fl c Ar cmdend +Command terminator, defaults to +.Ql go Ns . +.It Fl D +Database name on the server to use. +.It Fl e +Echo SQL input (usually in outputfile) +.It Fl E Ar editor +Specify +an editor to invoke. Defaults to vi. +.It Fl F +FIPS mode ON. Server returns a message (but processes the query anyway) +when it encounters a non-standard SQL command. +.It Fl g +Display a brief help message +.It Fl h Ar headers +Number +of rows after which to repeat the column headers. Default is once per resultset. +.It Fl H Ar hostname +Hostname +of the client machine as it will be told to the server. +.It Fl I Ar interfaces_file +Name +of the interfaces or freetds.conf file to use. +.It Fl i Ar inputfile +Name +of script file, containing SQL. +.It Fl J Ar client_charset +Not +implemented. +.It Fl l Ar login_timeout +How +long to wait for the server to acknowledge a login attempt. +.It Fl m Ar errorlevel +For +errors of the severity level specified or higher, +print only the message number, state, and error level. +Below that level, print nothing. +.It Fl n +Suppress line numbers in echoed output. +.It Fl o Ar outputfile +Name +of output file, holding result data. +.It Fl p +Prints performance statistics. Not implemented. +.It Fl P Ar password +Database +server password. +.It Fl s Ar colseparator +The +column separator. Default is space. Shell metacharacters require quoting. +.It Fl S Ar server +Database +server to which to connect. +.It Fl t Ar timeout +The +query timeout, in seconds. How long to wait for a query to be processed. +The default is indefinitely, or as determined by freetds.conf. +.It Fl U Ar username +Database +server login name. +.It Fl v +Display version and copyright. +.It Fl w Ar width +How +many characters wide to print the output. Defaults to 80. +.It Fl X +Use encrypted login. Not implemented in FreeTDS. +.It Fl y Pa sybase_dir +Sets +the +.Ev SYBASE +environment variable. Not used by FreeTDS. +.It Fl Y +Use chained transactions. +.It Fl z Ar language +Name +of a language for fisql's prompts and messages. +Cf. DBSETLNATLANG. +.El +.\" +.Sh NOTES +.Nm +is a filter; it reads from standard input, writes to standard output, +and writes errors to standard error. The +.Fl i Ns , +.FL o Ns , +and +.Fl e +options override these defaults. +.Pp +.Nm +uses the DB-Library API provided by FreeTDS. It was first implemented using +Sybase's own library and continues to work with it. Before (and after) modifying +it, it would be well to test it with Sybase's library to assure compatibility +between it and FreeTDS. +EXIT STATUS +.Pp +.Nm +exits 0 on success, and >0 if the server cannot process the query. +.Pp +.Nm +will report any errors returned by the server, but will continue +processing. In a production environment, this behavior may be insufficiently +stringent. To make it extremely intolerant of errors, change the message and +error handlers to call exit(3). +.\" +.Sh HISTORY +.Nm +first appeared in FreeTDS 0.65. +.\" +.Sh AUTHORS +The +.Nm +utility was written by +.An Nicholas S. Castellano Aq entropy@freetds.org Ns , +who contributed it to the FreeTDS project under the terms of the GPL. +.\" +.Sh BUGS +Requires the GNU readline library. diff --git a/freetds-1.1.24_build/share/man/man1/freebcp.1 b/freetds-1.1.24_build/share/man/man1/freebcp.1 new file mode 100644 index 0000000..49e9392 --- /dev/null +++ b/freetds-1.1.24_build/share/man/man1/freebcp.1 @@ -0,0 +1,227 @@ +.\" cf. groff_mdoc +.Dd March 25, 2015 +.Os FreeTDS 1.1.24 +.Dt FREEBCP 1 +.Sh NAME +.Nm freebcp +.Nd bulk loading utility for Sybase and Microsoft databases +.Sh SYNOPSIS +.Nm +.Bo Bo Ao Ar database Ac Ns . Bc Ns Ao Ar owner Ac Ns . Bc Ns Aq Ar object_name +.Bro +.Ar in +| +.Ar [query] Ns Ar out +.Brc +.Ar datafile +.Bro +.Fl c +| +.Fl n +| +.Fl f Ar formatfile +.Brc +.Op Fl S Ar servername +.Op Fl D Ar dbname +.Op Fl U Ar username +.Op Fl P Ar password +.Op Fl b Ar batchsize +.Op Fl F Ar firstrow +.Op Fl L Ar lastrow +.Op Fl e Ar errfile +.Op Fl I Ar interfaces +.Op Fl m Ar maxerror +.Op Fl t Ar field_term +.Op Fl r Ar row_term +.Op Fl h Ar hints +.Op Fl T Ar textsize +.Op Fl A Ar packet_size +.Op Fl O Ar options +.Op Fl i Ar inputfile +.Op Fl o Ar outputfile +.Op Fl C Ar charset +.Op Fl EdVv +.\" +.Sh DESCRIPTION +.Nm +is a utility program distributed with FreeTDS. +.Nm +replicates (in part at least) the functionality +of the bcp utility programs distributed by Sybase and Microsoft. +.Nm +makes use of the DB-Library bcp API provided by FreeTDS. This +API is also available to application developers. +.Pp +The manual pages or online help for Sybase or SQL Server can be +referenced for more detailed information on bcp functionality. +.\" +.Sh TABLES\ AND\ FILES +.Bl -tag -width indent +.It Ar database +The name of the database containing object to be copied. Optional if +the table/view is in the default database for +.Ar username . +.It Ar schema +The schema of the object being copied. If not provided, the default schema +for +.Ar username +is used. +.It Ar object +The name of the database object you wish to access, typically a +table. It can also be a view. All views can be read; some can be +written, subject to constraints. With +.Ar queryout Ns , Ar object +can also be an SQL query. +.It Ar in +Copy data from a host file to a database table. +.It Ar out +Copy data from a database table to a host file. +.It Ar queryout +indicates that +.Ar table_name +is in fact SQL, rather than a database object. +.Nm +will execute the query and write the results to a file. (It is a good +idea to have the query return one and only one result set.) +.It Ar datafile +The name of an operating system file. +.El +.\" +.Sh OPTIONS +.Bl -tag -width indent +.It Fl A Ar packet_size +Set the size of a TDS packet to packet_size. Not sure why you would +want to do this, except as an experiment. +.It Fl D Ar dbname +The name of the default database to use. Overrides default database associated with the login account. Causes +.Nm +to issue a +.Ic USE Ar dbname +command immediately after logging in, before commencing BCP operations. +.It Fl E +Write the data in datafile to the table's IDENTITY column. Without +this flag, the identity data present in the datafile will be ignored, +and new IDENTITY values will be generated for the imported rows. +.It Fl F Ar firstrow +The first row to copy from the input file or database table. The +default is the first row, row 1. +.It Fl I Ar interfaces +The name and location of the +.Pa interfaces +file to search when connecting to servername. Overrides +.Pa freetds.conf. +.It Fl L Ar lastrow +The last row to copy from an input file or +database table. The default is the last row. +.It Fl O Ar options +SQL text to set connection options prior to the bcp operation. If +.Ar options +is a valid filename, the SQL is read from the file +instead. Sometimes needed for +.Ar queryout . +Example: +.Li -O `SET QUOTED_IDENTIFIER ON' Ns . +.It Fl P Ar password +The password associated with +.Ar username . +.It Fl S Ar servername +The name of the Database Server to which to connect. +.It Fl T Ar textsize +For text or image columns, set the maximum number of characters to +request from the server. Defaults to the setting in +.Pa freetds.conf . +If +not specified anywhere, defaults to the full size of the data. +.It Fl U Ar username +A database login name. For TDS\ 7+ connections, a domain login is attempted +if +.Ar username +is not provided. +.It Fl b Ar batchsize +The number of rows per batch of data copied. Batching applies only +when you are bulk copying into the database. Each batch of data is +effectively +.Dq committed +into the database. The default value for +.Ar batchsize +is 1000. +.It Fl c +The host data file is (or will be) in "character" format, i.e., a text +file. Encoding is determined by the client charset attribute in +.Pa freetds.conf . +.It Fl d +Turn off any logging. (Unintuitive, perhaps.) +.It Fl e Ar errfile +Write errors to +.Ar errfile . +For uploads. Includes line and column +information, and the row data. +.It Fl f Ar formatfile +The format of the host data file is described by +.Ar formatfile . +The layout of +.Ar formatfile +is identical to that understood by the Sybase and +Microsoft bcp utilities, but is too complicated to describe here. +.It Fl h Ar hints +Set bcp hints. For valid values, cf. +.Fn bcp_options +in the FreeTDS Reference Manual. +.It Fl m Ar maxerror +Stop after encountering +.Ar maxerror +errors. Default 10. +.It Fl n +The host data file is in +.Dq native +format. This is a format that +.Nm +will be able to process, but is not portable or readable. +.It Fl r Ar row_term +The row terminator for a character file. May be more than one +character. Default is newline ('\\n'). Cf\&. +.Fl c Ns , +above. +.It Fl t Ar field_term +The field terminator for character file. Also known as a column +delimiter. May be more than one character. Default is tab +('\\t'). Cf\&. +.Fl c Ns +, above. +.It Fl v +.It Fl V +Print the version information and exit. +.It Fl i Ar inputfile +Read input data from file specified. +.It Fl o Ar outputfile +Write output data to file specified. +.It Fl C Ar charset +Specify character set to use to talk to server. +.El +.Sh ENVIRONMENT +.Ev DSQUERY +default +.Ar servername +.\" +.Sh NOTES +When connecting to a Sybase database server, it is required that the +TDS 5.0 protocol be used. When connecting to a Microsoft SQL Server +2000 database server, the TDS\ 7 (or later) protocol is required. +.Pp +Sybase and Microsoft define different versions of the bcp portion of TDS 4.2. +Because FreeTDS has no way of knowing which type of server it's connected to, +.Nm +does not support version 4.2 of the TDS protocol. +.\" +.Sh HISTORY +.Nm +first appeared in FreeTDS 0.60 +.Sh AUTHORS +The +.Nm +utility was written by +.An Bill Thompson Aq thompbil@exchange.uk.ml.com +.Sh BUGS +Currently, there is no support for text data types in +.Nm Ns , when +SQL Server 2000 is the target server. diff --git a/freetds-1.1.24_build/share/man/man1/osql.1 b/freetds-1.1.24_build/share/man/man1/osql.1 new file mode 100644 index 0000000..48c909f --- /dev/null +++ b/freetds-1.1.24_build/share/man/man1/osql.1 @@ -0,0 +1,103 @@ +.\" cf. groff_mdoc +.Dd April 26, 2012 +.Os FreeTDS 1.1.24 +.Dt OSQL FreeTDS "FreeTDS Reference Manual" +.\" +.Sh NAME +.Nm osql +.Nd utility to test FreeTDS connections and queries +.\" +.Sh SYNOPSIS +.Pp +.Nm +.Fl S Ar dsn +.Fl U Ar username +.Fl P Ar password +.Op Fl I Pa ini_directory +.\" +.Sh DESCRIPTION +.Pp +.Nm +is a diagnostic tool provided as part of FreeTDS. It is a +Bourne shell script that checks and reports on your configuration +files. If everything checks out OK, it invokes isql. +.Pp +.Nm +works only with the isql that comes with unixODBC. +.\" +.Sh OPTIONS +.Bl -tag -width indent +.It Fl S Ar dsn +the Data Source Name to which to connect, as known to +.Pa odbc.ini Ns . +.It Fl U Ar username +database +login name. +.It Fl P Ar password +database password. +.It Fl I Ar ini_dir +override +.Pa odbc.ini +file location. +.El +.\" +.Sh EXAMPLE +If you have an +.Pa odbc.ini +with a section like this: +.Bd -literal -offset indent +.Bq myDSN +servername = myserver +TDS_Version = 5.0 +.Ed +.Pp +You would invoke +.Nm +as: +.Pp +.Li osql -S myDSN +.Op .\|.\|.\& +.\" +.Sh FILES +.Pa odbc.ini +.Pa freetds.conf +.\" +.Sh NOTES +If you can connect with +.Ql osql -S servername -U user -P passwd Ns , +your FreeTDS ODBC installation is working. +.Pp +.Nm +guesses where unixODBC might look for its +.Pa odbc.ini +by examining the binary. This is not always an effective approach. If +it doesn't work, you'll receive a report of candidate strings. Kindly +pass along the output to help improve the guessing. +.Pp +If +.Nm +cannot intuit your +.Pa odbc.ini +directory, you can force the issue with +the +.Fl I +option. However, you're then instructing +.Nm +what to test, not where unixODBC will eventually look. Your override +is therefore only as good as you are. Look carefully at the error +output before overriding. +.Pp +If you have suggestions for ways to make +.Nm +more useful as a diagnostic tool, please post them to the FreeTDS +mailing list. +.\" +.Sh HISTORY +.Nm +first appeared in FreeTDS 0.65. +.\" +.Sh AUTHORS +The +.Nm +utility was written by +.An James K. Lowden Ns . diff --git a/freetds-1.1.24_build/share/man/man1/tsql.1 b/freetds-1.1.24_build/share/man/man1/tsql.1 new file mode 100644 index 0000000..b16658f --- /dev/null +++ b/freetds-1.1.24_build/share/man/man1/tsql.1 @@ -0,0 +1,160 @@ +.\" cf. groff_mdoc +.Dd March 25, 2015 +.Os FreeTDS 1.1.24 +.Dt TSQL FreeTDS "FreeTDS Reference Manual" +.Sh NAME +.Nm tsql +.Nd utility to test FreeTDS connections and queries +.Sh SYNOPSIS +.Nm +.Bro +.Fl S Ar servername +.Op Fl I Ar interface +| +.Fl H Ar hostname +.Op Fl L +.Op Fl p Ar port +.Brc +.Op Fl D Ar dbname +.Op Fl U Ar username +.Op Fl P Ar password +.Op Fl o Ar options +.Nm +.Fl C +.Sh DESCRIPTION +.Nm +is a FreeTDS diagnostic tool. It uses the TDS protocol to connect to a +Sybase or Microsoft SQL Server, and lets the user issue queries. +.Nm +does +not use the FreeTDS client libraries. Instead, it uses only the lowest level +library, libtds, to test the protocol implementation. +.Pp +.Nm +can be run in two ways, one which uses the freetds.conf and one which +connects directly using the server's hostname and port. +The +.Fl H +and +.Fl p +parameters are provided to let the user verify a server is listening on +the named host and port. These parameters override any configuration files +and environment variables. +.Pl +The +.Fl S +parameter can be used to test the local configuration. FreeTDS will use +freetds.conf (or equivalent) and environment variables in the normal way to +determine the server's IP address and port. You can use +.Fl I +to specify a filename, overriding FreeTDS's configuration file search +algorithm. +.Sh OPTIONS +.Bl -tag -width indent +.It Fl S Ar servername +database server to which to connect. +.It Fl D Ar dbname +database to use. +.It Fl I Ar interface +freetds.conf or interfaces file describing servername. +.It Fl H Ar hostname +DNS hostname of the server. +.It Fl p Ar port +port at which SQL Server is listening. +.It Fl U Ar username +database login name. If username is not provided, a domain +login is attempted for TDS 7+ connections. +.It Fl P Ar password +database password. +.It Fl L +list Microsoft server instances (with +.Fl H Ns ). +.It Fl C +print some of the compile-time configuration parameters. +.It Fl o Ar options +apply the options specified to every command. +.Bl -tag -width indent +.It Fl f +No footer +.Bq result count +.It Fl h +No header +.Bq titles +.It Fl t +Print time +.It Fl v +Print version +.It Fl q +Quiet +.El +.It Fl a Ar appname +application name. +.It Fl t Ar colterm +column terminator. +.It Fl r Ar rowterm +row terminator. +.It Fl r Ar rowterm +row terminator. +.It Fl J Ar charset +character set. +.It Fl v +verbose mode. +.El +.\" +.Sh NOTES +If you can connect with +.Ql tsql -S servername Ns , +your basic FreeTDS installation is working. +.Pp +Typing +.Ql exit Ns , +.Ql quit Ns , +or +.Ql bye +(or +.Li ^D Ns ) +exits +.Nm Ns . +.Pp +Typing +.Ql version +displays the TDS protocol version. +.Pp +Command batches may be separated with +.Ql go +or +.Ql GO Ns . +If +.Ql GO +the version string is reported before executing the batch. +.Pp +After prompting for the password (if not provided with +.Fl P Ns ), +.Nm +will attempt to connect to the remote server. +.Nm +displays a counter indicating the number +of seconds elapsed during the connection attempt. Typically, +.Nm +immediately responds with a +.Ql 1> +prompt. If you see the counter (1, 2, 3, ...), most likely +.Nm +is unable to connect to the indicated server. +.Pp +.Nm +is not a replacement for a complete isql such as sqsh (www.sqsh.org). +If you have suggestions for ways to make +.Nm +more useful as a diagnostic tool, please post them to the FreeTDS +mailing list for consideration. +.Sh HISTORY +.Nm +first appeared in FreeTDS 0.60. +.Sh AUTHORS +The +.Nm +utility was written by +.An Brian Bruns Ns . +.Sh BUGS +Several, to be sure, now that it's documented. :) diff --git a/freetds-1.1.24_build/share/man/man5/freetds.conf.5 b/freetds-1.1.24_build/share/man/man5/freetds.conf.5 new file mode 100644 index 0000000..a729dd1 --- /dev/null +++ b/freetds-1.1.24_build/share/man/man5/freetds.conf.5 @@ -0,0 +1,290 @@ +.Dd May 2, 2017 +.Os FreeTDS 1.1.24 +.Dt FREETDS.CONF "FreeTDS 5" "FreeTDS Reference Manual" +. +.Sh NAME +.Nm freetds.conf +.Nd configuration file for FreeTDS +. +.Sh SYNOPSIS +The +.Pa freetds.conf +file describes Sybase and Microsoft database servers to the FreeTDS +library. It comprises sections headed by a servername, followed by a +list of connection properties denoted as name-value pairs. Defaults +are defined via a +.Bq global +section. This file supersedes the +.Pa interfaces +file that +Sybase defines for the same purpose, although the latter is still supported. +. +.Sh DESCRIPTION +A section begins with a servername \(em the name of the server \(em in +square brackets. The servername is chosen at the client's descretion. +(One exception: with Sybase ASA the servername must match the database +name to be used.) +.Pp +Sections contain properties, one per line, in the form +.Pp +.Dl name = value +.Pp +where +.Ar name +is the connection property to be described. Servernames and properties +are not case sensitive. Values are case-preserving i.e., copied literally. +Comments begin with either a semicolon +.Pq So ; Sc +or pound sign +.Pq So # Sc +and continue to end of line. Blank lines are ignored. Whitespace surrounding the +.So = Sc is ignored. +. +.Sh PROPERTIES +.Bl -tag -width "emulate little endian" -compact +. +.It client charset +encoding of client data; overrides locale(1) settings +.Bl -tag -width "default:" -compact +.It Domain: +iconv character set names +.It Default: +ISO-8859-1 +.El +. +.It connect timeout +seconds to wait for response from connect request +.Bl -tag -width "default:" -compact +.It Domain: +0 to MAX_INT +.It Default: +none +.El +. +.It debug flags +logging granularity +.Bl -tag -width "default:" -compact +.It Domain: +32-bit integer +.It Default: +0x4fff +.El +. +.It dump file +specifies location of a logfile and turns on logging +.Bl -tag -width "default:" -compact +.It Domain: +valid file name +.It Default: +none +.El +. +.It dump file append +log data appended to file instead of re-writing for each connection +.Bl -tag -width "default:" -compact +.It Domain: +yes/no +.It Default: +no +.El +. +.It emulate little endian +forces big endian machines to act as little endian to communicate with +Microsoft Servers +.Bl -tag -width "default:" -compact +.It Domain: +yes/no +.It Default: +no +.El +. +.It encryption +.Bl -tag -compact +.It Em off +disables encryption +.It Em request +use if available (default when tds version greater than 7.0) +.It Em required +allow encrypted connections only +.El +. +.It host +Name of the host the server is running on. +.Bl -tag -width "default:" -compact +.It Domain: +host name or IP address +.It Default: +SYBASE +.El +. +.It initial block size +maximum size of a protocol block +.Bl -tag -width "default:" -compact +.It Domain: +multiple of 512 +.It Default: +512 +.El +. +.It instance +name of Microsoft SQL Server instance to connect to (supersedes +.Em port ) +.Bl -tag -width "default:" -compact +.It Domain: +instance name +.It Default: +none +.El +. +.It port +port number that the server is listening to +.Bl -tag -width "default:" -compact +.It Domain: +any valid port +.It Default: +TDS 5.0, 5000; TDS 7.0 and up, 1433 +.El +. +.It tds version +TDS protocol version to use +.Bl -tag -width "default:" -compact +.It Domain: +4.2, 5.0, 7.0, 7.1, 7.2 +.It Default: +.Fl -with-tdsver +value (5.0 if unspecified) +.El +. +.It text size +default value of TEXTSIZE, in bytes +.Bl -tag -width "default:" -compact +.It Domain: +0 to 4,294,967,295 +.It Default: +4,294,967,295 +.El +. +.It timeout +seconds to wait for response to a query +.Bl -tag -width "default:" -compact +.It Domain: +0 to MAX_INT +.It Default: +none (wait forever) +.El +. +.El +.Pp +Do not define both +.Fa port +and +.Fa instance Ns +\&. One implies the other. + + +.Pp +Boolean property values may be denoted as on/off, true/false, or 1/0. +. +.Ss DEBUG FLAGS +The log's granularity can be controlled with the +.Em debug flags +property. +.Bl -column -offset indent ".Sy 0x8000" ".Sy show source level info (source file and line)" +.It Sy Value Ta Sy Meaning +.It Li \ \ 0x02 severe error +.It Li \ \ 0x04 error +.It Li \ \ 0x08 warning +.It Li \ \ 0x10 network +.It Li \ \ 0x20 information level 1 +.It Li \ \ 0x40 information level 2 +.It Li \ \ 0x80 function trace and info +.It Li 0x1000 show pid +.It Li 0x2000 show time +.It Li 0x4000 show source level info (source file and line) +.It Li 0x8000 thread id (not implemented). +.El +. +.Sh NAMES AND LOCATIONS +The file is normally named +.Pa /etc/freetds.conf +or +.Pa ${HOME}/.freetds.conf . +That name can be overridden with the FREETDSCONF environment variable. +.Pp +FreeTDS will search conf files for a servername in the following order: +.Bl -enum -offset indent -compact +.It +a filename set programatically via dbsetifile() that is in .conf format +.It +a filename in the environment variable FREETDSCONF that is in .conf format +.It +.Pa ${HOME}/.freetds.conf +if extant +.It +.Pa ${prefix}/etc/freetds.conf +.El +.Pp +The search stops with the first file containing the servername. +.Pp +If no conf file is found, FreeTDS searches for +an +.Pa interfaces +file in the following order: +.Bl -enum -offset indent -compact +.It +a filename set programatically via dbsetifile() that is in +.Pa interfaces +format +.It +.Pa ${HOME}/.interfaces +.It +.Pa $SYBASE/interfaces +(where +.Ev $SYBASE is an environment variable) +.El +.Pp +If the requested servername is not found in any configuration file, the fallback +mechanism is: +.Bl -enum -offset indent -compact +.It +attempt to convert the name to an IP address with inet_addr(3), else +.It +attempt to convert the name to an IP address with gethostbyname(3), else +.It +attempt to look up the literal name +.Dq SYBASE +.El +. +.Sh ENVIRONMENT +.Bl -tag -width "TDSDUMPCONFIG" -compact +.It Ev FREETDSCONF +overrides name and location of the system-wide conf file +.It Ev TDSDUMP +overrides the name and location of the FreeTDS log file +.It Ev TDSDUMPCONFIG +specifies a name and location of a file that logs the search of +configuration files +.It Ev TDSHOST +overrides the host property +.It Ev TDSPORT +overrides the port property +.It Ev TDSQUERY +synonym for DSQUERY, the default servername +.It Ev TDSVER +overrides the version specified in the freetds.conf +.El +.Pp +The environment variables +.Ev TDSVER, Ev TDSDUMP, Ev TDSPORT, Ev TDSQUERY, and Ev TDSHOST +override values set by a .conf or +.Pa interfaces +file. +. +.Sh FILES +.Pa ${prefix}/etc/freetds.conf , ${HOME}/.freetds.conf +. +.Sh SEE ALSO +.%B FreeTDS User Guide +. +.Sh HISTORY +\.conf files first appeared with version 0.53 of FreeTDS. diff --git a/lib/sync_fgu_personal_data.rb b/lib/sync_fgu_personal_data.rb new file mode 100644 index 0000000..13c486e --- /dev/null +++ b/lib/sync_fgu_personal_data.rb @@ -0,0 +1,5 @@ +require "sync_fgu_personal_data/engine" + +module SyncNccuPersonalData + # Your code goes here... +end diff --git a/lib/sync_fgu_personal_data/engine.rb b/lib/sync_fgu_personal_data/engine.rb new file mode 100644 index 0000000..0640013 --- /dev/null +++ b/lib/sync_fgu_personal_data/engine.rb @@ -0,0 +1,4 @@ +module SyncNccuPersonalData + class Engine < ::Rails::Engine + end +end diff --git a/lib/sync_fgu_personal_data/version.rb b/lib/sync_fgu_personal_data/version.rb new file mode 100644 index 0000000..8878893 --- /dev/null +++ b/lib/sync_fgu_personal_data/version.rb @@ -0,0 +1,3 @@ +module SyncNccuPersonalData + VERSION = '0.1.1' +end diff --git a/lib/tasks/sync_fgu_personal_data_tasks.rake b/lib/tasks/sync_fgu_personal_data_tasks.rake new file mode 100644 index 0000000..985352c --- /dev/null +++ b/lib/tasks/sync_fgu_personal_data_tasks.rake @@ -0,0 +1,907 @@ +require "uri" +require "net/http" +module FguSyncPlugin + def self.init + @client = TinyTds::Client.new username: 'rulweb', password: 'Rul@0726', host: '192.168.164.12', port: 1433, tds_version: '7.0' + @client.execute("USE [Personnel]").to_a + @default_order_fields = {} + @default_order = 'ASC' # 原本同步庫是 'DESC' + @debug_sql_mode = false # true will print sql command + @debug_mode = true # true will print rss_id if it is new record + @test_mode = false + end + def self.close + @client.close + end + + def self.camelize(str) + str.split('_').map{|v| v.capitalize}.join(' ') + end + def self.fetch_key(data,key,role=nil,value_flag=false) + begin + attr_fields = (value_flag ? role.attribute_fields : data) + case key + when 'f_profession_list' + tmp_key = 'Research Expertise' + else + tmp_key = self.camelize(key) + end + tmp = attr_fields.select{|v| v.title_translations[:en].upcase.include?(tmp_key.upcase)}.first + value_flag ? data.where(:attribute_field_id => tmp.id).first : tmp + rescue => e + nil + end + end + + def self.sync_journal_papers(staff_id,mp) + + puts "*********************************************" + puts "Syncing journals for #{staff_id}" + data = self.get_journal_papers(staff_id) + I18n.locale = :zh_tw + if data.count > 0 + puts "Data found." + JournalPaper.where(:member_profile_id => mp.id, :rss2_id.nin => ([nil,''] + data.map{|dt| dt['journal_id']})).destroy_all + data.each_with_index do |dt, idx| + rss2id = dt["journal_id"] + + pd = Date.parse(dt["publication_date"]) rescue Date.today + paper_title = {"en" => dt["paper_title"],"zh_tw" => dt["paper_title"]} + journal_title = {"en" => dt["journal_title"],"zh_tw" => dt["journal_title"]} + from_to = dt["from_to"].split("-") + from_to[1] = "" if !from_to[1].present? + all_authors = [dt["author1"],dt["author2"],dt["author3"],dt["author4"]] + all_authors.delete("") + authors = {"en" => all_authors.join(", "), "zh_tw" => all_authors.join(", ")} + note = dt["department"] + " " + dt["country"] + " " + dt["note"] + + if !dt["paper_level"].empty? + level = JournalLevel.where(:title => dt["paper_level"]).first rescue nil + if level.nil? + level = JournalLevel.create(:key => "key_#{idx}", :title_translations => {"en" => dt["paper_level"], "zh_tw" => dt["paper_level"]}) + end + end + + if !dt["paper_type"].empty? + type = JournalPaperType.where(:title => dt["paper_type"]).first rescue nil + if type.nil? + type = JournalPaperType.create(:key => "key_#{idx}", :title_translations => {"en" => dt["paper_type"], "zh_tw" => dt["paper_type"]}) + end + end + + jp = JournalPaper.where(:rss2_id => rss2id).first rescue nil + jp_data = { + :publication_date => pd, :rss2_id => rss2id, :year => pd.strftime("%Y"), + :authors_translations => authors, :paper_title_translations => paper_title, + :journal_title_translations => journal_title, :vol_no => dt["vol_no"], :issue_no => dt["issue_no"], + :note => note, :form_to_start => from_to[0], :form_to_end => from_to[1] + } + if jp.nil? + jp = JournalPaper.new(jp_data) + puts "Saving new journal." + else + jp.update_attributes(jp_data) + puts "Updating journal #{jp.id}." + end + jp_mps = MemberProfile.where("tmp_name.zh_tw" => {"$in" => all_authors}).to_a + jp.member_profiles = jp_mps.size==0 ? [mp] : jp_mps + jp.journal_levels << level if !level.nil? + jp.journal_paper_type = type if !type.nil? + jp.save + end + else + puts "No data found." + end + puts "Sync complete for #{staff_id}" + puts "*********************************************" + end + + def self.sync_conference_papers(staff_id,mp) + puts "*********************************************" + puts "Syncing conference for #{staff_id}" + data = self.get_conference_papers(staff_id) + I18n.locale = :zh_tw + if data.count > 0 + puts "Data found." + WritingConference.where(:member_profile_id => mp.id, :rss2_id.nin => ([nil,''] + data.map{|dt| dt["conf_id"]})).destroy + data.each_with_index do |dt, idx| + rss2id = dt["conf_id"] + + start_date = Date.parse(dt["start_date"]) rescue Date.today + end_date = Date.parse(dt["end_date"]) rescue Date.today + paper_title = {"en" => dt["paper_title"],"zh_tw" => dt["paper_title"]} + conference_title = {"en" => dt["conference_name"],"zh_tw" => dt["conference_name"]} + authors = [dt["author1"],dt["author2"],dt["author3"],dt["author4"]] + authors.delete("") + authors = {"en" => authors.join(", "), "zh_tw" => authors.join(", ")} + note = dt["department"] + " " + dt["note"] + + cp = WritingConference.where(:rss2_id => rss2id).first rescue nil + cp_data = {:period_start_date => start_date, :period_end_date => end_date, :rss2_id => rss2id, :year => end_date.strftime("%Y"), :authors_translations => authors, :paper_title_translations => paper_title, :conference_title_translations => conference_title, :note => note, :location_translations => {"en" => dt["location"], "zh_tw" => dt["location"]}} + if cp.nil? + cp = WritingConference.new(cp_data) + puts "Saving new conference." + else + cp.update_attributes(cp_data) + puts "Updating conference #{cp.id}." + end + cp.member_profile = mp + cp.save + end + else + puts "No data found." + end + puts "Sync complete for #{staff_id}" + puts "*********************************************" + end + + # def self.sync_research_papers(staff_id,mp) + # data = self.get_research_papers(staff_id) + # puts "Starting Research Paper for staff #{staff_id}." + # if !data.nil? + # researches = data + # total = researches.count rescue 0 + # return if total == 0 + # Research.where(:rss2_id.nin => ([nil,''] + researches.map{|research| research["rss_id"]}),member_profile_id: mp.id).destroy + # researches.each_with_index do |research,index| + # if !research.blank? + # res = Research.where(:rss2_id => research["rss_id"]).first rescue nil + # if res.nil? + # res = Research.new(rss2_id: research["rss_id"]) + # puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%" + # puts "rss2_id: #{research["rss_id"]}" if @debug_mode + # else + # puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%" + # end + # res.publish_date = "#{research["publication_year"]}/#{research["publication_month"]}/01" + # res.url = research["url"] + # res.year = research["publication_year"] + # res.research_title_translations = research["title"] + # res.member_profile = mp + # res.save + # sleep 0.1 + # end + # end + # end + # puts "Research Paper for staff #{staff_id} completed." + # end + + def self.sync_books(staff_id,mp) + puts "*********************************************" + puts "Syncing book for #{staff_id}" + data = self.get_books(staff_id) + I18n.locale = :zh_tw + if data.count > 0 + puts "Data found." + Book.where(:member_profile_id => mp.id, :rss2_id.nin => ([nil,''] + data.map{|dt| dt["book_id"]})).destroy + data.each_with_index do |dt, idx| + rss2id = dt["book_id"] + + pd = Date.parse(dt["date_of_publication"]) rescue Date.today + book_title = {"en" => dt["book_title"],"zh_tw" => dt["book_title"]} + publisher = {"en" => dt["publisher"],"zh_tw" => dt["publisher"]} + authors = [dt["author1"],dt["author2"],dt["author3"],dt["author4"]] + authors.delete("") + authors = {"en" => authors.join(", "), "zh_tw" => authors.join(", ")} + note = dt["department"] + " " + dt["location"] + " " + dt["note"] + + if !dt["author_type"].empty? + authortype = BookAuthorType.where(:title => dt["author_type"]).first rescue nil + if authortype.nil? + authortype = BookAuthorType.create(:title_translations => {"en" => dt["author_type"], "zh_tw" => dt["author_type"]}) + end + end + + if !dt["book_type"].empty? + type = BookType.where(:title => dt["book_type"]).first rescue nil + if type.nil? + type = BookType.create(:title_translations => {"en" => dt["book_type"], "zh_tw" => dt["book_type"]}) + end + end + + book = Book.where(:rss2_id => rss2id).first rescue nil + book_data = {:publish_date => pd, :rss2_id => rss2id, :year => pd.strftime("%Y"), :authors_translations => authors, :publisher_translations => publisher, :book_title_translations => book_title, :isbn => dt["isbn"], :note => note, :language => dt["language"], :member_profile => mp} + if book.nil? + book = Book.new(book_data) + puts "Saving new book." + else + book.update_attributes(book_data) + puts "Updating book #{book.id}." + end + book.book_author_types << authortype if !authortype.nil? + book.book_type = type if !type.nil? + book.member_profile = mp + book.save + end + else + puts "No data found." + end + puts "Sync complete for #{staff_id}" + puts "*********************************************" + end + + def self.sync_diplomas(staff_id,mp) + puts "*********************************************" + puts "Syncing diplomas for #{staff_id}" + data = self.get_diplomas(staff_id) + I18n.locale = :zh_tw + if data.count > 0 + puts "Data found." + puts "Deleting old data" + Diploma.where(:member_profile_id => mp.id).destroy + data.each_with_index do |dt, idx| + start_date = Date.parse(dt["start_date"]) rescue Date.today + end_date = Date.parse(dt["end_date"]) rescue Date.today + school_name = {"en" => dt["school_name"], "zh_tw" => dt["school_name"]} + department = {"en" => dt["department"], "zh_tw" => dt["department"]} + degree = {"en" => dt["degree"], "zh_tw" => dt["degree"]} + Diploma.create(:start_date => start_date, :end_date => end_date, :school_name_translations => school_name, :department_translations => department, :degree_translations => degree, :member_profile => mp) + puts "Diploma created." + end + end + puts "Syncing diplomas for #{staff_id} complete." + puts "*********************************************" + end + + def self.sync_experiences(staff_id,mp) + puts "*********************************************" + puts "Syncing experiences for #{staff_id}" + data = self.get_experiences(staff_id) + I18n.locale = :zh_tw + if data.count > 0 + puts "Data found." + puts "Deleting old data" + Experience.where(:member_profile_id => mp.id).destroy + data.each_with_index do |dt, idx| + start_date = Date.parse(dt["start_date"]) rescue Date.today + end_date = Date.parse(dt["end_date"]) rescue Date.today + organization_title = {"en" => dt["organization_title"], "zh_tw" => dt["organization_title"]} + job_title = {"en" => dt["job_title"], "zh_tw" => dt["job_title"]} + if !dt["emp_type"].blank? + type = ExperienceType.where(:title => dt["emp_type"]).first rescue nil + if type.nil? + type = ExperienceType.create(:title_translations => {"en" => dt["emp_type"], "zh_tw" => dt["emp_type"]}) + end + end + exp = Experience.new(:start_date => start_date, :end_date => end_date, :organizationt_title_translations => organization_title, :job_title_translations => job_title, :member_profile => mp) + exp.experience_type = type if !type.nil? + exp.save + puts "Exp created." + end + end + puts "Syncing experiences for #{staff_id} complete." + puts "*********************************************" + end + + # def self.sync_projects(staff_id,mp) + # data = self.get_projects(staff_id) + # puts "Starting Projects for staff #{staff_id}." + # if !data.nil? + # projects = data + # total = projects.count rescue 0 + # return if total == 0 + # Project.where(:rss2_id.nin => ([nil,''] + projects.map{|project| project["rss_id"]}),member_profile_id: mp.id).destroy + # projects.each_with_index do |project,index| + # next if project.blank? + # proj = Project.where(:rss2_id => project["rss_id"]).first rescue nil + # pt_title = [project["category"]["zh_tw"],project["category"]["en"]].compact rescue [] + # pt = ProjectType.where(:title.in => pt_title).first rescue nil + # if pt.nil? && pt_title.count > 0 + # pt = ProjectType.new + # pt.title_translations = project["category"] + # pt.save + # end + # if proj.nil? + # proj = Project.new(rss2_id: project["rss_id"]) + # puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%" + # puts "rss2_id: #{project["rss_id"]}" if @debug_mode + # else + # puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%" + # end + # proj.period_start_date = project["start_date"] + # proj.period_end_date = project["end_date"] + # proj.url = project["url"] + # proj.year = project["year"] + # proj.project_title_translations = project["title"] + # proj.job_title_translations = project["job"] + # proj.participator_translations = project["participator"] + # proj.unit_translations = project["unit"] + # proj.member_profile = mp + # proj.project_type = pt + # proj.save + # sleep 0.1 + # end + # end + # puts "Projects for staff #{staff_id} completed." + # end + + # def self.sync_honors(staff_id,mp) + # data = self.get_honors(staff_id) + # puts "Starting Honors for staff #{staff_id}." + # if !data.nil? + # honors = data + # total = honors.count rescue 0 + # return if total == 0 + # Honor.where(:rss2_id.nin => ([nil,''] + honors.map{|honor| honor["rss_id"]}),member_profile_id: mp.id).destroy + # honors.each_with_index do |honor,index| + # next if honor.blank? + # hon = Honor.where(:rss2_id => honor["rss_id"]).first rescue nil + # ht_title = [honor["category"]["zh_tw"],honor["category"]["en"]].compact rescue [] + # ht = HonorType.where(:title.in => ht_title).first rescue nil + # if ht.nil? && ht_title.count > 0 + # ht = HonorType.new + # ht.title_translations = honor["category"] + # ht.save + # end + # if hon.nil? + # hon = Honor.new(rss2_id: honor["rss_id"]) + # puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%" + # puts "rss2_id: #{honor["rss_id"]}" if @debug_mode + # else + # puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%" + # end + # hon.award_name_translations = honor["title"] + # hon.awarding_unit_translations = honor["unit"] + # hon.year = honor["year"] + # hon.honor_type = ht + # hon.member_profile = mp + # hon.save + # sleep 0.1 + # end + # end + # puts "Honors for staff #{staff_id} completed." + # end + + def self.sync_activities(staff_id,mp) + puts "*********************************************" + puts "Syncing activities for #{staff_id}" + data = self.get_activities(staff_id) + I18n.locale = :zh_tw + if data.count > 0 + puts "Data found." + puts "Deleting old data" + Experience.where(:member_profile_id => mp.id).destroy + data.each_with_index do |dt, idx| + start_date = Date.parse(dt["start_date"]) rescue Date.today + end_date = Date.parse(dt["end_date"]) rescue Date.today + organization_title = {"en" => dt["organization_title"], "zh_tw" => dt["organization_title"]} + job_title = {"en" => dt["job_title"], "zh_tw" => dt["job_title"]} + if !dt["emp_type"].blank? + type = ExperienceType.where(:title => dt["emp_type"]).first rescue nil + if type.nil? + type = ExperienceType.create(:title_translations => {"en" => dt["emp_type"], "zh_tw" => dt["emp_type"]}) + end + end + exp = Experience.new(:start_date => start_date, :end_date => end_date, :organizationt_title_translations => organization_title, :job_title_translations => job_title, :member_profile => mp) + exp.experience_type = type if !type.nil? + exp.save + puts "Exp created." + end + end + puts "Syncing experiences for #{staff_id} complete." + puts "*********************************************" + end + + def self.sync_fgu_profile(staff_id, mp) + puts "*********************************************" + puts "Syncing profile for #{staff_id}" + params_to_send = {"plugin" => "profile", "id" => staff_id} + teacher_data = self.get_teacher_data(staff_id) + I18n.locale = :zh_tw + if teacher_data.present? + all_role_ids = mp.role_ids + all_role_status_ids = mp.role_status_ids + + case teacher_data["role"] + when "職員" + role = Role.where(:key => "staff").first + when "教師" + role = Role.where(:key => "teacher").first + when nil + role = Role.where(:key => "teacher").first + end + if !role.nil? + puts "Assigning role #{role.key}" + case teacher_data["job_status"] + when "專任" + role_status = role.role_statuses.select{|v| v[:title][:en].upcase == "Full-Time".upcase}.first + when "兼任" + role_status = role.role_statuses.select{|v| v[:title][:en].upcase == "Part-Time".upcase}.first + else + role_status = nil + end + if role.key == "teacher" + puts teacher_data + af = fetch_key(role.attribute_fields,"job_title") + if !af.nil? + options = af.option_list.values + job_title = options.index(options.find{|x| x["zh_tw"] == teacher_data["job_title"]}) + puts job_title.to_s + if job_title.blank? + job_title = af.option_list.keys.last.to_i + 1 + af.option_list[job_title] = {"en" => teacher_data["job_title"], "zh_tw" => teacher_data["job_title"]} + puts af.option_list.to_s + af.save + else + job_title = af.option_list.keys[job_title].to_i + end + end + #saving job title + av = fetch_key(mp.attribute_values,"job_title",role,true) + if av.nil? + field = fetch_key(role.attribute_fields,"job_title") + if !field.nil? + av = AttributeValue.new(:attribute_field_id => field.id, :member_profile_id => mp.id, :key => "job_title") + end + end + if !av.nil? + av.value= job_title + av.save + end + #saving profession list + av = fetch_key(mp.attribute_values,"f_profession_list",role,true) + if av.nil? + field = fetch_key(role.attribute_fields,"f_profession_list") + if !field.nil? + av = AttributeValue.new(:attribute_field_id => field.id, :member_profile_id => mp.id, :key => "f_profession_list") + end + end + if !av.nil? + av.value= {:en => teacher_data["profession_list"], :zh_tw => teacher_data["profession_list"]} + av.save + end + #saving courses + av = fetch_key(mp.attribute_values,"current_course",role,true) + if av.nil? + field = fetch_key(role.attribute_fields,"current_course") + if !field.nil? + av = AttributeValue.new(:attribute_field_id => field.id, :member_profile_id => mp.id) + end + end + if !av.nil? + course_html = "" + if teacher_data["courses"].blank? + av.value= {:en => course_html, :zh_tw => course_html} + av.save + end + teacher_data["courses"].each do |course| + course_url = course["course_url"] + course_url.gsub!(/http:\/\/(.*\.fgu\.edu\.tw)/, 'https://\1') + course_html += "#{course["course_id"]} #{course["course_name"]}
" + av.value= {:en => course_html, :zh_tw => course_html} + av.save + end + end + end + end + mp.email = teacher_data["email"] + mp.office_tel = teacher_data["office_tel"] + mp.address_translations = {"en" => teacher_data["address"], "zh_tw" => teacher_data["address"]} + mp.first_name_translations = {"en" => teacher_data["name"], "zh_tw" => teacher_data["name"]} + if (!role.nil? && !all_role_ids.include?(role.id)) + all_role_ids << role.id + end + if (!role_status.nil? && !all_role_status_ids.include?(role_status.id)) + all_role_status_ids << role_status.id + end + + puts [staff_id,all_role_ids.inspect] + if !all_role_ids.blank? + mp.role_ids = all_role_ids + all_role_ids.each do |r_id| + rr = Role.find(r_id) + if !rr.member_profile_ids.include?(mp.id) + rr.member_profile_ids << mp.id + rr.save + end + end + puts 'modify roles' + end + if !all_role_status_ids.blank? + mp.role_status_ids = all_role_status_ids + all_role_status_ids.each do |r_id| + rr = RoleStatus.find(r_id) + if !rr.member_profile_ids.include?(mp.id) + rr.member_profile_ids << mp.id + rr.save + end + end + puts 'modify role_statuses' + end + mp.save + end + puts "Syncing profile for #{staff_id} complete." + puts "*********************************************" + end + + def self.get_sql(table_name, filter_params={}, order_fields=nil) + key_mapping = { + 'v_rul_research_01' => { + "紀錄編號" => "journal_id", + "結束日" => "publication_date", + "填報系所" => "department", + "合著者1姓名" => "author1", + "合著者2姓名" => "author2", + "合著者3姓名" => "author3", + "合著者4以上" => "author4", + "期刊_學報之論文名稱" => "paper_title", + "期刊_學報名稱" => "journal_title", + "期刊_學報卷數" => "vol_no", + "期刊_學報期數" => "issue_no", + "論文發表型式" => "paper_type", + "國別地區代號" => "country", + "期刊_學報頁碼" => "from_to", + "期刊資料庫" => "paper_level", + "備註" => "note" + }, + 'v_rul_research_02' => { + "紀錄編號" => "conf_id", + "開始日" => "start_date", + "結束日" => "end_date", + "填報系所" => "department", + "合著者1姓名" => "author1", + "合著者2姓名" => "author2", + "合著者3姓名" => "author3", + "合著者4以上" => "author4", + "論文名稱" => "paper_title", + "會議名稱" => "conference_name", + "出版_發表地區" => "location", + "備註" => "note" + }, + 'v_rul_research_03' => { + "紀錄編號" => "book_id", + "結束日" => "date_of_publication", + "填報部門" => "department", + "作者類型" => "author_type", + "專書類別" => "book_type", + "合著者1姓名" => "author1", + "合著者2姓名" => "author2", + "合著者3姓名" => "author3", + "合著者4以上" => "author4", + "專書名稱" => "book_title", + "使用語文" => "language", + "出版社_發表處所名稱" => "publisher", + "專書ISBN編號或無" => "isbn", + "出版_發表地區" => "location", + "備註" => "note" + }, + 'vrul_sch' => { + "f_start" => "start_date", + "f_end" => "end_date", + "f_school" => "school_name", + "f_dep" => "department", + "f_degree" => "degree" + }, + 'vrul_exp' => { + "f_start" => "start_date", + "f_end" => "end_date", + "f_comp" => "organization_title", + "f_empname" => "job_title" + }, + 'vrul_inemp' => { + "f_start" => "start_date", + "f_end" => "end_date", + "f_unit" => "organization_title", + "f_empname" => "job_title", + "f_emptype" => "emp_type" + }, + 'dbo.v_rul_research_create' => { + "紀錄編號" => "activity_id", + "首次發表時間" => "created_at", + "更新日期" => "updated_at", + "展演舉行起日" => "activity_start_date", + "展演舉行迄日" => "activity_end_date", + "展演活動名稱" => "activity_name", + "展演作品名稱" => "", + "填報系所" => "unit", + "填報部門" => "department", + "所有作者群" => "authors", + "作者類型" => "author_type", + "專書類別" => "book_type", + "合著者1姓名" => "author1", + "合著者2姓名" => "author2", + "合著者3姓名" => "author3", + "合著者4以上" => "author4", + "專書名稱" => "book_title", + "使用語文" => "language", + "出版社_發表處所名稱" => "publisher", + "專書ISBN編號或無" => "isbn", + "出版_發表地區" => "location", + "備註" => "note" + }, + "作者別"=>"主要創作者、改編者", "所有作者群"=>"", "簡介"=>"母親節、父親節、重陽敬老節、中秋和新年...任何假期都是陪伴父母家 人的好時節。\r\n圖書館3樓主題展覽區本期展出:「帶著爸媽去旅行」成果特展,歡迎全校師生蒞臨賞析。\r\nhttps://libweb.fgu.edu.tw/zh_tw/News/-展覽-帶著爸媽去旅行-成果特展-歡迎全校師生蒞臨賞析-41046202", "展演主辦單位全銜"=>"未來與樂活產業學系", "展演協辦單位全銜"=>"", "展演活動辦理國別/地區"=>"台灣", "是否為巡演"=>"否", "巡演明細"=>"", "獎名"=>"", "頒獎單位"=>""} + 'vrul_base' => { + "f_email" => "email", + "f_phone" => "office_tel", + "f_office" => "address", + "f_name" => "name", + "f_teachwork" => "role", + "f_empname" => "job_title", + "f_emptype" => "job_status" + }, + 'vrul_profession' => { + 'f_profession_list' => 'profession_list' + }, + 'vrul_nowteachcour' => { + "f_ayear" => "year", + "f_asem" => "sem", + "f_cour_id" => "course_id", + "f_cour_name" => "course_name", + "f_cour_url" => "course_url" + } + } + if key_mapping.has_key?(table_name) && key_mapping[table_name].present? + tmp = key_mapping[table_name] + mapping_text = tmp.map{|k,v| "#{k} as #{v}"}.join(', ') + else + mapping_text = '*' + end + if order_fields.nil? + sql = "SELECT #{mapping_text} FROM [#{table_name}]" + field_prefix = "" + else # rss_id is the row index + if order_fields === false + sql = "SELECT #{mapping_text} FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) " + else + sql = "SELECT #{mapping_text} FROM (SELECT ROW_NUMBER() OVER(ORDER BY " + sql += order_fields.map{|k,v| "#{k} #{v}"}.join(', ') + sql += ") " + end + sql += "AS rss_id,* FROM [#{table_name}]) r" + field_prefix = "r." + end + if filter_params.present? + sql += " WHERE " + filter_params.each_with_index do |(k,v), i| + if i != 0 + sql += " AND " + end + if v.class == Array + if v.count > 0 + sql += "(" + v.each_with_index do |vv, i| + if i != 0 + sql += " OR " + end + if vv.class == String + sql += "#{field_prefix}#{k} = \"#{vv}\"" + else + sql += "#{field_prefix}#{k} = #{vv}" + end + end + sql += ")" + end + else + if v.class == String + sql += "#{field_prefix}#{k} = \"#{v}\"" + else + sql += "#{field_prefix}#{k} = #{v}" + end + end + end + end + if @debug_sql_mode + puts sql + end + sql + end + + def self.query_db(table_name, filter_params={}) + order_fields = {} # true => order by first column with desc order + rss_id_offsets = {} + # rss_id_offsets = { + # 'rsspublish' => 1073443 + # } + extra_condition = { + 'rss_pastapos_a' => { + 'dsp_flg' => 1, + 'inst_cod' => ['309210000Q','A09520000Q'] + }, + 'rss_pastapos_b' => { + 'dsp_flg' => 1 + }, + 'rss_paedu_vw' => { + 'dsp_flg' => 1 + } + } + order_field = order_fields[table_name] + if order_field === true + order_field = @default_order_fields[table_name] + if order_field.nil? + order_field = {@client.execute("SELECT name FROM sys.columns WHERE object_id = OBJECT_ID('#{table_name}')").to_a.map{|h| h['name']}.first => @default_order} + @default_order_fields[table_name] = order_field + end + end + if @test_mode + filter_params = {} + end + #'origin field name' => 'new field name' + extra_key_mapping = {} + sql = self.get_sql(table_name, filter_params.merge(extra_condition[table_name].to_h), order_field) + result = @client.execute(sql).to_a + if extra_key_mapping.has_key?(table_name) && extra_key_mapping[table_name].present? + tmp = extra_key_mapping[table_name] + rss_id_offset = rss_id_offsets[table_name] + result.each do |h| + if rss_id_offset && h['rss_id'] + h['rss_id'] = h['rss_id'] + rss_id_offset + end + h.each do |k,v| + if v.class == String + h[k] = v.strip + end + end + tmp.each do |k,v| + if k.class != String + tmp_value = k + else + tmp_value = h[k] + end + if v.class == Array + include_key = false + v.each do |vv| + if vv.include?('.') + vv_k, locale = vv.split('.') + include_key = true if vv_k == k + unless h.has_key?(vv_k) + h[vv_k] = {} + end + h[vv_k][locale] = tmp_value + else + include_key = true if vv == k + h[vv] = tmp_value + end + end + unless include_key + h.delete(k) + end + else + if v.include?('.') + v_k, locale = v.split('.') + unless h.has_key?(v_k) + h[v_k] = {} + end + h[v_k][locale] = tmp_value + else + if v.ends_with?('_date') && tmp_value.present? && tmp_value.scan(/\d/).count == 6 + if tmp_value.length == 6 #年月,ex: 202005 + tmp_value += "01" + else #有分隔符號 + tmp_value = "#{tmp_value.gsub(/\/|-|,/, '-')}-01" + end + end + h[v] = tmp_value + end + h.delete(k) + end + end + end + else + result.each do |h| + if rss_id_offset && h['rss_id'] + h['rss_id'] = h['rss_id'] + rss_id_offset + end + h.each do |k,v| + if v.class == String + h[k] = v.strip + end + end + end + end + if @test_mode && table_name.start_with?('rss') + print result[0] + puts nil + raise 'error' + end + result + end + + def self.get_journal_papers(staff_id) + result = query_db('v_rul_research_01', {"填報者公號"=> "F#{staff_id}"}) + end + + def self.get_conference_papers(staff_id) + result = query_db('v_rul_research_02', {"填報者公號"=> "F#{staff_id}"}) + end + + def self.get_research_papers(staff_id) + result = query_db('rsspublish', {:sta_num=>staff_id, :publ_tpe=>'05'}) + end + + def self.get_books(staff_id) + result = query_db('v_rul_research_03', {"填報者公號"=> "F#{staff_id}"}) + end + + def self.get_diplomas(staff_id) + result = query_db('vrul_sch', {:f_uni_id=> "F#{staff_id}"}) + end + + def self.get_experiences(staff_id) + data = query_db('vrul_exp', {:f_uni_id=> "F#{staff_id}"}) + data1 = query_db('vrul_inemp', {:f_uni_id=> "F#{staff_id}"}) + data + data1 + end + + def self.get_activities(staff_id) + result = query_db('dbo.v_rul_research_create', {:f_uni_id=> "F#{staff_id}"}) + end + # def self.get_projects(staff_id) + # # url field not exist in original nccu database + # result = query_db('rssproject', {:sta_num=>staff_id}) + # category_mapping = { + # 'Y' => { + # 'zh_tw' => '科技部', + # 'en' => 'MOST Projects' + # }, + # 'N' => { + # 'zh_tw' => '非科技部', + # 'en' => 'Other Projects' + # } + # } + # result.each do |h| + # h['category'] = category_mapping[h['category']] + # end + # result + # end + + # def self.get_honors(staff_id) + # result = query_db('rssreward', {:sta_num=>staff_id}) + # category_mapping = { + # '1' => { + # 'zh_tw' => '校內', + # 'en' => 'Inside School' + # }, + # '2' => { + # 'zh_tw' => '校外', + # 'en' => 'Outside School' + # }, + # '3' => { + # 'zh_tw' => '事蹟', + # 'en' => 'Deeds' + # } + # } + # result.each do |h| + # h['category'] = category_mapping[h['category']] + # end + # result + # end + + def self.get_teacher_data(staff_id) + data = query_db('vrul_base', {:f_uni_id=> "F#{staff_id}"}) + data1 = query_db('vrul_profession', {:f_uni_id=> "F#{staff_id}"}) + tmp = {} + tmp.merge!(data[0].to_h).merge!(data1[0].to_h) + tmp['courses'] = query_db('vrul_nowteachcour', {:f_uni_id=> "F#{staff_id}"}) + tmp + end + +end +namespace :sync_nccu_personal_plugins do + task :sync,[:uid] => :environment do |task,args| + #require "#{ENV['PWD']}/app/models/member_profile" #it will cause circular dependency + FguSyncPlugin.init + if args.uid.present? + mps = MemberProfile.where(:uid=>args.uid).to_a + else + mps = MemberProfile.all.to_a + end + today = Date.today + mps.each do |mp| + staff_id = mp.sid rescue nil + if (!staff_id.blank? rescue false) + FguSyncPlugin.sync_journal_papers(staff_id,mp) + FguSyncPlugin.sync_conference_papers(staff_id,mp) + FguSyncPlugin.sync_books(staff_id,mp) + FguSyncPlugin.sync_diplomas(staff_id,mp) + FguSyncPlugin.sync_experiences(staff_id,mp) + FguSyncPlugin.sync_activities(staff_id, mp) + FguSyncPlugin.sync_fgu_profile(staff_id, mp) + # FguSyncPlugin.sync_research_papers(staff_id,mp) + # FguSyncPlugin.sync_projects(staff_id,mp) + # FguSyncPlugin.sync_honors(staff_id,mp) + + end + end + FguSyncPlugin.close + end +end \ No newline at end of file diff --git a/sync_fgu_personal_data.gemspec b/sync_fgu_personal_data.gemspec new file mode 100644 index 0000000..a29a385 --- /dev/null +++ b/sync_fgu_personal_data.gemspec @@ -0,0 +1,83 @@ +$:.push File.expand_path("lib", __dir__) + +# Maintain your gem's version: +require "sync_fgu_personal_data/version" +bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install' +if bundle_update_flag + env_pwd = ENV['PWD'] + begin + require ::File.expand_path('app/helpers/bundler_helper.rb', env_pwd) + extend BundlerHelper + rescue LoadError + def bundler_with_clean_env(&block) + if block_given? + if Bundler.respond_to?(:with_unbundled_env) + Bundler.with_unbundled_env(&block) + else + Bundler.with_clean_env(&block) + end + end + end + end + home_path = ENV['HOME'] + if Dir.glob("#{ENV["GEM_HOME"]}/gems/tiny_tds-*").count == 0 || Dir.glob("#{ENV["GEM_HOME"]}/extensions/*/*/tiny_tds-*/tiny_tds/*").count == 0 + app_path = File.expand_path(__dir__) + if home_path.nil? || home_path == "" + home_path = app_path + else + require "fileutils" + FileUtils.rm_r("#{home_path}/freetds-1.1.24_build", :force => true) + FileUtils.cp_r("#{app_path}/freetds-1.1.24_build/", "#{home_path}/.") + end + FileUtils.chmod_R( 0755, Dir.glob("#{home_path}/freetds-1.1.24_build/bin/*")) + puts "Installing tiny_tds gem ..." + bundler_with_clean_env{ system("gem install tiny_tds -- '--with-freetds-dir=#{home_path}/freetds-1.1.24_build'") } + end + crontab_sync = `crontab -l|grep 'bundle exec rake sync_nccu_personal_plugins:sync'|grep #{ENV['PWD']}` + sync_cron="0 0 * * * /bin/bash -l -c 'cd #{ENV['PWD']} && bundle exec rake sync_nccu_personal_plugins:sync > /dev/null'" + crontab_sync_jobs = crontab_sync.split("\n") + if crontab_sync_jobs.count == 0 + %x(CRON="#{sync_cron}" && (crontab -l; echo "$CRON" ) | crontab -) + elsif crontab_sync_jobs.count > 1 + crontab_jobs = `crontab -l` + crontab_sync_jobs[1..-1].each do |s| + crontab_jobs = crontab_jobs.sub(s,"") + end + %x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -) + elsif crontab_sync_jobs[0][0...3] == "0 5" #replace old cronjob settings + crontab_jobs = `crontab -l` + crontab_jobs = crontab_jobs.sub(crontab_sync_jobs[0],sync_cron) + %x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -) + elsif crontab_sync_jobs[0].include?("-23/12") #replace 12 hours to 24 hours + crontab_jobs = `crontab -l` + crontab_jobs = crontab_jobs.sub(crontab_sync_jobs[0],crontab_sync_jobs[0].sub("-23/12","")) + %x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -) + elsif crontab_sync_jobs[0].include?("*/12") #replace 12 hours to 24 hours + crontab_jobs = `crontab -l` + crontab_jobs = crontab_jobs.sub(crontab_sync_jobs[0],crontab_sync_jobs[0].sub("*/12","0")) + %x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -) + end +end +# Describe your gem and declare its dependencies: +Gem::Specification.new do |spec| + spec.name = "sync_fgu_personal_data" + spec.version = SyncNccuPersonalData::VERSION + spec.authors = ["Bohung Chiu"] + spec.email = ["bohung@rulingcom.com"] + spec.homepage = "https://w3.rulingcom.com/" + spec.summary = "Sync Asia University's personal data for teachers" + spec.description = "Sync Asia University's personal data for teachers" + spec.license = "MIT" + + # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' + # to allow pushing to a single host or delete this section to allow pushing to any host. + if spec.respond_to?(:metadata) + spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" + else + raise "RubyGems 2.0 or newer is required to protect against " \ + "public gem pushes." + end + + spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] + spec.add_dependency "tiny_tds" +end diff --git a/test/dummy/.ruby-version b/test/dummy/.ruby-version new file mode 100644 index 0000000..fe16b34 --- /dev/null +++ b/test/dummy/.ruby-version @@ -0,0 +1 @@ +2.5.4 diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/test/dummy/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/test/dummy/app/assets/config/manifest.js b/test/dummy/app/assets/config/manifest.js new file mode 100644 index 0000000..5918193 --- /dev/null +++ b/test/dummy/app/assets/config/manifest.js @@ -0,0 +1,2 @@ +//= link_tree ../images +//= link_directory ../stylesheets .css diff --git a/test/dummy/app/assets/images/.keep b/test/dummy/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css new file mode 100644 index 0000000..0ebd7fe --- /dev/null +++ b/test/dummy/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test/dummy/app/channels/application_cable/channel.rb b/test/dummy/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/test/dummy/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/test/dummy/app/channels/application_cable/connection.rb b/test/dummy/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/test/dummy/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/test/dummy/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/test/dummy/app/controllers/concerns/.keep b/test/dummy/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/dummy/app/javascript/packs/application.js b/test/dummy/app/javascript/packs/application.js new file mode 100644 index 0000000..67ce467 --- /dev/null +++ b/test/dummy/app/javascript/packs/application.js @@ -0,0 +1,15 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require_tree . diff --git a/test/dummy/app/jobs/application_job.rb b/test/dummy/app/jobs/application_job.rb new file mode 100644 index 0000000..d394c3d --- /dev/null +++ b/test/dummy/app/jobs/application_job.rb @@ -0,0 +1,7 @@ +class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError +end diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/test/dummy/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/test/dummy/app/models/application_record.rb b/test/dummy/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/test/dummy/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/test/dummy/app/models/concerns/.keep b/test/dummy/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb new file mode 100644 index 0000000..24307d3 --- /dev/null +++ b/test/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Dummy + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all' %> + + + + <%= yield %> + + diff --git a/test/dummy/app/views/layouts/mailer.html.erb b/test/dummy/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/test/dummy/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/test/dummy/app/views/layouts/mailer.text.erb b/test/dummy/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/test/dummy/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails new file mode 100644 index 0000000..0739660 --- /dev/null +++ b/test/dummy/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake new file mode 100644 index 0000000..1724048 --- /dev/null +++ b/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup new file mode 100644 index 0000000..0e39e8c --- /dev/null +++ b/test/dummy/bin/setup @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +require 'fileutils' + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to setup or update your development environment automatically. + # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:prepare' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/test/dummy/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb new file mode 100644 index 0000000..af5196e --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +Bundler.require(*Rails.groups) +require "sync_fgu_personal_data" + +module Dummy + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 6.0 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb new file mode 100644 index 0000000..c9aef85 --- /dev/null +++ b/test/dummy/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__) diff --git a/test/dummy/config/cable.yml b/test/dummy/config/cable.yml new file mode 100644 index 0000000..98367f8 --- /dev/null +++ b/test/dummy/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: dummy_production diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml new file mode 100644 index 0000000..4a8a1b2 --- /dev/null +++ b/test/dummy/config/database.yml @@ -0,0 +1,25 @@ +# SQLite. Versions 3.8.0 and up are supported. +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/test/dummy/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb new file mode 100644 index 0000000..7e49c00 --- /dev/null +++ b/test/dummy/config/environments/development.rb @@ -0,0 +1,62 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb new file mode 100644 index 0000000..b7ad81b --- /dev/null +++ b/test/dummy/config/environments/production.rb @@ -0,0 +1,112 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "dummy_production" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session +end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..de83a77 --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,48 @@ +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + config.cache_classes = false + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/initializers/application_controller_renderer.rb b/test/dummy/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/test/dummy/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb new file mode 100644 index 0000000..fe48fc3 --- /dev/null +++ b/test/dummy/config/initializers/assets.rb @@ -0,0 +1,12 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test/dummy/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test/dummy/config/initializers/content_security_policy.rb b/test/dummy/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..41c4301 --- /dev/null +++ b/test/dummy/config/initializers/content_security_policy.rb @@ -0,0 +1,28 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Set the nonce only to specific directives +# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/test/dummy/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/test/dummy/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test/dummy/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/test/dummy/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml new file mode 100644 index 0000000..cf9b342 --- /dev/null +++ b/test/dummy/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at https://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test/dummy/config/puma.rb b/test/dummy/config/puma.rb new file mode 100644 index 0000000..5ed4437 --- /dev/null +++ b/test/dummy/config/puma.rb @@ -0,0 +1,38 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked web server processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb new file mode 100644 index 0000000..c06383a --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html +end diff --git a/test/dummy/config/spring.rb b/test/dummy/config/spring.rb new file mode 100644 index 0000000..db5bf13 --- /dev/null +++ b/test/dummy/config/spring.rb @@ -0,0 +1,6 @@ +Spring.watch( + ".ruby-version", + ".rbenv-vars", + "tmp/restart.txt", + "tmp/caching-dev.txt" +) diff --git a/test/dummy/config/storage.yml b/test/dummy/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/test/dummy/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/log/.keep b/test/dummy/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/test/dummy/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +

+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/test/dummy/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/test/dummy/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/dummy/public/apple-touch-icon-precomposed.png b/test/dummy/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/apple-touch-icon.png b/test/dummy/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/navigation_test.rb b/test/integration/navigation_test.rb new file mode 100644 index 0000000..29e59d8 --- /dev/null +++ b/test/integration/navigation_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class NavigationTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/sync_fgu_personal_data_test.rb b/test/sync_fgu_personal_data_test.rb new file mode 100644 index 0000000..b6c9424 --- /dev/null +++ b/test/sync_fgu_personal_data_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SyncNccuPersonalData::Test < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, SyncNccuPersonalData + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..d2af136 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,18 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require_relative "../test/dummy/config/environment" +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] +require "rails/test_help" + +# Filter out the backtrace from minitest while preserving the one from other libraries. +Minitest.backtrace_filter = Minitest::BacktraceFilter.new + + +# Load fixtures from the engine +if ActiveSupport::TestCase.respond_to?(:fixture_path=) + ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__) + ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path + ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files" + ActiveSupport::TestCase.fixtures :all +end