glob for Windows

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/libtar_lab/glob/?root=svn
エミュレートできた、と思う。
大丈夫かな…。

#include <stdio.h>
#include <stdlib.h>
#include "compat.h"

int main() {
  glob_t globbuf;
  int i;

  puts("pattern: /usr/local/*");

  if (openbsd_glob("/usr/local/*", 0, NULL, &globbuf) == 0) {
    printf("gl_pathc: %d\n", globbuf.gl_pathc);

    for (i = 0; i < globbuf.gl_pathc; i++) {
      puts(globbuf.gl_pathv[i]);
    }
  }

  puts("\npattern: /usr/local/s*");

  if (openbsd_glob("/usr/local/s*", 0, NULL, &globbuf) == 0) {
    printf("gl_pathc: %d\n", globbuf.gl_pathc);

    for (i = 0; i < globbuf.gl_pathc; i++) {
      puts(globbuf.gl_pathv[i]);
    }
  }

  puts("\npattern: /usr/local/{bin,src}");

  if (openbsd_glob("/usr/local/{bin,src}", GLOB_BRACE, NULL, &globbuf) == 0) {
    printf("gl_pathc: %d\n", globbuf.gl_pathc);

    for (i = 0; i < globbuf.gl_pathc; i++) {
      puts(globbuf.gl_pathv[i]);
    }
  }

  puts("\npattern: ~/*");

  if (openbsd_glob("~/*",  GLOB_TILDE, NULL, &globbuf) == 0) {
    printf("gl_pathc: %d\n", globbuf.gl_pathc);

    for (i = 0; i < globbuf.gl_pathc; i++) {
      puts(globbuf.gl_pathv[i]);
    }
  }

  openbsd_globfree(&globbuf);

  return 0;
}


pattern: /usr/local/*
gl_pathc: 15
/usr/local/CollabNet Subversion
/usr/local/MySQL Server 4.1
/usr/local/bin


pattern: /usr/local/s*
gl_pathc: 2
/usr/local/share
/usr/local/src

pattern: /usr/local/{bin,src}
gl_pathc: 2
/usr/local/bin
/usr/local/src

pattern: ~/*
gl_pathc: 16
C:\Documents and Settings\sugawara/Application Data
C:\Documents and Settings\sugawara/Cookies
C:\Documents and Settings\sugawara/Favorites



続行するには何かキーを押してください . . .