CONTENTS | INDEX | PREV | NEXT

 expand_args

 NAME
  expand_args   - expand command line argument wildcards

 SYNOPSIS
  int error = expand_args(xac, xav, &ac, &av);
  int xac;
  const char **xav;
  int ac;
  char **av;

 FUNCTION
  expand_args() takes an argc/argv list and expands any wildcard
  arguments by scanning the appropriate directory.  expand_args()
  malloc()s however much memory it needs to create the new list and
  ignores xav[0] (i.e. just copies it to the returned av[0] without
  doing a wildcard expansion).

  expand_args() fills in the ac and av variables with its own
  malloc()d version of the argument list, now completely expanded.
  There is no limit to the number of files that may be in this
  result list (you could conceivably have THOUSANDS).

  expand_args() may be used to expand arbitrary AmigaDOS wildcards
  and is not limited to an anchored search.  For example, you could
  specify:

      sys:#?/#?

  In which case a list of a second level files/dirs will be generated.
  expand_args in the above case scans sys: then scans any sub directories
  found in sys:

  Generic AmigaDOS wildcarding is used and incredibly complex wildcards
  may be specified.  However, please note that any wildcard elements
  containing #? in combination with other elements (such as (a|b|c))
  will cause HUGE amounts of stack to be used and also quite a bit
  of memory during the scan.  expand_args() limits itself to 4K
  of stack before giving up.

  Any program that uses expand_args() should be run with at least
  8K of stack.

 EXAMPLE
  #include <stdio.h>

  main(xac, xav)
  int xac;
  char **xav;
  {
      int ac;
      char **av;
      short i;

      int error = expand_args(xac, xav, &ac, &av);
      for (i = 1; i < ac; ++i) {
      printf("%sn", av[i]);
      }
  }

 INPUTS
  int xac;        original argc
  char **xav;     original argv
  int *ac;        pointer to new argc
  char ***av;     pointer to new argv

 RESULTS
  int error;      0 if all went well, non-zero otherwise