From: dtb@otto (David Bath)
Newsgroups: comp.databases.oracle
Subject: Re: Using char pointers with Pro*C
Date: 17 Nov 92 06:13:57 GMT
Organization: RMIT Computer Centre
NNTP-Posting-Host: otto.bf.rmit.oz.au

ALANB@OWGVM0.VNET.IBM.COM (Alan Beal) writes:

>We are trying to use char * in SELECT INTO statements with Pro*C
>(version 7.0.9) on an RS/6000.  We are getting segmentation faults
>when we try to SELECT INTO more than one char *.  Are there any
>gotchas that one must watch out for?  Also, the columns being
>SELECTed are VARCHAR2 NOT NULL.  Does anyone have any examples
>that work?  Is there a general rule of thumb on using CHAR arrays
>with VARCHAR2 columns?  Thanks.

>Alan Beal         alanb@owgvm0.vnet.ibm.com
>                  (607)751-2026

This is the only safe way I have found of getting values into pointers.
We can skip the SQL here because getting a forms field is easier.
	EXEC SQL BEGIN DECLARE SECTION;
	static	varchar	*p;		/* Pointer to target data location */
	static	char	*f;		/* Pointer to field name as a varchar */
	EXEC SQL END DECLARE SECTION;
	/*
	*	The way the precompiler works is that when it gets a varchar
	*	pointer as a target, it checks the current length to figure out
	*	a "safe" length, but of course, if the existing value has zero
	*	length you are stuffed.  We cover for this by "filling in" the
	*	required maximum length first
	*/
	...
	p->len = len;

	/*	Do the actual work */
	EXEC IAF GET :f INTO :p;

You could then use my varchar functions to put the result in a string.

