1/* -*- Mode: conf -*- */ 2 3autogen definitions options; 4addtogroup = xml2ag; 5 6/* xmlopts.def: option definitions for xml2ag 7 * 8 * This file is part of AutoGen. 9 * AutoGen Copyright (C) 1992-2018 by Bruce Korb - all rights reserved 10 * 11 * AutoGen is free software: you can redistribute it and/or modify it 12 * under the terms of the GNU General Public License as published by the 13 * Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * AutoGen is distributed in the hope that it will be useful, but 17 * WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 * See the GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License along 22 * with this program. If not, see <http://www.gnu.org/licenses/>. 23 */ 24export = <<- EOExport 25 #include <sys/types.h> 26 #include <sys/stat.h> 27 28 #ifndef __USE_POSIX 29 # define __USE_POSIX /* for glib's pedantic needs */ 30 #endif 31 #ifndef __USE_XOPEN_EXTENDED 32 # define __USE_XOPEN_EXTENDED /* ditto */ 33 #endif 34 #include <stdio.h> 35 #include <ctype.h> 36 #include <errno.h> 37 #include <fcntl.h> 38 #include <limits.h> 39 #include <stdlib.h> 40 #include <string.h> 41 #include <unistd.h> 42 43 #include <libxml/parser.h> 44 #include <libxml/tree.h> 45 46 extern FILE * ag_pipe_fp; 47 #ifndef NUL 48 # define NUL '\0' 49 #endif 50 extern void fork_ag(char const * pzInput); 51 EOExport; 52 53flag = { 54 name = the-xml2ag-option; 55 documentation; 56 descrip = 'All other options are derived from autogen'; 57}; 58 59flag = { 60 name = output; 61 value = O; 62 arg-type = string; 63 arg-name = file; 64 descrip = "Output file in lieu of AutoGen processing"; 65 doc = 66 "By default, the output is handed to an AutoGen for processing.\n" 67 "However, you may save the definitions to a file instead."; 68 69 flag_code = <<- FLAG_CODE_END 70 if (strcmp(pOptDesc->optArg.argString, "-") == 0) 71 return; 72 73 if (freopen(pOptDesc->optArg.argString, "w", stdout) == NULL) { 74 fprintf(stderr, "Error %d (%s) opening `%s' for output", 75 errno, strerror(errno), pOptDesc->optArg.argString); 76 exit(EXIT_FAILURE); 77 } 78 FLAG_CODE_END ; 79}; 80 81flag = { 82 name = autogen-options; 83 documentation = <<- _EODoc_ 84 These options are @i{mostly} just passed throug to @code{autogen}. 85 The one exception is @code{--override-tpl} which replaces the 86 default template in the output definitions. It does not get passed 87 through on the command line. 88 _EODoc_; 89 90 descrip = 'All other options'; 91}; 92 93#define XML2AG 94#option templ-dir $top_srcdir/agen5 95#option templ-dir $top_srcdir/autoopts 96#include opts.def 97 98explain = <<- END_EXPLAIN 99 This program will convert any arbitrary XML file into equivalent 100 AutoGen definitions, and invoke AutoGen. 101 END_EXPLAIN ; 102 103detail = <<- END_DETAIL 104 The template will be derived from either: 105 * the ``--override-tpl'' command line option 106 * a top level XML attribute named, "template" 107 108 The ``base-name'' for the output will similarly be either: 109 * the ``--base-name'' command line option 110 * the base name of the .xml file 111 END_DETAIL ; 112 113prog-man-descrip = <<- END_DETAIL 114 The template will be derived from either: 115 .br 116 * the \fB--override-tpl\fP command line option 117 .br 118 * a top level XML attribute named, "template" 119 .br 120 One or the other \fBmust\fP be provided, or the program will 121 exit with a failure message. 122 .sp 1 123 The ``base-name'' for the output will similarly be either: 124 .br 125 * the \fB--base-name\fP command line option 126 .br 127 * the base name of the .xml file 128 END_DETAIL ; 129 130prog-info-descrip = <<- END_DETAIL 131 The template used will be derived from either: 132 @itemize @bullet 133 @item 134 The @strong{--override-tpl} command line option 135 @item 136 A top level XML attribute named, "@code{template}" 137 @end itemize 138 @noindent 139 One or the other @strong{must} be provided, or the program will 140 exit with a failure message. 141 142 The @emph{base-name} for the output will similarly be either: 143 @itemize @bullet 144 @item 145 The @strong{--base-name} command line option. 146 @item 147 The base name of the @file{.xml} file. 148 @end itemize 149 150 The definitions derived from XML generally have an extra layer 151 of definition. Specifically, this XML input: 152 @example 153 <mumble attr="foo"> 154 mumble-1 155 <grumble> 156 grumble, grumble, grumble. 157 </grumble>mumble, mumble 158 </mumble> 159 @end example 160 Will get converted into this: 161 @example 162 mumble = @{ 163 grumble = @{ 164 text = 'grumble, grumble, grumble'; 165 @}; 166 text = 'mumble-1'; 167 text = 'mumble, mumble'; 168 @}; 169 @end example 170 Please notice that some information is lost. AutoGen cannot tell that 171 "grumble" used to lie between the mumble texts. Also please note that 172 you cannot assign: 173 @example 174 grumble = 'grumble, grumble, grumble.'; 175 @end example 176 because if another "grumble" has an attribute or multiple texts, 177 it becomes impossible to have the definitions be the same type 178 (compound or text values). 179 END_DETAIL ; 180/* end of xmlopts.def */ 181