HP3000-L Archives

October 1996, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Stan Sieler <[log in to unmask]>
Reply To:
Stan Sieler <[log in to unmask]>
Date:
Wed, 23 Oct 1996 15:05:27 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (230 lines)
Hi,

here's a C equivalent for the "myxllist" SPLash! example:

<plug>
The C code was generated by SPLash! (via the $PPC option), and
was edited in only one place...to workaround a bug/flaw in HPDEBUG.

Oh yes, I added 2 lines to the SPLash! code I posted:
   $PPC        ... generate C source output
   $PPCOMMENTS ... carry over the original source code comments, where
                   possible
K
</plug>

Compile with the "-Aa" C compiler option.

SS

----------------------------------cut here-------------------------------

/* C-code generated by SPLash! 96H 4.12 on WED, OCT 23, 1996,  3:02 PM */
/* PPC PPCOMMENTS noPPEXPANDINTRIN PPLONGPTRS */

#include <ctype.h>
#include <setjmp.h>
#include <string.h>
#include "splash.h"

/*********************************************************/
void myxllist (INT32 *status, char *xllist, INT16 *xlcount, INT16 *max_bytes)
   {
   INT32 /* file# of a temp file*/
      fid         = 0,
      nobanner    = 0;

   INT16
      len,
      read_len, /* # chars read from input file*/
      tot_len     = 0; /* # output characters*/

   char
      strg        [256];

#pragma intrinsic FCLOSE
#pragma intrinsic FREAD
#pragma intrinsic HPDEBUG
#pragma intrinsic HPERRMSG
#pragma intrinsic HPFOPEN
#pragma intrinsic PRINT

   *status = 0;
   *xlcount = 0; /*purge any existing temp file with the name XLPATH*/
   SPLash_move (strg, "%XLPATH, oldtemp;acc=in%", 24);
   HPFOPEN (&fid, (void *) (status), 52, (void *) (strg), 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL);
   if (fid != 0)
      {             /* opened ok...purge it now...*/
      /* purge*/
      FCLOSE ((INT16) fid, 4, 0); /* ignore any error*/
      fid = 0; /*open new temp file*/
      }
   SPLash_move (strg, "%XLPATH,new;temp;acc=out;rec=-256,1,v, ascii;disc=16%",
                     53);
   HPFOPEN (&fid, (void *) (status), 52, (void *) (strg), 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL);
   if (*status != 0)
             /* failed to open file for OUTPUT*/
      { /*call hpdebug to generate loader info*/
      goto end_proc;
      }
   SPLash_move (strg, "%ignore quiet; LOADINFO; C%", 27);
   HPDEBUG ((void *) (status), (void *) (strg), 1, (INT32) (fid), 2, (INT32) (
                              nobanner), 0, 0, 0, 0, 0, 0);
   if (*status != 0)
      {
      goto end_proc;
      }
   FCLOSE ((INT16) fid, 0, 0); /* ignore any error*/
   fid = 0; /*reopen the tempfile for input*/
   SPLash_move (strg, "%XLPATH, oldtemp;acc=in%", 24);
   HPFOPEN (&fid, (void *) (status), 52, (void *) (strg), 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
                     0, NULL, 0, NULL);
   if (*status != 0)
             /* failed to re-open input file*/
 /*Sample Debug/iX output from a LOADINFO command...*/
 /*nm PROG  /SPLISH/PUB/TAD1              SID = $7ec*/
 /*    parm = #0  info = ""*/
 /*nm USER  XL2.HP30391.TURBONM           SID = $6d1*/
 /*nm USER  WHOINT.XL.SIELER              SID = $8ec*/
 /*nm USER  XL.PUB.SYS                    SID = $250*/
 /*nm SYS   NL.PUB.SYS                    SID = $a*/
 /*cm SYS   SL.PUB.SYS*/
 /*0123456789 123456789 123456789 123456789 123456789 <- byte offsets*/
 /*          10        20        30        40*/
      {   /*pick off the user xl file names*/
      goto end_proc;
      }
   tot_len = 0;
   *xlcount = 0;
   *strg = 0;
   SPLash_move (&strg [1], strg, 255);

   while ( (read_len = FREAD ((INT16) fid, (void *) (strg), -255)) > 0)
      {
      if (((SPLash_compare (strg, "nm USER", 7) == 0)) &&
                              ((SPLash_compare (&strg [9], "XL.PUB.SYS ",
                     11) != 0)))
         {
         len = SPLash_scan_until (&strg [9], ' ', -1);
         if ( ( (len + 2) + tot_len) >= *max_bytes)
            {
            *status = -1; /* too many output bytes*/
            goto end_proc;
            }
         if (*xlcount > 0)
            {
            tot_len = tot_len + SPLash_move (&xllist [tot_len], ", ", 2);
            }
         tot_len = tot_len + SPLash_move (&xllist [tot_len], &strg [9],
                     len);
         *xlcount = *xlcount + 1; /*# of xls found*/
         }
      *strg = 0;
      SPLash_move (&strg [1], strg, 255); /* while*/
      }
   xllist [tot_len] = 0; /*plant null terminator*/

end_proc:

   if (fid != 0)
      {
               /* purge it*/
      FCLOSE ((INT16) fid, 4, 0); /* ignore any error*/
      fid = 0;
      }

   } /* end myxllist proc */

/*********************************************************/
  /***************************************************************/
void test ()
   {
   UINT16
      buf         [67],
      xls         [1024];

   INT32
      altstatus,
      dummy,
      status;

   INT16
      len,
      max_bytes,
      num_xls;

   char
      *buf_       = (char *) (buf),
      *xls_       = (char *) (xls);

#pragma intrinsic ASCII
#pragma intrinsic DASCII
#pragma intrinsic dbopen
#pragma intrinsic HPERRMSG
#pragma intrinsic PRINT

   dummy = &dbopen;
   *buf = 0;
   SPLash_move (&buf [1], buf, 1023 * 2);
   max_bytes = 2048;
   myxllist (&status, xls_, &num_xls, &max_bytes);
   if (status != 0)
      {
      len = SPLash_move (buf_, "myxllist failed, error ", 23);
      len = len + DASCII ((INT32) (status), 10, (void *) (&buf_ [len]));
      len = len + SPLash_move (&buf_ [len], " ($", 3);
      DASCII ((INT32) (status), 16, (void *) (&buf_ [len]));
      len = len + 8;
      len = len + SPLash_move (&buf_ [len], ")", 1);
      PRINT ((void *) (buf), -(len), 0);
      if (status < -1)
         {
         HPERRMSG (2, 1, 0, (INT32) (status), NULL, NULL, (void *) (&altstatus));
         }
      goto end_proc;
      }
   len = SPLash_move (buf_, "myxllist ok, #XLs = ", 20);
   len = len + ASCII (num_xls, 10, (void *) (&buf_ [len]));
   PRINT ((void *) (buf), -(len), 0);
   len = SPLash_scan_until (xls_, 0, -1);
   PRINT ((void *) (xls), -(len), 0);

end_proc:

   ;

   } /* end test proc */

/*********************************************************/
INT32 main (INT32 argc, char *argv [], char **envp)
   {
   test ();

   return 0;

   } /* end main proc */
/*********************************************************/
--
Stan Sieler                                          [log in to unmask]
                                     http://www.allegro.com/sieler.html

ATOM RSS1 RSS2