CONTENTS | INDEX | PREV | NEXT

 getfnl

 NAME
  getfnl - get file name list.  Scan a directory and return list of
       files that match the optional wildcard

  This is a non-standard function and exists for compatibility with
  other commercial compilers.

 SYNOPSIS
  int n = getfnl(pat, buf, bufsize, attr);
  const char *pat;
  char *buf;
  int bufsize;
  int attr;

 FUNCTION
  getfnl() scans the specified anchored AmigaDOS pattern and fills
  the specified buffer (up to bufsize bytes) with file names
  separated by a nul character (0), ending the list with a double
  nul (00).  getfnl() returns the number of files/dirs in the buffer
  or -1 if there was not enough room

  The pattern pat is an AmigaDOS pattern such as "df0:#?.c".  buf
  is a buffer of bufsize bytes.  attr determines what kinds of
  files are valid:

      0   normal files only
      1   files and directories

 NOTE
  getfnl() exists for compatibility, but expand_args() is a much
  better function to use if you want a list of files & dirs.

 EXAMPLE
  #include <stdio.h>

  char Buf[4096];

  main(ac, av)
  int ac;
  char *av[];
  {
      int n;

      if (ac != 2) {
      puts("Expected an anchored wildcard such as '#?'");
      exit(1);
      }
      n = getfnl(av[1], Buf, sizeof(Buf), 1);
      {
      char *ptr = Buf;
      while (*ptr) {              /*  look for 00   */
          puts(ptr);
          ptr += strlen(ptr) + 1; /*  skip first 0   */
      }
      }
      return(0);
  }


 INPUTS
  const char *pat;    pattern to scan for (anchored)
  char *buf;      buffer to put results in
  int bufsize;        size of buffer
  int attr;       attribes (0 or 1)

 RESULTS
  int n;          number of file names in buffer or -1 on error

 SEE ALSO
  strbpl, wildcard