/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#include <stdlib.h>
#include <glob.h>

int main() {
    glob_t globbuf;
    int i;

    glob("glob.c", GLOB_MARK, NULL, &globbuf);
    printf("globbuf.gl_pathc = %d\n", globbuf.gl_pathc);
    printf("globbuf.gl_pathv = %p\n", globbuf.gl_pathv);
    for(i = globbuf.gl_pathc; i>0; i--)
      printf("globbuf.gl_pathv[%d] = %s\n", globbuf.gl_pathc-i,
              globbuf.gl_pathv[globbuf.gl_pathc-i]);
    globfree(&globbuf);
    printf("Ok!\n");

    glob(" glob.c", GLOB_MARK, NULL, &globbuf);
    printf("globbuf.gl_pathc = %d\n", globbuf.gl_pathc);
    printf("globbuf.gl_pathv = %p\n", globbuf.gl_pathv);
    for(i = globbuf.gl_pathc; i>0; i--)
      printf("globbuf.gl_pathv[%d] = %s\n", globbuf.gl_pathc-i,
              globbuf.gl_pathv[globbuf.gl_pathc-i]);
    globfree(&globbuf);
    printf("Ok!\n");

    glob("glob.c ", GLOB_MARK, NULL, &globbuf);
    printf("globbuf.gl_pathc = %d\n", globbuf.gl_pathc);
    printf("globbuf.gl_pathv = %p\n", globbuf.gl_pathv);
    for(i = globbuf.gl_pathc; i>0; i--)
      printf("globbuf.gl_pathv[%d] = %s\n", globbuf.gl_pathc-i,
              globbuf.gl_pathv[globbuf.gl_pathc-i]);
    globfree(&globbuf);
    printf("Ok!\n");

    glob("../", GLOB_MARK, NULL, &globbuf);
    printf("globbuf.gl_pathc = %d\n", globbuf.gl_pathc);
    printf("globbuf.gl_pathv = %p\n", globbuf.gl_pathv);
    for(i = globbuf.gl_pathc; i>0; i--)
      printf("globbuf.gl_pathv[%d] = %s\n", globbuf.gl_pathc-i,
              globbuf.gl_pathv[globbuf.gl_pathc-i]);
    globfree(&globbuf);
    printf("Ok!\n");
}
 
 
