home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / database / informix / 2325 < prev    next >
Encoding:
Internet Message Format  |  1992-11-06  |  34.2 KB

  1. Path: sparky!uunet!destroyer!gatech!emory!emory!not-for-mail
  2. From: johnl@obelix.informix.com (Jonathan Leffler)
  3. Newsgroups: comp.databases.informix
  4. Subject: Re:  Inserting BLOB into Database Table
  5. Date: 5 Nov 1992 14:53:17 -0500
  6. Organization: Mailing List Gateway
  7. Lines: 1180
  8. Sender: walt@mathcs.emory.edu
  9. Distribution: world
  10. Message-ID: <1dbu3dINNqhe@emory.mathcs.emory.edu>
  11. Reply-To: johnl@obelix.informix.com (Jonathan Leffler)
  12. NNTP-Posting-Host: emory.mathcs.emory.edu
  13. X-Informix-List-ID: <list.1572>
  14.  
  15.  
  16. You don't say what tools you have available...
  17.  
  18. If you have ISQL, the following info may be of relevance:
  19.  
  20. >From: johnl (Jonathan Leffler)
  21. >Date: Wed Nov 4 09:53:59 1992
  22. >To: skidwell@jupiter
  23. >Subject: Re:  loading into blob space thru sql
  24. >
  25. >>Date: Tue, 3 Nov 92 14:45:21 CST
  26. >>From: skidwell@jupiter (Sherri Kidwell)
  27. >>To: tech@jupiter
  28. >>Subject: loading into blob space thru sql
  29. >
  30. >>I have a customer that wants to load a gif file as a blob into
  31. >>a table through SQL only.  Can this be done?  If so, how?
  32. >
  33. >Dear Sherri,
  34. >
  35. >The only possible route is through The PROGRAM attribute in the blob field
  36. >attributes of a Perform screen -- the load command requires the data in its
  37. >own format, and nothing else gets close.
  38. >
  39. >The program specified by the form will be invoked with the name of a
  40. >temporary file as the blob.  When the program returns, the contents of that
  41. >file will be used as the blob.  So, the obvious solution seems to be a
  42. >script of some sort which allows the user to specify a GIF file name.  I
  43. >tried a solution which removed the original temporary file, and did a
  44. >symbolic link to the GIF file.  Perform should have cleaned up after itself
  45. >by removing the symbolic link.  However, this did not work satisfactorily
  46. >-- it zapped the script I had developed (because I pretended that the
  47. >script was a GIF file), which was a nuisance though hardly serious.  It
  48. >seems that the successful way of doing it is to copy the GIF file over the
  49. >temporary file, which leads to the following Bourne Shell script:
  50. >
  51. >echo
  52. >#echo -n "Enter name of GIF file: "
  53. >echo "Enter name of GIF file: \c"
  54. >read file
  55. >cp $file $1
  56. >
  57. >The first echo places the prompt on the line after the "Please wait!"
  58. >message issued by Perform.  The commented out echo might be necessary on a
  59. >BSD system where the Bourne shell does not recognise the "\c"
  60. >metacharacter, which means suppress the newline.
  61. >
  62. >Yours,
  63. >Jonathan Leffler (johnl@obelix)
  64.  
  65. If you ESQL/C, you may be interested in the program in the shell archive below.
  66. You may not need getopt.c and/or memmove.c, but I've supplied them just in
  67. case.  The code was developed on Intercative 386/IX 3.2.2 under OnLine and
  68. ESQL/C 5.00.UC1.  You use the program updblob as:
  69.  
  70. updblob -d database -t table -k column1=1234,column2=ABC -f blob-file
  71.  
  72. Put quotes around the key strings if there are spaces in the key.
  73. I cannot guarantee the behaviour of the key parsing code if you have
  74. either commas or equals signs in the key string.
  75.  
  76. Yours,
  77. Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h>
  78.  
  79. :    "@(#)shar.sh    1.8"
  80. #! /bin/sh
  81. #
  82. #    This is a shell archive.
  83. #    Remove everything above this line and run sh on the resulting file.
  84. #    If this archive is complete, you will see this message at the end:
  85. #    "All files extracted"
  86. #
  87. #    Created: Thu Nov  5 10:02:33 GMT 1992 by johnl at Informix Software Ltd.
  88. #    Files archived in this archive:
  89. #    updblob.ec
  90. #    getopt.c
  91. #    getopt.h
  92. #    stderr.c
  93. #    stderr.h
  94. #    memmove.c
  95. #
  96. #--------------------
  97. if [ -f updblob.ec -a "$1" != "-c" ]
  98. then echo shar: updblob.ec already exists
  99. else
  100. echo 'x - updblob.ec (4395 characters)'
  101. sed -e 's/^X//' >updblob.ec <<'SHAR-EOF'
  102. X/*
  103. X@(#)File:            updblob.ec
  104. X@(#)Version:         1.1
  105. X@(#)Last changed:    92/10/13
  106. X@(#)Purpose:         General program to update a blob from file
  107. X@(#)Author:          J Leffler
  108. X@(#)Copyright:       (C) JLSS 1992
  109. X@(#)Product:         :PRODUCT:
  110. X*/
  111. X
  112. X/*TABSTOP=4*/
  113. X
  114. X#include <stdio.h>
  115. X#include <string.h>
  116. X#include <sqlca.h>
  117. X#include <locator.h>
  118. X#include <sqltypes.h>
  119. X#include "stderr.h"
  120. X#include "getopt.h"
  121. X
  122. X#define BUFFSIZE    2048
  123. X#define NIL(x)        ((x)0)
  124. X#define DIM(x)        (sizeof(x)/sizeof(*(x)))
  125. X
  126. Xextern void sql_error();
  127. Xextern void locate_file();
  128. X
  129. Xstatic char usestr[] =
  130. X    "[-Vx] -d dbase -t table -c blobcolumn -k column=value,...  [-f] blobfile";
  131. X
  132. X#ifndef lint
  133. Xstatic char     sccs[] = "@(#)updblob.ec    1.1 92/10/13";
  134. X#endif
  135. X
  136. Xmain(argc, argv)
  137. Xint    argc;
  138. Xchar    **argv;
  139. X{
  140. X    EXEC SQL BEGIN DECLARE SECTION;
  141. X    char    *dbase = (char *)0;
  142. X    loc_t    blob;
  143. X    char     stmt[BUFFSIZE];
  144. X    EXEC SQL END DECLARE SECTION;
  145. X    char    *table = (char *)0;
  146. X    char    *blobcol = (char *)0;
  147. X    int         nkeycols = 0;
  148. X    char    *keycol[16];
  149. X    char    *keyval[16];
  150. X    char    *blobfile = (char *)0;
  151. X    int         opt;
  152. X    char    *pad;
  153. X    char    *s;
  154. X    int         i;
  155. X    int         xflag = 0;
  156. X    int         len;
  157. X
  158. X    setarg0(argv[0]);
  159. X    while ((opt = getopt(argc, argv, "Vxd:t:c:k:f:")) != EOF)
  160. X    {
  161. X        switch (opt)
  162. X        {
  163. X        case 'x':
  164. X            xflag = 1;
  165. X            break;
  166. X        case 'V':
  167. X            puts(&"@(#):UPDBLOB:"[4]);
  168. X            exit(0);
  169. X            /*NOTREACHED*/
  170. X        case 't':
  171. X            table = optarg;
  172. X            break;
  173. X        case 'c':
  174. X            blobcol = optarg;
  175. X            break;
  176. X        case 'd':
  177. X            dbase = optarg;
  178. X            break;
  179. X        case 'f':
  180. X            blobfile = optarg;
  181. X            break;
  182. X        case 'k':
  183. X            nkeycols = parse_columns(optarg, keycol, keyval, DIM(keyval));
  184. X            break;
  185. X        default:
  186. X            usage(usestr);
  187. X            /*NOTREACHED*/
  188. X        }
  189. X    }
  190. X
  191. X    if (blobfile == (char *)0 && optind == argc - 1)
  192. X        blobfile = argv[optind++];
  193. X    if (optind != argc || blobfile == NIL(char *) || dbase == NIL(char *) ||
  194. X        table == NIL(char *) || nkeycols == 0 || blobcol == NIL(char *))
  195. X        usage(usestr);
  196. X
  197. X    locate_file(&blob, SQLBYTES, blobfile);
  198. X    EXEC SQL DATABASE :dbase;
  199. X    if (sqlca.sqlcode != 0)
  200. X        sql_error("database", dbase);
  201. X
  202. X    sprintf(stmt, "UPDATE %s SET %s = ? WHERE", table, blobcol);
  203. X    pad = "";
  204. X    s = stmt + strlen(stmt);
  205. X    for (i = 0; i < nkeycols; i++)
  206. X    {
  207. X        sprintf(s, "%s %s = '%s'", pad, keycol[i], keyval[i]);
  208. X        pad = " AND";
  209. X        s += strlen(s);
  210. X    }
  211. X
  212. X    if (xflag)
  213. X    {
  214. X        len = strlen(stmt);
  215. X        for (i = 0; i < len; i += 75)
  216. X            printf("%.75s\n", &stmt[i]);
  217. X    }
  218. X
  219. X    EXEC SQL PREPARE p_update FROM :stmt;
  220. X    if (sqlca.sqlcode != 0)
  221. X        sql_error("prepare update", table);
  222. X    EXEC SQL EXECUTE p_update USING :blob;
  223. X    if (sqlca.sqlcode != 0)
  224. X        sql_error("execute update", table);
  225. X
  226. X    return(0);
  227. X}
  228. X
  229. Xvoid locate_file(blob, type, file)
  230. Xloc_t    *blob;
  231. Xint         type;
  232. Xchar    *file;
  233. X{
  234. X    blob->loc_indicator = 0;
  235. X    blob->loc_type = type;
  236. X    blob->loc_loctype = LOCFNAME;
  237. X    blob->loc_fname = file;
  238. X    blob->loc_oflags = LOC_RONLY;
  239. X    blob->loc_size = -1;
  240. X}
  241. X
  242. X/* Database generated error */
  243. Xvoid            sql_error(s1, s2)
  244. Xchar           *s1;
  245. Xchar           *s2;
  246. X{
  247. X    char            buffer[512];
  248. X
  249. X    fflush(stdout);
  250. X    rgetmsg(sqlca.sqlcode, buffer, sizeof(buffer));
  251. X    fprintf(stderr, "SQL %d: ", sqlca.sqlcode);
  252. X    if (sqlca.sqlerrd[1] != 0)
  253. X        fprintf(stderr, "(ISAM %d) ", sqlca.sqlerrd[1]);
  254. X    fprintf(stderr, buffer, sqlca.sqlerrm);
  255. X    if (s1 != NIL(char *))
  256. X        fprintf(stderr, "%s %s\n", s1, (s2 ? s2 : ""));
  257. X}
  258. X
  259. Xchar    *process_quote(optarg)
  260. Xchar    **optarg;
  261. X{
  262. X    char    *s = *optarg;
  263. X    char     q = *s++;
  264. X    char    *p = s;
  265. X    char     oc = '\0';        /* Anything except the quote in q */
  266. X    char     c;
  267. X
  268. X    while ((c == *s++) != '\0')
  269. X    {
  270. X        if (c == q && oc != '\\')
  271. X        {
  272. X            *(s-1) = '\0';
  273. X            break;
  274. X        }
  275. X        oc = c;
  276. X    }
  277. X
  278. X    if (c != q)
  279. X        error2("unclosed quotes in key value", p - 1);
  280. X
  281. X    *optarg = s;
  282. X    return(p);
  283. X}
  284. X
  285. Xint     parse_columns(optarg, keycol, keyval, maxkey)
  286. Xchar    *optarg;
  287. Xchar    **keycol;
  288. Xchar    **keyval;
  289. Xint          maxkey;
  290. X{
  291. X    int        i;
  292. X    char    *s;
  293. X
  294. X    for (i = 0; i < maxkey && *optarg != '\0'; i++)
  295. X    {
  296. X        if ((s = strchr(optarg, '=')) == NIL(char *))
  297. X            error2("key column format error (no '=')", optarg);
  298. X        *keycol++ = optarg;
  299. X        *s = '\0';
  300. X        optarg = s + 1;
  301. X        if (!*optarg)
  302. X            error2("key column with no key value", *(keycol-1));
  303. X        if (*optarg == '\'' || *optarg == '"')
  304. X            *keyval++ = process_quote(&optarg);
  305. X        else if ((s = strchr(optarg, ',')) == NIL(char *))
  306. X        {
  307. X            /* All done -- the only normal return from this code */
  308. X            *keyval++ = optarg;
  309. X            return(i+1);
  310. X        }
  311. X        else
  312. X        {
  313. X            *keyval++ = optarg;
  314. X            *s = '\0';
  315. X            optarg = s + 1;
  316. X        }
  317. X    }
  318. X    error2("too many key columns specified", optarg);
  319. X    /*NOTREACHED*/
  320. X}
  321. SHAR-EOF
  322. chmod 444 updblob.ec
  323. if [ `wc -c <updblob.ec` -ne 4395 ]
  324. then echo shar: updblob.ec unpacked with wrong size
  325. fi
  326. # end of overwriting check
  327. fi
  328. #--------------------
  329. if [ -f getopt.c -a "$1" != "-c" ]
  330. then echo shar: getopt.c already exists
  331. else
  332. echo 'x - getopt.c (17640 characters)'
  333. sed -e 's/^X//' >getopt.c <<'SHAR-EOF'
  334. X/*
  335. X@(#)File:            getopt.c
  336. X@(#)Version:         2.6
  337. X@(#)Last changed:    91/12/22
  338. X@(#)Purpose:         GNU version of GETOPT(3)
  339. X@(#)Copyright:       (C) 1987 Free Software Foundation, Inc.
  340. X@(#)Amendments:      J Leffler, JLSS
  341. X@(#)Product:         :PRODUCT:
  342. X*/
  343. X
  344. X/*TABSTOP=4*/
  345. X/*LINTLIBRARY*/
  346. X
  347. X#ifndef lint
  348. Xstatic    char    sccs[] = "@(#)getopt.c    2.6 91/12/22";
  349. X#endif
  350. X
  351. X/*
  352. X**  Function xmalloc removed -- inline code used instead.
  353. X**  Changed error message to "out of memory".
  354. X**    Use stdlib.h to declare malloc().  Use memmove() instead of memcpy().
  355. X**  Remove BSD bcopy and index stuff -- not POSIX compatible.
  356. X**
  357. X**    J Leffler, JLSS, 15th December 1991.
  358. X*/
  359. X
  360. X/*
  361. X**    Global variable optopt added to conform with System V Release 4.
  362. X**    This contains the function return value unless the return value is the
  363. X**    error return '?', in which case, optopt contains the value of the option
  364. X**    which caused the error return.  Also use isprint() (from ctype.h) to
  365. X**    determine whether character is printable (instead of the non-portable
  366. X**    and not always helpful (c < 040 || c >= 0177)).
  367. X**
  368. X**    J Leffler, Informix Software Ltd, 17th December 1990.
  369. X*/
  370. X
  371. X/*
  372. X**    Format of code and comments revised to suit local conventions.
  373. X**    Function completely unaltered, though appended memcpy() removed.
  374. X**    Default compilation changed to SYSV mode -- unless BSD is defined,
  375. X**    it will be compiled using strchr and memcpy.
  376. X**
  377. X**    NB: this version of getopt(3) allows for flags which take optional
  378. X**    arguments.  This is done by using "f::" in place of "f:" in the
  379. X**    option string.  The optional argument must be attached to flag.
  380. X**
  381. X**    J Leffler, Sphinx Ltd, 3rd April 1990.
  382. X*/
  383. X
  384. X/*
  385. X   Getopt for GNU.
  386. X   Modified by David MacKenzie to use malloc and free instead of alloca,
  387. X   and memcpy instead of bcopy under System V.
  388. X   Copyright (C) 1987 Free Software Foundation, Inc.
  389. X
  390. X               NO WARRANTY
  391. X
  392. XBECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  393. XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  394. XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  395. XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  396. XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  397. XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  398. XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  399. XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  400. XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  401. XCORRECTION.
  402. X
  403. XIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  404. XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  405. XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  406. XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  407. XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  408. XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  409. XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  410. XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  411. XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  412. XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  413. X
  414. X        GENERAL PUBLIC LICENSE TO COPY
  415. X
  416. X  1. You may copy and distribute verbatim copies of this source file
  417. Xas you receive it, in any medium, provided that you conspicuously and
  418. Xappropriately publish on each copy a valid copyright notice "Copyright
  419. X (C) 1987 Free Software Foundation, Inc."; and include following the
  420. Xcopyright notice a verbatim copy of the above disclaimer of warranty
  421. Xand of this License.  You may charge a distribution fee for the
  422. Xphysical act of transferring a copy.
  423. X
  424. X  2. You may modify your copy or copies of this source file or
  425. Xany portion of it, and copy and distribute such modifications under
  426. Xthe terms of Paragraph 1 above, provided that you also do the following:
  427. X
  428. X    a) cause the modified files to carry prominent notices stating
  429. X    that you changed the files and the date of any change; and
  430. X
  431. X    b) cause the whole of any work that you distribute or publish,
  432. X    that in whole or in part contains or is a derivative of this
  433. X    program or any part thereof, to be licensed at no charge to all
  434. X    third parties on terms identical to those contained in this
  435. X    License Agreement (except that you may choose to grant more
  436. X    extensive warranty protection to third parties, at your option).
  437. X
  438. X    c) You may charge a distribution fee for the physical act of
  439. X    transferring a copy, and you may at your option offer warranty
  440. X    protection in exchange for a fee.
  441. X
  442. X  3. You may copy and distribute this program or any portion of it in
  443. Xcompiled, executable or object code form under the terms of Paragraphs
  444. X1 and 2 above provided that you do the following:
  445. X
  446. X    a) cause each such copy to be accompanied by the
  447. X    corresponding machine-readable source code, which must
  448. X    be distributed under the terms of Paragraphs 1 and 2 above; or,
  449. X
  450. X    b) cause each such copy to be accompanied by a
  451. X    written offer, with no time limit, to give any third party
  452. X    free (except for a nominal shipping charge) a machine readable
  453. X    copy of the corresponding source code, to be distributed
  454. X    under the terms of Paragraphs 1 and 2 above; or,
  455. X
  456. X    c) in the case of a recipient of this program in compiled, executable
  457. X    or object code form (without the corresponding source code) you
  458. X    shall cause copies you distribute to be accompanied by a copy
  459. X    of the written offer of source code which you received along
  460. X    with the copy you received.
  461. X
  462. X  4. You may not copy, sublicense, distribute or transfer this program
  463. Xexcept as expressly provided under this License Agreement.  Any attempt
  464. Xotherwise to copy, sublicense, distribute or transfer this program is void and
  465. Xyour rights to use the program under this License agreement shall be
  466. Xautomatically terminated.  However, parties who have received computer
  467. Xsoftware programs from you with this License Agreement will not have
  468. Xtheir licenses terminated so long as such parties remain in full compliance.
  469. X
  470. X  5. If you wish to incorporate parts of this program into other free
  471. Xprograms whose distribution conditions are different, write to the Free
  472. XSoftware Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  473. Xworked out a simple rule that can be stated here, but we will often permit
  474. Xthis.  We will be guided by the two goals of preserving the free status of
  475. Xall derivatives of our free software and of promoting the sharing and reuse of
  476. Xsoftware.
  477. X
  478. XIn other words, you are welcome to use, share and improve this program.
  479. XYou are forbidden to forbid anyone else to use, share and improve
  480. Xwhat you give them.   Help stamp out software-hoarding!
  481. X*/
  482. X
  483. X/*
  484. X** This version of `getopt' appears to the caller like standard Unix `getopt'
  485. X** but it behaves differently for the user, since it allows the user
  486. X** to intersperse the options with the other arguments.
  487. X**
  488. X** As `getopt' works, it permutes the elements of `argv' so that,
  489. X** when it is done, all the options precede everything else.  Thus
  490. X** all application programs are extended to handle flexible argument order.
  491. X**
  492. X** Setting the environment variable _POSIX_OPTION_ORDER disables permutation.
  493. X** Then the behavior is completely standard.
  494. X**
  495. X** GNU application programs can use a third alternative mode in which
  496. X** they can distinguish the relative order of options and other arguments.
  497. X*/
  498. X
  499. X#include <stdio.h>
  500. X#include <stdlib.h>
  501. X#include <string.h>
  502. X#include <ctype.h>
  503. X
  504. X/*
  505. X**    optarg -- for communication from `getopt' to the caller.
  506. X**    When `getopt' finds an option that takes an argument,
  507. X**    the argument value is returned here.
  508. X**    Also, when `ordering' is RETURN_IN_ORDER,
  509. X**    each non-option ARGV-element is returned here.
  510. X*/
  511. Xchar *optarg = 0;
  512. X
  513. X/*
  514. X**    optind -- index in ARGV of the next element to be scanned.
  515. X**    This is used for communication to and from the caller
  516. X**    and for communication between successive calls to `getopt'.
  517. X**
  518. X**    On entry to `getopt', zero means this is the first call; initialize.
  519. X**
  520. X**    When `getopt' returns EOF, this is the index of the first of the
  521. X**    non-option elements that the caller should itself scan.
  522. X**
  523. X**    Otherwise, `optind' communicates from one call to the next
  524. X**    how much of ARGV has been scanned so far.
  525. X*/
  526. Xint optind = 0;
  527. X
  528. X/*
  529. X**    nextchar -- the next char to be scanned in the option-element
  530. X**    in which the last option character we returned was found.
  531. X**    This allows us to pick up the scan where we left off.
  532. X**
  533. X**    If this is zero, or a null string, it means resume the scan
  534. X**    by advancing to the next ARGV-element.
  535. X*/
  536. Xstatic char *nextchar;
  537. X
  538. X/*
  539. X**    opterr -- callers store zero here to inhibit the error message
  540. X**    for unrecognized options.
  541. X*/
  542. Xint opterr = 1;
  543. X
  544. X/*
  545. X**    optopt -- copy of option which was detected.  It is the same as the
  546. X**    function return value unless the function returns '?' (for an invalid
  547. X**    option) when optopt contains the actual flag which caused the error.
  548. X**    Added in conformity with UNIX System V Release 4.
  549. X*/
  550. Xint optopt;
  551. X
  552. X/*
  553. X**    Describe how to deal with options that follow non-option ARGV-elements.
  554. X**
  555. X**    UNSPECIFIED means the caller did not specify anything;
  556. X**    the default is then REQUIRE_ORDER if the environment variable
  557. X**    _POSIX_OPTION_ORDER is defined, PERMUTE otherwise.
  558. X**
  559. X**    REQUIRE_ORDER means don't recognize them as options.
  560. X**    Stop option processing when the first non-option is seen.
  561. X**    This is what Unix does.
  562. X**
  563. X**    PERMUTE is the default.  We permute the contents of `argv' as we scan,
  564. X**    so that eventually all the options are at the end.  This allows options
  565. X**    to be given in any order, even with programs that were not written to
  566. X**    expect this.
  567. X**
  568. X**    RETURN_IN_ORDER is an option available to programs that were written
  569. X**    to expect options and other ARGV-elements in any order and that care about
  570. X**    the ordering of the two.  We describe each non-option ARGV-element
  571. X**    as if it were the argument of an option with character code zero.
  572. X**    Using `-' as the first character of the list of option characters
  573. X**    requests this mode of operation.
  574. X**
  575. X**    The special argument `--' forces an end of option-scanning regardless
  576. X**    of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
  577. X**    `--' can cause `getopt' to return EOF with `optind' != ARGC.
  578. X*/
  579. Xstatic enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
  580. X
  581. X/* Handle permutation of arguments.  */
  582. X
  583. X/*
  584. X**    Describe the part of ARGV that contains non-options that have
  585. X**    been skipped.  `first_nonopt' is the index in ARGV of the first of them;
  586. X**    `last_nonopt' is the index after the last of them.
  587. X*/
  588. Xstatic int first_nonopt;
  589. Xstatic int last_nonopt;
  590. X
  591. X/*
  592. X**    Exchange two adjacent subsequences of ARGV.
  593. X**    One subsequence is elements [first_nonopt,last_nonopt)
  594. X**    which contains all the non-options that have been skipped so far.
  595. X**    The other is elements [last_nonopt,optind), which contains all
  596. X**    the options processed since those non-options were skipped.
  597. X**    `first_nonopt' and `last_nonopt' are relocated so that they describe
  598. X**    the new indices of the non-options in ARGV after they are moved.
  599. X*/
  600. X
  601. Xstatic void exchange(argv)
  602. Xchar **argv;
  603. X{
  604. X    int nonopts_size = (last_nonopt - first_nonopt) * sizeof(char *);
  605. X    char **temp;
  606. X
  607. X    if ((temp = (char **)malloc(nonopts_size)) == (char **)0)
  608. X    {
  609. X        fprintf(stderr, "out of memory\n");
  610. X        exit(1);
  611. X    }
  612. X
  613. X    /* Interchange the two blocks of data in argv.  */
  614. X    memmove(temp, &argv[first_nonopt], nonopts_size);
  615. X    memmove(&argv[first_nonopt], &argv[last_nonopt],
  616. X        (optind - last_nonopt) * sizeof(char *));
  617. X    memmove(&argv[first_nonopt + optind - last_nonopt], temp, nonopts_size);
  618. X
  619. X    free(temp);
  620. X
  621. X    /* Update records for the slots the non-options now occupy.  */
  622. X    first_nonopt += (optind - last_nonopt);
  623. X    last_nonopt = optind;
  624. X}
  625. X
  626. X/*
  627. X**    Scan elements of ARGV (whose length is ARGC) for option characters
  628. X**    given in OPTSTRING.
  629. X**
  630. X**    If an element of ARGV starts with '-', and is not exactly "-" or "--",
  631. X**    then it is an option element.  The characters of this element
  632. X**    (aside from the initial '-') are option characters.  If `getopt'
  633. X**    is called repeatedly, it returns successively each of the option characters
  634. X**    from each of the option elements.
  635. X**
  636. X**    If `getopt' finds another option character, it returns that character,
  637. X**    updating `optind' and `nextchar' so that the next call to `getopt' can
  638. X**    resume the scan with the following option character or ARGV-element.
  639. X**
  640. X**    If there are no more option characters, `getopt' returns `EOF'.
  641. X**    Then `optind' is the index in ARGV of the first ARGV-element
  642. X**    that is not an option.  (The ARGV-elements have been permuted
  643. X**    so that those that are not options now come last.)
  644. X**
  645. X**    OPTSTRING is a string containing the legitimate option characters.
  646. X**    A colon in OPTSTRING means that the previous character is an option
  647. X**    that wants an argument.  The argument is taken from the rest of the
  648. X**    current ARGV-element, or from the following ARGV-element,
  649. X**    and returned in `optarg'.
  650. X**
  651. X**    If an option character is seen that is not listed in OPTSTRING,
  652. X**    return '?' after printing an error message.  If you set `opterr' to
  653. X**    zero, the error message is suppressed but we still return '?'.
  654. X**
  655. X**    If a char in OPTSTRING is followed by a colon, that means it wants an arg,
  656. X**    so the following text in the same ARGV-element, or the text of the following
  657. X**    ARGV-element, is returned in `optarg.  Two colons mean an option that
  658. X**    wants an optional arg; if there is text in the current ARGV-element,
  659. X**    it is returned in `optarg'.
  660. X**
  661. X**    If OPTSTRING starts with `-', it requests a different method of handling the
  662. X**    non-option ARGV-elements.  See the comments about RETURN_IN_ORDER, above.
  663. X*/
  664. X
  665. Xint getopt(argc, argv, optstring)
  666. Xint argc;
  667. Xchar **argv;
  668. Xchar *optstring;
  669. X{
  670. X
  671. X    if (optind == 0)
  672. X    {
  673. X        /*
  674. X        ** Initialize the internal data when the first call is made.
  675. X        ** Start processing options with ARGV-element 1 (since ARGV-element 0
  676. X        ** is the program name); the sequence of previously skipped
  677. X        ** non-option ARGV-elements is empty.
  678. X        */
  679. X        first_nonopt = last_nonopt = optind = 1;
  680. X        nextchar = 0;
  681. X
  682. X        /* Determine how to handle the ordering of options and nonoptions.  */
  683. X        if (optstring[0] == '-')
  684. X            ordering = RETURN_IN_ORDER;
  685. X        else if (getenv("_POSIX_OPTION_ORDER") != 0)
  686. X            ordering = REQUIRE_ORDER;
  687. X        else
  688. X            ordering = PERMUTE;
  689. X    }
  690. X
  691. X    if (nextchar == 0 || *nextchar == 0)
  692. X    {
  693. X        if (ordering == PERMUTE)
  694. X        {
  695. X            /*
  696. X            ** If we have just processed some options following some
  697. X            ** non-options, exchange them so that the options come first.
  698. X            */
  699. X            if (first_nonopt != last_nonopt && last_nonopt != optind)
  700. X                exchange(argv);
  701. X            else if (last_nonopt != optind)
  702. X                first_nonopt = optind;
  703. X
  704. X            /*
  705. X            ** Now skip any additional non-options and extend
  706. X            ** the range of non-options previously skipped.
  707. X            */
  708. X            while (optind < argc &&
  709. X                    (argv[optind][0] != '-' || argv[optind][1] == 0))
  710. X                optind++;
  711. X            last_nonopt = optind;
  712. X        }
  713. X
  714. X        /*
  715. X        ** Special ARGV-element `--' means premature end of options.
  716. X         ** Skip it like a null option, then exchange with previous
  717. X        ** non-options as if it were an option, then skip everything else
  718. X        ** like a non-option.
  719. X        */
  720. X        if (optind != argc && !strcmp(argv[optind], "--"))
  721. X        {
  722. X            optind++;
  723. X
  724. X            if (first_nonopt != last_nonopt && last_nonopt != optind)
  725. X                exchange(argv);
  726. X            else if (first_nonopt == last_nonopt)
  727. X                first_nonopt = optind;
  728. X            last_nonopt = argc;
  729. X
  730. X            optind = argc;
  731. X        }
  732. X
  733. X        /*
  734. X        ** If we have done all the ARGV-elements, stop the scan
  735. X         ** and back over any non-options that we skipped and permuted.
  736. X        */
  737. X        if (optind == argc)
  738. X        {
  739. X            /*
  740. X            ** Set the next-arg-index to point at the non-options
  741. X             ** that we previously skipped, so the caller will digest them.
  742. X            */
  743. X            if (first_nonopt != last_nonopt)
  744. X                optind = first_nonopt;
  745. X            return EOF;
  746. X        }
  747. X
  748. X        /*
  749. X        ** If we have come to a non-option and did not permute it,
  750. X         ** either stop the scan or describe it to the caller and pass it by.
  751. X        */
  752. X        if (argv[optind][0] != '-' || argv[optind][1] == 0)
  753. X        {
  754. X            if (ordering == REQUIRE_ORDER)
  755. X                return EOF;
  756. X            optarg = argv[optind++];
  757. X            return 0;
  758. X        }
  759. X
  760. X        /*
  761. X        ** We have found another option-ARGV-element.
  762. X         ** Start decoding its characters.
  763. X        */
  764. X        nextchar = argv[optind] + 1;
  765. X    }
  766. X
  767. X    /* Look at and handle the next option-character.  */
  768. X    {
  769. X        char c = *nextchar++;
  770. X        char *temp = strchr(optstring, c);
  771. X
  772. X        /* Set optopt */
  773. X        optopt = c;
  774. X
  775. X        /* Increment `optind' when we start to process its last character.  */
  776. X        if (*nextchar == 0)
  777. X            optind++;
  778. X
  779. X        if (temp == 0 || c == ':')
  780. X        {
  781. X            if (opterr != 0)
  782. X            {
  783. X                if (!isprint(c))
  784. X                    fprintf(stderr, "%s: unrecognized option, character code 0%o\n",
  785. X                        argv[0], c);
  786. X                else
  787. X                    fprintf(stderr, "%s: unrecognized option `-%c'\n",
  788. X                        argv[0], c);
  789. X            }
  790. X            return '?';
  791. X        }
  792. X        if (temp[1] == ':')
  793. X        {
  794. X            if (temp[2] == ':')
  795. X            {
  796. X                /* This is an option that accepts an argument optionally.  */
  797. X                if (*nextchar != 0)
  798. X                {
  799. X                    optarg = nextchar;
  800. X                    optind++;
  801. X                }
  802. X                else
  803. X                    optarg = 0;
  804. X                nextchar = 0;
  805. X            }
  806. X            else
  807. X            {
  808. X                /* This is an option that requires an argument.  */
  809. X                if (*nextchar != 0)
  810. X                {
  811. X                    optarg = nextchar;
  812. X                    /*
  813. X                    ** If we end this ARGV-element by taking the rest as
  814. X                    ** an arg, we must advance to the next element now.
  815. X                    */
  816. X                    optind++;
  817. X                }
  818. X                else if (optind == argc)
  819. X                {
  820. X                    if (opterr != 0)
  821. X                        fprintf(stderr, "%s: no argument for `-%c' option\n",
  822. X                            argv[0], c);
  823. X                    c = '?';
  824. X                }
  825. X                else
  826. X                {
  827. X                    /*
  828. X                    ** We already incremented `optind' once; increment it
  829. X                    ** again when taking next ARGV-elt as argument.
  830. X                    */
  831. X                    optarg = argv[optind++];
  832. X                }
  833. X                nextchar = 0;
  834. X            }
  835. X        }
  836. X        return c;
  837. X    }
  838. X}
  839. SHAR-EOF
  840. chmod 444 getopt.c
  841. if [ `wc -c <getopt.c` -ne 17640 ]
  842. then echo shar: getopt.c unpacked with wrong size
  843. fi
  844. # end of overwriting check
  845. fi
  846. #--------------------
  847. if [ -f getopt.h -a "$1" != "-c" ]
  848. then echo shar: getopt.h already exists
  849. else
  850. echo 'x - getopt.h (489 characters)'
  851. sed -e 's/^X//' >getopt.h <<'SHAR-EOF'
  852. X/*
  853. X@(#)File:            getopt.h
  854. X@(#)Version:         1.1
  855. X@(#)Last changed:    92/03/23
  856. X@(#)Purpose:         Definitions for GETOPT(3)
  857. X@(#)Author:          J Leffler
  858. X@(#)Copyright:       JLSS (C) 1992
  859. X*/
  860. X
  861. X#ifndef GETOPT_H
  862. X#define GETOPT_H
  863. X
  864. Xextern int      optopt;
  865. Xextern int      opterr;
  866. Xextern int      optind;
  867. Xextern char    *optarg;
  868. X
  869. X#ifdef __STDC__
  870. Xextern int      getopt(int argc, char **argv, char *opts);
  871. X#else
  872. Xextern int      getopt();
  873. X#endif    /* __STDC__ */
  874. X
  875. X#endif    /* GETOPT_H */
  876. SHAR-EOF
  877. chmod 444 getopt.h
  878. if [ `wc -c <getopt.h` -ne 489 ]
  879. then echo shar: getopt.h unpacked with wrong size
  880. fi
  881. # end of overwriting check
  882. fi
  883. #--------------------
  884. if [ -f stderr.c -a "$1" != "-c" ]
  885. then echo shar: stderr.c already exists
  886. else
  887. echo 'x - stderr.c (2995 characters)'
  888. sed -e 's/^X//' >stderr.c <<'SHAR-EOF'
  889. X/*
  890. X@(#)File:            stderr.c
  891. X@(#)Version:         6.2
  892. X@(#)Last changed:    91/12/22
  893. X@(#)Purpose:         Error reporting routines -- using stdio
  894. X@(#)Author:          J Leffler
  895. X@(#)Copyright:       (C) JLSS 1991
  896. X@(#)Product:         :PRODUCT:
  897. X*/
  898. X
  899. X/*TABSTOP=4*/
  900. X/*LINTLIBRARY*/
  901. X
  902. X#include <stdio.h>
  903. X#include <string.h>
  904. X#include <stdlib.h>
  905. X
  906. X#include "stderr.h"
  907. X
  908. X#ifdef __STDC__
  909. X#include <stdarg.h>
  910. X#else
  911. X#include <varargs.h>
  912. X#endif /* __STDC__ */
  913. X
  914. X#define global        /* Defined here -- accessible elsewhere */
  915. X#define NIL(x)        ((x)0)
  916. X#define MAX_CLEANUPS    32    /* Same as Standard C for atexit */
  917. X
  918. Xstatic void     (*cleanuplist[MAX_CLEANUPS])();
  919. Xstatic int      n_cleanups = 0;
  920. Xstatic char     _arg0[15] = "**undefined**";    /* Actual string */
  921. Xglobal char    *arg0 = _arg0;    /* Name of command */
  922. X
  923. X#ifndef lint
  924. Xstatic char     sccs[] = "@(#)stderr.c    6.2 91/12/22";
  925. X#endif    /* lint */
  926. X
  927. Xvoid            err_setcleanup(p)
  928. Xvoid            (*p)();
  929. X{
  930. X    if (n_cleanups < MAX_CLEANUPS)
  931. X        cleanuplist[n_cleanups++] = p;
  932. X}
  933. X
  934. Xvoid            remark2(s1, s2)
  935. Xchar           *s1;            /* In: First  error message string */
  936. Xchar           *s2;            /* In: Second error message string */
  937. X{
  938. X    err_report(ERR_REM, ERR_STAT, "%s %s\n", (s1), (s2));
  939. X}
  940. X
  941. Xvoid            remark(s1)
  942. Xchar           *s1;            /* In: Error message */
  943. X{
  944. X    err_report(ERR_REM, ERR_STAT, "%s\n", (s1));
  945. X}
  946. X
  947. Xvoid            error2(s1, s2)
  948. Xchar           *s1;            /* In: First  error message string */
  949. Xchar           *s2;            /* In: Second error message string */
  950. X{
  951. X    err_report(ERR_ERR, ERR_STAT, "%s %s\n", (s1), (s2));
  952. X}
  953. X
  954. Xvoid            error(s1)
  955. Xchar           *s1;            /* In: Error message */
  956. X{
  957. X    err_report(ERR_ERR, ERR_STAT, "%s\n", (s1));
  958. X}
  959. X
  960. Xvoid            stop(s1)
  961. Xchar           *s1;            /* In: Error message */
  962. X{
  963. X    err_report(ERR_ABT, ERR_STAT, "%s\n", (s1));
  964. X}
  965. X
  966. Xvoid            usage(s1)
  967. Xchar           *s1;            /* In: Usage message */
  968. X{
  969. X    err_report(ERR_USE, ERR_STAT, (s1));
  970. X}
  971. X
  972. Xvoid            setarg0(s)
  973. Xchar           *s;                /* In: argv[0] */
  974. X{
  975. X    char           *cp;
  976. X
  977. X    while ((cp = strrchr(s, '/')) != NIL(char *) &&*(cp + 1) == '\0')
  978. X        *cp = '\0';
  979. X    (void)strncpy(_arg0, ((cp == NIL(char *)) ? s : cp + 1), 14);
  980. X}
  981. X
  982. X/* VARARGS */
  983. X#ifdef __STDC__
  984. Xvoid            err_report(int flags, int estat, char *string,...)
  985. X#else
  986. Xvoid            err_report(va_alist)
  987. Xva_dcl
  988. X#endif    /* __STDC__ */
  989. X{
  990. X    int             i;
  991. X    va_list         args;
  992. X
  993. X#ifndef __STDC__
  994. X    int             flags;
  995. X    int             estat;
  996. X    char           *string;
  997. X
  998. X    va_start(args);
  999. X    flags = va_arg(args, int);
  1000. X    estat = va_arg(args, int);
  1001. X    string = va_arg(args, char *);
  1002. X#else
  1003. X    va_start(args, string);
  1004. X#endif    /* __STDC__ */
  1005. X
  1006. X    if (flags & ERR_FLUSH)
  1007. X        (void)fflush(stdout);
  1008. X    if (flags & ERR_USAGE)
  1009. X        (void)fprintf(stderr, "Usage: %s %s\n", arg0, string);
  1010. X    else if (flags & ERR_COMM)
  1011. X    {
  1012. X        (void)fprintf(stderr, "%s: ", arg0);
  1013. X        (void)vfprintf(stderr, string, args);
  1014. X    }
  1015. X    if (flags & ERR_ABORT)
  1016. X        abort();
  1017. X    if (flags & ERR_EXIT)
  1018. X    {
  1019. X        for (i = 0; i < n_cleanups; i++)
  1020. X            (*cleanuplist[i])();
  1021. X        exit(estat);
  1022. X    }
  1023. X}
  1024. SHAR-EOF
  1025. chmod 444 stderr.c
  1026. if [ `wc -c <stderr.c` -ne 2995 ]
  1027. then echo shar: stderr.c unpacked with wrong size
  1028. fi
  1029. # end of overwriting check
  1030. fi
  1031. #--------------------
  1032. if [ -f stderr.h -a "$1" != "-c" ]
  1033. then echo shar: stderr.h already exists
  1034. else
  1035. echo 'x - stderr.h (1591 characters)'
  1036. sed -e 's/^X//' >stderr.h <<'SHAR-EOF'
  1037. X/*
  1038. X@(#)File:           stderr.h
  1039. X@(#)Version:        6.1
  1040. X@(#)Last changed:   91/12/15
  1041. X@(#)Purpose:        Header file for standard error functions
  1042. X@(#)Author:         J Leffler
  1043. X*/
  1044. X
  1045. X#ifndef STDERR_H
  1046. X#define STDERR_H
  1047. X
  1048. X#ifdef MAIN_PROGRAM
  1049. X#ifndef lint
  1050. Xstatic char stderr_h[] = "@(#)stderr.h    6.1 91/12/15";
  1051. X#endif
  1052. X#endif
  1053. X
  1054. X/* -- Definitions for error handling */
  1055. X
  1056. X#define ERR_STAT    (1)            /* Default exit status     */
  1057. X
  1058. X#define ERR_COMM    (0x01)        /* Print message on stderr */
  1059. X#define ERR_USAGE    (0x02)        /* Print usage   on stderr */
  1060. X#define ERR_EXIT    (0x04)        /* Exit  -- do not return  */
  1061. X#define ERR_ABORT    (0x08)        /* Abort -- do not return  */
  1062. X#define ERR_FLUSH    (0x10)        /* Flush stdout            */
  1063. X
  1064. X/* -- Standard combinations of flags */
  1065. X
  1066. X#define ERR_USE    (ERR_USAGE|ERR_EXIT|ERR_FLUSH)
  1067. X#define ERR_REM    (ERR_COMM|ERR_FLUSH)
  1068. X#define ERR_ERR    (ERR_COMM|ERR_EXIT|ERR_FLUSH)
  1069. X#define ERR_ABT    (ERR_COMM|ERR_ABORT|ERR_FLUSH)
  1070. X
  1071. X/* -- Global definitions */
  1072. X
  1073. Xextern    char    *arg0;
  1074. X
  1075. X#ifdef __STDC__
  1076. X
  1077. Xextern    void    err_report(int flags, int estat, char *string, ...);
  1078. Xextern    void    err_setcleanup(void (*func)());
  1079. Xextern    void    error(char *s1);
  1080. Xextern    void    error2(char *s1, char *s2);
  1081. Xextern    void    remark(char *s1);
  1082. Xextern    void    remark2(char *s1, char *s2);
  1083. Xextern    void    setarg0(char *arg0);
  1084. Xextern    void    stop(char *s1);
  1085. Xextern    void    usage(char *s1);
  1086. X
  1087. X#else
  1088. X
  1089. X/* VARARGS */
  1090. Xextern    void    err_report();
  1091. Xextern    void    err_setcleanup();
  1092. Xextern    void    error();
  1093. Xextern    void    error2();
  1094. Xextern    void    remark();
  1095. Xextern    void    remark2();
  1096. Xextern    void    setarg0();
  1097. Xextern    void    stop();
  1098. Xextern    void    usage();
  1099. X
  1100. X#endif /* __STDC__ */
  1101. X
  1102. X#endif /* STDERR_H */
  1103. SHAR-EOF
  1104. chmod 444 stderr.h
  1105. if [ `wc -c <stderr.h` -ne 1591 ]
  1106. then echo shar: stderr.h unpacked with wrong size
  1107. fi
  1108. # end of overwriting check
  1109. fi
  1110. #--------------------
  1111. if [ -f memmove.c -a "$1" != "-c" ]
  1112. then echo shar: memmove.c already exists
  1113. else
  1114. echo 'x - memmove.c (1418 characters)'
  1115. sed -e 's/^X//' >memmove.c <<'SHAR-EOF'
  1116. X/*
  1117. X@(#)File:            memmove.c
  1118. X@(#)Version:         1.2
  1119. X@(#)Last changed:    91/12/22
  1120. X@(#)Purpose:         Simulate MEMMOVE(3)
  1121. X@(#)Author:          J Leffler
  1122. X@(#)Copyright:       (C) JLSS 1991
  1123. X@(#)Product:         :PRODUCT:
  1124. X*/
  1125. X
  1126. X/*TABSTOP=4*/
  1127. X/*LINTLIBRARY*/
  1128. X
  1129. X#ifndef lint
  1130. Xstatic char     sccs[] = "@(#)memmove.c    1.2 91/12/22";
  1131. X#endif
  1132. X
  1133. Xvoid           *memmove(s1, s2, n)
  1134. Xvoid           *s1;
  1135. Xvoid           *s2;
  1136. Xint             n;
  1137. X{
  1138. X    char           *t;
  1139. X    char           *t1 = (char *)s1;
  1140. X    char           *t2 = (char *)s2;
  1141. X    void           *s = s1;
  1142. X
  1143. X    if (t1 < t2)
  1144. X    {                            /* Copy forwards */
  1145. X        t = t1 + n;
  1146. X        while (t1 < t)
  1147. X            *t1++ = *t2++;
  1148. X    }
  1149. X    else
  1150. X    {                            /* Copy backwards */
  1151. X        t = t2;
  1152. X        t1 += n;
  1153. X        t2 += n;
  1154. X        while (t2 > t)
  1155. X            *--t1 = *--t2;
  1156. X    }
  1157. X    return(s);
  1158. X}
  1159. X
  1160. X#ifdef TEST
  1161. X
  1162. Xmain()
  1163. X{
  1164. X    char            buffer[80];
  1165. X    int             ok = 0;
  1166. X
  1167. X    strcpy(&buffer[0], "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  1168. X    printf("buffer = %s\n", buffer);
  1169. X    printf("memmove(&buffer[0], &buffer[9], 10);\n");
  1170. X    memmove(&buffer[0], &buffer[9], 10);
  1171. X    printf("buffer = %s\n", buffer);
  1172. X    if (strcmp(buffer, "JKLMNOPQRSKLMNOPQRSTUVWXYZ") != 0)
  1173. X        ok++, printf("** FAILED **\n");
  1174. X    printf("memmove(&buffer[5], &buffer[0], 10);\n");
  1175. X    memmove(&buffer[5], &buffer[0], 10);
  1176. X    printf("buffer = %s\n", buffer);
  1177. X    if (strcmp(buffer, "JKLMNJKLMNOPQRSPQRSTUVWXYZ") != 0)
  1178. X        ok++, printf("** FAILED **\n");
  1179. X
  1180. X    if (ok == 0)
  1181. X        printf("OK\n");
  1182. X    return(0);
  1183. X}
  1184. X
  1185. X#endif    /* TEST */
  1186. SHAR-EOF
  1187. chmod 444 memmove.c
  1188. if [ `wc -c <memmove.c` -ne 1418 ]
  1189. then echo shar: memmove.c unpacked with wrong size
  1190. fi
  1191. # end of overwriting check
  1192. fi
  1193. echo All files extracted
  1194. exit 0
  1195.