home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / database / oracle / 2222 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  84.4 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!bruce.cs.monash.edu.au!monu6!escargot!otto!dtb
  2. From: dtb@otto (David Bath)
  3. Newsgroups: comp.databases.oracle
  4. Subject: Re: Using char pointers with Pro*C
  5. Date: 17 Nov 92 06:13:57 GMT
  6. Organization: RMIT Computer Centre
  7. Lines: 2829
  8. Message-ID: <dtb.721980837@otto>
  9. References: <19921112.042545.38@almaden.ibm.com>
  10. NNTP-Posting-Host: otto.bf.rmit.oz.au
  11.  
  12. ALANB@OWGVM0.VNET.IBM.COM (Alan Beal) writes:
  13.  
  14. >We are trying to use char * in SELECT INTO statements with Pro*C
  15. >(version 7.0.9) on an RS/6000.  We are getting segmentation faults
  16. >when we try to SELECT INTO more than one char *.  Are there any
  17. >gotchas that one must watch out for?  Also, the columns being
  18. >SELECTed are VARCHAR2 NOT NULL.  Does anyone have any examples
  19. >that work?  Is there a general rule of thumb on using CHAR arrays
  20. >with VARCHAR2 columns?  Thanks.
  21.  
  22. >Alan Beal         alanb@owgvm0.vnet.ibm.com
  23. >                  (607)751-2026
  24.  
  25. This is the only safe way I have found of getting values into pointers.
  26. We can skip the SQL here because getting a forms field is easier.
  27.     EXEC SQL BEGIN DECLARE SECTION;
  28.     static    varchar    *p;        /* Pointer to target data location */
  29.     static    char    *f;        /* Pointer to field name as a varchar */
  30.     EXEC SQL END DECLARE SECTION;
  31.     /*
  32.     *    The way the precompiler works is that when it gets a varchar
  33.     *    pointer as a target, it checks the current length to figure out
  34.     *    a "safe" length, but of course, if the existing value has zero
  35.     *    length you are stuffed.  We cover for this by "filling in" the
  36.     *    required maximum length first
  37.     */
  38.     ...
  39.     p->len = len;
  40.  
  41.     /*    Do the actual work */
  42.     EXEC IAF GET :f INTO :p;
  43.  
  44. You could then use my varchar functions to put the result in a string.
  45.  
  46. Alternatively, fill a string up to desired length (but then you have to deal
  47. with a xxxx-load of spaces!
  48.  
  49. Here is the current code - but mind - I have not yet written a man page.
  50. This has altered since the last release ; see LICENCE and README
  51. It is System V ANSI C, you will not need Pro*C to build this library,
  52. but as you are on RS/6000 you'll have to port.  Let me know how this
  53. goes.
  54. David T. Bath
  55. dtb@otto.bf.rmit.oz.au
  56. -------------- CUT HERE -------------
  57. #! /bin/sh
  58. # This is a shell archive.  Remove anything before this line, then unpack
  59. # it by saving it into a file and typing "sh file".  To overwrite existing
  60. # files, type "sh file -c".  You can also feed this as standard input via
  61. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  62. # will see the following message at the end:
  63. #        "End of shell archive."
  64. # Contents:  FileList FileMap LICENCE MANIFEST Makefile README sv_cat.c
  65. #   sv_cpy.c sv_dup.c sv_ncat.c sv_ncpy.c sv_sub.c v_alloc.c v_cmp.c
  66. #   v_crspn.c v_cspn.c v_data.c v_len.c v_ncmp.c v_rspn.c v_set.c
  67. #   v_slen.c v_spn.c v_vers.c vch.h vs_cat.c vs_cpy.c vs_dup.c
  68. #   vs_ncat.c vs_ncpy.c vv_cat.c vv_cpy.c vv_dup.c vv_ncat.c vv_ncpy.c
  69. #   vv_rtrim.c
  70. # Wrapped by dtb@cheops on Tue Nov 17 16:56:57 1992
  71. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  72. if test -f 'FileList' -a "${1}" != "-c" ; then 
  73.   echo shar: Will not clobber existing file \"'FileList'\"
  74. else
  75. echo shar: Extracting \"'FileList'\" \(323 characters\)
  76. sed "s/^X//" >'FileList' <<'END_OF_FILE'
  77. XFileList
  78. XFileMap
  79. XLICENCE
  80. XMANIFEST
  81. XMakefile
  82. XREADME
  83. Xsv_cat.c
  84. Xsv_cpy.c
  85. Xsv_dup.c
  86. Xsv_ncat.c
  87. Xsv_ncpy.c
  88. Xsv_sub.c
  89. Xv_alloc.c
  90. Xv_cmp.c
  91. Xv_crspn.c
  92. Xv_cspn.c
  93. Xv_data.c
  94. Xv_len.c
  95. Xv_ncmp.c
  96. Xv_rspn.c
  97. Xv_set.c
  98. Xv_slen.c
  99. Xv_spn.c
  100. Xv_vers.c
  101. Xvch.h
  102. Xvs_cat.c
  103. Xvs_cpy.c
  104. Xvs_dup.c
  105. Xvs_ncat.c
  106. Xvs_ncpy.c
  107. Xvv_cat.c
  108. Xvv_cpy.c
  109. Xvv_dup.c
  110. Xvv_ncat.c
  111. Xvv_ncpy.c
  112. Xvv_rtrim.c
  113. END_OF_FILE
  114. if test 323 -ne `wc -c <'FileList'`; then
  115.     echo shar: \"'FileList'\" unpacked with wrong size!
  116. fi
  117. # end of 'FileList'
  118. fi
  119. if test -f 'FileMap' -a "${1}" != "-c" ; then 
  120.   echo shar: Will not clobber existing file \"'FileMap'\"
  121. else
  122. echo shar: Extracting \"'FileMap'\" \(100 characters\)
  123. sed "s/^X//" >'FileMap' <<'END_OF_FILE'
  124. XFileMap:filemap
  125. XFileList:filelist
  126. XLICENCE:licence
  127. XMANIFEST:manifest
  128. XMakefile:makefile
  129. XREADME:readme
  130. END_OF_FILE
  131. if test 100 -ne `wc -c <'FileMap'`; then
  132.     echo shar: \"'FileMap'\" unpacked with wrong size!
  133. fi
  134. # end of 'FileMap'
  135. fi
  136. if test -f 'LICENCE' -a "${1}" != "-c" ; then 
  137.   echo shar: Will not clobber existing file \"'LICENCE'\"
  138. else
  139. echo shar: Extracting \"'LICENCE'\" \(7260 characters\)
  140. sed "s/^X//" >'LICENCE' <<'END_OF_FILE'
  141. X            LICENCE FOR VARCHAR LIBRARY PACKAGE
  142. X            ===================================
  143. X
  144. XThe purpose of this licence agreement is to permit fair use of
  145. Xthe software for non-commercial purposes, but to properly reward
  146. Xthe copyright holders when the software is used in a commercial
  147. Xmanner.
  148. X
  149. XAll rights are reserved by the copyright holders.
  150. X
  151. X1.    Copyright Messages
  152. X    Portions copyright 1986, David T. Bath
  153. X    Portions copyright 1992, Global Technology Group
  154. X
  155. X2.    Source Code Distribution
  156. X    The source code may be freely distributed providing that
  157. X        2.1.    The complete package including documentation is
  158. X                provided.
  159. X
  160. X        2.2.    No charge is made other than to cover the costs of
  161. X                distribution.
  162. X
  163. X        2.3.    If distributing modifications or corrections, you
  164. X                must either distribute your modifications as patches
  165. X                or include a complete unaltered copy of the original
  166. X                package.
  167. X
  168. X        2.4.    You do not use knowledge gained from the source code
  169. X                to develop software of similar functionality.  If
  170. X                you wish to develo a similar product, you will need
  171. X                to be able to demonstrate that such development
  172. X                has occurred in a "clean shop" or risk legal
  173. X                action.
  174. X
  175. X3.    Derived Works Distribution
  176. X    Derived works (including executables, object files, archives
  177. X    and any intermediate files) may be distributed providing that
  178. X        3.1.    All applicable licence fees have been paid and
  179. X                you have registered with Global Technology
  180. X                Group.
  181. X
  182. X        3.2.    The receiver of your derived works understands
  183. X                the source of this software and receives a
  184. X                complete copy of the documentation and licence
  185. X                agreement.
  186. X
  187. X        3.3.    The copyright messages are include in all
  188. X                documentation.
  189. X
  190. X        3.4.    Interactive executables must display the
  191. X                copyright messages on startup.  Non-interactive
  192. X                executables must have a documented option that
  193. X                displays the copyright messages.
  194. X
  195. X4.    Licensee category
  196. X    The category the licensee falls into determines how you may use the
  197. X    software and what fees may be charged.
  198. X    A.    Individuals using the product domestically
  199. X    B.    Charitable institutions
  200. X    C.    Educational and research institutions
  201. X    D.    Commercial institutions - small workgroups
  202. X    E.    Software developers - including internal commercial consultants
  203. X    F.    Military organizations or weapons systems developers
  204. X
  205. X5.    Licence Arrangements
  206. X
  207. X    Category A
  208. X    ----------
  209. X        License fees are not payable if you are using this code for 
  210. X        domestic purposes only.
  211. X
  212. X    Category B
  213. X    ----------
  214. X        Licence fees will be waived if you are a registered charity or
  215. X        non-profit organization providing that the derived works are
  216. X        purely for internal use.  The licence fee shall be considered
  217. X        a donation by Global Technology Group.  You are still encouraged
  218. X        to register your use with Global Technology Group.
  219. X
  220. X    Category C
  221. X    ----------
  222. X        Educational and research institutions are treated as if they
  223. X        are category B if the code or derived works are used
  224. X        primarily within teaching or research areas.  Administrative
  225. X        areas of such institutions using the software for commercial
  226. X        or quasi-commercial use shall be considered to be commercial
  227. X        users (categories D or E).  You are required to contact
  228. X        Global Technology Group within 30 days of executable
  229. X        programs being used so we may assess if a licence fee is
  230. X        applicable.
  231. X
  232. X    Category D
  233. X    ----------
  234. X        Commercial organizations are permitted to use this product 
  235. X        internally at no charge providing that the use of any particular 
  236. X        derived work does not extend beyond your immediate work group, 
  237. X        in which case you are considered a software developer.
  238. X
  239. X        If an executable is available to or processes data of more than
  240. X        16 users, then it is considered use outside your workgroup.
  241. X
  242. X        Category D users must register their use of the software within
  243. X        30 days of the executable being used on production data.
  244. X
  245. X
  246. X    Category E
  247. X    ----------
  248. X        Category E includes commercial software developers, commercial
  249. X        organizations making wide use of the software and information
  250. X        technology consultancies (including consultancies internal to
  251. X        a commercial organization).
  252. X
  253. X        You must register your use of the software within 30 days of the
  254. X        executable being invoiced or delivered to a client for testing.
  255. X        A licence fee will be applicable depending on your use of our 
  256. X        product.  You are strongly encouraged to contact us when planning 
  257. X        your product.
  258. X
  259. X        Software developers are also referred to conditions for category 
  260. X        F users should your potential clients fall into this category.
  261. X
  262. X
  263. X    Category F
  264. X    ----------
  265. X        Category F users include any military organization or weapons 
  266. X        systems developer.  This product must not be used to assist in 
  267. X        the sale, procurement, development, testing, manufacturing or 
  268. X        usage of any offensive weapon.
  269. X
  270. X        This product may however be used by category VI users for purely
  271. X        defensive hardware.  For example, you can use it to develop a
  272. X        shield but not a sword.  It must not be used in the deployment 
  273. X        of troops or equipment in combat, except for non-combatant units 
  274. X        such as medical personnel.
  275. X
  276. X        These conditions do not apply to United Nations military forces or
  277. X        administration, where categories D and E are relevant.
  278. X    
  279. X6.    Licence Fees
  280. X    Licence fees take into consideration the contribution this software
  281. X    makes to your product and the use you make of it.  Licence fees are
  282. X    payable once-only unless you wish to receive support from Global
  283. X    Technology Group or are making repeated sales or releases of
  284. X    this software or derived works.
  285. X
  286. X7.    Support
  287. X    Support and further documentation may be negotiated with Global 
  288. X    Technology Group.  This software is provided "as-is".  All
  289. X    responsibility for deciding on the suitability and use rests
  290. X    with the licensee.
  291. X
  292. X8.    General
  293. X    Global Technology Group offers a range of services in the computing
  294. X    fields.  These include personnel services, where we deal with both
  295. X    contractors and permanent staff.  Other more general consulting
  296. X    services are also available, with an emphasis on UNIX and Oracle.
  297. X
  298. X9.    Information required for registration
  299. X    Name
  300. X    Position
  301. X    Organization
  302. X    Organization's address
  303. X    Phone number
  304. X    Fax number
  305. X    Email address
  306. X
  307. X    Describe the core business of your organization and workgroup.
  308. X
  309. X    Where did you obtain the software ?
  310. X
  311. X    What category licensee do you believe is applicable to you ?
  312. X
  313. X    Describe desirable update policy and support.
  314. X
  315. X    Do you wish to participate in a user forum for this software ?
  316. X
  317. X    Describe target machines and operating systems, including version
  318. X    numbers.
  319. X
  320. X    What are the applications for which the software is used ?
  321. X
  322. X    How many people may access the software or derived works ?
  323. X
  324. X    How many people have their data processed by the software or derived 
  325. X    works ?
  326. X
  327. X    Describe the pricing structure of any derived works you sell for
  328. X    profit or the fees charged when using this software or derived works
  329. X    as part of a consultancy.
  330. X
  331. X    Which type of licence do you consider relevant ?
  332. X        A.    Site licence
  333. X        B.    Software developer's licence (one off)
  334. X        C.    Software developer's licence per units sold.
  335. X
  336. X    Do you agree to re-register the software with Global Technology Group
  337. X    when usage of the software changes ?
  338. X
  339. X10.    Contact Mechanisms
  340. X    Global Technology Group
  341. X    179 Grattan Street
  342. X    Carlton, Victoria, 3053
  343. X    AUSTRALIA
  344. X    Phone:    (03) 347-7511
  345. X    Fax:    (03) 347-0182
  346. X    Email:    dtb@otto.bf.rmit.oz.au
  347. END_OF_FILE
  348. if test 7260 -ne `wc -c <'LICENCE'`; then
  349.     echo shar: \"'LICENCE'\" unpacked with wrong size!
  350. fi
  351. # end of 'LICENCE'
  352. fi
  353. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  354.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  355. else
  356. echo shar: Extracting \"'MANIFEST'\" \(1800 characters\)
  357. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  358. X   File Name        Archive #    Description
  359. X-----------------------------------------------------------
  360. X FileList                   1    List of basic files
  361. X FileMap                    1    Mappings for non-UNIX systems
  362. X LICENCE                    2    Licence information
  363. X MANIFEST                   1    This file
  364. X Makefile                   2    Make control file
  365. X README                     1    READ this first
  366. X sv_cat.c                   1    Library function
  367. X sv_cpy.c                   1    Library function
  368. X sv_dup.c                   1    Library function
  369. X sv_ncat.c                  1    Library function
  370. X sv_ncpy.c                  1    Library function
  371. X sv_sub.c                   1    Library function
  372. X v_alloc.c                  1    Library function
  373. X v_cmp.c                    1    Library function
  374. X v_crspn.c                  1    Library function
  375. X v_cspn.c                   1    Library function
  376. X v_data.c                   1    Library function
  377. X v_len.c                    1    Library function
  378. X v_ncmp.c                   1    Library function
  379. X v_rspn.c                   1    Library function
  380. X v_set.c                    1    Library function
  381. X v_slen.c                   1    Library function
  382. X v_spn.c                    1    Library function
  383. X v_vers.c                   1    Library function
  384. X vch.h                      2    Library function
  385. X vs_cat.c                   1    Library function
  386. X vs_cpy.c                   1    Library function
  387. X vs_dup.c                   1    Library function
  388. X vs_ncat.c                  1    Library function
  389. X vs_ncpy.c                  1    Library function
  390. X vv_cat.c                   1    Library function
  391. X vv_cpy.c                   1    Library function
  392. X vv_dup.c                   1    Library function
  393. X vv_ncat.c                  1    Library function
  394. X vv_ncpy.c                  1    Library function
  395. X vv_rtrim.c                 1    Library function
  396. END_OF_FILE
  397. if test 1800 -ne `wc -c <'MANIFEST'`; then
  398.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  399. fi
  400. # end of 'MANIFEST'
  401. fi
  402. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  403.   echo shar: Will not clobber existing file \"'Makefile'\"
  404. else
  405. echo shar: Extracting \"'Makefile'\" \(4886 characters\)
  406. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  407. X#!/bin/make
  408. X########################################################################
  409. X# $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/Makefile,v $
  410. X# $Revision: 1.1 $
  411. X# $Date: 1992/11/17 05:50:08 $
  412. X# $State: Exp $
  413. X# $Locker:  $
  414. X# $Author: dtb $
  415. X########################################################################
  416. X# 
  417. X# $Log: Makefile,v $
  418. X# Revision 1.1  1992/11/17  05:50:08  dtb
  419. X# initial real cut
  420. X#
  421. X# 
  422. X########################################################################
  423. X# Description
  424. X# Control file for make(1) to build up the varchar library which allows
  425. X# conversion between standard C strings and Oracle varchars as well as
  426. X# various utility functions that operate on varchars but are similar to
  427. X# those found in string.h
  428. X########################################################################
  429. X
  430. X########################################################################
  431. X# Variables for the C compiler
  432. X########################################################################
  433. XCC = cc
  434. XCCOPTS = -O
  435. X
  436. X########################################################################
  437. X# Variables for installation
  438. X#    LIBINSTALLDIR    Directory in which library will be installed
  439. X#    HDRINSTALLDIR    Directory in which header will be installed
  440. X#    INST_USR        User name for ownership of installed files
  441. X#    INST_GRP        Group name for ownership of installed files
  442. X########################################################################
  443. XLIBINSTALLDIR = $(ORACLE_HOME)/local/lib
  444. XHDRINSTALLDIR = $(ORACLE_HOME)/local/include
  445. XINST_USR = oracle
  446. XINST_GRP = dba
  447. X
  448. X########################################################################
  449. X# Variables for names of objects, etc
  450. X#    These will not usually need to be altered unless you add or delete
  451. X#    various functions.
  452. X#    LIBNAME        Name of library file to be built
  453. X#    LIBOBJ        Objects to be included in library
  454. X#    VCHOBJ        Objects forming part of this package
  455. X########################################################################
  456. XLIBNAME = libvch.a
  457. X
  458. XLIBOBJ = \
  459. X    sv_cat.o    sv_cpy.o    sv_dup.o    sv_ncat.o \
  460. X    sv_ncpy.o    sv_sub.o    v_alloc.o    v_cmp.o    \
  461. X    v_crspn.o    v_cspn.o    v_data.o    v_len.o    \
  462. X    v_ncmp.o    v_rspn.o    v_set.o        v_slen.o \
  463. X    v_spn.o        v_vers.o    vs_cat.o    vs_cpy.o \
  464. X    vs_dup.o    vs_ncat.o    vs_ncpy.o    vv_cat.o \
  465. X    vv_cpy.o    vv_dup.o    vv_ncat.o    vv_ncpy.o \
  466. X    vv_rtrim.o
  467. X
  468. XVCHOBJ = $(LIBOBJ)
  469. X
  470. X########################################################################
  471. X# Definitions of targets
  472. X#    all            Builds everything but does not install it
  473. X#    install        Installs existing made objects
  474. X#    clean        Cleans up temporary files
  475. X########################################################################
  476. X
  477. Xall : $(VCHOBJ) $(LIBNAME)
  478. X
  479. Xclean :
  480. X    - rm *.o *.a
  481. X    - ls *.pc | sed 's/pc$$/c/' | xargs rm
  482. X
  483. Xinstall : $(LIBINSTALLDIR)/$(LIBNAME) $(HDRINSTALLDIR)/vch.h
  484. X
  485. X$(LIBNAME) : $(LIBOBJ)
  486. X    ar -ruv $(LIBNAME) $(LIBOBJ)
  487. X
  488. X$(LIBINSTALLDIR)/$(LIBNAME) : $(LIBNAME)
  489. X    cp $(LIBNAME) $(LIBINSTALLDIR)/$(LIBNAME)
  490. X    chmod 644 $(LIBINSTALLDIR)/$(LIBNAME)
  491. X    chgrp $(INST_GRP) $(LIBINSTALLDIR)/$(LIBNAME)
  492. X    chown $(INST_USR) $(LIBINSTALLDIR)/$(LIBNAME)
  493. X
  494. X$(HDRINSTALLDIR)/vch.h : vch.h
  495. X    cp vch.h $(HDRINSTALLDIR)/vch.h
  496. X    chmod 644 $(HDRINSTALLDIR)/vch.h
  497. X    chgrp $(INST_GRP) $(HDRINSTALLDIR)/vch.h
  498. X    chown $(INST_USR) $(HDRINSTALLDIR)/vch.h
  499. X
  500. X########################################################################
  501. X# YOU WILL NOT REALLY NEED TO ALTER ANYTHING BELOW THIS LINE
  502. X########################################################################
  503. X
  504. Xsv_cat.o    : sv_cat.c vch.h
  505. X    $(CC) -c $(CCOPTS) $*.c
  506. X
  507. Xsv_cpy.o    : sv_cpy.c vch.h
  508. X    $(CC) -c $(CCOPTS) $*.c
  509. X
  510. Xsv_dup.o    : sv_dup.c vch.h
  511. X    $(CC) -c $(CCOPTS) $*.c
  512. X
  513. Xsv_ncat.o    : sv_ncat.c vch.h
  514. X    $(CC) -c $(CCOPTS) $*.c
  515. X
  516. Xsv_ncpy.o    : sv_ncpy.c vch.h
  517. X    $(CC) -c $(CCOPTS) $*.c
  518. X
  519. Xv_alloc.o    : v_alloc.c vch.h
  520. X    $(CC) -c $(CCOPTS) $*.c
  521. X
  522. Xv_cmp.o    : v_cmp.c vch.h
  523. X    $(CC) -c $(CCOPTS) $*.c
  524. X
  525. Xv_data.o    : v_data.c vch.h
  526. X    $(CC) -c $(CCOPTS) $*.c
  527. X
  528. Xv_len.o    : v_len.c vch.h
  529. X    $(CC) -c $(CCOPTS) $*.c
  530. X
  531. Xv_ncmp.o    : v_ncmp.c vch.h
  532. X    $(CC) -c $(CCOPTS) $*.c
  533. X
  534. Xv_set.o    : v_set.c vch.h
  535. X    $(CC) -c $(CCOPTS) $*.c
  536. X
  537. Xv_slen.o    : v_len.c vch.h
  538. X    $(CC) -c $(CCOPTS) $*.c
  539. X
  540. Xv_vers.o    : v_vers.c vch.h
  541. X    $(CC) -c $(CCOPTS) $*.c
  542. X
  543. Xvs_cat.o    : vs_cat.c vch.h
  544. X    $(CC) -c $(CCOPTS) $*.c
  545. X
  546. Xvs_cpy.o    : vs_cpy.c vch.h
  547. X    $(CC) -c $(CCOPTS) $*.c
  548. X
  549. Xvs_crspn.o    : vs_crspn.c vch.h
  550. X    $(CC) -c $(CCOPTS) $*.c
  551. X
  552. Xvs_cspn.o    : vs_cspn.c vch.h
  553. X    $(CC) -c $(CCOPTS) $*.c
  554. X
  555. Xvs_dup.o    : vs_dup.c vch.h
  556. X    $(CC) -c $(CCOPTS) $*.c
  557. X
  558. Xvs_ncat.o    : vs_ncat.c vch.h
  559. X    $(CC) -c $(CCOPTS) $*.c
  560. X
  561. Xvs_ncpy.o    : vs_ncpy.c vch.h
  562. X    $(CC) -c $(CCOPTS) $*.c
  563. X
  564. Xvs_rspn.o    : vs_rspn.c vch.h
  565. X    $(CC) -c $(CCOPTS) $*.c
  566. X
  567. Xvs_spn.o    : vs_spn.c vch.h
  568. X    $(CC) -c $(CCOPTS) $*.c
  569. X
  570. Xvv_cat.o    : vv_cat.c vch.h
  571. X    $(CC) -c $(CCOPTS) $*.c
  572. X
  573. Xvv_cpy.o    : vv_cpy.c vch.h
  574. X    $(CC) -c $(CCOPTS) $*.c
  575. X
  576. Xvv_dup.o    : vv_dup.c vch.h
  577. X    $(CC) -c $(CCOPTS) $*.c
  578. X
  579. Xvv_ncat.o    : vv_ncat.c vch.h
  580. X    $(CC) -c $(CCOPTS) $*.c
  581. X
  582. Xvv_ncpy.o    : vv_ncpy.c vch.h
  583. X    $(CC) -c $(CCOPTS) $*.c
  584. X
  585. Xvv_rtrim.o    : vv_rtrim.c vch.h
  586. X    $(CC) -c $(CCOPTS) $*.c
  587. X
  588. END_OF_FILE
  589. if test 4886 -ne `wc -c <'Makefile'`; then
  590.     echo shar: \"'Makefile'\" unpacked with wrong size!
  591. fi
  592. # end of 'Makefile'
  593. fi
  594. if test -f 'README' -a "${1}" != "-c" ; then 
  595.   echo shar: Will not clobber existing file \"'README'\"
  596. else
  597. echo shar: Extracting \"'README'\" \(5773 characters\)
  598. sed "s/^X//" >'README' <<'END_OF_FILE'
  599. X                    README FOR VARCHAR LIBRARY
  600. X                    ==========================
  601. X
  602. XPurpose
  603. X-------
  604. X
  605. X    Allows C programmers to deal with Oracle varchar types without
  606. X    the need to put your code through the Oracle Pro*C precompiler.
  607. X    Apart from allowing you to declare and address varchars in
  608. X    "normal" C, various functions are provided to let you move
  609. X    information between varchars and standard strings.
  610. X
  611. X    Hacking the header file should allow these functions to be used
  612. X    with Ingres varchars as well.
  613. X
  614. X    In general, when moving from a varchar to a string, a null
  615. X    character to terminate the string will be provided.  When moving
  616. X    from a string to a varchar, terminating nulls are not considered
  617. X    part of the data, but are usually transferred.
  618. X
  619. X    Functions provided to access varchars are patterned on the
  620. X    string functions of standard C.
  621. X
  622. X    In general, if you want to convert between varchars and binary
  623. X    memory, the conversion functions will not be very useful.  Such
  624. X    functions are essentially trivial.
  625. X
  626. XPortability
  627. X-----------
  628. X
  629. X    The functions have been written in ANSI C style for a system V
  630. X    platform.  If you are porting to BSD, you will need to check out
  631. X    the difference between <string.h> and <strings.h>.  Functions
  632. X    declared in <memory.h> of system V have analogues in BSD that a
  633. X    couple of definitions in vch.h should fix up.  An example would
  634. X    be to convert calls to memcpy() to use bcpy() instead.
  635. X
  636. X    I managed a port to SunOS 4.1, in under an hour.
  637. X
  638. X    Porting to MS-DOS has not been considered apart from keeping file
  639. X    names unique within DOS limits.
  640. X
  641. XHistory
  642. X-------
  643. X
  644. X    This package was started back in 1986 when I first started to
  645. X    work with Oracle.  It has been reworked a number of times since
  646. X    then.
  647. X
  648. X    After comp.databases.oracle was started, I mentioned I had some
  649. X    of these functions available and received quite a few requests.
  650. X    Unfortunately, before I could post it, my disk got blown away
  651. X    and the version I posted was the wrong backup and had a number
  652. X    of bugs and documentation errors.
  653. X
  654. X    This version has been more thoroughly tested and some of the
  655. X    functions have altered in their parameters and the way they
  656. X    work from the previous release.
  657. X
  658. X    The current version has copyright partially assigned to Global
  659. X    Technology Group.  This basically means that there are
  660. X    limitations on the use of this code for commercial purposes.
  661. X
  662. X    Read the LICENCE file for details.
  663. X
  664. XMaking the library
  665. X-----------------
  666. X
  667. X    First, read and edit the Makefile.  You may need to create the
  668. X    target directories.  Then it should simply be a matter of :
  669. X        make all
  670. X        make install
  671. X
  672. X    If you have Pro*C, it is worth checking out whether the type
  673. X    information in vch.h is appropriate.  Precompile the following
  674. X
  675. X        EXEC SQL BEGIN DECLARE SECION;
  676. X        varchar    testvar[20];
  677. X        EXEC SQL END DECLARE SECTION;
  678. X
  679. X    then check out the C file produced.  This will give you clues to
  680. X    editing vch.h.
  681. X
  682. XUsing varchar pointers with Pro*C objects
  683. X-----------------------------------------
  684. X
  685. X    When getting data from Oracle variables into varchars using
  686. X    Pro*C, there are a few things of which to be aware.  The major
  687. X    thing is that if the binding is a pointer, the current length is
  688. X    considered the maximum allowed length.  If you are passing Vchmin
  689. X    pointers to such routines, you may want to co-erce the length to
  690. X    the desired maximum first - providing that the routines do not
  691. X    read the data.  Similar problems exist with standard C strings.
  692. X
  693. X    See the Oracle documentation for details - or better still, look
  694. X    at the output from Pro*C.
  695. X
  696. XWhy not use Pro*C ?
  697. X-------------------
  698. X
  699. X    Basically, Pro*C does not compare favorably with the standard C
  700. X    precompiler, and has a few nasty limitations including
  701. X
  702. X        input and output line length
  703. X            This causes the precompiler to barf regularly on version
  704. X            control and other long strings.  The absolute limit for
  705. X            both is 127 characters, but it defaults to less.
  706. X
  707. X        no ability for symbol replacement
  708. X            You cannot define a value for a symbol - thus you need
  709. X            to hardcode all varchar lengths.
  710. X
  711. X        scope
  712. X            Variables are considered by the precompiler to have file
  713. X            scope rather than the scope in which they are declared.
  714. X            This leads to a number of unexpected compile failures
  715. X            and namespace conflicts.
  716. X
  717. X    Also, debugging and profiling is made more difficult when using
  718. X    Pro*C.
  719. X
  720. X    Simply, for a whole heap of reasons you will probably prefer to
  721. X    write many functions in C and avoid the precompiler except for
  722. X    the times you are actually interracting with the Oracle engine.
  723. X
  724. XMiscellaneous Files
  725. X-------------------
  726. X
  727. X    FileMap
  728. X    A file called FileMap contains information to map filenames
  729. X    between UNIX and non-case sensitive filesystems.  Fields are
  730. X    colon separated.  If you got these files via DOS or VMS, then
  731. X    you will need to change the filenames using this information.
  732. X
  733. X    Filelist
  734. X    List of files in this package
  735. X
  736. X    LICENCE
  737. X    Read this file to check out limitations on the use of this code.
  738. X
  739. X    MANIFEST
  740. X    Used by makekit(1) to create a shar file.
  741. X
  742. XNotes
  743. X-----
  744. X
  745. X    Currently, Oracle has a maximum length for strings of 255.  It used
  746. X    to be 240.  This code imposes no such limitations.
  747. X
  748. X    You do not need Pro*C to compile these routines.
  749. X
  750. X    These routines do not reference any Oracle provided function or
  751. X    variable - so they could even be used without any Oracle libraries
  752. X    to help manage a similarly structured datatype.
  753. X
  754. XBug Reports
  755. X-----------
  756. X
  757. X    Please send any reports of bugs, comments or religious disputes to
  758. X    one of my addresses below.
  759. X
  760. XTo Do
  761. X-----
  762. X    I am writing up a manual page at the moment
  763. X
  764. X
  765. XDavid T. Bath                                 | Email: dtb@otto.bf.rmit.oz.au
  766. XSenior Technical Consultant                   | Phone: (03) 347-7511
  767. XGlobal Technology Group                       | Fax  : (03) 347-0182
  768. X179 Grattan St, CARLTON, VIC, 3053, AUSTRALIA | #include <disclaimer.h>
  769. END_OF_FILE
  770. if test 5773 -ne `wc -c <'README'`; then
  771.     echo shar: \"'README'\" unpacked with wrong size!
  772. fi
  773. # end of 'README'
  774. fi
  775. if test -f 'sv_cat.c' -a "${1}" != "-c" ; then 
  776.   echo shar: Will not clobber existing file \"'sv_cat.c'\"
  777. else
  778. echo shar: Extracting \"'sv_cat.c'\" \(1669 characters\)
  779. sed "s/^X//" >'sv_cat.c' <<'END_OF_FILE'
  780. X/***********************************************************************
  781. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_cat.c,v $
  782. X* $Revision: 1.1 $
  783. X* $Date: 1992/11/17 05:50:08 $
  784. X* $State: Exp $
  785. X* $Locker:  $
  786. X* $Author: dtb $
  787. X************************************************************************
  788. X* 
  789. X* $Log: sv_cat.c,v $
  790. X* Revision 1.1  1992/11/17  05:50:08  dtb
  791. X* initial real cut
  792. X*
  793. X* 
  794. X************************************************************************
  795. X* Description
  796. X*    Appends varchar to string
  797. X***********************************************************************/
  798. X
  799. 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 $" ;
  800. X
  801. X#include <stdio.h>
  802. X#include <string.h>
  803. X#include <memory.h>
  804. X#include "vch.h"
  805. X
  806. X/***********************************************************************
  807. X* NAME
  808. X*     str_vchcat()
  809. X* PURPOSE
  810. X*     Add varchar to end of string
  811. X* SYNOPSIS
  812. X*     str_vchcat (s, v)
  813. X*     char     *s;
  814. X*     struct vch_min *v;
  815. X* DESCRIPTION
  816. X*     This function copies the data from a varchar to its length (or to
  817. X*     a null, whichever is first) onto the end of a standard C string and 
  818. X*    returns a pointer to the result.  Unlike strcat, however, a null
  819. X*    character will be placed on the end.
  820. X***********************************************************************/
  821. Xchar     *    str_vchcat
  822. X    (
  823. X    char     *    s,
  824. X    Vchmin    *    v
  825. X    )
  826. X{
  827. X    int newlen = -1;    /* Set to -1 initially */
  828. X    if (memchr(v->arr, '\0', v->len) == NULL) 
  829. X        newlen = strlen (s) + v->len;
  830. X    strncat (s, v->arr, v->len);    /* Copy the basic data */
  831. X    if (newlen >= 0)    /* No null characters, put it in by hand */
  832. X        *(s + newlen) = '\0';
  833. X
  834. X    return (s);
  835. X}
  836. X
  837. END_OF_FILE
  838. if test 1669 -ne `wc -c <'sv_cat.c'`; then
  839.     echo shar: \"'sv_cat.c'\" unpacked with wrong size!
  840. fi
  841. # end of 'sv_cat.c'
  842. fi
  843. if test -f 'sv_cpy.c' -a "${1}" != "-c" ; then 
  844.   echo shar: Will not clobber existing file \"'sv_cpy.c'\"
  845. else
  846. echo shar: Extracting \"'sv_cpy.c'\" \(1489 characters\)
  847. sed "s/^X//" >'sv_cpy.c' <<'END_OF_FILE'
  848. X/***********************************************************************
  849. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_cpy.c,v $
  850. X* $Revision: 1.1 $
  851. X* $Date: 1992/11/17 05:50:09 $
  852. X* $State: Exp $
  853. X* $Locker:  $
  854. X* $Author: dtb $
  855. X************************************************************************
  856. X* 
  857. X* $Log: sv_cpy.c,v $
  858. X* Revision 1.1  1992/11/17  05:50:09  dtb
  859. X* initial real cut
  860. X*
  861. X* 
  862. X************************************************************************
  863. X* Description
  864. X*    Copies varchar to string
  865. X***********************************************************************/
  866. X
  867. 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 $" ;
  868. X
  869. X#include <stdio.h>
  870. X#include <string.h>
  871. X#include <memory.h>
  872. X#include "vch.h"
  873. X
  874. X/***********************************************************************
  875. X* NAME
  876. X*     str_vchcpy()
  877. X* PURPOSE
  878. X*     Copy the string from a varchar into standard C string
  879. X* SYNOPSIS
  880. X*     str_vchcpy (s, v)
  881. X*     char     *s;
  882. X*     Vchmin *v;
  883. X* DESCRIPTION
  884. X*     This function copies the data from a varchar to the length (or to
  885. X*     a null, whichever is first) into a standard C string and returns
  886. X*     the pointer to the result.  A null character is placed at the end
  887. X*    of the string.
  888. X***********************************************************************/
  889. Xchar     *str_vchcpy 
  890. X    (
  891. X    char     *s,
  892. X    Vchmin    *v 
  893. X    )
  894. X{
  895. X    strncpy (s, v->arr, v->len);
  896. X    if (memchr(s, '\0', v->len) == NULL)
  897. X        *(s+(v->len)) = '\0';
  898. X    return (s);
  899. X}
  900. X
  901. END_OF_FILE
  902. if test 1489 -ne `wc -c <'sv_cpy.c'`; then
  903.     echo shar: \"'sv_cpy.c'\" unpacked with wrong size!
  904. fi
  905. # end of 'sv_cpy.c'
  906. fi
  907. if test -f 'sv_dup.c' -a "${1}" != "-c" ; then 
  908.   echo shar: Will not clobber existing file \"'sv_dup.c'\"
  909. else
  910. echo shar: Extracting \"'sv_dup.c'\" \(1457 characters\)
  911. sed "s/^X//" >'sv_dup.c' <<'END_OF_FILE'
  912. X/***********************************************************************
  913. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_dup.c,v $
  914. X* $Revision: 1.1 $
  915. X* $Date: 1992/11/17 05:50:09 $
  916. X* $State: Exp $
  917. X* $Locker:  $
  918. X* $Author: dtb $
  919. X************************************************************************
  920. X* 
  921. X* $Log: sv_dup.c,v $
  922. X* Revision 1.1  1992/11/17  05:50:09  dtb
  923. X* initial real cut
  924. X*
  925. X* 
  926. X************************************************************************
  927. X* Description
  928. X*    Duplicates varchar as string
  929. X***********************************************************************/
  930. X
  931. 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 $" ;
  932. X
  933. X#include <stdio.h>
  934. X#include <string.h>
  935. X#include <memory.h>
  936. X#include "vch.h"
  937. X
  938. X/***********************************************************************
  939. X* NAME
  940. X*     str_vchdup()
  941. X* PURPOSE
  942. X*     Duplicate varchar as string
  943. X* SYNOPSIS
  944. X*     str_vchdup (v)
  945. X*     Vchmin *v;
  946. X* DESCRIPTION
  947. X*     Allocates and copies a varchar into a standard C string.  If
  948. X*    necessary, extra bytes will be allocated for a terminating null
  949. X*    character.
  950. X************************************************************************/
  951. Xchar     *str_vchdup
  952. X    (
  953. X    Vchmin    *v
  954. X    )
  955. X{
  956. X    char     *d = NULL;
  957. X    int        vlen;
  958. X
  959. X    if (v != NULL) {
  960. X        vlen = vch_strlen (v);
  961. X        if ((d = (char *)malloc (vlen + 1)) != (char *)NULL) {
  962. X            memcpy (d, v->arr, vlen);
  963. X            *(d+(vlen)) = '\0';
  964. X        }
  965. X    }
  966. X    return (d);
  967. X}
  968. X
  969. END_OF_FILE
  970. if test 1457 -ne `wc -c <'sv_dup.c'`; then
  971.     echo shar: \"'sv_dup.c'\" unpacked with wrong size!
  972. fi
  973. # end of 'sv_dup.c'
  974. fi
  975. if test -f 'sv_ncat.c' -a "${1}" != "-c" ; then 
  976.   echo shar: Will not clobber existing file \"'sv_ncat.c'\"
  977. else
  978. echo shar: Extracting \"'sv_ncat.c'\" \(1715 characters\)
  979. sed "s/^X//" >'sv_ncat.c' <<'END_OF_FILE'
  980. X/***********************************************************************
  981. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_ncat.c,v $
  982. X* $Revision: 1.1 $
  983. X* $Date: 1992/11/17 05:50:09 $
  984. X* $State: Exp $
  985. X* $Locker:  $
  986. X* $Author: dtb $
  987. X************************************************************************
  988. X* 
  989. X* $Log: sv_ncat.c,v $
  990. X* Revision 1.1  1992/11/17  05:50:09  dtb
  991. X* initial real cut
  992. X*
  993. X* 
  994. X************************************************************************
  995. X* Description
  996. X*    Length limited append of varchar to string
  997. X*    type in a manner similar to the string handling library of C and
  998. X*    with a number of functions converting between VARCHARS and strings.
  999. X***********************************************************************/
  1000. X
  1001. 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 $" ;
  1002. X
  1003. X#include <stdio.h>
  1004. X#include <string.h>
  1005. X#include <memory.h>
  1006. X#include "vch.h"
  1007. X
  1008. X/***********************************************************************
  1009. X* NAME
  1010. X*     str_vchncat()
  1011. X* PURPOSE
  1012. X*     Add varchar to end of string
  1013. X* DESCRIPTION
  1014. X*     This function copies the data from a varchar to its length (or to
  1015. X*     a null, whichever is first) onto the end of a standard C string and 
  1016. X*    returns a pointer to the result up to a maximum of n bytes.  A null
  1017. X*    null character will be appended if none were found.
  1018. X***********************************************************************/
  1019. Xchar     *str_vchncat
  1020. X    (
  1021. X    char     *    s,
  1022. X    Vchmin    *    v,
  1023. X    unsigned int n
  1024. X    )
  1025. X{
  1026. X    int    newlen = -1;
  1027. X
  1028. X    if (n > v->len)
  1029. X        n = v->len;
  1030. X    if (memchr(v->arr, '\0', n) == NULL)
  1031. X        newlen = strlen (s) + n;
  1032. X    strncat (s, v->arr, n);
  1033. X    if (newlen >= 0)
  1034. X        *(s + newlen) = '\0';
  1035. X
  1036. X    return (s);
  1037. X}
  1038. X
  1039. END_OF_FILE
  1040. if test 1715 -ne `wc -c <'sv_ncat.c'`; then
  1041.     echo shar: \"'sv_ncat.c'\" unpacked with wrong size!
  1042. fi
  1043. # end of 'sv_ncat.c'
  1044. fi
  1045. if test -f 'sv_ncpy.c' -a "${1}" != "-c" ; then 
  1046.   echo shar: Will not clobber existing file \"'sv_ncpy.c'\"
  1047. else
  1048. echo shar: Extracting \"'sv_ncpy.c'\" \(1611 characters\)
  1049. sed "s/^X//" >'sv_ncpy.c' <<'END_OF_FILE'
  1050. X/***********************************************************************
  1051. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_ncpy.c,v $
  1052. X* $Revision: 1.1 $
  1053. X* $Date: 1992/11/17 05:50:10 $
  1054. X* $State: Exp $
  1055. X* $Locker:  $
  1056. X* $Author: dtb $
  1057. X************************************************************************
  1058. X* 
  1059. X* $Log: sv_ncpy.c,v $
  1060. X* Revision 1.1  1992/11/17  05:50:10  dtb
  1061. X* initial real cut
  1062. X*
  1063. X* 
  1064. X************************************************************************
  1065. X* Description
  1066. X*    Length limited copy of varchar to string
  1067. X***********************************************************************/
  1068. X
  1069. 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 $" ;
  1070. X
  1071. X#include <stdio.h>
  1072. X#include <string.h>
  1073. X#include <memory.h>
  1074. X#include "vch.h"
  1075. X
  1076. X/***********************************************************************
  1077. X* NAME
  1078. X*     str_vchncpy()
  1079. X* PURPOSE
  1080. X*     Copy the string from a varchar into standard C string length limited
  1081. X* SYNOPSIS
  1082. X*     str_vchncpy (s, v, n)
  1083. X*     char     *s;
  1084. X*     Vchmin *v;
  1085. X*     unsigned int n;
  1086. X* DESCRIPTION
  1087. X*     This function copies the data from a varchar to the length (or to
  1088. X*     a null, whichever is first) into a standard C string to a maximum
  1089. X*     length n and returns a pointer to the result.  Unlike strncpy, 
  1090. X*    however, a null character is always placed at the end of s.
  1091. X***********************************************************************/
  1092. Xchar     *str_vchncpy
  1093. X    (
  1094. X    char     *s,
  1095. X    Vchmin    *v,
  1096. X    unsigned int n
  1097. X    )
  1098. X{
  1099. X    int vlen;
  1100. X
  1101. X    if (n > (vlen = vch_strlen(v)))
  1102. X        n = vlen;
  1103. X    strncpy (s, v->arr, n);
  1104. X    *(s+n)='\0';
  1105. X    return (s);
  1106. X}
  1107. X
  1108. END_OF_FILE
  1109. if test 1611 -ne `wc -c <'sv_ncpy.c'`; then
  1110.     echo shar: \"'sv_ncpy.c'\" unpacked with wrong size!
  1111. fi
  1112. # end of 'sv_ncpy.c'
  1113. fi
  1114. if test -f 'sv_sub.c' -a "${1}" != "-c" ; then 
  1115.   echo shar: Will not clobber existing file \"'sv_sub.c'\"
  1116. else
  1117. echo shar: Extracting \"'sv_sub.c'\" \(1726 characters\)
  1118. sed "s/^X//" >'sv_sub.c' <<'END_OF_FILE'
  1119. X
  1120. X/***********************************************************************
  1121. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/sv_sub.c,v $
  1122. X* $Revision: 1.1 $
  1123. X* $Date: 1992/11/17 05:50:10 $
  1124. X* $State: Exp $
  1125. X* $Locker:  $
  1126. X* $Author: dtb $
  1127. X************************************************************************
  1128. X* 
  1129. X* $Log: sv_sub.c,v $
  1130. X* Revision 1.1  1992/11/17  05:50:10  dtb
  1131. X* initial real cut
  1132. X*
  1133. X* 
  1134. X************************************************************************
  1135. X* Description
  1136. X*    Extracts substring of varchar to string.
  1137. X***********************************************************************/
  1138. X
  1139. 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 $" ;
  1140. X
  1141. X#include <stdio.h>
  1142. X#include <string.h>
  1143. X#include <memory.h>
  1144. X#include "vch.h"
  1145. X
  1146. X/***********************************************************************
  1147. X* NAME
  1148. X*     str_vchsub()
  1149. X* PURPOSE
  1150. X*     Extracts substring of varchar to standard C string
  1151. X* DESCRIPTION
  1152. X*     This function copies the data from a varchar to the length (or to
  1153. X*     a null, whichever is first) into a standard C string to a maximum
  1154. X*     length n and returns a pointer to the result.  Unlike strncpy, 
  1155. X*    however, a null character is always placed at the end of s.
  1156. X***********************************************************************/
  1157. Xchar     *    str_vchsub
  1158. X    (
  1159. X    char         *s,
  1160. X    Vchmin        *v,
  1161. X    unsigned    offset,
  1162. X    unsigned    len
  1163. X    )
  1164. X{
  1165. X    int vlen;
  1166. X
  1167. X    vlen = vch_strlen(v);    /* Current "string length" of varchar */
  1168. X
  1169. X    *s = '\0';
  1170. X    if (offset < vlen) {
  1171. X        /* Does not start past the "string length" of the varchar */
  1172. X        if (len > vlen - offset)
  1173. X            len = vlen - offset;
  1174. X        strncpy (s, (char *)(v->arr + offset), len);
  1175. X        *(s + len) = '\0';
  1176. X    }
  1177. X    return (s);
  1178. X}
  1179. X
  1180. END_OF_FILE
  1181. if test 1726 -ne `wc -c <'sv_sub.c'`; then
  1182.     echo shar: \"'sv_sub.c'\" unpacked with wrong size!
  1183. fi
  1184. # end of 'sv_sub.c'
  1185. fi
  1186. if test -f 'v_alloc.c' -a "${1}" != "-c" ; then 
  1187.   echo shar: Will not clobber existing file \"'v_alloc.c'\"
  1188. else
  1189. echo shar: Extracting \"'v_alloc.c'\" \(1428 characters\)
  1190. sed "s/^X//" >'v_alloc.c' <<'END_OF_FILE'
  1191. X/***********************************************************************
  1192. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_alloc.c,v $
  1193. X* $Revision: 1.1 $
  1194. X* $Date: 1992/11/17 05:50:10 $
  1195. X* $State: Exp $
  1196. X* $Locker:  $
  1197. X* $Author: dtb $
  1198. X************************************************************************
  1199. X* 
  1200. X* $Log: v_alloc.c,v $
  1201. X* Revision 1.1  1992/11/17  05:50:10  dtb
  1202. X* initial real cut
  1203. X*
  1204. X* 
  1205. X************************************************************************
  1206. X* Description
  1207. X*    Allocates space for a varchar
  1208. X***********************************************************************/
  1209. X
  1210. 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 $" ;
  1211. X
  1212. X#include <stdio.h>
  1213. X#include <string.h>
  1214. X#include <memory.h>
  1215. X#include "vch.h"
  1216. X
  1217. X/***********************************************************************
  1218. X* NAME
  1219. X*     vch_alloc()
  1220. X* PURPOSE
  1221. X*     Allocate storage for a varchar
  1222. X* SYNOPSIS
  1223. X*     Vchmin *vch_alloc(n)
  1224. X*     VCH_LEN_TYPE     n;
  1225. X* DESCRIPTION
  1226. X*     Allocates storage for a varchar with data length n.  Actually,
  1227. X*     the storage requirement will be rounded up to a multiple of 2
  1228. X*     to be "neat".
  1229. X***********************************************************************/
  1230. XVchmin     *vch_alloc
  1231. X    (
  1232. X    VCH_LEN_TYPE     n
  1233. X    )
  1234. X{
  1235. X    int     size_req;
  1236. X    size_req = sizeof (struct vch_min) + n - VCH_MIN_ARR_LEN ;
  1237. X    size_req += size_req % 2;
  1238. X    return ( (Vchmin *) malloc (size_req) );
  1239. X}
  1240. X
  1241. END_OF_FILE
  1242. if test 1428 -ne `wc -c <'v_alloc.c'`; then
  1243.     echo shar: \"'v_alloc.c'\" unpacked with wrong size!
  1244. fi
  1245. # end of 'v_alloc.c'
  1246. fi
  1247. if test -f 'v_cmp.c' -a "${1}" != "-c" ; then 
  1248.   echo shar: Will not clobber existing file \"'v_cmp.c'\"
  1249. else
  1250. echo shar: Extracting \"'v_cmp.c'\" \(1831 characters\)
  1251. sed "s/^X//" >'v_cmp.c' <<'END_OF_FILE'
  1252. X/***********************************************************************
  1253. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_cmp.c,v $
  1254. X* $Revision: 1.1 $
  1255. X* $Date: 1992/11/17 05:50:11 $
  1256. X* $State: Exp $
  1257. X* $Locker:  $
  1258. X* $Author: dtb $
  1259. X************************************************************************
  1260. X* 
  1261. X* $Log: v_cmp.c,v $
  1262. X* Revision 1.1  1992/11/17  05:50:11  dtb
  1263. X* initial real cut
  1264. X*
  1265. X* 
  1266. X************************************************************************
  1267. X* Description
  1268. X*    Compares varchar
  1269. X***********************************************************************/
  1270. X
  1271. 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 $" ;
  1272. X
  1273. X#include <stdio.h>
  1274. X#include <string.h>
  1275. X#include <memory.h>
  1276. X#include "vch.h"
  1277. X
  1278. X/***********************************************************************
  1279. X* NAME
  1280. X*     vch_cmp()
  1281. X* PURPOSE
  1282. X*     Compares varchars
  1283. X* SYNOPSIS
  1284. X*     vch_cmp (v1, v2)
  1285. X*     Vchmin *v1, *v2;
  1286. X* DESCRIPTION
  1287. X*     Compares v1 and v2 in manner similar to strcmp
  1288. X************************************************************************/
  1289. Xint     vch_cmp
  1290. X    (
  1291. X    Vchmin    *v1,
  1292. X    Vchmin    *v2 
  1293. X    )
  1294. X{
  1295. X    int        rval;        /* Return value */
  1296. X    int        cmplen;        /* Comparison length */
  1297. X    int        len1;
  1298. X    int        len2;
  1299. X    char    *mem1;
  1300. X    char    *mem2;
  1301. X
  1302. X    /* Set up defaults in local variables so NULL parameters do not dump */
  1303. X    len1 = len2 = 0;
  1304. X    mem1 = mem2 = NULL;
  1305. X
  1306. X    /* Get real values into local variables */
  1307. X    if (v1 != NULL) {
  1308. X        len1 = v1->len;
  1309. X        mem1 = (char *)v1->arr;
  1310. X    }
  1311. X    if (v2 != NULL) {
  1312. X        len2 = v2->len;
  1313. X        mem2 = (char *)v2->arr;
  1314. X    }
  1315. X
  1316. X    /* Do comparison up to common length */
  1317. X    cmplen = (len2 > len1) ? len2 : len1;
  1318. X    rval = memcmp (mem1, mem2, cmplen);
  1319. X
  1320. X    /* Adjust if same so far but one longer than the other */
  1321. X    if ((rval == 0) && (len1 != len2)) {
  1322. X        rval = (len1 > len2) ? 1 : -1;
  1323. X    }
  1324. X    return (rval);
  1325. X}
  1326. X
  1327. X
  1328. END_OF_FILE
  1329. if test 1831 -ne `wc -c <'v_cmp.c'`; then
  1330.     echo shar: \"'v_cmp.c'\" unpacked with wrong size!
  1331. fi
  1332. # end of 'v_cmp.c'
  1333. fi
  1334. if test -f 'v_crspn.c' -a "${1}" != "-c" ; then 
  1335.   echo shar: Will not clobber existing file \"'v_crspn.c'\"
  1336. else
  1337. echo shar: Extracting \"'v_crspn.c'\" \(1431 characters\)
  1338. sed "s/^X//" >'v_crspn.c' <<'END_OF_FILE'
  1339. X/***********************************************************************
  1340. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_crspn.c,v $
  1341. X* $Revision: 1.1 $
  1342. X* $Date: 1992/11/17 05:50:11 $
  1343. X* $State: Exp $
  1344. X* $Locker:  $
  1345. X* $Author: dtb $
  1346. X************************************************************************
  1347. X* 
  1348. X* $Log: v_crspn.c,v $
  1349. X* Revision 1.1  1992/11/17  05:50:11  dtb
  1350. X* initial real cut
  1351. X*
  1352. X* 
  1353. X************************************************************************
  1354. X* Description
  1355. X*    Returns number of characters in leader of varchar made entirely of
  1356. X*    characters in the string.
  1357. X***********************************************************************/
  1358. X
  1359. 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 $" ;
  1360. X
  1361. X#include <stdio.h>
  1362. X#include <string.h>
  1363. X#include "vch.h"
  1364. X
  1365. X/***********************************************************************
  1366. X* NAME
  1367. X*     vch_crspn()
  1368. X* DESCRIPTION
  1369. X*     Looks at the trailing data characters of the varchar v and checks
  1370. X*     which are in not the set of characters in the string s, returning the
  1371. X*    length of the matching span in v.
  1372. X************************************************************************/
  1373. Xint     vch_crspn
  1374. X    (
  1375. X    Vchmin    *v,
  1376. X    char     *s
  1377. X    )
  1378. X{
  1379. X    int            pos;
  1380. X    int            len;
  1381. X    char    *    vc;
  1382. X
  1383. X    vc    = (char *) ((v->arr)+(len=v->len)-1);
  1384. X    for (pos = 0; len--; pos++) {
  1385. X        if (strchr(s, *vc--) != NULL)
  1386. X            break;
  1387. X    }
  1388. X    return (pos);
  1389. X}
  1390. X
  1391. END_OF_FILE
  1392. if test 1431 -ne `wc -c <'v_crspn.c'`; then
  1393.     echo shar: \"'v_crspn.c'\" unpacked with wrong size!
  1394. fi
  1395. # end of 'v_crspn.c'
  1396. fi
  1397. if test -f 'v_cspn.c' -a "${1}" != "-c" ; then 
  1398.   echo shar: Will not clobber existing file \"'v_cspn.c'\"
  1399. else
  1400. echo shar: Extracting \"'v_cspn.c'\" \(1387 characters\)
  1401. sed "s/^X//" >'v_cspn.c' <<'END_OF_FILE'
  1402. X/***********************************************************************
  1403. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_cspn.c,v $
  1404. X* $Revision: 1.1 $
  1405. X* $Date: 1992/11/17 05:50:11 $
  1406. X* $State: Exp $
  1407. X* $Locker:  $
  1408. X* $Author: dtb $
  1409. X************************************************************************
  1410. X* 
  1411. X* $Log: v_cspn.c,v $
  1412. X* Revision 1.1  1992/11/17  05:50:11  dtb
  1413. X* initial real cut
  1414. X*
  1415. X* 
  1416. X************************************************************************
  1417. X* Description
  1418. X*    Returns number of characters in leader of varchar not made of
  1419. X*    characters in the string.
  1420. X***********************************************************************/
  1421. X
  1422. 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 $" ;
  1423. X
  1424. X#include <stdio.h>
  1425. X#include <string.h>
  1426. X#include <memory.h>
  1427. X#include "vch.h"
  1428. X
  1429. X/***********************************************************************
  1430. X* NAME
  1431. X*     vch_cspn()
  1432. X* DESCRIPTION
  1433. X*     Looks at the leading data characters of the varchar v and checks
  1434. X*     which are in the set of characters not in the string s, returning
  1435. X*    the length of the matching span in v.
  1436. X************************************************************************/
  1437. Xint     vch_cspn
  1438. X    (
  1439. X    Vchmin    *v,
  1440. X    char     *s
  1441. X    )
  1442. X{
  1443. X    int    pos;
  1444. X
  1445. X    for (pos = 0; pos <= v->len; pos++) {
  1446. X        if (strchr(s, *(v->arr)+pos) != NULL)
  1447. X            break;
  1448. X    }
  1449. X    return (pos);
  1450. X}
  1451. END_OF_FILE
  1452. if test 1387 -ne `wc -c <'v_cspn.c'`; then
  1453.     echo shar: \"'v_cspn.c'\" unpacked with wrong size!
  1454. fi
  1455. # end of 'v_cspn.c'
  1456. fi
  1457. if test -f 'v_data.c' -a "${1}" != "-c" ; then 
  1458.   echo shar: Will not clobber existing file \"'v_data.c'\"
  1459. else
  1460. echo shar: Extracting \"'v_data.c'\" \(1272 characters\)
  1461. sed "s/^X//" >'v_data.c' <<'END_OF_FILE'
  1462. X/***********************************************************************
  1463. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_data.c,v $
  1464. X* $Revision: 1.1 $
  1465. X* $Date: 1992/11/17 05:50:12 $
  1466. X* $State: Exp $
  1467. X* $Locker:  $
  1468. X* $Author: dtb $
  1469. X************************************************************************
  1470. X* 
  1471. X* $Log: v_data.c,v $
  1472. X* Revision 1.1  1992/11/17  05:50:12  dtb
  1473. X* initial real cut
  1474. X*
  1475. X* 
  1476. X************************************************************************
  1477. X* Description
  1478. X*    Gets length of varchar
  1479. X***********************************************************************/
  1480. X
  1481. 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 $" ;
  1482. X
  1483. X#include <stdio.h>
  1484. X#include <string.h>
  1485. X#include <memory.h>
  1486. X#include "vch.h"
  1487. X
  1488. X/***********************************************************************
  1489. X* NAME
  1490. X*     vch_data()
  1491. X* PURPOSE
  1492. X*     Return length of a varchar type
  1493. X* SYNOPSIS
  1494. X*     r = vch_len (v)
  1495. X*     int     r;
  1496. X*     Vchmin     *v;
  1497. X* DESCRIPTION
  1498. X*     Passed the pointer to a varchar type, this returns a char pointer to
  1499. X*     the data.
  1500. X***********************************************************************/
  1501. Xchar    *     vch_data
  1502. X    (
  1503. X    Vchmin *v
  1504. X    )
  1505. X{
  1506. X    return ( v == (Vchmin *) NULL ? (char *) NULL : (char *) (v->arr));
  1507. X}
  1508. X
  1509. END_OF_FILE
  1510. if test 1272 -ne `wc -c <'v_data.c'`; then
  1511.     echo shar: \"'v_data.c'\" unpacked with wrong size!
  1512. fi
  1513. # end of 'v_data.c'
  1514. fi
  1515. if test -f 'v_len.c' -a "${1}" != "-c" ; then 
  1516.   echo shar: Will not clobber existing file \"'v_len.c'\"
  1517. else
  1518. echo shar: Extracting \"'v_len.c'\" \(1484 characters\)
  1519. sed "s/^X//" >'v_len.c' <<'END_OF_FILE'
  1520. X/***********************************************************************
  1521. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_len.c,v $
  1522. X* $Revision: 1.1 $
  1523. X* $Date: 1992/11/17 05:50:12 $
  1524. X* $State: Exp $
  1525. X* $Locker:  $
  1526. X* $Author: dtb $
  1527. X************************************************************************
  1528. X* 
  1529. X* $Log: v_len.c,v $
  1530. X* Revision 1.1  1992/11/17  05:50:12  dtb
  1531. X* initial real cut
  1532. X*
  1533. X* 
  1534. X************************************************************************
  1535. X* Description
  1536. X*    Gets length of varchar
  1537. X***********************************************************************/
  1538. X
  1539. 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 $" ;
  1540. X
  1541. X#include <stdio.h>
  1542. X#include <string.h>
  1543. X#include <memory.h>
  1544. X#include "vch.h"
  1545. X
  1546. X/***********************************************************************
  1547. X* NAME
  1548. X*     vch_len()
  1549. X* PURPOSE
  1550. X*     Return length of a varchar type
  1551. X* SYNOPSIS
  1552. X*     r = vch_len (v)
  1553. X*     int     r;
  1554. X*     Vchmin     *v;
  1555. X* DESCRIPTION
  1556. X*     Passed the pointer to a varchar type, the length is evaluated using
  1557. X*     the len element (rather than strlen() the arr element).  Although the
  1558. X*     type of the len element is typically an unsigned short, a signed integer
  1559. X*     is returned to allow for error codes.
  1560. X* DIAGNOSTICS
  1561. X*     A value of -1 is returned on error, such as a null pointer.
  1562. X***********************************************************************/
  1563. Xint     vch_len
  1564. X    (
  1565. X    Vchmin *v
  1566. X    )
  1567. X{
  1568. X    return ( v == NULL ? -1 : v->len);
  1569. X}
  1570. X
  1571. END_OF_FILE
  1572. if test 1484 -ne `wc -c <'v_len.c'`; then
  1573.     echo shar: \"'v_len.c'\" unpacked with wrong size!
  1574. fi
  1575. # end of 'v_len.c'
  1576. fi
  1577. if test -f 'v_ncmp.c' -a "${1}" != "-c" ; then 
  1578.   echo shar: Will not clobber existing file \"'v_ncmp.c'\"
  1579. else
  1580. echo shar: Extracting \"'v_ncmp.c'\" \(1886 characters\)
  1581. sed "s/^X//" >'v_ncmp.c' <<'END_OF_FILE'
  1582. X/***********************************************************************
  1583. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_ncmp.c,v $
  1584. X* $Revision: 1.1 $
  1585. X* $Date: 1992/11/17 05:50:12 $
  1586. X* $State: Exp $
  1587. X* $Locker:  $
  1588. X* $Author: dtb $
  1589. X************************************************************************
  1590. X* 
  1591. X* $Log: v_ncmp.c,v $
  1592. X* Revision 1.1  1992/11/17  05:50:12  dtb
  1593. X* initial real cut
  1594. X*
  1595. X* 
  1596. X************************************************************************
  1597. X* Description
  1598. X*    Compares varchar
  1599. X***********************************************************************/
  1600. X
  1601. 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 $" ;
  1602. X
  1603. X#include <stdio.h>
  1604. X#include <string.h>
  1605. X#include <memory.h>
  1606. X#include "vch.h"
  1607. X
  1608. X/***********************************************************************
  1609. X* NAME
  1610. X*     vch_ncmp()
  1611. X* PURPOSE
  1612. X*     Compares varchars
  1613. X* SYNOPSIS
  1614. X*     vch_ncmp (v1, v2, n)
  1615. X*     Vchmin *v1, *v2;
  1616. X*    int    n;
  1617. X*    int n;
  1618. X* DESCRIPTION
  1619. X*     Compares v1 and v2 in manner similar to strncmp
  1620. X************************************************************************/
  1621. Xint     vch_ncmp
  1622. X    (
  1623. X    Vchmin    *v1,
  1624. X    Vchmin    *v2,
  1625. X    int        n
  1626. X    )
  1627. X{
  1628. X    int        rval;        /* Return value */
  1629. X    int        cmplen;        /* Comparison length */
  1630. X    int        len1;
  1631. X    int        len2;
  1632. X    char    *mem1;
  1633. X    char    *mem2;
  1634. X
  1635. X    /* Set up defaults in local variables so NULL parameters do not dump */
  1636. X    len1 = len2 = 0;
  1637. X    mem1 = mem2 = NULL;
  1638. X
  1639. X    /* Get real values into local variables */
  1640. X    if (v1 != NULL) {
  1641. X        len1 = v1->len;
  1642. X        mem1 = (char *) v1->arr;
  1643. X    }
  1644. X    if (v2 != NULL) {
  1645. X        len2 = v2->len;
  1646. X        mem2 = (char *) v2->arr;
  1647. X    }
  1648. X
  1649. X    /* Do comparison up to common length */
  1650. X    cmplen = (len2 > len1) ? len2 : len1;
  1651. X    rval = memcmp (mem1, mem2, ((n > cmplen) ? cmplen : n));
  1652. X
  1653. X    /* Adjust for longest if warranted */
  1654. X    if ((rval == 0) && (n > cmplen) && (len1 != len2)) {
  1655. X        rval = (len1 > len2) ? 1 : -1;
  1656. X    }
  1657. X    return (rval);
  1658. X}
  1659. X
  1660. X
  1661. END_OF_FILE
  1662. if test 1886 -ne `wc -c <'v_ncmp.c'`; then
  1663.     echo shar: \"'v_ncmp.c'\" unpacked with wrong size!
  1664. fi
  1665. # end of 'v_ncmp.c'
  1666. fi
  1667. if test -f 'v_rspn.c' -a "${1}" != "-c" ; then 
  1668.   echo shar: Will not clobber existing file \"'v_rspn.c'\"
  1669. else
  1670. echo shar: Extracting \"'v_rspn.c'\" \(1420 characters\)
  1671. sed "s/^X//" >'v_rspn.c' <<'END_OF_FILE'
  1672. X/***********************************************************************
  1673. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_rspn.c,v $
  1674. X* $Revision: 1.1 $
  1675. X* $Date: 1992/11/17 05:50:12 $
  1676. X* $State: Exp $
  1677. X* $Locker:  $
  1678. X* $Author: dtb $
  1679. X************************************************************************
  1680. X* 
  1681. X* $Log: v_rspn.c,v $
  1682. X* Revision 1.1  1992/11/17  05:50:12  dtb
  1683. X* initial real cut
  1684. X*
  1685. X* 
  1686. X************************************************************************
  1687. X* Description
  1688. X*    Returns number of characters in leader of varchar made entirely of
  1689. X*    characters in the string.
  1690. X***********************************************************************/
  1691. X
  1692. 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 $" ;
  1693. X
  1694. X#include <stdio.h>
  1695. X#include <string.h>
  1696. X#include "vch.h"
  1697. X
  1698. X/***********************************************************************
  1699. X* NAME
  1700. X*     vch_rspn()
  1701. X* DESCRIPTION
  1702. X*     Looks at the trailing data characters of the varchar v and checks
  1703. X*     which are in the set of characters in the string s, returning the
  1704. X*    length of the matching span in v.
  1705. X************************************************************************/
  1706. Xint     vch_rspn
  1707. X    (
  1708. X    Vchmin    *v,
  1709. X    char     *s
  1710. X    )
  1711. X{
  1712. X    int            pos;
  1713. X    int            len;
  1714. X    char    *    vc;
  1715. X
  1716. X    vc    = (char *)((v->arr)+(len=v->len)-1);
  1717. X    for (pos = 0; len--; pos++) {
  1718. X        if (strchr(s, *vc--) == NULL)
  1719. X            break;
  1720. X    }
  1721. X    return (pos);
  1722. X}
  1723. END_OF_FILE
  1724. if test 1420 -ne `wc -c <'v_rspn.c'`; then
  1725.     echo shar: \"'v_rspn.c'\" unpacked with wrong size!
  1726. fi
  1727. # end of 'v_rspn.c'
  1728. fi
  1729. if test -f 'v_set.c' -a "${1}" != "-c" ; then 
  1730.   echo shar: Will not clobber existing file \"'v_set.c'\"
  1731. else
  1732. echo shar: Extracting \"'v_set.c'\" \(1467 characters\)
  1733. sed "s/^X//" >'v_set.c' <<'END_OF_FILE'
  1734. X/***********************************************************************
  1735. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_set.c,v $
  1736. X* $Revision: 1.1 $
  1737. X* $Date: 1992/11/17 05:50:13 $
  1738. X* $State: Exp $
  1739. X* $Locker:  $
  1740. X* $Author: dtb $
  1741. X************************************************************************
  1742. X* 
  1743. X* $Log: v_set.c,v $
  1744. X* Revision 1.1  1992/11/17  05:50:13  dtb
  1745. X* initial real cut
  1746. X*
  1747. X* 
  1748. X************************************************************************
  1749. X* Description
  1750. X*    Sets varchar to specified length of nominated characters
  1751. X***********************************************************************/
  1752. X
  1753. 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 $" ;
  1754. X
  1755. X#include <stdio.h>
  1756. X#include <string.h>
  1757. X#include <memory.h>
  1758. X#include "vch.h"
  1759. X
  1760. X/***********************************************************************
  1761. X* NAME
  1762. X*     vch_set()
  1763. X* PURPOSE
  1764. X*     Sets varchar to specified length of nominated characters.
  1765. X* SYNOPSIS
  1766. X*     vch_set (v, c, n)
  1767. X*     Vchmin *v;
  1768. X*    int    c, n;
  1769. X* DESCRIPTION
  1770. X*     Fills v with n bytes of character c and sets length accordingly.
  1771. X*     Analogous to memset(3).
  1772. X* WARNINGS
  1773. X*    No checking is done to make sure you do not overwrite data past the
  1774. X*    end of the allocated space for the varchar.
  1775. X************************************************************************/
  1776. XVchmin     *vch_set
  1777. X    (
  1778. X    Vchmin    *v,
  1779. X    int        c,
  1780. X    int        n
  1781. X    )
  1782. X{
  1783. X    memset (v->arr, c, n);
  1784. X    v->len = n;
  1785. X    return (v);
  1786. X}
  1787. X
  1788. END_OF_FILE
  1789. if test 1467 -ne `wc -c <'v_set.c'`; then
  1790.     echo shar: \"'v_set.c'\" unpacked with wrong size!
  1791. fi
  1792. # end of 'v_set.c'
  1793. fi
  1794. if test -f 'v_slen.c' -a "${1}" != "-c" ; then 
  1795.   echo shar: Will not clobber existing file \"'v_slen.c'\"
  1796. else
  1797. echo shar: Extracting \"'v_slen.c'\" \(1730 characters\)
  1798. sed "s/^X//" >'v_slen.c' <<'END_OF_FILE'
  1799. X/***********************************************************************
  1800. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_slen.c,v $
  1801. X* $Revision: 1.1 $
  1802. X* $Date: 1992/11/17 05:50:13 $
  1803. X* $State: Exp $
  1804. X* $Locker:  $
  1805. X* $Author: dtb $
  1806. X************************************************************************
  1807. X* 
  1808. X* $Log: v_slen.c,v $
  1809. X* Revision 1.1  1992/11/17  05:50:13  dtb
  1810. X* initial real cut
  1811. X*
  1812. X* 
  1813. X************************************************************************
  1814. X* Description
  1815. X*    Gets string length of varchar
  1816. X***********************************************************************/
  1817. X
  1818. 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 $" ;
  1819. X
  1820. X#include <stdio.h>
  1821. X#include <string.h>
  1822. X#include <memory.h>
  1823. X#include "vch.h"
  1824. X
  1825. X/***********************************************************************
  1826. X* NAME
  1827. X*     vch_len()
  1828. X* PURPOSE
  1829. X*     Return string length of a varchar type
  1830. X* DESCRIPTION
  1831. X*     Passed the pointer to a varchar type, the length is evaluated using
  1832. X*     memchr on the array looking for the null character within the length
  1833. X*    nominated by the len element.  This represents the "string" length
  1834. X*     of the data and is typically an unsigned short, but a signed integer
  1835. X*     is returned.  Note that if no null character is found within the
  1836. X*    data part of the varchar, the information in the length element is
  1837. X*    returned.
  1838. X* AUTHOR
  1839. X*     David T. Bath, Global Technology Group
  1840. X***********************************************************************/
  1841. Xint     vch_strlen
  1842. X    (
  1843. X    Vchmin *v
  1844. X    )
  1845. X{
  1846. X    static    int    len;
  1847. X
  1848. X    if ( v == NULL ) {
  1849. X        len = 0;
  1850. X    } else {
  1851. X        if (memchr(v->arr, '\0', v->len) == NULL)
  1852. X            len = v->len;
  1853. X        else
  1854. X            len = strlen (v->arr);
  1855. X    }
  1856. X
  1857. X    return (len);
  1858. X}
  1859. X
  1860. END_OF_FILE
  1861. if test 1730 -ne `wc -c <'v_slen.c'`; then
  1862.     echo shar: \"'v_slen.c'\" unpacked with wrong size!
  1863. fi
  1864. # end of 'v_slen.c'
  1865. fi
  1866. if test -f 'v_spn.c' -a "${1}" != "-c" ; then 
  1867.   echo shar: Will not clobber existing file \"'v_spn.c'\"
  1868. else
  1869. echo shar: Extracting \"'v_spn.c'\" \(1383 characters\)
  1870. sed "s/^X//" >'v_spn.c' <<'END_OF_FILE'
  1871. X/***********************************************************************
  1872. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_spn.c,v $
  1873. X* $Revision: 1.1 $
  1874. X* $Date: 1992/11/17 05:50:13 $
  1875. X* $State: Exp $
  1876. X* $Locker:  $
  1877. X* $Author: dtb $
  1878. X************************************************************************
  1879. X* 
  1880. X* $Log: v_spn.c,v $
  1881. X* Revision 1.1  1992/11/17  05:50:13  dtb
  1882. X* initial real cut
  1883. X*
  1884. X* 
  1885. X************************************************************************
  1886. X* Description
  1887. X*    Returns number of characters in leader of varchar made entirely of
  1888. X*    characters in the string.
  1889. X***********************************************************************/
  1890. X
  1891. 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 $" ;
  1892. X
  1893. X#include <stdio.h>
  1894. X#include <string.h>
  1895. X#include <memory.h>
  1896. X#include "vch.h"
  1897. X
  1898. X/***********************************************************************
  1899. X* NAME
  1900. X*     vch_spn()
  1901. X* DESCRIPTION
  1902. X*     Looks at the leading data characters of the varchar v and checks
  1903. X*     which are in the set of characters in the string s, returning the
  1904. X*    length of the matching span in v.
  1905. X************************************************************************/
  1906. Xint     vch_spn
  1907. X    (
  1908. X    Vchmin    *v,
  1909. X    char     *s
  1910. X    )
  1911. X{
  1912. X    int    pos;
  1913. X
  1914. X    for (pos = 0; pos <= v->len; pos++) {
  1915. X        if (strchr(s, *(v->arr)+pos) == NULL)
  1916. X            break;
  1917. X    }
  1918. X    return (pos);
  1919. X}
  1920. END_OF_FILE
  1921. if test 1383 -ne `wc -c <'v_spn.c'`; then
  1922.     echo shar: \"'v_spn.c'\" unpacked with wrong size!
  1923. fi
  1924. # end of 'v_spn.c'
  1925. fi
  1926. if test -f 'v_vers.c' -a "${1}" != "-c" ; then 
  1927.   echo shar: Will not clobber existing file \"'v_vers.c'\"
  1928. else
  1929. echo shar: Extracting \"'v_vers.c'\" \(1507 characters\)
  1930. sed "s/^X//" >'v_vers.c' <<'END_OF_FILE'
  1931. X/***********************************************************************
  1932. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/v_vers.c,v $
  1933. X* $Revision: 1.1 $
  1934. X* $Date: 1992/11/17 05:50:14 $
  1935. X* $State: Exp $
  1936. X* $Locker:  $
  1937. X* $Author: dtb $
  1938. X************************************************************************
  1939. X* 
  1940. X* $Log: v_vers.c,v $
  1941. X* Revision 1.1  1992/11/17  05:50:14  dtb
  1942. X* initial real cut
  1943. X*
  1944. X* 
  1945. X************************************************************************
  1946. X* Description
  1947. X*    Provides copyright and version information
  1948. X***********************************************************************/
  1949. X
  1950. 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 $" ;
  1951. X
  1952. X#include <stdio.h>
  1953. X#include "vch.h"
  1954. X
  1955. X/***********************************************************************
  1956. X* NAME
  1957. X*     vch_version
  1958. X* PURPOSE
  1959. X*     Pointer to version
  1960. X***********************************************************************/
  1961. Xchar     *vch_version = "VCH Varchar Handling Library - Ver 1.1";
  1962. X
  1963. X/***********************************************************************
  1964. X* NAME
  1965. X*     vch_copyright
  1966. X* PURPOSE
  1967. X*     Provides copyright message to nominated file
  1968. X***********************************************************************/
  1969. Xvoid    vch_copyright
  1970. X    (
  1971. X    FILE    *fp
  1972. X    )
  1973. X{
  1974. X    char *m0="Portions copyright, ";
  1975. X    char *m1="1986, David T. Bath";
  1976. X    char *m2="1992, Global Technology Group";
  1977. X
  1978. X    if (fp == (FILE *)NULL)
  1979. X        fp = stdout;
  1980. X    fprintf (fp, "%s%s\n%s%s\n", m0, m1, m0, m2);
  1981. X}
  1982. X
  1983. END_OF_FILE
  1984. if test 1507 -ne `wc -c <'v_vers.c'`; then
  1985.     echo shar: \"'v_vers.c'\" unpacked with wrong size!
  1986. fi
  1987. # end of 'v_vers.c'
  1988. fi
  1989. if test -f 'vch.h' -a "${1}" != "-c" ; then 
  1990.   echo shar: Will not clobber existing file \"'vch.h'\"
  1991. else
  1992. echo shar: Extracting \"'vch.h'\" \(4656 characters\)
  1993. sed "s/^X//" >'vch.h' <<'END_OF_FILE'
  1994. X/***********************************************************************
  1995. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vch.h,v $
  1996. X* $Revision: 1.1 $
  1997. X* $Date: 1992/11/17 05:50:14 $
  1998. X* $State: Exp $
  1999. X* $Locker:  $
  2000. X* $Author: dtb $
  2001. X************************************************************************
  2002. X* 
  2003. X* $Log: vch.h,v $
  2004. X* Revision 1.1  1992/11/17  05:50:14  dtb
  2005. X* initial real cut
  2006. X*
  2007. X* 
  2008. X************************************************************************
  2009. X* Description
  2010. X*    Header for Oracle VARCHAR interface functions.
  2011. X*    It can probably be hacked to deal with Ingres VCHAR datatypes
  2012. X*    without too much drama, if you redefine the variables in the
  2013. X*    platform specific section.
  2014. X***********************************************************************/
  2015. X
  2016. X#if ! defined VCH_HDR_INCL
  2017. X#define VCH_HDR_INCL
  2018. X
  2019. X/***********************************************************************
  2020. X*    PLATFORM SPECIFIC SECION
  2021. X*    This section should be edited on porting to each new system or
  2022. X*    with new releases of the Oracle Pro*C precompiler.
  2023. X*    Essentially, you need to put the put the following inside 
  2024. X*    enclosing EXEC SQL BEGIN/END DECLARE SECTION marks:
  2025. X*        varchar    x[2];
  2026. X*    You should then look at the results and edit the definitions
  2027. X*    to match datatypes.
  2028. X*    The VCH_MIN_ARR_LEN setting could be set to 1, but I prefer 2,
  2029. X*    simply for aesthetic reasons.
  2030. X***********************************************************************/
  2031. X#if ! defined VCH_LEN_TYPE
  2032. X#define VCH_LEN_TYPE unsigned short
  2033. X#endif
  2034. X#if ! defined VCH_LEN_TYPE
  2035. X#define VCH_LEN_TYPE unsigned short
  2036. X#endif
  2037. X#if ! defined VCH_ARR_TYPE_PREFIX
  2038. X#define VCH_ARR_TYPE_PREFIX unsigned char
  2039. X#endif
  2040. X#if ! defined VCH_MIN_ARR_LEN
  2041. X#define VCH_MIN_ARR_LEN     2
  2042. X#endif
  2043. X
  2044. X/***********************************************************************
  2045. X*    DATATYPES
  2046. X*    The vch_min structure is the structure for a minimum length varchar.
  2047. X*    This is setup to allow the typedef of Vchmin, which gives you
  2048. X*    declarations.
  2049. X*    The Vchmin datatype should NOT actually be used, as you will not
  2050. X*    have much space for storing data inside it!  However, it DOES give
  2051. X*    you a datatype that can take a pointer that will be appropriately
  2052. X*    aligned for structures and the length unit.
  2053. X*    You can then fairly safely pass pointers to Vchmin around as a
  2054. X*    means of manipulating varchars.
  2055. X***********************************************************************/
  2056. Xstruct vch_min { 
  2057. X    VCH_LEN_TYPE len;    /* specifies the length of the data in arr */
  2058. X    VCH_ARR_TYPE_PREFIX     arr [ VCH_MIN_ARR_LEN ] ;    /* data */
  2059. X} ;
  2060. Xtypedef struct vch_min Vchmin;
  2061. X
  2062. X/***********************************************************************
  2063. X*    DECLARATION MACRO
  2064. X*    This declaration can be placed in your code so that it is easy to
  2065. X*    declare a variable with a VARCHAR structure with the length
  2066. X*    determined at compile time.
  2067. X*
  2068. X*    To use this to declare a varchar called fld to store 22 data bytes
  2069. X*        VCH_DECL(fld,22)
  2070. X*
  2071. X*    Note, however, that Oracle only supports varchars up to 255 data
  2072. X*    bytes at the time of writing.  This library, however, has no such
  2073. X*    limitation.
  2074. X***********************************************************************/
  2075. X#define VCH_DECL(a,b) \
  2076. X    struct { VCH_LEN_TYPE len; VCH_ARR_TYPE_PREFIX arr [ b ]; } a
  2077. X
  2078. X#endif
  2079. X
  2080. X/***********************************************************************
  2081. X*    FUNCTIONS AVAILABLE IN THE LIBRARY
  2082. X*    The naming conventions are generally as follows,
  2083. X*    For binary operations, the function xxx_yyyzzz has the target
  2084. X*    datatype xxx, source datatype yyy and operation zzz similar to
  2085. X*    the last part of the more common C string function.
  2086. X*    For example, vch_strncpy is like strncpy, but copies to a
  2087. X*    varchar.  The str_vchncpy on the other hand uses a varchar as
  2088. X*    source and a standard string as the target.
  2089. X***********************************************************************/
  2090. Xextern    Vchmin     *vch_alloc        ();
  2091. Xextern    Vchmin     *vch_set        ();
  2092. Xextern    Vchmin     *vch_strcat        ();
  2093. Xextern    Vchmin     *vch_strcpy        ();
  2094. Xextern    Vchmin     *vch_strdup        ();
  2095. Xextern    Vchmin     *vch_strncat    ();
  2096. Xextern    Vchmin     *vch_strncpy    ();
  2097. Xextern    Vchmin     *vch_vchcat        ();
  2098. Xextern    Vchmin     *vch_vchcpy        ();
  2099. Xextern    Vchmin     *vch_vchdup        ();
  2100. Xextern    Vchmin     *vch_vchncat    ();
  2101. Xextern    Vchmin     *vch_vchncpy    ();
  2102. Xextern    Vchmin     *vch_vchrtrim    ();
  2103. Xextern    void    vch_copyright    ();
  2104. Xextern    char     *str_vchcat        ();
  2105. Xextern    char     *str_vchcpy     ();
  2106. Xextern    char     *str_vchdup        ();
  2107. Xextern    char     *str_vchncat    ();
  2108. Xextern    char     *str_vchncpy    ();
  2109. Xextern    char     *str_vchsub        ();
  2110. Xextern    char     *vch_data        ();
  2111. Xextern    int     vch_cmp            ();
  2112. Xextern    int     vch_len            ();
  2113. Xextern    int     vch_ncmp        ();
  2114. Xextern    int     vch_crspn        ();
  2115. Xextern    int     vch_cspn        ();
  2116. Xextern    int     vch_strlen        ();
  2117. Xextern    int     vch_rspn        ();
  2118. Xextern    int     vch_spn            ();
  2119. END_OF_FILE
  2120. if test 4656 -ne `wc -c <'vch.h'`; then
  2121.     echo shar: \"'vch.h'\" unpacked with wrong size!
  2122. fi
  2123. # end of 'vch.h'
  2124. fi
  2125. if test -f 'vs_cat.c' -a "${1}" != "-c" ; then 
  2126.   echo shar: Will not clobber existing file \"'vs_cat.c'\"
  2127. else
  2128. echo shar: Extracting \"'vs_cat.c'\" \(1501 characters\)
  2129. sed "s/^X//" >'vs_cat.c' <<'END_OF_FILE'
  2130. X/***********************************************************************
  2131. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_cat.c,v $
  2132. X* $Revision: 1.1 $
  2133. X* $Date: 1992/11/17 05:50:14 $
  2134. X* $State: Exp $
  2135. X* $Locker:  $
  2136. X* $Author: dtb $
  2137. X************************************************************************
  2138. X* 
  2139. X* $Log: vs_cat.c,v $
  2140. X* Revision 1.1  1992/11/17  05:50:14  dtb
  2141. X* initial real cut
  2142. X*
  2143. X* 
  2144. X************************************************************************
  2145. X* Description
  2146. X*    Appends string to varchar
  2147. X***********************************************************************/
  2148. X
  2149. 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 $" ;
  2150. X
  2151. X#include <stdio.h>
  2152. X#include <string.h>
  2153. X#include <memory.h>
  2154. X#include "vch.h"
  2155. X
  2156. X/***********************************************************************
  2157. X* NAME
  2158. X*     vch_strcat()
  2159. X* PURPOSE
  2160. X*     Copy the string into a varchar 
  2161. X* SYNOPSIS
  2162. X*     vch_strcat (v, s)
  2163. X*     char     *s;
  2164. X*     Vchmin *v;
  2165. X* DESCRIPTION
  2166. X*     Copies the string (including the null) into a varchar and adds the
  2167. X*     string length of to the length of the varchar.  The terminating
  2168. X*    null character is NOT included in the varchar length.
  2169. X* WARNINGS
  2170. X*    No checking is done that you will not overwrite past the end
  2171. X*    of the varchar.
  2172. X************************************************************************/
  2173. XVchmin     *vch_strcat
  2174. X    (
  2175. X    Vchmin    *v,
  2176. X    char     *s
  2177. X    )
  2178. X{
  2179. X    strcpy ((char *) (v->arr+v->len), s);
  2180. X    v->len += strlen (s);
  2181. X    return (v);
  2182. X}
  2183. X
  2184. END_OF_FILE
  2185. if test 1501 -ne `wc -c <'vs_cat.c'`; then
  2186.     echo shar: \"'vs_cat.c'\" unpacked with wrong size!
  2187. fi
  2188. # end of 'vs_cat.c'
  2189. fi
  2190. if test -f 'vs_cpy.c' -a "${1}" != "-c" ; then 
  2191.   echo shar: Will not clobber existing file \"'vs_cpy.c'\"
  2192. else
  2193. echo shar: Extracting \"'vs_cpy.c'\" \(1318 characters\)
  2194. sed "s/^X//" >'vs_cpy.c' <<'END_OF_FILE'
  2195. X/***********************************************************************
  2196. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_cpy.c,v $
  2197. X* $Revision: 1.1 $
  2198. X* $Date: 1992/11/17 05:50:15 $
  2199. X* $State: Exp $
  2200. X* $Locker:  $
  2201. X* $Author: dtb $
  2202. X************************************************************************
  2203. X* 
  2204. X* $Log: vs_cpy.c,v $
  2205. X* Revision 1.1  1992/11/17  05:50:15  dtb
  2206. X* initial real cut
  2207. X*
  2208. X* 
  2209. X************************************************************************
  2210. X* Description
  2211. X*    Copies string to varchar
  2212. X***********************************************************************/
  2213. X
  2214. 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 $" ;
  2215. X
  2216. X#include <stdio.h>
  2217. X#include <string.h>
  2218. X#include <memory.h>
  2219. X#include "vch.h"
  2220. X
  2221. X/***********************************************************************
  2222. X* NAME
  2223. X*     vch_strcpy()
  2224. X* PURPOSE
  2225. X*     Copy the string into a varchar 
  2226. X* SYNOPSIS
  2227. X*     vch_strcpy (v, s)
  2228. X*     char     *s;
  2229. X*     Vchmin *v;
  2230. X* DESCRIPTION
  2231. X*     Copies the string (including the null) into a varchar
  2232. X*     and sets the length of the varchar to the string length.
  2233. X************************************************************************/
  2234. XVchmin     *vch_strcpy
  2235. X    (
  2236. X    Vchmin    *v,
  2237. X    char     *s
  2238. X    )
  2239. X{
  2240. X    strcpy (v->arr, s);
  2241. X    v->len = strlen (v->arr);
  2242. X    return (v);
  2243. X}
  2244. X
  2245. END_OF_FILE
  2246. if test 1318 -ne `wc -c <'vs_cpy.c'`; then
  2247.     echo shar: \"'vs_cpy.c'\" unpacked with wrong size!
  2248. fi
  2249. # end of 'vs_cpy.c'
  2250. fi
  2251. if test -f 'vs_dup.c' -a "${1}" != "-c" ; then 
  2252.   echo shar: Will not clobber existing file \"'vs_dup.c'\"
  2253. else
  2254. echo shar: Extracting \"'vs_dup.c'\" \(1398 characters\)
  2255. sed "s/^X//" >'vs_dup.c' <<'END_OF_FILE'
  2256. X/***********************************************************************
  2257. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_dup.c,v $
  2258. X* $Revision: 1.1 $
  2259. X* $Date: 1992/11/17 05:50:15 $
  2260. X* $State: Exp $
  2261. X* $Locker:  $
  2262. X* $Author: dtb $
  2263. X************************************************************************
  2264. X* 
  2265. X* $Log: vs_dup.c,v $
  2266. X* Revision 1.1  1992/11/17  05:50:15  dtb
  2267. X* initial real cut
  2268. X*
  2269. X* 
  2270. X************************************************************************
  2271. X* Description
  2272. X*    Duplicates string as varchar
  2273. X***********************************************************************/
  2274. X
  2275. 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 $" ;
  2276. X
  2277. X#include <stdio.h>
  2278. X#include <string.h>
  2279. X#include <memory.h>
  2280. X#include "vch.h"
  2281. X
  2282. X/***********************************************************************
  2283. X* NAME
  2284. X*     vch_strdup()
  2285. X* PURPOSE
  2286. X*     Duplicate string as varchar
  2287. X* SYNOPSIS
  2288. X*     vch_vchdup (s)
  2289. X*     char *s;
  2290. X* DESCRIPTION
  2291. X*     Allocates and copies a string as varchar.  Note that space is
  2292. X*    allocated for the terminating null of the string to be copied
  2293. X*    as well.
  2294. X***********************************************************************/
  2295. XVchmin     *vch_strdup
  2296. X    (
  2297. X    char    *    s
  2298. X    )
  2299. X{
  2300. X    Vchmin     *v = NULL;
  2301. X
  2302. X    if (s != NULL) {
  2303. X        if ((v = (Vchmin *) vch_alloc (strlen(s)+1)) != (Vchmin *)NULL) {
  2304. X            vch_strcpy (v, s);
  2305. X        }
  2306. X    }
  2307. X    return (v);
  2308. X}
  2309. X
  2310. END_OF_FILE
  2311. if test 1398 -ne `wc -c <'vs_dup.c'`; then
  2312.     echo shar: \"'vs_dup.c'\" unpacked with wrong size!
  2313. fi
  2314. # end of 'vs_dup.c'
  2315. fi
  2316. if test -f 'vs_ncat.c' -a "${1}" != "-c" ; then 
  2317.   echo shar: Will not clobber existing file \"'vs_ncat.c'\"
  2318. else
  2319. echo shar: Extracting \"'vs_ncat.c'\" \(1693 characters\)
  2320. sed "s/^X//" >'vs_ncat.c' <<'END_OF_FILE'
  2321. X/***********************************************************************
  2322. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_ncat.c,v $
  2323. X* $Revision: 1.1 $
  2324. X* $Date: 1992/11/17 05:50:15 $
  2325. X* $State: Exp $
  2326. X* $Locker:  $
  2327. X* $Author: dtb $
  2328. X************************************************************************
  2329. X* 
  2330. X* $Log: vs_ncat.c,v $
  2331. X* Revision 1.1  1992/11/17  05:50:15  dtb
  2332. X* initial real cut
  2333. X*
  2334. X* 
  2335. X************************************************************************
  2336. X* Description
  2337. X*    Length limited append from string to varchar
  2338. X***********************************************************************/
  2339. X
  2340. 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 $" ;
  2341. X
  2342. X#include <stdio.h>
  2343. X#include <string.h>
  2344. X#include <memory.h>
  2345. X#include "vch.h"
  2346. X
  2347. X/***********************************************************************
  2348. X* NAME
  2349. X*     vch_strncat()
  2350. X* PURPOSE
  2351. X*     Concatenates the string onto end of a varchar (length limited)
  2352. X* SYNOPSIS
  2353. X*     vch_strncat (v, s, n)
  2354. X*     char     *s;
  2355. X*     Vchmin *v;
  2356. X*     unsigned int n;
  2357. X* DESCRIPTION
  2358. X*     Concatenates the string (including the null if found under the
  2359. X*    specified length) into a varchar *     and adds the string length to 
  2360. X*    the varchar length.  Up to n bytes are taken from the string.
  2361. X*    Any null character terminating the string is NOT included in the
  2362. X*    addition to the length of the varchar.
  2363. X************************************************************************/
  2364. XVchmin     *vch_strncat
  2365. X    (
  2366. X    Vchmin    *v,
  2367. X    char     *s,
  2368. X    unsigned int n
  2369. X    )
  2370. X{
  2371. X    int l;
  2372. X    int    a;
  2373. X
  2374. X    l = strlen(s);
  2375. X    a = (n > l) ? l : n;
  2376. X    strncpy (v->arr+v->len, s, a);
  2377. X    v->len += a;
  2378. X    if (n > l)
  2379. X        *(v->arr + l) = '\0';
  2380. X    return (v);
  2381. X}
  2382. X
  2383. END_OF_FILE
  2384. if test 1693 -ne `wc -c <'vs_ncat.c'`; then
  2385.     echo shar: \"'vs_ncat.c'\" unpacked with wrong size!
  2386. fi
  2387. # end of 'vs_ncat.c'
  2388. fi
  2389. if test -f 'vs_ncpy.c' -a "${1}" != "-c" ; then 
  2390.   echo shar: Will not clobber existing file \"'vs_ncpy.c'\"
  2391. else
  2392. echo shar: Extracting \"'vs_ncpy.c'\" \(1580 characters\)
  2393. sed "s/^X//" >'vs_ncpy.c' <<'END_OF_FILE'
  2394. X/***********************************************************************
  2395. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vs_ncpy.c,v $
  2396. X* $Revision: 1.1 $
  2397. X* $Date: 1992/11/17 05:50:16 $
  2398. X* $State: Exp $
  2399. X* $Locker:  $
  2400. X* $Author: dtb $
  2401. X************************************************************************
  2402. X* 
  2403. X* $Log: vs_ncpy.c,v $
  2404. X* Revision 1.1  1992/11/17  05:50:16  dtb
  2405. X* initial real cut
  2406. X*
  2407. X* 
  2408. X************************************************************************
  2409. X* Description
  2410. X*    Length limited copy of string to varchar
  2411. X***********************************************************************/
  2412. X
  2413. 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 $" ;
  2414. X
  2415. X#include <stdio.h>
  2416. X#include <string.h>
  2417. X#include <memory.h>
  2418. X#include "vch.h"
  2419. X
  2420. X/***********************************************************************
  2421. X* NAME
  2422. X*     vch_strncpy()
  2423. X* PURPOSE
  2424. X*     Copy the string into a varchar (length limited)
  2425. X* SYNOPSIS
  2426. X*     Vchmin *vch_strncpy (v, s, n)
  2427. X*     char     *s;
  2428. X*     Vchmin *v;
  2429. X*     unsigned int n;
  2430. X* DESCRIPTION
  2431. X*     Copies the string (including the null if less than n) into a varchar
  2432. X*     and sets the length of the varchar to the string length, up to
  2433. X*     a maximum of length n and returns a pointer to the result.
  2434. X************************************************************************/
  2435. XVchmin     *vch_strncpy
  2436. X    (
  2437. X    Vchmin    *v,
  2438. X    char     *s,
  2439. X    unsigned int     n
  2440. X    )
  2441. X{
  2442. X    int slen;
  2443. X
  2444. X    strncpy (v->arr, s, n);        /* Copy the data */
  2445. X
  2446. X    if (memchr(s, '\0', n) == NULL)
  2447. X        v->len = n;
  2448. X    else
  2449. X        v->len = strlen (v->arr);
  2450. X
  2451. X    return (v);
  2452. X}
  2453. X
  2454. END_OF_FILE
  2455. if test 1580 -ne `wc -c <'vs_ncpy.c'`; then
  2456.     echo shar: \"'vs_ncpy.c'\" unpacked with wrong size!
  2457. fi
  2458. # end of 'vs_ncpy.c'
  2459. fi
  2460. if test -f 'vv_cat.c' -a "${1}" != "-c" ; then 
  2461.   echo shar: Will not clobber existing file \"'vv_cat.c'\"
  2462. else
  2463. echo shar: Extracting \"'vv_cat.c'\" \(1323 characters\)
  2464. sed "s/^X//" >'vv_cat.c' <<'END_OF_FILE'
  2465. X/***********************************************************************
  2466. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_cat.c,v $
  2467. X* $Revision: 1.1 $
  2468. X* $Date: 1992/11/17 05:50:16 $
  2469. X* $State: Exp $
  2470. X* $Locker:  $
  2471. X* $Author: dtb $
  2472. X************************************************************************
  2473. X* 
  2474. X* $Log: vv_cat.c,v $
  2475. X* Revision 1.1  1992/11/17  05:50:16  dtb
  2476. X* initial real cut
  2477. X*
  2478. X* 
  2479. X************************************************************************
  2480. X* Description
  2481. X*    Appends from varchar to varchar
  2482. X***********************************************************************/
  2483. X
  2484. 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 $" ;
  2485. X
  2486. X#include <stdio.h>
  2487. X#include <string.h>
  2488. X#include <memory.h>
  2489. X#include "vch.h"
  2490. X
  2491. X/***********************************************************************
  2492. X* NAME
  2493. X*     vch_vchcat()
  2494. X* PURPOSE
  2495. X*     Concatenate varchar to another varchar
  2496. X* SYNOPSIS
  2497. X*     vch_vchcat (v1, v2)
  2498. X*     Vchmin *v1, *v2;
  2499. X* DESCRIPTION
  2500. X*     Concatenate varchar v2 onto end of varchar v1
  2501. X************************************************************************/
  2502. XVchmin     *vch_vchcat
  2503. X(
  2504. X    Vchmin    *v1,
  2505. X    Vchmin    *v2
  2506. X)
  2507. X{
  2508. X    if ((v1 != NULL) && (v2 != NULL)) {
  2509. X        memcpy (v1->arr + v1->len, v2->arr, v2->len);
  2510. X        v1->len += v2->len;
  2511. X    }
  2512. X    return (v1);
  2513. X}
  2514. X
  2515. END_OF_FILE
  2516. if test 1323 -ne `wc -c <'vv_cat.c'`; then
  2517.     echo shar: \"'vv_cat.c'\" unpacked with wrong size!
  2518. fi
  2519. # end of 'vv_cat.c'
  2520. fi
  2521. if test -f 'vv_cpy.c' -a "${1}" != "-c" ; then 
  2522.   echo shar: Will not clobber existing file \"'vv_cpy.c'\"
  2523. else
  2524. echo shar: Extracting \"'vv_cpy.c'\" \(1237 characters\)
  2525. sed "s/^X//" >'vv_cpy.c' <<'END_OF_FILE'
  2526. X/***********************************************************************
  2527. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_cpy.c,v $
  2528. X* $Revision: 1.1 $
  2529. X* $Date: 1992/11/17 05:50:16 $
  2530. X* $State: Exp $
  2531. X* $Locker:  $
  2532. X* $Author: dtb $
  2533. X************************************************************************
  2534. X* 
  2535. X* $Log: vv_cpy.c,v $
  2536. X* Revision 1.1  1992/11/17  05:50:16  dtb
  2537. X* initial real cut
  2538. X*
  2539. X* 
  2540. X************************************************************************
  2541. X* Description
  2542. X*    Copies varchar to varchar
  2543. X***********************************************************************/
  2544. X
  2545. 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 $" ;
  2546. X
  2547. X#include <stdio.h>
  2548. X#include <string.h>
  2549. X#include <memory.h>
  2550. X#include "vch.h"
  2551. X
  2552. X/***********************************************************************
  2553. X* NAME
  2554. X*     vch_vchcpy()
  2555. X* PURPOSE
  2556. X*     Copy varchar to another varchar
  2557. X* SYNOPSIS
  2558. X*     vch_vchcpy (v1, v2)
  2559. X*     Vchmin *v1, *v2;
  2560. X* DESCRIPTION
  2561. X*     Copies varchar v2 into varchar v1
  2562. X************************************************************************/
  2563. XVchmin     *vch_vchcpy
  2564. X    (
  2565. X    Vchmin    *v1,
  2566. X    Vchmin    *v2 
  2567. X    )
  2568. X{
  2569. X    memcpy (v1->arr, v2->arr, v1->len=v2->len);
  2570. X    return (v1);
  2571. X}
  2572. X
  2573. X
  2574. END_OF_FILE
  2575. if test 1237 -ne `wc -c <'vv_cpy.c'`; then
  2576.     echo shar: \"'vv_cpy.c'\" unpacked with wrong size!
  2577. fi
  2578. # end of 'vv_cpy.c'
  2579. fi
  2580. if test -f 'vv_dup.c' -a "${1}" != "-c" ; then 
  2581.   echo shar: Will not clobber existing file \"'vv_dup.c'\"
  2582. else
  2583. echo shar: Extracting \"'vv_dup.c'\" \(1271 characters\)
  2584. sed "s/^X//" >'vv_dup.c' <<'END_OF_FILE'
  2585. X/***********************************************************************
  2586. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_dup.c,v $
  2587. X* $Revision: 1.1 $
  2588. X* $Date: 1992/11/17 05:50:16 $
  2589. X* $State: Exp $
  2590. X* $Locker:  $
  2591. X* $Author: dtb $
  2592. X************************************************************************
  2593. X* 
  2594. X* $Log: vv_dup.c,v $
  2595. X* Revision 1.1  1992/11/17  05:50:16  dtb
  2596. X* initial real cut
  2597. X*
  2598. X* 
  2599. X************************************************************************
  2600. X* Description
  2601. X*    Duplicates varchar
  2602. X***********************************************************************/
  2603. X
  2604. 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 $" ;
  2605. X
  2606. X#include <stdio.h>
  2607. X#include <string.h>
  2608. X#include <memory.h>
  2609. X#include "vch.h"
  2610. X
  2611. X/***********************************************************************
  2612. X* NAME
  2613. X*     vch_vchdup()
  2614. X* PURPOSE
  2615. X*     Duplicate varchar
  2616. X* SYNOPSIS
  2617. X*     vch_vchdup (v)
  2618. X*     Vchmin *v;
  2619. X* DESCRIPTION
  2620. X*     Allocates and copies a varchar
  2621. X************************************************************************/
  2622. XVchmin     *vch_vchdup
  2623. X    (
  2624. X    Vchmin    *v
  2625. X    )
  2626. X{
  2627. X    Vchmin     *d = NULL;
  2628. X
  2629. X    if (v != NULL) {
  2630. X        if ((d = (Vchmin *) vch_alloc (v->len)) != (Vchmin *)NULL) {
  2631. X            vch_vchcpy (d, v);
  2632. X        }
  2633. X    }
  2634. X    return (d);
  2635. X}
  2636. X
  2637. END_OF_FILE
  2638. if test 1271 -ne `wc -c <'vv_dup.c'`; then
  2639.     echo shar: \"'vv_dup.c'\" unpacked with wrong size!
  2640. fi
  2641. # end of 'vv_dup.c'
  2642. fi
  2643. if test -f 'vv_ncat.c' -a "${1}" != "-c" ; then 
  2644.   echo shar: Will not clobber existing file \"'vv_ncat.c'\"
  2645. else
  2646. echo shar: Extracting \"'vv_ncat.c'\" \(1447 characters\)
  2647. sed "s/^X//" >'vv_ncat.c' <<'END_OF_FILE'
  2648. X/***********************************************************************
  2649. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_ncat.c,v $
  2650. X* $Revision: 1.1 $
  2651. X* $Date: 1992/11/17 05:50:17 $
  2652. X* $State: Exp $
  2653. X* $Locker:  $
  2654. X* $Author: dtb $
  2655. X************************************************************************
  2656. X* 
  2657. X* $Log: vv_ncat.c,v $
  2658. X* Revision 1.1  1992/11/17  05:50:17  dtb
  2659. X* initial real cut
  2660. X*
  2661. X* 
  2662. X************************************************************************
  2663. X* Description
  2664. X*    Length limited append from varchar to varchar
  2665. X***********************************************************************/
  2666. X
  2667. 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 $" ;
  2668. X
  2669. X#include <stdio.h>
  2670. X#include <string.h>
  2671. X#include <memory.h>
  2672. X#include "vch.h"
  2673. X
  2674. X/***********************************************************************
  2675. X* NAME
  2676. X*     vch_vchncat()
  2677. X* PURPOSE
  2678. X*     Concatenate varchar to another varchar (length limited)
  2679. X* SYNOPSIS
  2680. X*     vch_vchncat (v1, v2, n)
  2681. X*     Vchmin *v1, *v2;
  2682. X*     VCH_LEN_TYPE     n;
  2683. X* DESCRIPTION
  2684. X*     Concatenate varchar v2 onto end of varchar v1 adding max on n bytes
  2685. X************************************************************************/
  2686. XVchmin     *vch_vchncat
  2687. X    (
  2688. X    Vchmin    *v1,
  2689. X    Vchmin    *v2,
  2690. X    VCH_LEN_TYPE n
  2691. X    )
  2692. X{
  2693. X    if ((v1 != NULL) && (v2 != NULL)) {
  2694. X        if (n > v2->len)
  2695. X            n = v2->len;
  2696. X        memcpy (v1->arr + v1->len, v2->arr, n);
  2697. X        v1->len += n;
  2698. X    }
  2699. X    return (v1);
  2700. X}
  2701. X
  2702. END_OF_FILE
  2703. if test 1447 -ne `wc -c <'vv_ncat.c'`; then
  2704.     echo shar: \"'vv_ncat.c'\" unpacked with wrong size!
  2705. fi
  2706. # end of 'vv_ncat.c'
  2707. fi
  2708. if test -f 'vv_ncpy.c' -a "${1}" != "-c" ; then 
  2709.   echo shar: Will not clobber existing file \"'vv_ncpy.c'\"
  2710. else
  2711. echo shar: Extracting \"'vv_ncpy.c'\" \(1358 characters\)
  2712. sed "s/^X//" >'vv_ncpy.c' <<'END_OF_FILE'
  2713. X/***********************************************************************
  2714. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_ncpy.c,v $
  2715. X* $Revision: 1.1 $
  2716. X* $Date: 1992/11/17 05:50:17 $
  2717. X* $State: Exp $
  2718. X* $Locker:  $
  2719. X* $Author: dtb $
  2720. X************************************************************************
  2721. X* 
  2722. X* $Log: vv_ncpy.c,v $
  2723. X* Revision 1.1  1992/11/17  05:50:17  dtb
  2724. X* initial real cut
  2725. X*
  2726. X* 
  2727. X************************************************************************
  2728. X* Description
  2729. X*    Length limited copy from varchar to varchar
  2730. X***********************************************************************/
  2731. X
  2732. 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 $" ;
  2733. X
  2734. X#include <stdio.h>
  2735. X#include <string.h>
  2736. X#include <memory.h>
  2737. X#include "vch.h"
  2738. X
  2739. X/***********************************************************************
  2740. X* NAME
  2741. X*     vch_vchncpy()
  2742. X* PURPOSE
  2743. X*     Copy varchar to another varchar (length limited)
  2744. X* SYNOPSIS
  2745. X*     vch_vchncpy (v1, v2, n)
  2746. X*     Vchmin *v1, *v2;
  2747. X*     VCH_LEN_TYPE     n;
  2748. X* DESCRIPTION
  2749. X*     Copies varchar v2 into varchar v1 (length limited)
  2750. X***********************************************************************/
  2751. XVchmin     *vch_vchncpy
  2752. X    (
  2753. X    Vchmin    *v1,
  2754. X    Vchmin    *v2,
  2755. X    VCH_LEN_TYPE     n
  2756. X    )
  2757. X{
  2758. X    memcpy (v1->arr, v2->arr, v1->len = ((v2->len < n) ? v2->len : n ));
  2759. X    return (v1);
  2760. X}
  2761. X
  2762. END_OF_FILE
  2763. if test 1358 -ne `wc -c <'vv_ncpy.c'`; then
  2764.     echo shar: \"'vv_ncpy.c'\" unpacked with wrong size!
  2765. fi
  2766. # end of 'vv_ncpy.c'
  2767. fi
  2768. if test -f 'vv_rtrim.c' -a "${1}" != "-c" ; then 
  2769.   echo shar: Will not clobber existing file \"'vv_rtrim.c'\"
  2770. else
  2771. echo shar: Extracting \"'vv_rtrim.c'\" \(1480 characters\)
  2772. sed "s/^X//" >'vv_rtrim.c' <<'END_OF_FILE'
  2773. X/***********************************************************************
  2774. X* $Source: /usr/oracle/v6.0.30.3/local/src/lib/varchar/RCS/vv_rtrim.c,v $
  2775. X* $Revision: 1.1 $
  2776. X* $Date: 1992/11/17 05:50:17 $
  2777. X* $State: Exp $
  2778. X* $Locker:  $
  2779. X* $Author: dtb $
  2780. X************************************************************************
  2781. X* 
  2782. X* $Log: vv_rtrim.c,v $
  2783. X* Revision 1.1  1992/11/17  05:50:17  dtb
  2784. X* initial real cut
  2785. X*
  2786. X* 
  2787. X************************************************************************
  2788. X* Description
  2789. X*    Trims varchar from right if character in second varchar
  2790. X***********************************************************************/
  2791. X
  2792. 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 $" ;
  2793. X
  2794. X#include <stdio.h>
  2795. X#include <string.h>
  2796. X#include <memory.h>
  2797. X#include "vch.h"
  2798. X
  2799. X/***********************************************************************
  2800. X* NAME
  2801. X*     vch_vchrtrim()
  2802. X* PURPOSE
  2803. X*     Trims varchar from right if character in second varchar
  2804. X* SYNOPSIS
  2805. X*     vch_vchrtrim (v1, v2)
  2806. X*     Vchmin *v1, *v2;
  2807. X* DESCRIPTION
  2808. X*     Trims v1 from right for characters in set v2
  2809. X************************************************************************/
  2810. XVchmin     *vch_vchrtrim
  2811. X    (
  2812. X    Vchmin    *v1,
  2813. X    Vchmin    *v2 
  2814. X    )
  2815. X{
  2816. X    int    l;
  2817. X
  2818. X    for (l=(vchlen(v1)); l > 0; l--) {
  2819. X        if (memchr(v2->arr, (int) *(v1->arr + l - 1), v2->len) == NULL)
  2820. X            break;
  2821. X        v1->len = v1->len - 1;
  2822. X        *(v1->arr + v1->len) = '\0';    /* Set it to null character */
  2823. X    }
  2824. X    return (v1);
  2825. X}
  2826. X
  2827. X
  2828. END_OF_FILE
  2829. if test 1480 -ne `wc -c <'vv_rtrim.c'`; then
  2830.     echo shar: \"'vv_rtrim.c'\" unpacked with wrong size!
  2831. fi
  2832. # end of 'vv_rtrim.c'
  2833. fi
  2834. echo shar: End of shell archive.
  2835. exit 0
  2836. -- 
  2837. David T. Bath
  2838. email:     dtb@otto.bf.rmit.oz.au
  2839. Work:     Global Technology Corporation, Carlton, Vic, OZ  (03) 3477511
  2840. #include <disclaimer.h>
  2841.