/src/gdal/frmts/pcraster/libcsf/mperror.c
Line | Count | Source |
1 | | #include "csf.h" |
2 | | #include "csfimpl.h" |
3 | | |
4 | | |
5 | | static const char * const errolist[ERRORNO]={ |
6 | | "No error", |
7 | | "File could not be opened or does not exist", |
8 | | "File is not a PCRaster file", |
9 | | "Wrong C.S.F.-version", |
10 | | "Wrong byte order", |
11 | | "Not enough memory", |
12 | | "Illegal cell representation constant", |
13 | | "Access denied", |
14 | | "Row number to big", |
15 | | "Column number to big", |
16 | | "Map is not a raster file", |
17 | | "Illegal conversion", |
18 | | "No space on device to write", |
19 | | "A write error occurred", |
20 | | "Illegal handle", |
21 | | "A read error occurred", |
22 | | "Illegal access mode constant", |
23 | | "Attribute not found", |
24 | | "Attribute already in file", |
25 | | "Cell size <= 0", |
26 | | "Conflict between cell representation and value scale", |
27 | | "Illegal value scale", |
28 | | "XXXXXXXXXXXXXXXXXXXX", |
29 | | "Angle < -0.5 pi or > 0.5 pi", |
30 | | "Can't read as a boolean map", |
31 | | "Can't write as a boolean map", |
32 | | "Can't write as a ldd map", |
33 | | "Can't use as a ldd map", |
34 | | "Can't write to version 1 cell representation", |
35 | | "Usetype is not version 2 cell representation, VS_LDD or VS_BOOLEAN" |
36 | | }; |
37 | | |
38 | | /* write error message to stderr |
39 | | * Mperror writes the error message belonging to the current Merrno |
40 | | * value to stderr, prefixed by a userString, separated by a semicolon. |
41 | | * |
42 | | * example |
43 | | * .so examples/csfdump1.tr |
44 | | */ |
45 | | void Mperror( |
46 | | const char *userString) /* prefix string */ |
47 | 0 | { |
48 | 0 | (void)fprintf(stderr,"%s : %s\n", userString, errolist[Merrno]); |
49 | 0 | } |
50 | | |
51 | | /* write error message to stderr and exits |
52 | | * Mperror first writes the error message belonging to the current Merrno |
53 | | * value to stderr, prefixed by userString, separated by a semicolon. |
54 | | * Then Mperror exits by calling exit() with the given exit code. |
55 | | * |
56 | | * returns |
57 | | * NEVER RETURNS! |
58 | | * |
59 | | * example |
60 | | * .so examples/csfdump2.tr |
61 | | */ |
62 | | void MperrorExit( |
63 | | const char *userString, /* prefix string */ |
64 | | int exitCode) /* exit code */ |
65 | 0 | { |
66 | 0 | Mperror(userString); |
67 | 0 | exit(exitCode); |
68 | 0 | } |
69 | | |
70 | | /* error message |
71 | | * MstrError returns the error message belonging to the current Merrno |
72 | | * value. |
73 | | * returns the error message belonging to the current Merrno |
74 | | * |
75 | | * example |
76 | | * .so examples/testcsf.tr |
77 | | */ |
78 | | const char *MstrError(void) |
79 | 0 | { |
80 | 0 | return(errolist[Merrno]); |
81 | 0 | } |