/*
* "$Id: mxmldoc.c 197 2005-04-24 23:23:59Z mike $"
*
* Documentation generator using Mini-XML, a small XML-like file parsing
* library.
*
* Copyright 2003-2005 by Michael Sweet.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2, or (at your option) any later version.
*
* This program 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.
*
* Contents:
*
* main() - Main entry for test program.
* add_variable() - Add a variable or argument.
* safe_strcpy() - Copy a string allowing for overlapping strings.
* scan_file() - Scan a source file.
* sort_node() - Insert a node sorted into a tree.
* update_comment() - Update a comment node.
* write_documentation() - Write HTML documentation.
* write_element() - Write an elements text nodes.
* write_string() - Write a string, quoting XHTML special chars
* as needed...
* ws_cb() - Whitespace callback for saving.
*/
/*
* Include necessary headers...
*/
#include "config.h"
#include "mxml.h"
/*
* This program scans source and header files and produces public API
* documentation for code that conforms to the CUPS Configuration
* Management Plan (CMP) coding standards. Please see the following web
* page for details:
*
* http://www.cups.org/cmp.html
*
* Using Mini-XML, this program creates and maintains an XML representation
* of the public API code documentation which can then be converted to HTML
* as desired. The following is a poor-man's schema:
*
* <?xml version="1.0"?>
* <mxmldoc xmlns="http://www.easysw.com"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xsi:schemaLocation="http://www.easysw.com/~mike/mxml/mxmldoc.xsd">
*
* <namespace name=""> [optional...]
* <constant name="">
* <description>descriptive text</description>
* </constant>
*
* <enumeration name="">
* <description>descriptive text</description>
* <constant name="">...</constant>
* </enumeration>
*
* <typedef name="">
* <description>descriptive text</description>
* <type>type string</type>
* </typedef>
*
* <function name="" scope="">
* <description>descriptive text</description>
* <argument name="" direction="I|O|IO" default="">
* <description>descriptive text</description>
* <type>type string</type>
* </argument>
* <returnvalue>
* <description>descriptive text</description>
* <type>type string</type>
* </returnvalue>
* <seealso>function names separated by spaces</seealso>
* </function>
*
* <variable name="" scope="">
* <description>descriptive text</description>
* <type>type string</type>
* </variable>
*
* <struct name="">
* <description>descriptive text</description>
* <variable name="">...</variable>
* <function name="">...</function>
* </struct>
*
* <union name="">
* <description>descriptive text</description>
* <variable name="">...</variable>
* </union>
*
* <class name="" parent="">
* <description>descriptive text</description>
* <class name="">...</class>
* <enumeration name="">...</enumeration>
* <function name="">...</function>
* <struct name="">...</struct>
* <variable name="">...</variable>
* </class>
* </namespace>
* </mxmldoc>
*/
/*
* Basic states for file parser...
*/
#define STATE_NONE 0 /* No state - whitespace, etc. */
#define STATE_PREPROCESSOR 1 /* Preprocessor directive */
#define STATE_C_COMMENT 2 /* Inside a C comment */
#define STATE_CXX_COMMENT 3 /* Inside a C++ comment */
#define STATE_STRING 4 /* Inside a string constant */
#define STATE_CHARACTER 5 /* Inside a character constant */
#define STATE_IDENTIFIER 6 /* Inside a keyword/identifier */
/*
* Local functions...
*/
static mxml_node_t *add_variable(mxml_node_t *parent, const char *name,
mxml_node_t *type);
static void safe_strcpy(char *dst, const char *src);
static int scan_file(const char *filename, FILE *fp,
mxml_node_t *doc);
static void sort_node(mxml_node_t *tree, mxml_node_t *func);
static void update_comment(mxml_node_t *parent,
mxml_node_t *comment);
static void write_documentation(mxml_node_t *doc);
static void write_element(mxml_node_t *doc, mxml_node_t *element);
static void write_string(const char *s);
static const char *ws_cb(mxml_node_t *node, int where);
/*
* 'main()' - Main entry for test program.
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line args */
{
int i; /* Looping var */
FILE *fp; /* File to read */
mxml_node_t *doc; /* XML documentation tree */
mxml_node_t *mxmldoc; /* mxmldoc node */
/*
* Check arguments...
*/
if (argc < 2)
{
fputs("Usage: mxmldoc filename.xml [source files] >filename.html\n", stderr);
return (1);
}
/*
* Read the XML documentation file, if it exists...
*/
if ((fp = fopen(argv[1], "r")) != NULL)
{
/*
* Read the existing XML file...
*/
doc = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
fclose(fp);
if (!doc)
{
mxmldoc = NULL;
fprintf(stderr, "mxmldoc: Unable to read the XML documentation file \"%s\"!\n",
argv[1]);
}
else if ((mxmldoc = mxmlFindElement(doc, doc, "mxmldoc", NULL,
NULL, MXML_DESCEND)) == NULL)
{
fprintf(stderr, "mxmldoc: XML documentation file \"%s\" is missing <mxmldoc> node!!\n",
argv[1]);
mxmlDelete(doc);
doc = NULL;
}
}
else
{
doc = NULL;
mxmldoc = NULL;
}
if (!doc)
{
/*
* Create an empty XML documentation file...
*/
doc = mxmlNewElement(NULL, "?xml version=\"1.0\"?");
mxmldoc = mxmlNewElement(doc, "mxmldoc");
#ifdef MXML_INCLUDE_SCHEMA
/*
* Currently we don't include the schema/namespace stuff with the
* XML output since some validators don't seem to like it...
*/
mxmlElementSetAttr(mxmldoc, "xmlns", "http://www.easysw.com");
mxmlElementSetAttr(mxmldoc, "xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance");
mxmlElementSetAttr(mxmldoc, "xsi:schemaLocation",
"http://www.easysw.com/~mike/mxml/mxmldoc.xsd");
#endif /* MXML_INCLUDE_SCHEMA */
}
/*
* Loop through all of the source files...
*/
for (i = 2; i < argc; i ++)
if ((fp = fopen(argv[i], "r")) == NULL)
{
fprintf(stderr, "Unable to open source file \"%s\": %s\n", argv[i],
strerror(errno));
mxmlDelete(doc);
return (1);
}
else if (scan_file(argv[i], fp, mxmldoc))
{
fclose(fp);
mxmlDelete(doc);
return (1);
}
else
fclose(fp);
if (argc > 2)
{
/*
* Save the updated XML documentation file...
*/
if ((fp = fopen(argv[1], "w")) != NULL)
{
/*
* Write over the existing XML file...
*/
if (mxmlSaveFile(doc, fp, ws_cb))
{
fprintf(stderr, "Unable to write the XML documentation file \"%s\": %s!\n",
argv[1], strerror(errno));
fclose(fp);
mxmlDelete(doc);
return (1);
}
fclose(fp);
}
else
{
fprintf(stderr, "Unable to create the XML documentation file \"%s\": %s!\n",
argv[1], strerror(errno));
mxmlDelete(doc);
return (1);
}
}
/*
* Write HTML d
没有合适的资源?快使用搜索试试~ 我知道了~
mxml-2.2.1.tar.gz_mxml
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 155 浏览量
2022-09-14
16:47:10
上传
评论
收藏 203KB GZ 举报
温馨提示
共54个文件
c:11个
html:10个
in:5个
非常好用的XML解析库mxml-2.2.1.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
mxml-2.2.1.tar.gz (54个子文件)
mxml-2.2.1
mxmldoc.c 73KB
mxml.xml 36KB
mxml-entity.c 10KB
test
function.cxx 1KB
.cvsignore 43B
enum.cxx 189B
struct.cxx 759B
dotest.sh 191B
class.cxx 1KB
mxml-search.c 5KB
mxml.spec 3KB
mxml-private.c 2KB
config.h.in 1KB
mxml.h 9KB
CHANGES 7KB
ANNOUNCEMENT 269B
configure.in 6KB
README 6KB
mxml-index.c 14KB
vcnet
config.h 1KB
mxmldoc.vcproj 3KB
mxml.sln 1KB
mxml.vcproj 4KB
Makefile.in 8KB
.cvsignore 121B
test.xml 867B
install-sh 5KB
mxml.list.in 3KB
doc
mxmldoc.html 13KB
reference.html 49KB
refapp.html 132B
install.html 3KB
advanced.html 14KB
mxml.html 141KB
mxmldoc.man 2KB
makedocs.sh 1003B
mxml.man 5KB
intro.html 7KB
mxmldoc.xsd 7KB
license.html 26KB
.cvsignore 53B
mxml.book 906B
logo.png 35KB
basics.html 10KB
relnotes.html 8KB
mxml-string.c 8KB
configure 132KB
mxml-set.c 6KB
testmxml.c 15KB
mxml.pc.in 198B
mxml-attr.c 4KB
mxml-file.c 58KB
COPYING 25KB
mxml-node.c 15KB
共 54 条
- 1
资源评论
邓凌佳
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功