Alternatively, fill a string up to desired length (but then you have to deal
with a xxxx-load of spaces!

Here is the current code - but mind - I have not yet written a man page.
This has altered since the last release ; see LICENCE and README
It is System V ANSI C, you will not need Pro*C to build this library,
but as you are on RS/6000 you'll have to port.  Let me know how this
goes.
David T. Bath
dtb@otto.bf.rmit.oz.au
-------------- CUT HERE -------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  FileList FileMap LICENCE MANIFEST Makefile README sv_cat.c
#   sv_cpy.c sv_dup.c sv_ncat.c sv_ncpy.c sv_sub.c v_alloc.c v_cmp.c
#   v_crspn.c v_cspn.c v_data.c v_len.c v_ncmp.c v_rspn.c v_set.c
#   v_slen.c v_spn.c v_vers.c vch.h vs_cat.c vs_cpy.c vs_dup.c
#   vs_ncat.c vs_ncpy.c vv_cat.c vv_cpy.c vv_dup.c vv_ncat.c vv_ncpy.c
#   vv_rtrim.c
# Wrapped by dtb@cheops on Tue Nov 17 16:56:57 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'FileList' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FileList'\"
else
echo shar: Extracting \"'FileList'\" \(323 characters\)
sed "s/^X//" >'FileList' <<'END_OF_FILE'
XFileList
XFileMap
XLICENCE
XMANIFEST
XMakefile
XREADME
Xsv_cat.c
Xsv_cpy.c
Xsv_dup.c
Xsv_ncat.c
Xsv_ncpy.c
Xsv_sub.c
Xv_alloc.c
Xv_cmp.c
Xv_crspn.c
Xv_cspn.c
Xv_data.c
Xv_len.c
Xv_ncmp.c
Xv_rspn.c
Xv_set.c
Xv_slen.c
Xv_spn.c
Xv_vers.c
Xvch.h
Xvs_cat.c
Xvs_cpy.c
Xvs_dup.c
Xvs_ncat.c
Xvs_ncpy.c
Xvv_cat.c
Xvv_cpy.c
Xvv_dup.c
Xvv_ncat.c
Xvv_ncpy.c
Xvv_rtrim.c
END_OF_FILE
if test 323 -ne `wc -c <'FileList'`; then
    echo shar: \"'FileList'\" unpacked with wrong size!
fi
# end of 'FileList'
fi
if test -f 'FileMap' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FileMap'\"
else
echo shar: Extracting \"'FileMap'\" \(100 characters\)
sed "s/^X//" >'FileMap' <<'END_OF_FILE'
XFileMap:filemap
XFileList:filelist
XLICENCE:licence
XMANIFEST:manifest
XMakefile:makefile
XREADME:readme
END_OF_FILE
if test 100 -ne `wc -c <'FileMap'`; then
    echo shar: \"'FileMap'\" unpacked with wrong size!
fi
# end of 'FileMap'
fi
if test -f 'LICENCE' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'LICENCE'\"
else
echo shar: Extracting \"'LICENCE'\" \(7260 characters\)
sed "s/^X//" >'LICENCE' <<'END_OF_FILE'
X			LICENCE FOR VARCHAR LIBRARY PACKAGE
X			===================================
X
XThe purpose of this licence agreement is to permit fair use of
Xthe software for non-commercial purposes, but to properly reward
Xthe copyright holders when the software is used in a commercial
Xmanner.
X
XAll rights are reserved by the copyright holders.
X
X1.	Copyright Messages
X	Portions copyright 1986, David T. Bath
X	Portions copyright 1992, Global Technology Group
X
X2.	Source Code Distribution
X	The source code may be freely distributed providing that
X		2.1.	The complete package including documentation is
X				provided.
X
X		2.2.	No charge is made other than to cover the costs of
X				distribution.
X
X		2.3.	If distributing modifications or corrections, you
X				must either distribute your modifications as patches
X				or include a complete unaltered copy of the original
X				package.
X
X		2.4.	You do not use knowledge gained from the source code
X				to develop software of similar functionality.  If
X				you wish to develo a similar product, you will need
X				to be able to demonstrate that such development
X				has occurred in a "clean shop" or risk legal
X				action.
X
X3.	Derived Works Distribution
X	Derived works (including executables, object files, archives
X	and any intermediate files) may be distributed providing that
X		3.1.	All applicable licence fees have been paid and
X				you have registered with Global Technology
X				Group.
X
X		3.2.	The receiver of your derived works understands
X				the source of this software and receives a
X				complete copy of the documentation and licence
X				agreement.
X
X		3.3.	The copyright messages are include in all
X				documentation.
X
X		3.4.	Interactive executables must display the
X				copyright messages on startup.  Non-interactive
X				executables must have a documented option that
X				displays the copyright messages.
X
X4.	Licensee category
X	The category the licensee falls into determines how you may use the
X	software and what fees may be charged.
X	A.	Individuals using the product domestically
X	B.	Charitable institutions
X	C.	Educational and research institutions
X	D.	Commercial institutions - small workgroups
X	E.	Software developers - including internal commercial consultants
X	F.	Military organizations or weapons systems developers
X
X5.	Licence Arrangements
X
X	Category A
X	----------
X		License fees are not payable if you are using this code for 
X		domestic purposes only.
X
X	Category B
X	----------
X		Licence fees will be waived if you are a registered charity or
X		non-profit organization providing that the derived works are
X		purely for internal use.  The licence fee shall be considered
X		a donation by Global Technology Group.  You are still encouraged
X		to register your use with Global Technology Group.
X
X	Category C
X	----------
X		Educational and research institutions are treated as if they
X		are category B if the code or derived works are used
X		primarily within teaching or research areas.  Administrative
X		areas of such institutions using the software for commercial
X		or quasi-commercial use shall be considered to be commercial
X		users (categories D or E).  You are required to contact
X		Global Technology Group within 30 days of executable
X		programs being used so we may assess if a licence fee is
X		applicable.
X
X	Category D
X	----------
X		Commercial organizations are permitted to use this product 
X		internally at no charge providing that the use of any particular 
X		derived work does not extend beyond your immediate work group, 
X		in which case you are considered a software developer.
X
X		If an executable is available to or processes data of more than
X		16 users, then it is considered use outside your workgroup.
X
X		Category D users must register their use of the software within
X		30 days of the executable being used on production data.
X
X
X	Category E
X	----------
X		Category E includes commercial software developers, commercial
X		organizations making wide use of the software and information
X		technology consultancies (including consultancies internal to
X		a commercial organization).
X
X		You must register your use of the software within 30 days of the
X		executable being invoiced or delivered to a client for testing.
X		A licence fee will be applicable depending on your use of our 
X		product.  You are strongly encouraged to contact us when planning 
X		your product.
X
X		Software developers are also referred to conditions for category 
X		F users should your potential clients fall into this category.
X
X
X	Category F
X	----------
X		Category F users include any military organization or weapons 
X		systems developer.  This product must not be used to assist in 
X		the sale, procurement, development, testing, manufacturing or 
X		usage of any offensive weapon.
X
X		This product may however be used by category VI users for purely
X		defensive hardware.  For example, you can use it to develop a
X		shield but not a sword.  It must not be used in the deployment 
X		of troops or equipment in combat, except for non-combatant units 
X		such as medical personnel.
X
X		These conditions do not apply to United Nations military forces or
X		administration, where categories D and E are relevant.
X	
X6.	Licence Fees
X	Licence fees take into consideration the contribution this software
X	makes to your product and the use you make of it.  Licence fees are
X	payable once-only unless you wish to receive support from Global
X	Technology Group or are making repeated sales or releases of
X	this software or derived works.
X
X7.	Support
X	Support and further documentation may be negotiated with Global 
X	Technology Group.  This software is provided "as-is".  All
X	responsibility for deciding on the suitability and use rests
X	with the licensee.
X
X8.	General
X	Global Technology Group offers a range of services in the computing
X	fields.  These include personnel services, where we deal with both
X	contractors and permanent staff.  Other more general consulting
X	services are also available, with an emphasis on UNIX and Oracle.
X
X9.	Information required for registration
X	Name
X	Position
X	Organization
X	Organization's address
X	Phone number
X	Fax number
X	Email address
X
X	Describe the core business of your organization and workgroup.
X
X	Where did you obtain the software ?
X
X	What category licensee do you believe is applicable to you ?
X
X	Describe desirable update policy and support.
X
X	Do you wish to participate in a user forum for this software ?
X
X	Describe target machines and operating systems, including version
X	numbers.
X
X	What are the applications for which the software is used ?
X
X	How many people may access the software or derived works ?
X
X	How many people have their data processed by the software or derived 
X	works ?
X
X	Describe the pricing structure of any derived works you sell for
X	profit or the fees charged when using this software or derived works
X	as part of a consultancy.
X
X	Which type of licence do you consider relevant ?
X		A.	Site licence
X		B.	Software developer's licence (one off)
X		C.	Software developer's licence per units sold.
X
X	Do you agree to re-register the software with Global Technology Group
X	when usage of the software changes ?
X
X10.	Contact Mechanisms
X	Global Technology Group
X	179 Grattan Street
X	Carlton, Victoria, 3053
X	AUSTRALIA
X	Phone:	(03) 347-7511
X	Fax:	(03) 347-0182
X	Email:	dtb@otto.bf.rmit.oz.au
END_OF_FILE
if test 7260 -ne `wc -c <'LICENCE'`; then
    echo shar: \"'LICENCE'\" unpacked with wrong size!
fi
# end of 'LICENCE'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(1800 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X FileList                   1	List of basic files
X FileMap                    1	Mappings for non-UNIX systems
X LICENCE                    2	Licence information
X MANIFEST                   1	This file
X Makefile                   2	Make control file
X README                     1	READ this first
X sv_cat.c                   1	Library function
X sv_cpy.c                   1	Library function
X sv_dup.c                   1	Library function
X sv_ncat.c                  1	Library function
X sv_ncpy.c                  1	Library function
X sv_sub.c                   1	Library function
X v_alloc.c                  1	Library function
X v_cmp.c                    1	Library function
X v_crspn.c                  1	Library function
X v_cspn.c                   1	Library function
X v_data.c                   1	Library function
X v_len.c                    1	Library function
X v_ncmp.c                   1	Library function
X v_rspn.c                   1	Library function
X v_set.c                    1	Library function
X v_slen.c                   1	Library function
X v_spn.c                    1	Library function
X v_vers.c                   1	Library function
X vch.h                      2	Library function
X vs_cat.c                   1	Library function
X vs_cpy.c                   1	Library function
X vs_dup.c                   1	Library function
X vs_ncat.c                  1	Library function
X vs_ncpy.c                  1	Library function
X vv_cat.c                   1	Library function
X vv_cpy.c                   1	Library function
X vv_dup.c                   1	Library function
X vv_ncat.c                  1	Library function
X vv_ncpy.c                  1	Library function
X vv_rtrim.c                 1	Library function
END_OF_FILE
if test 1800 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(4886 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#!/bin/make
X########################################################################
X# $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/Makefile,v $
X# $Revision: 1.1 $
X# $Date: 1992/11/17 05:50:08 $
X# $State: Exp $
X# $Locker:  $
X# $Author: dtb $
X########################################################################
X# 
X# $Log: Makefile,v $
X# Revision 1.1  1992/11/17  05:50:08  dtb
X# initial real cut
X#
X# 
X########################################################################
X# Description
X# Control file for make(1) to build up the varchar library which allows
X# conversion between standard C strings and Oracle varchars as well as
X# various utility functions that operate on varchars but are similar to
X# those found in string.h
X########################################################################
X
X########################################################################
X# Variables for the C compiler
X########################################################################
XCC = cc
XCCOPTS = -O
X
X########################################################################
X# Variables for installation
X#	LIBINSTALLDIR	Directory in which library will be installed
X#	HDRINSTALLDIR	Directory in which header will be installed
X#	INST_USR		User name for ownership of installed files
X#	INST_GRP		Group name for ownership of installed files
X########################################################################
XLIBINSTALLDIR = $(ORACLE_HOME)/local/lib
XHDRINSTALLDIR = $(ORACLE_HOME)/local/include
XINST_USR = oracle
XINST_GRP = dba
X
X########################################################################
X# Variables for names of objects, etc
X#	These will not usually need to be altered unless you add or delete
X#	various functions.
X#	LIBNAME		Name of library file to be built
X#	LIBOBJ		Objects to be included in library
X#	VCHOBJ		Objects forming part of this package
X########################################################################
XLIBNAME = libvch.a
X
XLIBOBJ = \
X	sv_cat.o	sv_cpy.o	sv_dup.o	sv_ncat.o \
X	sv_ncpy.o	sv_sub.o	v_alloc.o	v_cmp.o	\
X	v_crspn.o	v_cspn.o	v_data.o	v_len.o	\
X	v_ncmp.o	v_rspn.o	v_set.o		v_slen.o \
X	v_spn.o		v_vers.o	vs_cat.o	vs_cpy.o \
X	vs_dup.o	vs_ncat.o	vs_ncpy.o	vv_cat.o \
X	vv_cpy.o	vv_dup.o	vv_ncat.o	vv_ncpy.o \
X	vv_rtrim.o
X
XVCHOBJ = $(LIBOBJ)
X
X########################################################################
X# Definitions of targets
X#	all			Builds everything but does not install it
X#	install		Installs existing made objects
X#	clean		Cleans up temporary files
X########################################################################
X
Xall : $(VCHOBJ) $(LIBNAME)
X
Xclean :
X	- rm *.o *.a
X	- ls *.pc | sed 's/pc$$/c/' | xargs rm
X
Xinstall : $(LIBINSTALLDIR)/$(LIBNAME) $(HDRINSTALLDIR)/vch.h
X
X$(LIBNAME) : $(LIBOBJ)
X	ar -ruv $(LIBNAME) $(LIBOBJ)
X
X$(LIBINSTALLDIR)/$(LIBNAME) : $(LIBNAME)
X	cp $(LIBNAME) $(LIBINSTALLDIR)/$(LIBNAME)
X	chmod 644 $(LIBINSTALLDIR)/$(LIBNAME)
X	chgrp $(INST_GRP) $(LIBINSTALLDIR)/$(LIBNAME)
X	chown $(INST_USR) $(LIBINSTALLDIR)/$(LIBNAME)
X
X$(HDRINSTALLDIR)/vch.h : vch.h
X	cp vch.h $(HDRINSTALLDIR)/vch.h
X	chmod 644 $(HDRINSTALLDIR)/vch.h
X	chgrp $(INST_GRP) $(HDRINSTALLDIR)/vch.h
X	chown $(INST_USR) $(HDRINSTALLDIR)/vch.h
X
X########################################################################
X# YOU WILL NOT REALLY NEED TO ALTER ANYTHING BELOW THIS LINE
X########################################################################
X
Xsv_cat.o	: sv_cat.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xsv_cpy.o	: sv_cpy.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xsv_dup.o	: sv_dup.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xsv_ncat.o	: sv_ncat.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xsv_ncpy.o	: sv_ncpy.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xv_alloc.o	: v_alloc.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xv_cmp.o	: v_cmp.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xv_data.o	: v_data.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xv_len.o	: v_len.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xv_ncmp.o	: v_ncmp.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xv_set.o	: v_set.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xv_slen.o	: v_len.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xv_vers.o	: v_vers.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_cat.o	: vs_cat.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_cpy.o	: vs_cpy.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_crspn.o	: vs_crspn.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_cspn.o	: vs_cspn.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_dup.o	: vs_dup.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_ncat.o	: vs_ncat.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_ncpy.o	: vs_ncpy.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_rspn.o	: vs_rspn.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvs_spn.o	: vs_spn.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvv_cat.o	: vv_cat.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvv_cpy.o	: vv_cpy.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvv_dup.o	: vv_dup.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvv_ncat.o	: vv_ncat.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvv_ncpy.o	: vv_ncpy.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
Xvv_rtrim.o	: vv_rtrim.c vch.h
X	$(CC) -c $(CCOPTS) $*.c
X
END_OF_FILE
if test 4886 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(5773 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X					README FOR VARCHAR LIBRARY
X					==========================
X
XPurpose
X-------
X
X	Allows C programmers to deal with Oracle varchar types without
X	the need to put your code through the Oracle Pro*C precompiler.
X	Apart from allowing you to declare and address varchars in
X	"normal" C, various functions are provided to let you move
X	information between varchars and standard strings.
X
X	Hacking the header file should allow these functions to be used
X	with Ingres varchars as well.
X
X	In general, when moving from a varchar to a string, a null
X	character to terminate the string will be provided.  When moving
X	from a string to a varchar, terminating nulls are not considered
X	part of the data, but are usually transferred.
X
X	Functions provided to access varchars are patterned on the
X	string functions of standard C.
X
X	In general, if you want to convert between varchars and binary
X	memory, the conversion functions will not be very useful.  Such
X	functions are essentially trivial.
X
XPortability
X-----------
X
X	The functions have been written in ANSI C style for a system V
X	platform.  If you are porting to BSD, you will need to check out
X	the difference between <string.h> and <strings.h>.  Functions
X	declared in <memory.h> of system V have analogues in BSD that a
X	couple of definitions in vch.h should fix up.  An example would
X	be to convert calls to memcpy() to use bcpy() instead.
X
X	I managed a port to SunOS 4.1, in under an hour.
X
X	Porting to MS-DOS has not been considered apart from keeping file
X	names unique within DOS limits.
X
XHistory
X-------
X
X	This package was started back in 1986 when I first started to
X	work with Oracle.  It has been reworked a number of times since
X	then.
X
X	After comp.databases.oracle was started, I mentioned I had some
X	of these functions available and received quite a few requests.
X	Unfortunately, before I could post it, my disk got blown away
X	and the version I posted was the wrong backup and had a number
X	of bugs and documentation errors.
X
X	This version has been more thoroughly tested and some of the
X	functions have altered in their parameters and the way they
X	work from the previous release.
X
X	The current version has copyright partially assigned to Global
X	Technology Group.  This basically means that there are
X	limitations on the use of this code for commercial purposes.
X
X	Read the LICENCE file for details.
X
XMaking the library
X-----------------
X
X	First, read and edit the Makefile.  You may need to create the
X	target directories.  Then it should simply be a matter of :
X		make all
X		make install
X
X	If you have Pro*C, it is worth checking out whether the type
X	information in vch.h is appropriate.  Precompile the following
X
X		EXEC SQL BEGIN DECLARE SECION;
X		varchar	testvar[20];
X		EXEC SQL END DECLARE SECTION;
X
X	then check out the C file produced.  This will give you clues to
X	editing vch.h.
X
XUsing varchar pointers with Pro*C objects
X-----------------------------------------
X
X	When getting data from Oracle variables into varchars using
X	Pro*C, there are a few things of which to be aware.  The major
X	thing is that if the binding is a pointer, the current length is
X	considered the maximum allowed length.  If you are passing Vchmin
X	pointers to such routines, you may want to co-erce the length to
X	the desired maximum first - providing that the routines do not
X	read the data.  Similar problems exist with standard C strings.
X
X	See the Oracle documentation for details - or better still, look
X	at the output from Pro*C.
X
XWhy not use Pro*C ?
X-------------------
X
X	Basically, Pro*C does not compare favorably with the standard C
X	precompiler, and has a few nasty limitations including
X
X		input and output line length
X			This causes the precompiler to barf regularly on version
X			control and other long strings.  The absolute limit for
X			both is 127 characters, but it defaults to less.
X
X		no ability for symbol replacement
X			You cannot define a value for a symbol - thus you need
X			to hardcode all varchar lengths.
X
X		scope
X			Variables are considered by the precompiler to have file
X			scope rather than the scope in which they are declared.
X			This leads to a number of unexpected compile failures
X			and namespace conflicts.
X
X	Also, debugging and profiling is made more difficult when using
X	Pro*C.
X
X	Simply, for a whole heap of reasons you will probably prefer to
X	write many functions in C and avoid the precompiler except for
X	the times you are actually interracting with the Oracle engine.
X
XMiscellaneous Files
X-------------------
X
X	FileMap
X	A file called FileMap contains information to map filenames
X	between UNIX and non-case sensitive filesystems.  Fields are
X	colon separated.  If you got these files via DOS or VMS, then
X	you will need to change the filenames using this information.
X
X	Filelist
X	List of files in this package
X
X	LICENCE
X	Read this file to check out limitations on the use of this code.
X
X	MANIFEST
X	Used by makekit(1) to create a shar file.
X
XNotes
X-----
X
X	Currently, Oracle has a maximum length for strings of 255.  It used
X	to be 240.  This code imposes no such limitations.
X
X	You do not need Pro*C to compile these routines.
X
X	These routines do not reference any Oracle provided function or
X	variable - so they could even be used without any Oracle libraries
X	to help manage a similarly structured datatype.
X
XBug Reports
X-----------
X
X	Please send any reports of bugs, comments or religious disputes to
X	one of my addresses below.
X
XTo Do
X-----
X	I am writing up a manual page at the moment
X
X
XDavid T. Bath                                 | Email: dtb@otto.bf.rmit.oz.au
XSenior Technical Consultant                   | Phone: (03) 347-7511
XGlobal Technology Group                       | Fax  : (03) 347-0182
X179 Grattan St, CARLTON, VIC, 3053, AUSTRALIA | #include <disclaimer.h>
END_OF_FILE
if test 5773 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'sv_cat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sv_cat.c'\"
else
echo shar: Extracting \"'sv_cat.c'\" \(1669 characters\)
sed "s/^X//" >'sv_cat.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_cat.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:08 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: sv_cat.c,v $
X* Revision 1.1  1992/11/17  05:50:08  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Appends varchar to string
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_cat.c,v 1.1 1992/11/17 05:50:08 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	str_vchcat()
X* PURPOSE
X* 	Add varchar to end of string
X* SYNOPSIS
X* 	str_vchcat (s, v)
X* 	char 	*s;
X* 	struct vch_min *v;
X* DESCRIPTION
X* 	This function copies the data from a varchar to its length (or to
X* 	a null, whichever is first) onto the end of a standard C string and 
X*	returns a pointer to the result.  Unlike strcat, however, a null
X*	character will be placed on the end.
X***********************************************************************/
Xchar 	*	str_vchcat
X	(
X	char 	*	s,
X	Vchmin	*	v
X	)
X{
X	int newlen = -1;	/* Set to -1 initially */
X	if (memchr(v->arr, '\0', v->len) == NULL) 
X		newlen = strlen (s) + v->len;
X	strncat (s, v->arr, v->len);	/* Copy the basic data */
X	if (newlen >= 0)	/* No null characters, put it in by hand */
X		*(s + newlen) = '\0';
X
X	return (s);
X}
X
END_OF_FILE
if test 1669 -ne `wc -c <'sv_cat.c'`; then
    echo shar: \"'sv_cat.c'\" unpacked with wrong size!
fi
# end of 'sv_cat.c'
fi
if test -f 'sv_cpy.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sv_cpy.c'\"
else
echo shar: Extracting \"'sv_cpy.c'\" \(1489 characters\)
sed "s/^X//" >'sv_cpy.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_cpy.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:09 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: sv_cpy.c,v $
X* Revision 1.1  1992/11/17  05:50:09  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Copies varchar to string
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_cpy.c,v 1.1 1992/11/17 05:50:09 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	str_vchcpy()
X* PURPOSE
X* 	Copy the string from a varchar into standard C string
X* SYNOPSIS
X* 	str_vchcpy (s, v)
X* 	char 	*s;
X* 	Vchmin *v;
X* DESCRIPTION
X* 	This function copies the data from a varchar to the length (or to
X* 	a null, whichever is first) into a standard C string and returns
X* 	the pointer to the result.  A null character is placed at the end
X*	of the string.
X***********************************************************************/
Xchar 	*str_vchcpy 
X	(
X	char 	*s,
X	Vchmin	*v 
X	)
X{
X	strncpy (s, v->arr, v->len);
X	if (memchr(s, '\0', v->len) == NULL)
X		*(s+(v->len)) = '\0';
X	return (s);
X}
X
END_OF_FILE
if test 1489 -ne `wc -c <'sv_cpy.c'`; then
    echo shar: \"'sv_cpy.c'\" unpacked with wrong size!
fi
# end of 'sv_cpy.c'
fi
if test -f 'sv_dup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sv_dup.c'\"
else
echo shar: Extracting \"'sv_dup.c'\" \(1457 characters\)
sed "s/^X//" >'sv_dup.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_dup.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:09 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: sv_dup.c,v $
X* Revision 1.1  1992/11/17  05:50:09  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Duplicates varchar as string
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_dup.c,v 1.1 1992/11/17 05:50:09 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	str_vchdup()
X* PURPOSE
X* 	Duplicate varchar as string
X* SYNOPSIS
X* 	str_vchdup (v)
X* 	Vchmin *v;
X* DESCRIPTION
X* 	Allocates and copies a varchar into a standard C string.  If
X*	necessary, extra bytes will be allocated for a terminating null
X*	character.
X************************************************************************/
Xchar 	*str_vchdup
X	(
X	Vchmin	*v
X	)
X{
X	char 	*d = NULL;
X	int		vlen;
X
X	if (v != NULL) {
X		vlen = vch_strlen (v);
X		if ((d = (char *)malloc (vlen + 1)) != (char *)NULL) {
X			memcpy (d, v->arr, vlen);
X			*(d+(vlen)) = '\0';
X		}
X	}
X	return (d);
X}
X
END_OF_FILE
if test 1457 -ne `wc -c <'sv_dup.c'`; then
    echo shar: \"'sv_dup.c'\" unpacked with wrong size!
fi
# end of 'sv_dup.c'
fi
if test -f 'sv_ncat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sv_ncat.c'\"
else
echo shar: Extracting \"'sv_ncat.c'\" \(1715 characters\)
sed "s/^X//" >'sv_ncat.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_ncat.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:09 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: sv_ncat.c,v $
X* Revision 1.1  1992/11/17  05:50:09  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Length limited append of varchar to string
X*	type in a manner similar to the string handling library of C and
X*	with a number of functions converting between VARCHARS and strings.
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_ncat.c,v 1.1 1992/11/17 05:50:09 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	str_vchncat()
X* PURPOSE
X* 	Add varchar to end of string
X* DESCRIPTION
X* 	This function copies the data from a varchar to its length (or to
X* 	a null, whichever is first) onto the end of a standard C string and 
X*	returns a pointer to the result up to a maximum of n bytes.  A null
X*	null character will be appended if none were found.
X***********************************************************************/
Xchar 	*str_vchncat
X	(
X	char 	*	s,
X	Vchmin	*	v,
X	unsigned int n
X	)
X{
X	int	newlen = -1;
X
X	if (n > v->len)
X		n = v->len;
X	if (memchr(v->arr, '\0', n) == NULL)
X		newlen = strlen (s) + n;
X	strncat (s, v->arr, n);
X	if (newlen >= 0)
X		*(s + newlen) = '\0';
X
X	return (s);
X}
X
END_OF_FILE
if test 1715 -ne `wc -c <'sv_ncat.c'`; then
    echo shar: \"'sv_ncat.c'\" unpacked with wrong size!
fi
# end of 'sv_ncat.c'
fi
if test -f 'sv_ncpy.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sv_ncpy.c'\"
else
echo shar: Extracting \"'sv_ncpy.c'\" \(1611 characters\)
sed "s/^X//" >'sv_ncpy.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_ncpy.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:10 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: sv_ncpy.c,v $
X* Revision 1.1  1992/11/17  05:50:10  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Length limited copy of varchar to string
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_ncpy.c,v 1.1 1992/11/17 05:50:10 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	str_vchncpy()
X* PURPOSE
X* 	Copy the string from a varchar into standard C string length limited
X* SYNOPSIS
X* 	str_vchncpy (s, v, n)
X* 	char 	*s;
X* 	Vchmin *v;
X* 	unsigned int n;
X* DESCRIPTION
X* 	This function copies the data from a varchar to the length (or to
X* 	a null, whichever is first) into a standard C string to a maximum
X* 	length n and returns a pointer to the result.  Unlike strncpy, 
X*	however, a null character is always placed at the end of s.
X***********************************************************************/
Xchar 	*str_vchncpy
X	(
X	char 	*s,
X	Vchmin	*v,
X	unsigned int n
X	)
X{
X	int vlen;
X
X	if (n > (vlen = vch_strlen(v)))
X		n = vlen;
X	strncpy (s, v->arr, n);
X	*(s+n)='\0';
X	return (s);
X}
X
END_OF_FILE
if test 1611 -ne `wc -c <'sv_ncpy.c'`; then
    echo shar: \"'sv_ncpy.c'\" unpacked with wrong size!
fi
# end of 'sv_ncpy.c'
fi
if test -f 'sv_sub.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sv_sub.c'\"
else
echo shar: Extracting \"'sv_sub.c'\" \(1726 characters\)
sed "s/^X//" >'sv_sub.c' <<'END_OF_FILE'
X
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_sub.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:10 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: sv_sub.c,v $
X* Revision 1.1  1992/11/17  05:50:10  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Extracts substring of varchar to string.
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_sub.c,v 1.1 1992/11/17 05:50:10 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	str_vchsub()
X* PURPOSE
X* 	Extracts substring of varchar to standard C string
X* DESCRIPTION
X* 	This function copies the data from a varchar to the length (or to
X* 	a null, whichever is first) into a standard C string to a maximum
X* 	length n and returns a pointer to the result.  Unlike strncpy, 
X*	however, a null character is always placed at the end of s.
X***********************************************************************/
Xchar 	*	str_vchsub
X	(
X	char 		*s,
X	Vchmin		*v,
X	unsigned	offset,
X	unsigned	len
X	)
X{
X	int vlen;
X
X	vlen = vch_strlen(v);	/* Current "string length" of varchar */
X
X	*s = '\0';
X	if (offset < vlen) {
X		/* Does not start past the "string length" of the varchar */
X		if (len > vlen - offset)
X			len = vlen - offset;
X		strncpy (s, (char *)(v->arr + offset), len);
X		*(s + len) = '\0';
X	}
X	return (s);
X}
X
END_OF_FILE
if test 1726 -ne `wc -c <'sv_sub.c'`; then
    echo shar: \"'sv_sub.c'\" unpacked with wrong size!
fi
# end of 'sv_sub.c'
fi
if test -f 'v_alloc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_alloc.c'\"
else
echo shar: Extracting \"'v_alloc.c'\" \(1428 characters\)
sed "s/^X//" >'v_alloc.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_alloc.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:10 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_alloc.c,v $
X* Revision 1.1  1992/11/17  05:50:10  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Allocates space for a varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_alloc.c,v 1.1 1992/11/17 05:50:10 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_alloc()
X* PURPOSE
X* 	Allocate storage for a varchar
X* SYNOPSIS
X* 	Vchmin *vch_alloc(n)
X* 	VCH_LEN_TYPE 	n;
X* DESCRIPTION
X* 	Allocates storage for a varchar with data length n.  Actually,
X* 	the storage requirement will be rounded up to a multiple of 2
X* 	to be "neat".
X***********************************************************************/
XVchmin 	*vch_alloc
X	(
X	VCH_LEN_TYPE 	n
X	)
X{
X	int 	size_req;
X	size_req = sizeof (struct vch_min) + n - VCH_MIN_ARR_LEN ;
X	size_req += size_req % 2;
X	return ( (Vchmin *) malloc (size_req) );
X}
X
END_OF_FILE
if test 1428 -ne `wc -c <'v_alloc.c'`; then
    echo shar: \"'v_alloc.c'\" unpacked with wrong size!
fi
# end of 'v_alloc.c'
fi
if test -f 'v_cmp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_cmp.c'\"
else
echo shar: Extracting \"'v_cmp.c'\" \(1831 characters\)
sed "s/^X//" >'v_cmp.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_cmp.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:11 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_cmp.c,v $
X* Revision 1.1  1992/11/17  05:50:11  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Compares varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_cmp.c,v 1.1 1992/11/17 05:50:11 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_cmp()
X* PURPOSE
X* 	Compares varchars
X* SYNOPSIS
X* 	vch_cmp (v1, v2)
X* 	Vchmin *v1, *v2;
X* DESCRIPTION
X* 	Compares v1 and v2 in manner similar to strcmp
X************************************************************************/
Xint 	vch_cmp
X	(
X	Vchmin	*v1,
X	Vchmin	*v2 
X	)
X{
X	int		rval;		/* Return value */
X	int		cmplen;		/* Comparison length */
X	int		len1;
X	int		len2;
X	char	*mem1;
X	char	*mem2;
X
X	/* Set up defaults in local variables so NULL parameters do not dump */
X	len1 = len2 = 0;
X	mem1 = mem2 = NULL;
X
X	/* Get real values into local variables */
X	if (v1 != NULL) {
X		len1 = v1->len;
X		mem1 = (char *)v1->arr;
X	}
X	if (v2 != NULL) {
X		len2 = v2->len;
X		mem2 = (char *)v2->arr;
X	}
X
X	/* Do comparison up to common length */
X	cmplen = (len2 > len1) ? len2 : len1;
X	rval = memcmp (mem1, mem2, cmplen);
X
X	/* Adjust if same so far but one longer than the other */
X	if ((rval == 0) && (len1 != len2)) {
X		rval = (len1 > len2) ? 1 : -1;
X	}
X	return (rval);
X}
X
X
END_OF_FILE
if test 1831 -ne `wc -c <'v_cmp.c'`; then
    echo shar: \"'v_cmp.c'\" unpacked with wrong size!
fi
# end of 'v_cmp.c'
fi
if test -f 'v_crspn.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_crspn.c'\"
else
echo shar: Extracting \"'v_crspn.c'\" \(1431 characters\)
sed "s/^X//" >'v_crspn.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_crspn.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:11 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_crspn.c,v $
X* Revision 1.1  1992/11/17  05:50:11  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Returns number of characters in leader of varchar made entirely of
X*	characters in the string.
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_crspn.c,v 1.1 1992/11/17 05:50:11 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_crspn()
X* DESCRIPTION
X* 	Looks at the trailing data characters of the varchar v and checks
X* 	which are in not the set of characters in the string s, returning the
X*	length of the matching span in v.
X************************************************************************/
Xint 	vch_crspn
X	(
X	Vchmin	*v,
X	char 	*s
X	)
X{
X	int			pos;
X	int			len;
X	char	*	vc;
X
X	vc	= (char *) ((v->arr)+(len=v->len)-1);
X	for (pos = 0; len--; pos++) {
X		if (strchr(s, *vc--) != NULL)
X			break;
X	}
X	return (pos);
X}
X
END_OF_FILE
if test 1431 -ne `wc -c <'v_crspn.c'`; then
    echo shar: \"'v_crspn.c'\" unpacked with wrong size!
fi
# end of 'v_crspn.c'
fi
if test -f 'v_cspn.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_cspn.c'\"
else
echo shar: Extracting \"'v_cspn.c'\" \(1387 characters\)
sed "s/^X//" >'v_cspn.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_cspn.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:11 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_cspn.c,v $
X* Revision 1.1  1992/11/17  05:50:11  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Returns number of characters in leader of varchar not made of
X*	characters in the string.
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_cspn.c,v 1.1 1992/11/17 05:50:11 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_cspn()
X* DESCRIPTION
X* 	Looks at the leading data characters of the varchar v and checks
X* 	which are in the set of characters not in the string s, returning
X*	the length of the matching span in v.
X************************************************************************/
Xint 	vch_cspn
X	(
X	Vchmin	*v,
X	char 	*s
X	)
X{
X	int	pos;
X
X	for (pos = 0; pos <= v->len; pos++) {
X		if (strchr(s, *(v->arr)+pos) != NULL)
X			break;
X	}
X	return (pos);
X}
END_OF_FILE
if test 1387 -ne `wc -c <'v_cspn.c'`; then
    echo shar: \"'v_cspn.c'\" unpacked with wrong size!
fi
# end of 'v_cspn.c'
fi
if test -f 'v_data.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_data.c'\"
else
echo shar: Extracting \"'v_data.c'\" \(1272 characters\)
sed "s/^X//" >'v_data.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_data.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:12 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_data.c,v $
X* Revision 1.1  1992/11/17  05:50:12  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Gets length of varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_data.c,v 1.1 1992/11/17 05:50:12 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_data()
X* PURPOSE
X* 	Return length of a varchar type
X* SYNOPSIS
X* 	r = vch_len (v)
X* 	int 	r;
X* 	Vchmin 	*v;
X* DESCRIPTION
X* 	Passed the pointer to a varchar type, this returns a char pointer to
X* 	the data.
X***********************************************************************/
Xchar	* 	vch_data
X	(
X	Vchmin *v
X	)
X{
X	return ( v == (Vchmin *) NULL ? (char *) NULL : (char *) (v->arr));
X}
X
END_OF_FILE
if test 1272 -ne `wc -c <'v_data.c'`; then
    echo shar: \"'v_data.c'\" unpacked with wrong size!
fi
# end of 'v_data.c'
fi
if test -f 'v_len.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_len.c'\"
else
echo shar: Extracting \"'v_len.c'\" \(1484 characters\)
sed "s/^X//" >'v_len.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_len.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:12 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_len.c,v $
X* Revision 1.1  1992/11/17  05:50:12  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Gets length of varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_len.c,v 1.1 1992/11/17 05:50:12 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_len()
X* PURPOSE
X* 	Return length of a varchar type
X* SYNOPSIS
X* 	r = vch_len (v)
X* 	int 	r;
X* 	Vchmin 	*v;
X* DESCRIPTION
X* 	Passed the pointer to a varchar type, the length is evaluated using
X* 	the len element (rather than strlen() the arr element).  Although the
X* 	type of the len element is typically an unsigned short, a signed integer
X* 	is returned to allow for error codes.
X* DIAGNOSTICS
X* 	A value of -1 is returned on error, such as a null pointer.
X***********************************************************************/
Xint 	vch_len
X	(
X	Vchmin *v
X	)
X{
X	return ( v == NULL ? -1 : v->len);
X}
X
END_OF_FILE
if test 1484 -ne `wc -c <'v_len.c'`; then
    echo shar: \"'v_len.c'\" unpacked with wrong size!
fi
# end of 'v_len.c'
fi
if test -f 'v_ncmp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_ncmp.c'\"
else
echo shar: Extracting \"'v_ncmp.c'\" \(1886 characters\)
sed "s/^X//" >'v_ncmp.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_ncmp.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:12 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_ncmp.c,v $
X* Revision 1.1  1992/11/17  05:50:12  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Compares varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_ncmp.c,v 1.1 1992/11/17 05:50:12 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_ncmp()
X* PURPOSE
X* 	Compares varchars
X* SYNOPSIS
X* 	vch_ncmp (v1, v2, n)
X* 	Vchmin *v1, *v2;
X*	int	n;
X*	int n;
X* DESCRIPTION
X* 	Compares v1 and v2 in manner similar to strncmp
X************************************************************************/
Xint 	vch_ncmp
X	(
X	Vchmin	*v1,
X	Vchmin	*v2,
X	int		n
X	)
X{
X	int		rval;		/* Return value */
X	int		cmplen;		/* Comparison length */
X	int		len1;
X	int		len2;
X	char	*mem1;
X	char	*mem2;
X
X	/* Set up defaults in local variables so NULL parameters do not dump */
X	len1 = len2 = 0;
X	mem1 = mem2 = NULL;
X
X	/* Get real values into local variables */
X	if (v1 != NULL) {
X		len1 = v1->len;
X		mem1 = (char *) v1->arr;
X	}
X	if (v2 != NULL) {
X		len2 = v2->len;
X		mem2 = (char *) v2->arr;
X	}
X
X	/* Do comparison up to common length */
X	cmplen = (len2 > len1) ? len2 : len1;
X	rval = memcmp (mem1, mem2, ((n > cmplen) ? cmplen : n));
X
X	/* Adjust for longest if warranted */
X	if ((rval == 0) && (n > cmplen) && (len1 != len2)) {
X		rval = (len1 > len2) ? 1 : -1;
X	}
X	return (rval);
X}
X
X
END_OF_FILE
if test 1886 -ne `wc -c <'v_ncmp.c'`; then
    echo shar: \"'v_ncmp.c'\" unpacked with wrong size!
fi
# end of 'v_ncmp.c'
fi
if test -f 'v_rspn.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_rspn.c'\"
else
echo shar: Extracting \"'v_rspn.c'\" \(1420 characters\)
sed "s/^X//" >'v_rspn.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_rspn.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:12 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_rspn.c,v $
X* Revision 1.1  1992/11/17  05:50:12  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Returns number of characters in leader of varchar made entirely of
X*	characters in the string.
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_rspn.c,v 1.1 1992/11/17 05:50:12 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_rspn()
X* DESCRIPTION
X* 	Looks at the trailing data characters of the varchar v and checks
X* 	which are in the set of characters in the string s, returning the
X*	length of the matching span in v.
X************************************************************************/
Xint 	vch_rspn
X	(
X	Vchmin	*v,
X	char 	*s
X	)
X{
X	int			pos;
X	int			len;
X	char	*	vc;
X
X	vc	= (char *)((v->arr)+(len=v->len)-1);
X	for (pos = 0; len--; pos++) {
X		if (strchr(s, *vc--) == NULL)
X			break;
X	}
X	return (pos);
X}
END_OF_FILE
if test 1420 -ne `wc -c <'v_rspn.c'`; then
    echo shar: \"'v_rspn.c'\" unpacked with wrong size!
fi
# end of 'v_rspn.c'
fi
if test -f 'v_set.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_set.c'\"
else
echo shar: Extracting \"'v_set.c'\" \(1467 characters\)
sed "s/^X//" >'v_set.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_set.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:13 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_set.c,v $
X* Revision 1.1  1992/11/17  05:50:13  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Sets varchar to specified length of nominated characters
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_set.c,v 1.1 1992/11/17 05:50:13 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_set()
X* PURPOSE
X* 	Sets varchar to specified length of nominated characters.
X* SYNOPSIS
X* 	vch_set (v, c, n)
X* 	Vchmin *v;
X*	int	c, n;
X* DESCRIPTION
X* 	Fills v with n bytes of character c and sets length accordingly.
X* 	Analogous to memset(3).
X* WARNINGS
X*	No checking is done to make sure you do not overwrite data past the
X*	end of the allocated space for the varchar.
X************************************************************************/
XVchmin 	*vch_set
X	(
X	Vchmin	*v,
X	int		c,
X	int		n
X	)
X{
X	memset (v->arr, c, n);
X	v->len = n;
X	return (v);
X}
X
END_OF_FILE
if test 1467 -ne `wc -c <'v_set.c'`; then
    echo shar: \"'v_set.c'\" unpacked with wrong size!
fi
# end of 'v_set.c'
fi
if test -f 'v_slen.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_slen.c'\"
else
echo shar: Extracting \"'v_slen.c'\" \(1730 characters\)
sed "s/^X//" >'v_slen.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_slen.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:13 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_slen.c,v $
X* Revision 1.1  1992/11/17  05:50:13  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Gets string length of varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_slen.c,v 1.1 1992/11/17 05:50:13 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_len()
X* PURPOSE
X* 	Return string length of a varchar type
X* DESCRIPTION
X* 	Passed the pointer to a varchar type, the length is evaluated using
X* 	memchr on the array looking for the null character within the length
X*	nominated by the len element.  This represents the "string" length
X* 	of the data and is typically an unsigned short, but a signed integer
X* 	is returned.  Note that if no null character is found within the
X*	data part of the varchar, the information in the length element is
X*	returned.
X* AUTHOR
X* 	David T. Bath, Global Technology Group
X***********************************************************************/
Xint 	vch_strlen
X	(
X	Vchmin *v
X	)
X{
X	static	int	len;
X
X	if ( v == NULL ) {
X		len = 0;
X	} else {
X		if (memchr(v->arr, '\0', v->len) == NULL)
X			len = v->len;
X		else
X			len = strlen (v->arr);
X	}
X
X	return (len);
X}
X
END_OF_FILE
if test 1730 -ne `wc -c <'v_slen.c'`; then
    echo shar: \"'v_slen.c'\" unpacked with wrong size!
fi
# end of 'v_slen.c'
fi
if test -f 'v_spn.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_spn.c'\"
else
echo shar: Extracting \"'v_spn.c'\" \(1383 characters\)
sed "s/^X//" >'v_spn.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_spn.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:13 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_spn.c,v $
X* Revision 1.1  1992/11/17  05:50:13  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Returns number of characters in leader of varchar made entirely of
X*	characters in the string.
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_spn.c,v 1.1 1992/11/17 05:50:13 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_spn()
X* DESCRIPTION
X* 	Looks at the leading data characters of the varchar v and checks
X* 	which are in the set of characters in the string s, returning the
X*	length of the matching span in v.
X************************************************************************/
Xint 	vch_spn
X	(
X	Vchmin	*v,
X	char 	*s
X	)
X{
X	int	pos;
X
X	for (pos = 0; pos <= v->len; pos++) {
X		if (strchr(s, *(v->arr)+pos) == NULL)
X			break;
X	}
X	return (pos);
X}
END_OF_FILE
if test 1383 -ne `wc -c <'v_spn.c'`; then
    echo shar: \"'v_spn.c'\" unpacked with wrong size!
fi
# end of 'v_spn.c'
fi
if test -f 'v_vers.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'v_vers.c'\"
else
echo shar: Extracting \"'v_vers.c'\" \(1507 characters\)
sed "s/^X//" >'v_vers.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_vers.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:14 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: v_vers.c,v $
X* Revision 1.1  1992/11/17  05:50:14  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Provides copyright and version information
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_vers.c,v 1.1 1992/11/17 05:50:14 dtb Exp $" ;
X
X#include <stdio.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_version
X* PURPOSE
X* 	Pointer to version
X***********************************************************************/
Xchar 	*vch_version = "VCH Varchar Handling Library - Ver 1.1";
X
X/***********************************************************************
X* NAME
X* 	vch_copyright
X* PURPOSE
X* 	Provides copyright message to nominated file
X***********************************************************************/
Xvoid	vch_copyright
X	(
X	FILE	*fp
X	)
X{
X	char *m0="Portions copyright, ";
X	char *m1="1986, David T. Bath";
X	char *m2="1992, Global Technology Group";
X
X	if (fp == (FILE *)NULL)
X		fp = stdout;
X	fprintf (fp, "%s%s\n%s%s\n", m0, m1, m0, m2);
X}
X
END_OF_FILE
if test 1507 -ne `wc -c <'v_vers.c'`; then
    echo shar: \"'v_vers.c'\" unpacked with wrong size!
fi
# end of 'v_vers.c'
fi
if test -f 'vch.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vch.h'\"
else
echo shar: Extracting \"'vch.h'\" \(4656 characters\)
sed "s/^X//" >'vch.h' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vch.h,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:14 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vch.h,v $
X* Revision 1.1  1992/11/17  05:50:14  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Header for Oracle VARCHAR interface functions.
X*	It can probably be hacked to deal with Ingres VCHAR datatypes
X*	without too much drama, if you redefine the variables in the
X*	platform specific section.
X***********************************************************************/
X
X#if ! defined VCH_HDR_INCL
X#define VCH_HDR_INCL
X
X/***********************************************************************
X*	PLATFORM SPECIFIC SECION
X*	This section should be edited on porting to each new system or
X*	with new releases of the Oracle Pro*C precompiler.
X*	Essentially, you need to put the put the following inside 
X*	enclosing EXEC SQL BEGIN/END DECLARE SECTION marks:
X*		varchar	x[2];
X*	You should then look at the results and edit the definitions
X*	to match datatypes.
X*	The VCH_MIN_ARR_LEN setting could be set to 1, but I prefer 2,
X*	simply for aesthetic reasons.
X***********************************************************************/
X#if ! defined VCH_LEN_TYPE
X#define VCH_LEN_TYPE unsigned short
X#endif
X#if ! defined VCH_LEN_TYPE
X#define VCH_LEN_TYPE unsigned short
X#endif
X#if ! defined VCH_ARR_TYPE_PREFIX
X#define VCH_ARR_TYPE_PREFIX unsigned char
X#endif
X#if ! defined VCH_MIN_ARR_LEN
X#define VCH_MIN_ARR_LEN 	2
X#endif
X
X/***********************************************************************
X*	DATATYPES
X*	The vch_min structure is the structure for a minimum length varchar.
X*	This is setup to allow the typedef of Vchmin, which gives you
X*	declarations.
X*	The Vchmin datatype should NOT actually be used, as you will not
X*	have much space for storing data inside it!  However, it DOES give
X*	you a datatype that can take a pointer that will be appropriately
X*	aligned for structures and the length unit.
X*	You can then fairly safely pass pointers to Vchmin around as a
X*	means of manipulating varchars.
X***********************************************************************/
Xstruct vch_min { 
X	VCH_LEN_TYPE len;	/* specifies the length of the data in arr */
X	VCH_ARR_TYPE_PREFIX 	arr [ VCH_MIN_ARR_LEN ] ;	/* data */
X} ;
Xtypedef struct vch_min Vchmin;
X
X/***********************************************************************
X*	DECLARATION MACRO
X*	This declaration can be placed in your code so that it is easy to
X*	declare a variable with a VARCHAR structure with the length
X*	determined at compile time.
X*
X*	To use this to declare a varchar called fld to store 22 data bytes
X*		VCH_DECL(fld,22)
X*
X*	Note, however, that Oracle only supports varchars up to 255 data
X*	bytes at the time of writing.  This library, however, has no such
X*	limitation.
X***********************************************************************/
X#define VCH_DECL(a,b) \
X	struct { VCH_LEN_TYPE len; VCH_ARR_TYPE_PREFIX arr [ b ]; } a
X
X#endif
X
X/***********************************************************************
X*	FUNCTIONS AVAILABLE IN THE LIBRARY
X*	The naming conventions are generally as follows,
X*	For binary operations, the function xxx_yyyzzz has the target
X*	datatype xxx, source datatype yyy and operation zzz similar to
X*	the last part of the more common C string function.
X*	For example, vch_strncpy is like strncpy, but copies to a
X*	varchar.  The str_vchncpy on the other hand uses a varchar as
X*	source and a standard string as the target.
X***********************************************************************/
Xextern	Vchmin 	*vch_alloc		();
Xextern	Vchmin 	*vch_set		();
Xextern	Vchmin 	*vch_strcat		();
Xextern	Vchmin 	*vch_strcpy		();
Xextern	Vchmin 	*vch_strdup		();
Xextern	Vchmin 	*vch_strncat	();
Xextern	Vchmin 	*vch_strncpy	();
Xextern	Vchmin 	*vch_vchcat		();
Xextern	Vchmin 	*vch_vchcpy		();
Xextern	Vchmin 	*vch_vchdup		();
Xextern	Vchmin 	*vch_vchncat	();
Xextern	Vchmin 	*vch_vchncpy	();
Xextern	Vchmin 	*vch_vchrtrim	();
Xextern	void	vch_copyright	();
Xextern	char 	*str_vchcat		();
Xextern	char 	*str_vchcpy 	();
Xextern	char 	*str_vchdup		();
Xextern	char 	*str_vchncat	();
Xextern	char 	*str_vchncpy	();
Xextern	char 	*str_vchsub		();
Xextern	char 	*vch_data		();
Xextern	int 	vch_cmp			();
Xextern	int 	vch_len			();
Xextern	int 	vch_ncmp		();
Xextern	int 	vch_crspn		();
Xextern	int 	vch_cspn		();
Xextern	int 	vch_strlen		();
Xextern	int 	vch_rspn		();
Xextern	int 	vch_spn			();
END_OF_FILE
if test 4656 -ne `wc -c <'vch.h'`; then
    echo shar: \"'vch.h'\" unpacked with wrong size!
fi
# end of 'vch.h'
fi
if test -f 'vs_cat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vs_cat.c'\"
else
echo shar: Extracting \"'vs_cat.c'\" \(1501 characters\)
sed "s/^X//" >'vs_cat.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_cat.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:14 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vs_cat.c,v $
X* Revision 1.1  1992/11/17  05:50:14  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Appends string to varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_cat.c,v 1.1 1992/11/17 05:50:14 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_strcat()
X* PURPOSE
X* 	Copy the string into a varchar 
X* SYNOPSIS
X* 	vch_strcat (v, s)
X* 	char 	*s;
X* 	Vchmin *v;
X* DESCRIPTION
X* 	Copies the string (including the null) into a varchar and adds the
X* 	string length of to the length of the varchar.  The terminating
X*	null character is NOT included in the varchar length.
X* WARNINGS
X*	No checking is done that you will not overwrite past the end
X*	of the varchar.
X************************************************************************/
XVchmin 	*vch_strcat
X	(
X	Vchmin	*v,
X	char 	*s
X	)
X{
X	strcpy ((char *) (v->arr+v->len), s);
X	v->len += strlen (s);
X	return (v);
X}
X
END_OF_FILE
if test 1501 -ne `wc -c <'vs_cat.c'`; then
    echo shar: \"'vs_cat.c'\" unpacked with wrong size!
fi
# end of 'vs_cat.c'
fi
if test -f 'vs_cpy.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vs_cpy.c'\"
else
echo shar: Extracting \"'vs_cpy.c'\" \(1318 characters\)
sed "s/^X//" >'vs_cpy.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_cpy.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:15 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vs_cpy.c,v $
X* Revision 1.1  1992/11/17  05:50:15  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Copies string to varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_cpy.c,v 1.1 1992/11/17 05:50:15 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_strcpy()
X* PURPOSE
X* 	Copy the string into a varchar 
X* SYNOPSIS
X* 	vch_strcpy (v, s)
X* 	char 	*s;
X* 	Vchmin *v;
X* DESCRIPTION
X* 	Copies the string (including the null) into a varchar
X* 	and sets the length of the varchar to the string length.
X************************************************************************/
XVchmin 	*vch_strcpy
X	(
X	Vchmin	*v,
X	char 	*s
X	)
X{
X	strcpy (v->arr, s);
X	v->len = strlen (v->arr);
X	return (v);
X}
X
END_OF_FILE
if test 1318 -ne `wc -c <'vs_cpy.c'`; then
    echo shar: \"'vs_cpy.c'\" unpacked with wrong size!
fi
# end of 'vs_cpy.c'
fi
if test -f 'vs_dup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vs_dup.c'\"
else
echo shar: Extracting \"'vs_dup.c'\" \(1398 characters\)
sed "s/^X//" >'vs_dup.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_dup.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:15 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vs_dup.c,v $
X* Revision 1.1  1992/11/17  05:50:15  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Duplicates string as varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_dup.c,v 1.1 1992/11/17 05:50:15 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_strdup()
X* PURPOSE
X* 	Duplicate string as varchar
X* SYNOPSIS
X* 	vch_vchdup (s)
X* 	char *s;
X* DESCRIPTION
X* 	Allocates and copies a string as varchar.  Note that space is
X*	allocated for the terminating null of the string to be copied
X*	as well.
X***********************************************************************/
XVchmin 	*vch_strdup
X	(
X	char	*	s
X	)
X{
X	Vchmin 	*v = NULL;
X
X	if (s != NULL) {
X		if ((v = (Vchmin *) vch_alloc (strlen(s)+1)) != (Vchmin *)NULL) {
X			vch_strcpy (v, s);
X		}
X	}
X	return (v);
X}
X
END_OF_FILE
if test 1398 -ne `wc -c <'vs_dup.c'`; then
    echo shar: \"'vs_dup.c'\" unpacked with wrong size!
fi
# end of 'vs_dup.c'
fi
if test -f 'vs_ncat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vs_ncat.c'\"
else
echo shar: Extracting \"'vs_ncat.c'\" \(1693 characters\)
sed "s/^X//" >'vs_ncat.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_ncat.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:15 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vs_ncat.c,v $
X* Revision 1.1  1992/11/17  05:50:15  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Length limited append from string to varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_ncat.c,v 1.1 1992/11/17 05:50:15 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_strncat()
X* PURPOSE
X* 	Concatenates the string onto end of a varchar (length limited)
X* SYNOPSIS
X* 	vch_strncat (v, s, n)
X* 	char 	*s;
X* 	Vchmin *v;
X* 	unsigned int n;
X* DESCRIPTION
X* 	Concatenates the string (including the null if found under the
X*	specified length) into a varchar * 	and adds the string length to 
X*	the varchar length.  Up to n bytes are taken from the string.
X*	Any null character terminating the string is NOT included in the
X*	addition to the length of the varchar.
X************************************************************************/
XVchmin 	*vch_strncat
X	(
X	Vchmin	*v,
X	char 	*s,
X	unsigned int n
X	)
X{
X	int l;
X	int	a;
X
X	l = strlen(s);
X	a = (n > l) ? l : n;
X	strncpy (v->arr+v->len, s, a);
X	v->len += a;
X	if (n > l)
X		*(v->arr + l) = '\0';
X	return (v);
X}
X
END_OF_FILE
if test 1693 -ne `wc -c <'vs_ncat.c'`; then
    echo shar: \"'vs_ncat.c'\" unpacked with wrong size!
fi
# end of 'vs_ncat.c'
fi
if test -f 'vs_ncpy.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vs_ncpy.c'\"
else
echo shar: Extracting \"'vs_ncpy.c'\" \(1580 characters\)
sed "s/^X//" >'vs_ncpy.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_ncpy.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:16 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vs_ncpy.c,v $
X* Revision 1.1  1992/11/17  05:50:16  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Length limited copy of string to varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_ncpy.c,v 1.1 1992/11/17 05:50:16 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_strncpy()
X* PURPOSE
X* 	Copy the string into a varchar (length limited)
X* SYNOPSIS
X* 	Vchmin *vch_strncpy (v, s, n)
X* 	char 	*s;
X* 	Vchmin *v;
X* 	unsigned int n;
X* DESCRIPTION
X* 	Copies the string (including the null if less than n) into a varchar
X* 	and sets the length of the varchar to the string length, up to
X* 	a maximum of length n and returns a pointer to the result.
X************************************************************************/
XVchmin 	*vch_strncpy
X	(
X	Vchmin	*v,
X	char 	*s,
X	unsigned int 	n
X	)
X{
X	int slen;
X
X	strncpy (v->arr, s, n);		/* Copy the data */
X
X	if (memchr(s, '\0', n) == NULL)
X		v->len = n;
X	else
X		v->len = strlen (v->arr);
X
X	return (v);
X}
X
END_OF_FILE
if test 1580 -ne `wc -c <'vs_ncpy.c'`; then
    echo shar: \"'vs_ncpy.c'\" unpacked with wrong size!
fi
# end of 'vs_ncpy.c'
fi
if test -f 'vv_cat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vv_cat.c'\"
else
echo shar: Extracting \"'vv_cat.c'\" \(1323 characters\)
sed "s/^X//" >'vv_cat.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_cat.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:16 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vv_cat.c,v $
X* Revision 1.1  1992/11/17  05:50:16  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Appends from varchar to varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_cat.c,v 1.1 1992/11/17 05:50:16 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_vchcat()
X* PURPOSE
X* 	Concatenate varchar to another varchar
X* SYNOPSIS
X* 	vch_vchcat (v1, v2)
X* 	Vchmin *v1, *v2;
X* DESCRIPTION
X* 	Concatenate varchar v2 onto end of varchar v1
X************************************************************************/
XVchmin 	*vch_vchcat
X(
X	Vchmin	*v1,
X	Vchmin	*v2
X)
X{
X	if ((v1 != NULL) && (v2 != NULL)) {
X		memcpy (v1->arr + v1->len, v2->arr, v2->len);
X		v1->len += v2->len;
X	}
X	return (v1);
X}
X
END_OF_FILE
if test 1323 -ne `wc -c <'vv_cat.c'`; then
    echo shar: \"'vv_cat.c'\" unpacked with wrong size!
fi
# end of 'vv_cat.c'
fi
if test -f 'vv_cpy.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vv_cpy.c'\"
else
echo shar: Extracting \"'vv_cpy.c'\" \(1237 characters\)
sed "s/^X//" >'vv_cpy.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_cpy.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:16 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vv_cpy.c,v $
X* Revision 1.1  1992/11/17  05:50:16  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Copies varchar to varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_cpy.c,v 1.1 1992/11/17 05:50:16 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_vchcpy()
X* PURPOSE
X* 	Copy varchar to another varchar
X* SYNOPSIS
X* 	vch_vchcpy (v1, v2)
X* 	Vchmin *v1, *v2;
X* DESCRIPTION
X* 	Copies varchar v2 into varchar v1
X************************************************************************/
XVchmin 	*vch_vchcpy
X	(
X	Vchmin	*v1,
X	Vchmin	*v2 
X	)
X{
X	memcpy (v1->arr, v2->arr, v1->len=v2->len);
X	return (v1);
X}
X
X
END_OF_FILE
if test 1237 -ne `wc -c <'vv_cpy.c'`; then
    echo shar: \"'vv_cpy.c'\" unpacked with wrong size!
fi
# end of 'vv_cpy.c'
fi
if test -f 'vv_dup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vv_dup.c'\"
else
echo shar: Extracting \"'vv_dup.c'\" \(1271 characters\)
sed "s/^X//" >'vv_dup.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_dup.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:16 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vv_dup.c,v $
X* Revision 1.1  1992/11/17  05:50:16  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Duplicates varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_dup.c,v 1.1 1992/11/17 05:50:16 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_vchdup()
X* PURPOSE
X* 	Duplicate varchar
X* SYNOPSIS
X* 	vch_vchdup (v)
X* 	Vchmin *v;
X* DESCRIPTION
X* 	Allocates and copies a varchar
X************************************************************************/
XVchmin 	*vch_vchdup
X	(
X	Vchmin	*v
X	)
X{
X	Vchmin 	*d = NULL;
X
X	if (v != NULL) {
X		if ((d = (Vchmin *) vch_alloc (v->len)) != (Vchmin *)NULL) {
X			vch_vchcpy (d, v);
X		}
X	}
X	return (d);
X}
X
END_OF_FILE
if test 1271 -ne `wc -c <'vv_dup.c'`; then
    echo shar: \"'vv_dup.c'\" unpacked with wrong size!
fi
# end of 'vv_dup.c'
fi
if test -f 'vv_ncat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vv_ncat.c'\"
else
echo shar: Extracting \"'vv_ncat.c'\" \(1447 characters\)
sed "s/^X//" >'vv_ncat.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_ncat.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:17 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vv_ncat.c,v $
X* Revision 1.1  1992/11/17  05:50:17  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Length limited append from varchar to varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_ncat.c,v 1.1 1992/11/17 05:50:17 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_vchncat()
X* PURPOSE
X* 	Concatenate varchar to another varchar (length limited)
X* SYNOPSIS
X* 	vch_vchncat (v1, v2, n)
X* 	Vchmin *v1, *v2;
X* 	VCH_LEN_TYPE 	n;
X* DESCRIPTION
X* 	Concatenate varchar v2 onto end of varchar v1 adding max on n bytes
X************************************************************************/
XVchmin 	*vch_vchncat
X	(
X	Vchmin	*v1,
X	Vchmin	*v2,
X	VCH_LEN_TYPE n
X	)
X{
X	if ((v1 != NULL) && (v2 != NULL)) {
X		if (n > v2->len)
X			n = v2->len;
X		memcpy (v1->arr + v1->len, v2->arr, n);
X		v1->len += n;
X	}
X	return (v1);
X}
X
END_OF_FILE
if test 1447 -ne `wc -c <'vv_ncat.c'`; then
    echo shar: \"'vv_ncat.c'\" unpacked with wrong size!
fi
# end of 'vv_ncat.c'
fi
if test -f 'vv_ncpy.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vv_ncpy.c'\"
else
echo shar: Extracting \"'vv_ncpy.c'\" \(1358 characters\)
sed "s/^X//" >'vv_ncpy.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_ncpy.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:17 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vv_ncpy.c,v $
X* Revision 1.1  1992/11/17  05:50:17  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Length limited copy from varchar to varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_ncpy.c,v 1.1 1992/11/17 05:50:17 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_vchncpy()
X* PURPOSE
X* 	Copy varchar to another varchar (length limited)
X* SYNOPSIS
X* 	vch_vchncpy (v1, v2, n)
X* 	Vchmin *v1, *v2;
X* 	VCH_LEN_TYPE 	n;
X* DESCRIPTION
X* 	Copies varchar v2 into varchar v1 (length limited)
X***********************************************************************/
XVchmin 	*vch_vchncpy
X	(
X	Vchmin	*v1,
X	Vchmin	*v2,
X	VCH_LEN_TYPE 	n
X	)
X{
X	memcpy (v1->arr, v2->arr, v1->len = ((v2->len < n) ? v2->len : n ));
X	return (v1);
X}
X
END_OF_FILE
if test 1358 -ne `wc -c <'vv_ncpy.c'`; then
    echo shar: \"'vv_ncpy.c'\" unpacked with wrong size!
fi
# end of 'vv_ncpy.c'
fi
if test -f 'vv_rtrim.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vv_rtrim.c'\"
else
echo shar: Extracting \"'vv_rtrim.c'\" \(1480 characters\)
sed "s/^X//" >'vv_rtrim.c' <<'END_OF_FILE'
X/***********************************************************************
X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_rtrim.c,v $
X* $Revision: 1.1 $
X* $Date: 1992/11/17 05:50:17 $
X* $State: Exp $
X* $Locker:  $
X* $Author: dtb $
X************************************************************************
X* 
X* $Log: vv_rtrim.c,v $
X* Revision 1.1  1992/11/17  05:50:17  dtb
X* initial real cut
X*
X* 
X************************************************************************
X* Description
X*	Trims varchar from right if character in second varchar
X***********************************************************************/
X
Xstatic char *RCS_Id = "$Header: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_rtrim.c,v 1.1 1992/11/17 05:50:17 dtb Exp $" ;
X
X#include <stdio.h>
X#include <string.h>
X#include <memory.h>
X#include "vch.h"
X
X/***********************************************************************
X* NAME
X* 	vch_vchrtrim()
X* PURPOSE
X* 	Trims varchar from right if character in second varchar
X* SYNOPSIS
X* 	vch_vchrtrim (v1, v2)
X* 	Vchmin *v1, *v2;
X* DESCRIPTION
X* 	Trims v1 from right for characters in set v2
X************************************************************************/
XVchmin 	*vch_vchrtrim
X	(
X	Vchmin	*v1,
X	Vchmin	*v2 
X	)
X{
X	int	l;
X
X	for (l=(vchlen(v1)); l > 0; l--) {
X		if (memchr(v2->arr, (int) *(v1->arr + l - 1), v2->len) == NULL)
X			break;
X		v1->len = v1->len - 1;
X		*(v1->arr + v1->len) = '\0';	/* Set it to null character */
X	}
X	return (v1);
X}
X
X
END_OF_FILE
if test 1480 -ne `wc -c <'vv_rtrim.c'`; then
    echo shar: \"'vv_rtrim.c'\" unpacked with wrong size!
fi
# end of 'vv_rtrim.c'
fi
echo shar: End of shell archive.
exit 0
-- 
David T. Bath
email: 	dtb@otto.bf.rmit.oz.au
Work: 	Global Technology Corporation, Carlton, Vic, OZ  (03) 3477511
#include <disclaimer.h>
Newsgroups: comp.databases.oracle