xref: /illumos-gate/usr/src/cmd/idmap/idmap/idmap_engine.h (revision 4c87aefe8930bd07275b8dd2e96ea5f24d93a52e)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /* Debug macros */
33 #define	DPTR(a) printf("%s::%d  %s = %p\n", __FILE__, __LINE__, #a, a);
34 #define	DSTRING(a) printf("%s::%d  %s = \"%s\"\n", __FILE__, __LINE__, #a, \
35 			a ? a : "(null)");
36 #define	DINT(a) printf("%s::%d  %s = %d\n", __FILE__, __LINE__, #a, a);
37 #define	DHEX(a) printf("%s::%d  %s = %X\n", __FILE__, __LINE__, #a, a);
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 typedef char *flag_t;
44 #define	FLAG_SET (char *)1
45 #define	FLAG_ALPHABET_SIZE 255
46 
47 #define	IDMAP_ENG_OK 0
48 #define	IDMAP_ENG_ERROR -1
49 #define	IDMAP_ENG_ERROR_SILENT -2
50 
51 typedef struct cmd_pos {
52 	int linenum;		/* line number */
53 	char *line;		/* line content */
54 } cmd_pos_t;
55 
56 
57 typedef struct cmd_ops {
58 	const char *cmd;	/* the subcommand */
59 	const char *options;	/* getopt string for the subcommand params */
60 	int (*p_do_func)(flag_t *f,
61 	    int argc,
62 	    char **argv,
63 	    cmd_pos_t *pos); /* handle */
64 } cmd_ops_t;
65 
66 extern int engine_init(int comc, cmd_ops_t *comv, int argc, char **argv,
67     int *is_batch_mode);
68 extern int engine_fini();
69 
70 extern int run_engine(int argc, char **argv);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif	/* _IDMAP_ENGINE_H */
77