Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / client / cmdline / main.h
1 /* $Id$
2  * Include file for client cmdline interface control functions 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 #ifndef _CAPTIVE_CLIENT_CMDLINE_MAIN_H
21 #define _CAPTIVE_CLIENT_CMDLINE_MAIN_H 1
22
23
24 #include <glib/gtypes.h>
25 #include <libgnomevfs/gnome-vfs-result.h>
26 #include <captive/client-vfs.h>
27
28
29 #define CMDLINE_POPT(longname,shortname,argInfoP,argP,descripP,argDescripP) \
30                 { \
31                         longName: (longname), \
32                         shortName: (shortname), \
33                         argInfo: (argInfoP), \
34                         arg: (void *)argP, \
35                         val: 0, \
36                         descrip: (descripP), \
37                         argDescrip: (argDescripP), \
38                 }
39 extern const struct poptOption cmdline_poptHelpOptions[];
40 #define CMDLINE_POPT_AUTOHELP \
41                 { NULL,'\0',POPT_ARG_INCLUDE_TABLE,(struct poptOption *)cmdline_poptHelpOptions,0,"Help options:",NULL },
42
43
44 #define CMDLINE_MAIN_ERROR (cmdline_main_error_quark())
45 GQuark cmdline_main_error_quark(void);
46
47 typedef enum {
48         CMDLINE_MAIN_ERROR_UNKNOWN_COMMAND,
49         CMDLINE_MAIN_ERROR_INVALID_COMMAND_ARGUMENTS,
50         CMDLINE_MAIN_ERROR_READING_COMMAND_CONFIG,
51         CMDLINE_MAIN_ERROR_EXCEEDING_COMMAND_OPTION,
52         CMDLINE_MAIN_ERROR_INVALID_COMMAND_ARGUMENT_COUNT,
53         CMDLINE_MAIN_ERROR_GENERIC_ERROR
54         } CmdlineMainError;
55
56
57 struct cmdline_command {
58         const gchar *name,*description;
59         const struct poptOption *table;
60         void (*func)(const char **cmd_argv,GError **errp);
61         gint argsn_min,argsn_max;
62         };
63
64 extern const struct cmdline_command cmdline_command_table[];
65
66
67 extern CaptiveVfsObject *cmdline_captive_vfs_object;
68
69
70 void invoke_cmd(int cmd_argc,const char **cmd_argv);
71 void err_cleanup(GError **errp);
72 gboolean errvfsresult_to_gerr(GError **errp,GnomeVFSResult errvfsresult);
73 void main_exit(void);
74
75
76 #endif /* _CAPTIVE_CLIENT_CMDLINE_MAIN_H */