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