added Vector_zeroEnd() function
[util-vserver.git] / util-vserver / src / vunify-init.hc
1 // $Id$    --*- c -*--
2
3 // Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 //  
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.
8 //  
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.
13 //  
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.
17
18 #include "pathconfig.h"
19
20 static void
21 initModeManually(struct Arguments const UNUSED *args, int argc, char *argv[])
22 {
23   int           i, count=argc/2;
24   
25   if (argc%2) {
26     WRITE_MSG(2, "Odd number of (path,excludelist) arguments\n");
27     exit(1);
28   }
29
30   if (count<2) {
31     WRITE_MSG(2, "No reference path(s) given\n");
32     exit(1);
33   }
34
35   MatchList_initManually(&global_info.dst_list, 0, strdup(argv[0]), argv[1]);
36
37   --count;
38   global_info.src_lists.v = Emalloc(sizeof(struct MatchList) * count);
39   global_info.src_lists.l = count;
40
41   for (i=0; i<count; ++i)
42     MatchList_initManually(global_info.src_lists.v+i, 0,
43                            strdup(argv[2 + i*2]), argv[3 + i*2]);
44 }
45
46
47 static void
48 initModeVserver(struct Arguments const UNUSED *args, int argc, char *argv[])
49 {
50   char const    *appdir;
51   
52   if (argc!=1) {
53     WRITE_MSG(2, "More than one vserver is not supported\n");
54     exit(1);
55   }
56
57   if (!MatchList_initByVserver(&global_info.dst_list, argv[0], &appdir)) {
58     WRITE_MSG(2, "unification not configured for this vserver\n");
59     exit(1);
60   }
61
62   MatchList_initRefserverList(&global_info.src_lists.v,
63                               &global_info.src_lists.l,
64                               appdir);
65   
66   free(const_cast(char *)(appdir));
67 }