3 // Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "matchlist.h"
31 #define ENSC_WRAPPERS_FCNTL 1
32 #define ENSC_WRAPPERS_UNISTD 1
33 #define ENSC_WRAPPERS_STDLIB 1
37 selectRefserver(struct dirent const *ent)
39 return strncmp(ent->d_name, "refserver.", 10)==0;
43 MatchList_initRefserverList(struct MatchList **lst, size_t *cnt,
46 int cur_dir = Eopen(".", O_RDONLY, 0);
47 struct dirent **entries;
51 count = scandir(".", &entries, selectRefserver, alphasort);
58 WRITE_MSG(2, "no reference vserver configured\n");
62 *lst = Emalloc(sizeof(struct MatchList) * count);
64 for (i=0; i<count; ++i) {
65 char const *tmp = entries[i]->d_name;
66 size_t l = strlen(tmp);
67 char vname[sizeof("./") + l];
68 struct MatchVserverInfo vserver = {
73 memcpy(vname, "./", 2);
74 memcpy(vname+2, tmp, l+1);
76 if (!MatchVserverInfo_init(&vserver)) {
77 WRITE_MSG(2, "failed to initialize unification of reference vserver\n");
81 if (!MatchList_initByVserver((*lst)+i, &vserver)) {
82 WRITE_MSG(2, "unification for reference vserver not configured\n");
87 MatchVserverInfo_free(&vserver);