1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef MODUTIL_ERROR_H
6 #define MODUTIL_ERROR_H
7 
8 /*
9  * The values of these enumerated constants are immutable and must not be
10  * changed.
11  */
12 typedef enum {
13     NO_ERR = 0,
14     INVALID_USAGE_ERR,
15     UNEXPECTED_ARG_ERR,
16     UNKNOWN_OPTION_ERR,
17     MULTIPLE_COMMAND_ERR,
18     OPTION_NEEDS_ARG_ERR,
19     DUPLICATE_OPTION_ERR,
20     MISSING_PARAM_ERR,
21     INVALID_FIPS_ARG,
22     NO_COMMAND_ERR,
23     NO_DBDIR_ERR,
24     FIPS_SWITCH_FAILED_ERR,
25     FIPS_ALREADY_ON_ERR,
26     FIPS_ALREADY_OFF_ERR,
27     FILE_ALREADY_EXISTS_ERR,
28     FILE_DOESNT_EXIST_ERR,
29     FILE_NOT_READABLE_ERR,
30     FILE_NOT_WRITEABLE_ERR,
31     DIR_DOESNT_EXIST_ERR,
32     DIR_NOT_READABLE_ERR,
33     DIR_NOT_WRITEABLE_ERR,
34     INVALID_CONSTANT_ERR,
35     ADD_MODULE_FAILED_ERR,
36     UNUSED_ERR, /* reserved for future use */
37     OUT_OF_MEM_ERR,
38     DELETE_INTERNAL_ERR,
39     DELETE_FAILED_ERR,
40     NO_LIST_LOCK_ERR,
41     NO_MODULE_LIST_ERR,
42     NO_SUCH_MODULE_ERR,
43     MOD_INFO_ERR,
44     SLOT_INFO_ERR,
45     TOKEN_INFO_ERR,
46     NO_SUCH_TOKEN_ERR,
47     CHANGEPW_FAILED_ERR,
48     BAD_PW_ERR,
49     DB_ACCESS_ERR,
50     AUTHENTICATION_FAILED_ERR,
51     NO_SUCH_SLOT_ERR,
52     ENABLE_FAILED_ERR,
53     UPDATE_MOD_FAILED_ERR,
54     DEFAULT_FAILED_ERR,
55     UNDEFAULT_FAILED_ERR,
56     STDIN_READ_ERR,
57     UNSPECIFIED_ERR,
58     NOCERTDB_MISUSE_ERR,
59     NSS_INITIALIZE_FAILED_ERR,
60     INITPW_FAILED_ERR,
61 
62     LAST_ERR /* must be last */
63 } Error;
64 #define SUCCESS NO_ERR
65 
66 /* !!! Should move this into its own .c and un-static it. */
67 static char *errStrings[] = {
68     "Operation completed successfully.\n",
69     "ERROR: Invalid command line.\n",
70     "ERROR: Not expecting argument \"%s\".\n",
71     "ERROR: Unknown option: %s.\n",
72     "ERROR: %s: multiple commands are not allowed on the command line.\n",
73     "ERROR: %s: option needs an argument.\n",
74     "ERROR: %s: option cannot be given more than once.\n",
75     "ERROR: Command \"%s\" requires parameter \"%s\".\n",
76     "ERROR: Argument to -fips must be \"true\" or \"false\".\n",
77     "ERROR: No command was specified.\n",
78     "ERROR: Cannot determine database directory: use the -dbdir option.\n",
79     "ERROR: Unable to switch FIPS modes.\n",
80     "FIPS mode already enabled.\n",
81     "FIPS mode already disabled.\n",
82     "ERROR: File \"%s\" already exists.\n",
83     "ERROR: File \"%s\" does not exist.\n",
84     "ERROR: File \"%s\" is not readable.\n",
85     "ERROR: File \"%s\" is not writeable.\n",
86     "ERROR: Directory \"%s\" does not exist.\n",
87     "ERROR: Directory \"%s\" is not readable.\n",
88     "ERROR: Directory \"%s\" is not writeable.\n",
89     "\"%s\" is not a recognized value.\n",
90     "ERROR: Failed to add module \"%s\". Probable cause : \"%s\".\n",
91     "Unused error string",
92     "ERROR: Out of memory.\n",
93     "ERROR: Cannot delete internal module.\n",
94     "ERROR: Failed to delete module \"%s\".\n",
95     "ERROR: Unable to obtain lock on module list.\n",
96     "ERROR: Unable to obtain module list.\n",
97     "ERROR: Module \"%s\" not found in database.\n",
98     "ERROR: Unable to get information about module \"%s\".\n",
99     "ERROR: Unable to get information about slot \"%s\".\n",
100     "ERROR: Unable to get information about token \"%s\".\n",
101     "ERROR: Token \"%s\" not found.\n",
102     "ERROR: Unable to change password on token \"%s\".\n",
103     "ERROR: Incorrect password.\n",
104     "ERROR: Unable to access database \"%s\".\n",
105     "ERROR: Unable to authenticate to token \"%s\".\n",
106     "ERROR: Slot \"%s\" not found.\n",
107     "ERROR: Failed to %s slot \"%s\".\n",
108     "ERROR: Failed to update module \"%s\".\n",
109     "ERROR: Failed to change defaults.\n",
110     "ERROR: Failed to change default.\n",
111     "ERROR: Unable to read from standard input.\n",
112     "ERROR: Unknown error occurred.\n",
113     "ERROR: -nocertdb option can only be used with the -jar command.\n",
114     "ERROR: NSS_Initialize() failed.\n",
115     "ERROR: Unable to set initial password on the database.\n"
116 };
117 
118 typedef enum {
119     FIPS_ENABLED_MSG = 0,
120     FIPS_DISABLED_MSG,
121     USING_DBDIR_MSG,
122     CREATING_DB_MSG,
123     ADD_MODULE_SUCCESS_MSG,
124     DELETE_SUCCESS_MSG,
125     CHANGEPW_SUCCESS_MSG,
126     BAD_PW_MSG,
127     PW_MATCH_MSG,
128     DONE_MSG,
129     ENABLE_SUCCESS_MSG,
130     DEFAULT_SUCCESS_MSG,
131     UNDEFAULT_SUCCESS_MSG,
132     BROWSER_RUNNING_MSG,
133     ABORTING_MSG,
134     P11_KIT_ENABLED_MSG,
135 
136     LAST_MSG /* must be last */
137 } Message;
138 
139 /* defined in modutil.c */
140 extern char *msgStrings[];
141 
142 #endif /* MODUTIL_ERROR_H */
143