1 // $Id: matchvserverinfo-init.c,v 1.2 2005/03/24 00:09:58 ensc Exp $ --*- c -*--
3 // Copyright (C) 2005 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"
26 #include <pathconfig.h>
32 #include <sys/param.h>
35 exists(char *path, size_t len, char const *name)
37 if (name) strcpy(path + len, name);
39 return access(path, R_OK)!=-1;
42 #define EXISTS(X) exists(X, sizeof(X)-1, 0)
43 #define DEFAULT_EXISTS(X) EXISTS(CONFDIR "/.defaults/apps/vunify/" X)
46 MatchVserverInfo_init(struct MatchVserverInfo *info)
48 assert(info->name!=0);
49 assert(info->vdir.d==0 && info->appdir.d==0);
51 info->style = vc_getVserverCfgStyle(info->name);
52 info->vdir.d = vc_getVserverVdir (info->name, info->style, true);
53 info->appdir.d = vc_getVserverAppDir (info->name, info->style, "vunify");
55 if (info->vdir.d==0 || info->appdir.d==0) {
56 free(const_cast(char *)(info->vdir.d));
57 free(const_cast(char *)(info->appdir.d));
62 info->vdir.l = strlen(info->vdir.d);
63 info->appdir.l = strlen(info->appdir.d);
65 size_t const l = info->appdir.l;
66 char tmp[l + MAX(sizeof("/pkgmgmt-ignore"),sizeof("/pkgmgmt-force"))];
68 memcpy(tmp, info->appdir.d, l);
70 if (exists(tmp, l, "/pkgmgmt-ignore")) info->use_pkgmgmt = false;
71 else if (exists(tmp, l, "/pkgmgmt-force")) info->use_pkgmgmt = true;
72 else if (DEFAULT_EXISTS ("pkgmgmt-ignore")) info->use_pkgmgmt = false;
73 else if (DEFAULT_EXISTS ("pkgmgmt-force")) info->use_pkgmgmt = true;