+captive-sandbox-server for isolated filesystem sendbox server
[captive.git] / src / client / sandbox-server / main.c
1 /* $Id$
2  * filesystem sandbox server stub for libcaptive
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
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; exactly version 2 of June 1991 is required
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
19
20 #include "config.h"
21
22 #include <glib/gmessages.h>
23 #include <stdlib.h>
24 #include <glib/giochannel.h>
25 #include <glib/gerror.h>
26 #include <popt.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include <locale.h>
30 #include "captive/options.h"
31 #include <glib-object.h>
32
33
34 GQuark sandbox_server_main_error_quark(void)
35 {
36 GQuark r=0;
37
38         if (!r)
39                 r=g_quark_from_static_string("sandbox-server");
40
41         return r;
42 }
43
44
45 static const struct poptOption popt_table[]={
46                 CAPTIVE_POPT_INCLUDE,
47                 POPT_AUTOHELP
48                 POPT_TABLEEND
49                 };
50
51
52 int main(int argc,char **argv)
53 {
54 poptContext context;
55 int errint;
56 const char *cmd_arg;
57 struct captive_options options;
58
59         /* Initialize the i18n stuff */
60         setlocale(LC_ALL,"");
61         bindtextdomain(PACKAGE,LOCALEDIR);
62         textdomain(PACKAGE);
63
64         /* Initialize GObject subsystem of GLib. */
65         g_type_init();
66
67         captive_options_init(&options);
68         captive_options=&options;       /* for parsing by 'CAPTIVE_POPT_INCLUDE' */
69
70         context=poptGetContext(
71                         PACKAGE,        /* name */
72                         argc,(/*en-const*/const char **)argv,   /* argc,argv */
73                         popt_table,     /* options */
74                         POPT_CONTEXT_POSIXMEHARDER);    /* flags; && !POPT_CONTEXT_KEEP_FIRST */
75         if (context==NULL) {
76                 g_assert_not_reached(); /* argument recognization args_error */
77                 return EXIT_FAILURE;
78                 }
79         errint=poptReadDefaultConfig(context,
80                         TRUE);  /* useEnv */
81         if (errint!=0) {
82                 g_assert_not_reached(); /* argument recognization args_error */
83                 return EXIT_FAILURE;
84                 }
85         errint=poptGetNextOpt(context);
86         if (errint!=-1) {
87                 g_assert_not_reached(); /* some non-callbacked argument reached */
88                 return EXIT_FAILURE;
89                 }
90         cmd_arg=poptPeekArg(context);
91         if (cmd_arg) {
92                 g_assert_not_reached(); /* some non-option argument reached */
93                 return EXIT_FAILURE;
94                 }
95         /* 'cmd_arg'-style args gets cleared by 'poptFreeContext(context);' below */
96         poptFreeContext(context);
97
98         captive_options=NULL;   /* already parsed by 'CAPTIVE_POPT_INCLUDE' */
99
100         captive_corba_sandbox_child();
101
102         g_assert_not_reached();
103         return EXIT_SUCCESS;
104 }