Translation update done using Pootle.
[gammu.git] / tests / dump-error-codes.c
blobe365a97a4c53e64f758bcb28ab19ee4c0cf7e46d
1 /* Sample code to dump all error codes and their descriptions */
3 #include <gammu.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <string.h>
8 int main(int argc, char **argv)
10 GSM_Error error;
11 gboolean numeric = FALSE, manpage = FALSE, doc = FALSE;
12 int rc = 0;
13 const char *errorstring;
14 const char *errorname;
16 if (argc >= 2 && strcmp(argv[1], "-n") == 0) {
17 numeric = TRUE;
20 if (argc >= 2 && strcmp(argv[1], "-m") == 0) {
21 manpage = TRUE;
24 if (argc >= 2 && strcmp(argv[1], "-d") == 0) {
25 doc = TRUE;
28 for (error = ERR_NONE; error < ERR_LAST_VALUE; error++) {
29 errorstring = GSM_ErrorString(error);
30 errorname = GSM_ErrorName(error);
31 if (strcmp("Unknown error description.", errorstring) == 0) {
32 fprintf(stderr, "Unknown error message for %d!\n", error);
33 rc = 1;
35 if (errorname == NULL) {
36 fprintf(stderr, "Unknown error name for %d!\n", error);
37 rc = 1;
39 if (numeric) {
40 printf("%d. %s - %s\n", error, errorname, errorstring);
41 } else if (manpage) {
42 printf(".SS %d\n%s\n", 100 + error, errorstring);
43 } else if (doc) {
44 printf("%d\n %s\n", 100 + error, errorstring);
45 } else {
46 printf("# %s - %s\n", errorname, errorstring);
50 return rc;
53 /* Editor configuration
54 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: