#include <stdlib.h>
#include <fnmatch.h>
#include <stdio.h>

int main(int argc, char* argv[]) {
	char* pattern = argv[1];

	for (int i = 2; i < argc; i++) {
		int result = fnmatch(pattern, argv[i], FNM_PATHNAME | FNM_PERIOD);
		if (result == 0) {
			printf("matched %s\n", argv[i]);
		}
		else if (result == FNM_NOMATCH) {
			continue;
		}
		else {
			fprintf(stderr, "fnmatch failed on '%s'\n", argv[i]);
			exit(EXIT_FAILURE);
		}
	}
	exit(EXIT_SUCCESS);
}
