Thanks!

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf
Of Bernd Oppolzer
Sent: Tuesday, May 01, 2012 6:09 PM
To: [email protected]
Subject: Re: Does C/LE open of DD:ddname(member) use SVC 99 or FIND?

Thank you!

Here is an excerpt of a C program which reads a directory of a PDS and
inserts the member names into an AVL tree (the insert is not shown, it is
done by a function call - see below).

Kind regards

Bernd



static int lese_memberliste (char *parm_infile,
                              baumMEMknoten **pres)

/************************************************/
/*   Funktion zum Lesen einer Memberliste       */
/*   einer PO-Datei; die Membernamen werden     */
/*   in einen AVL-Baum eingetragen              */
/************************************************/

{
    FILE *direct;
    char buf [256];
    int x;
    char *cp;
    int laenge;
    unsigned long ttrc;
    int ttr;
    int anz_bytes;
    int eof;
    int rc = 0;

    char mem_high [8];

    baumMEMknoten *proot = NULL;
    baumMEMknoten *pneu;
    int hchanged;
    membname m;

    eof = 0;

    memset (mem_high, 0xff, 8);

    /************************************************/
    /*   raus, wenn Directory nicht aufgeht         */
    /************************************************/

    direct = fopen (parm_infile, "rb");
    if (direct == NULL)
       RETURN_VALUE 8;

    for (;;)
    {
       /************************************************/
       /*   naechsten Directory-Block einlesen         */
       /************************************************/

       memset (buf, 0x00, 256);
       x = fread (buf, 1, 256, direct);
       if (x == 0)
          break;

#ifdef TEST

       printf ("[cp2970] \n");
       printf ("[cp2970] Rueckgabe von fread = %d\n", x);
       printf ("[cp2970] \n");

       dump (buf, buf + x - 1, stdout);

#endif

       cp = buf + 2;
       laenge = *((short *) buf) - 2;

       while (laenge > 0)
       {
          /************************************************/
          /*   naehere Info hierzu in den IBM-Brosch.     */
          /*   zum Aufbau der PO-Directories.             */
          /************************************************/

          if (memcmp (cp, mem_high, 8) == 0)
          {
             eof = 1;
             break;
          }

          /************************************************/
          /*   Laenge des Eintrags in Halbworten steht    */
          /*   in den Bits 3 bis 7 des TTRC-Wortes        */
          /************************************************/

          ttrc = *((unsigned long *) (cp + 8));
          ttr = ttrc >> 8;
          anz_bytes = (ttrc & 0x1f) * 2;

#ifdef TEST

          printf ("[cp2970] Member %-8.8s  TTR %06X  Laenge/Bytes %d\n",
                  cp, ttr, anz_bytes);

#endif

          if (memcmp (cp, "ED", 2) == 0)
          {
             memcpy (m.name, cp, 8);

             hchanged = 0;
             pneu = baumMEMsuche (&m, &proot, &hchanged, 1);
             pneu -> obj = atoi (cp + 2);
          }

          cp += (anz_bytes + 12);
          laenge -= (anz_bytes + 12);
       }

       if (eof)
          break;
    }

    fclose (direct);

    *pres = proot;

    RETURN_VALUE rc;
}




Am 01.05.2012 23:52, schrieb John Gilmore:
> The point here is not what some particular routine oor utility may do 
> or permit.  It is what can be done ab initio by an programmer who 
> wants to do it using the HLASM or some particular SLPL .
>
> z/OS MVS does permit one to open a PDS as a PS data set in a routine 
> written in assembly language or PL/I, and what one then gets with 
> successive reads are its successive directory blocks.
>
> I have done this many times without incident, but I do not of course 
> recommend it to novices.
>
> I have not myself done it in C; but Bernd Oppolzer is a careful, 
> highly reliable reporter of his experience; and I am thus sure that it 
> can be done in C too.
>
> John Gilmore, Ashland, MA 01721 - USA
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions, send 
> email to [email protected] with the message: INFO IBM-MAIN
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email
to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to