1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#include <stdio.h>
#include "WxdkdrawObj.h"
#include "WxdkdrawRead.h"
static int exval = EXIT_FAILURE;
/* Test program to read a drawing.
Specify drawing file name as first argument.
*/
int main(int argc, char *argv[])
{
wxdrd_status_t status;
Wxd_drawing_t *pdrw;
FILE *fipo;
if (1 < argc) {
fipo = fopen(argv[1], "r");
if (NULL != fipo) {
wxdrd_status_init(&status);
pdrw = wxdrd_read_file(fipo, &status);
if (NULL != pdrw) {
fputs("Successfully read file \"", stdout);
fputs(argv[1], stdout);
fputs("\".\n", stdout);
exval = EXIT_SUCCESS;
wxdobj_drw_delete(pdrw);
}
else {
fputs("ERROR: Failed to read drawing!\n", stderr);
fprintf(stderr, "Line number: %lu\n", status.ln);
fprintf(
stderr, "Text word: %lu\n", (unsigned long)(status.te)
);
fprintf(stderr, "Error code: %d\n", status.ec);
}
fclose(fipo);
}
else {
fputs("ERROR: Failed to open file \"", stderr);
fputs(argv[1], stderr);
fputs("\"!\n", stderr);
}
}
else {
fputs("ERROR: Missing file name\n", stderr);
}
return exval;
}
/* vim: set ai sw=4 ts=4 : */
|