summaryrefslogtreecommitdiff
path: root/support/dktools/testread.cpp
blob: 1a7b211fe675b24eb6fc16c5c9691e044ee02ae5 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
	WARNING: This file was generated by the dkct program (see
	http://dktools.sourceforge.net/ for details).
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: testread.cpt
*/

/**	@file testread.cpp The testread module.
*/


#line 1 "testread.cpt"

#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 : */