2 * Copyright (C) 2018 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
29 char buffer[1024], *str;
30 const struct globset_handler *gh;
33 setvbuf(stdout, NULL, _IOLBF, 0);
34 set = globset_create();
35 while (fgets(buffer, sizeof buffer, stdin)) {
36 str = strchr(buffer,'\n');
41 rc = globset_add(set, &buffer[1], NULL, NULL);
42 printf("add [%s]: %d, %m\n", &buffer[1], rc);
45 rc = globset_del(set, &buffer[1], NULL);
46 printf("del [%s]: %d, %m\n", &buffer[1], rc);
49 gh = globset_search(set, &buffer[1]);
50 printf("search [%s]: %s%s\n", &buffer[1], gh ? "found " : "NOT FOUND", gh ? gh->pattern : "");
53 gh = globset_match(set, buffer);
54 printf("match [%s]: %s%s\n", buffer, gh ? "found by " : "NOT FOUND", gh ? gh->pattern : "");