summaryrefslogtreecommitdiff
path: root/xml2ag/xmlopts.def
blob: 242a874a0dcdea3d84d38b6a86a9fe9864bebf3b (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/* -*- Mode: conf -*- */

autogen definitions options;

// Time-stamp:        "2012-04-07 09:05:33 bkorb"

/*
 *  This file is part of AutoGen.
 *  AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
 *
 *  AutoGen is free software: you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AutoGen is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
export = <<-  EOExport
	#include <sys/types.h>
	#include <sys/stat.h>

	#ifndef __USE_POSIX
	#  define __USE_POSIX /* for glib's pedantic needs */
	#endif
	#ifndef __USE_XOPEN_EXTENDED
	#  define __USE_XOPEN_EXTENDED  /* ditto */
	#endif
	#include <stdio.h>
	#include <ctype.h>
	#include <errno.h>
	#include <fcntl.h>
	#include <limits.h>
	#include <stdlib.h>
	#include <string.h>
	#include <unistd.h>

	#include <libxml/parser.h>
	#include <libxml/tree.h>

	extern FILE* outFp;
	#ifndef NUL
	#  define NUL '\0'
	#endif
	extern void forkAutogen( char const* pzInput );
	EOExport;

flag = {
    name        = the-xml2ag-option;
    documentation;
    descrip = 'All other options are derived from autogen';
};

flag = {
    name        = output;
    value       = O;
    arg-type    = string;
    arg-name    = file;
    descrip     = "Output file in lieu of AutoGen processing";
    doc =
    "By default, the output is handed to an AutoGen for processing.\n"
    "However, you may save the definitions to a file instead.";

    flag_code = <<- FLAG_CODE_END
	    if (strcmp(pOptDesc->optArg.argString, "-") == 0)
	        return;

	    if (freopen(pOptDesc->optArg.argString, "w", stdout) == NULL) {
	        fprintf(stderr, "Error %d (%s) opening `%s' for output",
	                errno, strerror(errno), pOptDesc->optArg.argString);
	        exit(EXIT_FAILURE);
	    }
	FLAG_CODE_END ;
};

flag = {
    name        = autogen-options;
    documentation = <<- _EODoc_
	These options are @i{mostly} just passed throug to @code{autogen}.
	The one exception is @code{--override-tpl} which replaces the
	default template in the output definitions.  It does not get passed
	through on the command line.
	_EODoc_;

    descrip = 'All other options';
};

#define XML2AG
#option templ-dir  $top_srcdir/agen5
#option templ-dir  $top_srcdir/autoopts
#include opts.def

explain = <<-  END_EXPLAIN
	This program will convert any arbitrary XML file into equivalent
	AutoGen definitions, and invoke AutoGen.
	END_EXPLAIN ;

detail = <<-  END_DETAIL
	The template will be derived from either:
	*  the ``--override-tpl'' command line option
	*  a top level XML attribute named, "template"

	The ``base-name'' for the output will similarly be either:
	*  the ``--base-name'' command line option
	*  the base name of the .xml file
	END_DETAIL ;

prog-man-descrip = <<-  END_DETAIL
	The template will be derived from either:
	.br
	*  the \fB--override-tpl\fP command line option
	.br
	*  a top level XML attribute named, "template"
	.br
	One or the other \fBmust\fP be provided, or the program will
	exit with a failure message.
	.sp 1
	The ``base-name'' for the output will similarly be either:
	.br
	*  the \fB--base-name\fP command line option
	.br
	*  the base name of the .xml file
	END_DETAIL ;

prog-info-descrip = <<-  END_DETAIL
	The template used will be derived from either:
	@itemize @bullet
	@item
	The @strong{--override-tpl} command line option
	@item
	A top level XML attribute named, "@code{template}"
	@end itemize
	@noindent
	One or the other @strong{must} be provided, or the program will
	exit with a failure message.

	The @emph{base-name} for the output will similarly be either:
	@itemize @bullet
	@item
	The @strong{--base-name} command line option.
	@item
	The base name of the @file{.xml} file.
	@end itemize

	The definitions derived from XML generally have an extra layer
	of definition.  Specifically, this XML input:
	@example
	<mumble attr="foo">
	  mumble-1
	  <grumble>
	  grumble, grumble, grumble.
	</grumble>mumble, mumble
	</mumble>
	@end example
	Will get converted into this:
	@example
	mumble = @{
	  grumble = @{
	    text = 'grumble, grumble, grumble';
	  @};
	  text = 'mumble-1';
	  text = 'mumble, mumble';
	@};
	@end example
	Please notice that some information is lost.  AutoGen cannot tell that
	"grumble" used to lie between the mumble texts.  Also please note that
	you cannot assign:
	@example
	grumble = 'grumble, grumble, grumble.';
	@end example
	because if another "grumble" has an attribute or multiple texts,
	it becomes impossible to have the definitions be the same type
	(compound or text values).
	END_DETAIL ;
/* end of opts.def */