xref: /titanic_51/usr/src/cmd/krb5/kadmin/ktutil/ktutil_ct.c (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /*
9  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
10  *
11  *	Openvision retains the copyright to derivative works of
12  *	this source code.  Do *NOT* create a derivative of this
13  *	source code before consulting with your legal department.
14  *	Do *NOT* integrate *ANY* of this source code into another
15  *	product before consulting with your legal department.
16  *
17  *	For further information, read the top-level Openvision
18  *	copyright which is contained in the top-level MIT Kerberos
19  *	copyright.
20  *
21  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
22  *
23  */
24 
25 
26 /* ktutil_ct.c - automatically generated from ktutil_ct.ct */
27 /* Above no longer appears to be true */
28 
29 #include <libintl.h>
30 #include <ss/ss.h>
31 #include "k5-int.h"
32 
33 /*
34  * I18n hack. We sill define gettext(s) to be s here. That way the info_strings
35  * will be extracted to the .po file.
36  */
37 
38 #define	gettext(s) s
39 
40 #ifndef __STDC__
41 #define const
42 #endif
43 
44 static char const * const ssu00001[] = {
45 "clear_list",
46     "clear",
47     (char const *)0
48 };
49 extern void ktutil_clear_list __SS_PROTO;
50 static char const * const ssu00002[] = {
51 "read_kt",
52     "rkt",
53     (char const *)0
54 };
55 extern void ktutil_read_v5 __SS_PROTO;
56 static char const * const ssu00003[] = {
57 "read_st",
58     "rst",
59     (char const *)0
60 };
61 extern void ktutil_read_v4 __SS_PROTO;
62 static char const * const ssu00004[] = {
63 "write_kt",
64     "wkt",
65     (char const *)0
66 };
67 extern void ktutil_write_v5 __SS_PROTO;
68 static char const * const ssu00005[] = {
69 "write_st",
70     "wst",
71     (char const *)0
72 };
73 extern void ktutil_write_v4 __SS_PROTO;
74 static char const * const ssu00006[] = {
75 "add_entry",
76     "addent",
77     (char const *)0
78 };
79 extern void ktutil_add_entry __SS_PROTO;
80 static char const * const ssu00007[] = {
81 "delete_entry",
82     "delent",
83     (char const *)0
84 };
85 extern void ktutil_delete_entry __SS_PROTO;
86 static char const * const ssu00008[] = {
87 "list",
88     "l",
89     (char const *)0
90 };
91 extern void ktutil_list __SS_PROTO;
92 static char const * const ssu00009[] = {
93 "list_requests",
94     "lr",
95     "?",
96     (char const *)0
97 };
98 extern void ss_list_requests __SS_PROTO;
99 static char const * const ssu00010[] = {
100 "quit",
101     "exit",
102     "q",
103     (char const *)0
104 };
105 extern void ss_quit __SS_PROTO;
106 static ss_request_entry ssu00011[] = {
107     { ssu00001,
108       ktutil_clear_list,
109 		gettext("Clear the current keylist."),
110       0 },
111     { ssu00002,
112       ktutil_read_v5,
113 		gettext("Read a krb5 keytab into the current keylist."),
114       0 },
115     { ssu00003,
116       ktutil_read_v4,
117 		gettext("Read a krb4 srvtab into the current keylist."),
118       0 },
119     { ssu00004,
120       ktutil_write_v5,
121 		gettext("Write the current keylist to a krb5 keytab."),
122       0 },
123     { ssu00005,
124       ktutil_write_v4,
125 		gettext("Write the current keylist to a krb4 srvtab."),
126       0 },
127     { ssu00006,
128       ktutil_add_entry,
129 		gettext("Add an entry to the current keylist."),
130       0 },
131     { ssu00007,
132       ktutil_delete_entry,
133 		gettext("Delete an entry from the current keylist."),
134       0 },
135     { ssu00008,
136       ktutil_list,
137 		gettext("List the current keylist."),
138       0 },
139     { ssu00009,
140       ss_list_requests,
141 		gettext("List available requests."),
142       0 },
143     { ssu00010,
144       ss_quit,
145 		gettext("Exit program."),
146       0 },
147     { 0, 0, 0, 0 }
148 };
149 
150 ss_request_table ktutil_cmds = { 2, ssu00011 };
151 
152 #undef gettext
153 
154 /*
155  * This routine is responsible for localizing all the displayable
156  * messages in the table.  This was necessary since ktutil will be
157  * invoking library calls that need to be able to display the messages
158  * in the correct text domain (which only ktutil knows).
159  *
160  * This function assumes that the US version of the messages are
161  * pre-loaded in the table and will be used should gettext not be
162  * successful.  This routine does NOT free the replaced strings as
163  * its expected they may be in the heap (as above) and not malloc'ed.
164  * If the caller malloc'ed the strings, they should retain pointers
165  * and free them if not matching the contents of the table.
166  */
167 krb5_error_code
168 ktutil_initialize_cmds_table(ss_request_table *ktutil_cmds)
169 {
170 	char *localized_text;
171 	ss_request_entry *ss_cmd;
172 	krb5_error_code retval = 0;
173 
174 	if (ktutil_cmds) {
175 		for (ss_cmd = ktutil_cmds->requests;
176 		ss_cmd->info_string && *(ss_cmd->info_string) != '\0';
177 		++ss_cmd) {
178 			localized_text = gettext(ss_cmd->info_string);
179 
180 			if ((strcmp(localized_text, ss_cmd->info_string))
181 				!= 0) {
182 				ss_cmd->info_string = strdup(localized_text);
183 			}
184 		}
185 	}
186 	else
187 		retval = EINVAL;
188 
189 	return (retval);
190 }
191