From - Thu Oct 30 07:26:23 1997
Path: news.mitre.org!blanket.mitre.org!news.tufts.edu!cam-news-feed5.bbnplanet.com!cam-news-hub1.bbnplanet.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!howland.erols.net!psinntp!news.amrcorp.com!news-admin@sabre.com
From: Arlen Williams <remove_arlen_williams@remove_sabre.com>
Newsgroups: comp.os.vms
Subject: Re: find_file in VAX C
Date: Wed, 29 Oct 1997 14:35:01 -1300
Organization: The SABRE Group
Lines: 61
Message-ID: <34574995.2A67C525@remove_sabre.com>
References: <6380t5$g6r$1@nnrp1.crl.com>
NNTP-Posting-Host: 172.29.63.102
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0b8Gold (X11; I; OpenVMS V6.2     AlphaStation 250 4/266)

Michael Weimholt wrote:
> 
> Help!
> 
> I'm new to VAX C programming and I can't find out how to find
> files in VAX C using a wildcard specification. I'm familiar with the old
> DOS routines like dos_findfirst and dos_findnext, but I can't find
> anything equivalent on the VAX. I have the VAX C run-time library manual,
> and it doesn't list any such functions. I tried digging around in the
> local sys$library directory, and I found a file called lib$routines.h,
> which contains a function prototype for lib$find_file, but the header
> file doesn't tell how to use the function, or what the parameters are.
> Our documentation at this company is virtually nil. What's the VAX
> equivalent of find_file, how do I set it up (including .h files,
> initializing structures, etc), how do I invoke it, and what do I need to
> do to clean up after invoking it?


#include <descrip.h>
#include <lib$routines>
#include <rmsdef.h>
#include <stdio.h>
#include <string.h>

main()
  {
           int     status, context, i;
    static char   *find_file = "Sys$Login:Login.Com;*";
           struct  dsc$descriptor_s find_desc;
    static char    file_name[ 200 ];
    $DESCRIPTOR( file_desc, file_name );

      /* make descriptor */
    find_desc.dsc$w_length  = strlen( find_file );
    find_desc.dsc$b_dtype   = DSC$K_DTYPE_T;
    find_desc.dsc$b_class   = DSC$K_CLASS_S;
    find_desc.dsc$a_pointer = find_file;

      /* get all the files */
    context = 0;
    status = lib$find_file( &find_desc, &file_desc,
                            &context, 0, 0, 0, 0 );
    while ( status == RMS$_NORMAL )
      {
        for ( i = 0; ; i++ )
          {
            if ( file_name[ i ] == ' ' )
              {
                file_name[ i ] = '\0';
                break;
              }
          }
        printf( "File - %s\n", file_name );

        status = lib$find_file( &find_desc, &file_desc,
                                &context, 0, 0, 0, 0 );
      }

      /* clean up */
    status = lib$find_file_end( &context );
  }
