Fix for modules which take no options at all. Getopt() was terminating the
[userinfo.git] / src / ui.h
blob57ea0c84fc6e9abb9feabffaacaf5b6af5379e20
1 /* $Id: ui.h,v 2.3 2005-07-30 15:46:52 bjk Exp $ */
2 /*
3 Copyright (C) 2001-2005 Ben Kibbey <bjk@arbornet.org>
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; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef UI_H
20 #define UI_H
22 #ifdef HAVE_LIBGEN_H
23 #include <libgen.h>
24 #endif
26 #ifdef HAVE_DLFCN_H
27 #include <dlfcn.h>
28 #endif
30 #ifdef HAVE_STRING_H
31 #include <string.h>
32 #endif
34 #ifdef HAVE_ERR_H
35 #include <err.h>
36 #endif
38 #ifdef HAVE_LIMITS_H
39 #include <limits.h>
40 #endif
42 #ifdef HAVE_PATHS_H
43 #include <paths.h>
44 #else
45 #ifndef _PATH_DEV
46 #define _PATH_DEV "/dev/"
47 #endif
48 #endif
50 #define COPYRIGHT "Copyright (c) 2001-2005 " PACKAGE_BUGREPORT
51 #define STAT(file, sstat) ((followsymlinks) ? stat(file, sstat) : lstat(file, sstat))
52 #define TIMEBUFSIZE 64
53 #define UNKNOWN "!"
54 #define NONE "-"
55 #define ON "1"
56 #define OFF "0"
57 #define MODULE_DUP 0x001
58 #define MODULE_OUTPUT 0x002
59 #define MODULE_CHAINED 0x004
60 #define MODULE_CHAINABLE 0x008
61 #define MODULE_VERBOSE 0x010
62 #define SET_FLAG(var, f) (var |= f)
63 #define TEST_FLAG(var, f) (var & f)
66 enum {
67 OUTPUT_DONE,
68 OUTPUT_APPEND
71 /* These are functions found in loadable modules. */
72 typedef void (module_init) (int *);
73 typedef void (module_exit) (void);
74 typedef void (module_help) (void);
75 typedef char *(module_options_init) (char **);
76 typedef int (module_options) (int argc, char **argv);
77 typedef int (module_exec) (char ***, const struct passwd *, const int,
78 const int, char *);
80 struct module {
81 char name[64]; /* The filename of the module. */
82 void *m; /* The module handle. */
83 unsigned flags; /* dup, chained, chainable, and output. */
84 } *modules;
86 static int verbose, delimchar, multichar, usefile;
87 static int followsymlinks;
88 static char tf[TIMEBUFSIZE];
89 static int chaining;
90 static int chain_output;
91 static int module_index;
93 #ifdef HAVE___PROGNAME
94 extern char *__progname;
95 #else
96 static char *__progname;
97 #endif
99 #ifdef WITH_DMALLOC
100 #include <dmalloc.h>
101 #endif
103 #endif