/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	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.

**********************************************************************/


#include <stdio.h>
////////////////////////////////////////////////////////
//簡易SAX風インターフェース

typedef struct xml_attr{
	struct xml_attr *pPrev;
	struct xml_attr *pNext;
	char *szName;
	char *szValue;
}XML_ATTR;

typedef struct xml_element{
	char *szName;
	char *szText;
	char *szDirectory;
	int nAttrCount;
	XML_ATTR *attr;
}XML_ELEMENT;

typedef struct xml_event{
	void *(*beginElement)(XML_ELEMENT *ele, void *Param);
	void *(*endElement)(char *szName,void *Param);
	void *(*characters)(char *szText,void *Param);
}XML_EVENT;


/*
//使い方サンプル
void *XMLBeginElement(XML_ELEMENT *ele, void *Param){
	return Param;
}
void *XMLEndElement(char *szName, void *Param){
	return Param;
}
void *XMLCharacters(char *szText, void *Param){
	return Param;
}
int main(int argc, char *argv[])
{
	XML_EVENT x_eve;
	FILE *fp;
	memset(&x_eve,0,sizeof(XML_EVENT));
	x_eve.beginElement = XMLBeginElement;
	x_eve.endElement = XMLEndElement;
	x_eve.characters = XMLCharacters;
	fp = fopen(argv[1], "r");
	XMLParse(fp, &x_eve, NULL);
	fclose(fp);
	return 0;
}
*/

//public
//パースする
void XMLParse(FILE *fp, XML_EVENT *eve, void *Param);


//ユーティリティ関数
//szArgに含まれない文字が現れるまで読み込み、含まれない文字の最初の一文字を返す
char ReadAndFindFirstNotOf(FILE *fp, const char *szArg, char *szBuff, int nBuffSize);
//szDelimsの中のいずれかの文字が見つかるまで読み込み、見つかった文字を返す
char ReadAndFindOneOf(FILE *fp, const char *szDelims, char *szBuff, int nBuffSize);

//private
void free_xml_attr(XML_ATTR *attr);
void free_xml_element(XML_ELEMENT *ele);

////////////////////////////////////////////////////////
