xref: /illumos-gate/usr/src/cmd/idmap/idmap/idmap_engine.h (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 
27 #ifndef _IDMAP_ENGINE_H
28 #define	_IDMAP_ENGINE_H
29 
30 /* Debug macros */
31 #define	DPTR(a) printf("%s::%d  %s = %p\n", __FILE__, __LINE__, #a, a);
32 #define	DSTRING(a) printf("%s::%d  %s = \"%s\"\n", __FILE__, __LINE__, #a, \
33 			a ? a : "(null)");
34 #define	DINT(a) printf("%s::%d  %s = %d\n", __FILE__, __LINE__, #a, a);
35 #define	DHEX(a) printf("%s::%d  %s = %X\n", __FILE__, __LINE__, #a, a);
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 typedef char *flag_t;
42 #define	FLAG_SET (char *)1
43 #define	FLAG_ALPHABET_SIZE 255
44 
45 #define	IDMAP_ENG_OK 0
46 #define	IDMAP_ENG_ERROR -1
47 #define	IDMAP_ENG_ERROR_SILENT -2
48 
49 typedef struct cmd_pos {
50 	int linenum;		/* line number */
51 	char *line;		/* line content */
52 } cmd_pos_t;
53 
54 
55 typedef struct cmd_ops {
56 	const char *cmd;	/* the subcommand */
57 	const char *options;	/* getopt string for the subcommand params */
58 	int (*p_do_func)(flag_t *f,
59 	    int argc,
60 	    char **argv,
61 	    cmd_pos_t *pos); /* handle */
62 } cmd_ops_t;
63 
64 extern int engine_init(int comc, cmd_ops_t *comv, int argc, char **argv,
65     int *is_batch_mode);
66 extern int engine_fini();
67 
68 extern int run_engine(int argc, char **argv);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif	/* _IDMAP_ENGINE_H */
75