/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
/*
* This file is part of The Croco Library
*
* modify it under the terms of version 2.1 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Author: Dodji Seketeli
* See COPYRIGHTS file for copyright information.
*/
#include <string.h>
#include "cr-utils.h"
#include "cr-om-parser.h"
/**
*@CROMParser:
*
*The definition of the CSS Object Model Parser.
*This parser uses (and sits) the SAC api of libcroco defined
*in cr-parser.h and cr-doc-handler.h
*/
struct _CROMParserPriv {
};
/*
*Forward declaration of a type defined later
*in this file.
*/
struct _ParsingContext;
static ParsingContext *new_parsing_context (void);
GList * a_media_list);
struct _ParsingContext {
};
/********************************************
*Private methods
********************************************/
static ParsingContext *
new_parsing_context (void)
{
if (!result) {
cr_utils_trace_info ("Out of Memory");
return NULL;
}
return result;
}
static void
{
if (a_ctxt->stylesheet) {
}
}
}
static enum CRStatus
{
&sac_handler);
if (!sac_handler) {
}
/*
*initialyze here the sac handler.
*/
if (created_handler) {
}
return status;
}
static void
{
ctxt = new_parsing_context ();
}
static void
{
(void) a_location;
}
static void
{
&& ctxt->stylesheet);
if (!stmts)
goto error;
return;
}
if (!stmts) {
}
}
static void
{
goto error;
return;
if (ctxt) {
}
}
static void
{
(void) a_location;
if (!stmt2) {
if (stmt) {
}
if (charset) {
}
return;
}
}
static void
{
(void) a_location;
if (a_page) {
cr_string_dup (a_page) ;
goto error;
}
}
if (a_pseudo) {
goto error;
}
}
return;
}
}
static void
{
(void) a_page;
(void) a_pseudo_page;
&& ctxt->stylesheet);
if (stmt) {
}
}
}
static void
{
(void) a_location;
&& ctxt->stylesheet);
if (a_media_list) {
/*duplicate the media_list */
(a_media_list);
}
}
static void
{
(void) a_media_list;
&& ctxt->cur_media_stmt
&& ctxt->stylesheet);
if (!stmts) {
}
a_media_list = NULL;
}
static void
{
(void) a_uri_default_ns;
(void) a_location;
if (a_media_list)
if (!stmt)
goto error;
if (!stmt2)
goto error;
} else {
stmt);
if (!stmt2)
goto error;
}
return;
if (uri) {
}
if (stmt) {
}
}
static void
{
/*hmm, this should be NULL so free it */
}
}
static void
{
(void) a_selector_list;
if (ctxt->cur_media_stmt) {
if (!stmts) {
("Could not append a new statement");
return;
}
} else {
if (!stmts) {
("Could not append a new statement");
return;
}
}
}
}
static void
{
/*
*make sure a current ruleset statement has been allocated
*already.
*/
&&
if (a_name) {
}
/*instanciates a new declaration */
/*
*add the new declaration to the current statement
*being build.
*/
case RULESET_STMT:
if (!decl2) {
("Could not append decl to ruleset");
goto error;
}
break;
case AT_FONT_FACE_RULE_STMT:
decl);
if (!decl2) {
("Could not append decl to ruleset");
goto error;
}
break;
case AT_PAGE_RULE_STMT:
if (!decl2) {
("Could not append decl to ruleset");
goto error;
}
break;
default:
goto error;
break;
}
return;
if (str) {
}
if (decl) {
}
}
static void
{
}
}
static void
{
if (ctxt) {
if (ctxt->stylesheet) {
}
}
}
/********************************************
*Public methods
********************************************/
/**
* cr_om_parser_new:
*@a_input: the input stream.
*
*Constructor of the CROMParser.
*Returns the newly built instance of #CROMParser.
*/
{
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
}
cr_utils_trace_info ("Out of memory");
goto error;
}
cr_utils_trace_info ("parsing instanciation failed");
goto error;
}
goto error;
}
return result;
if (result) {
}
return NULL;
}
/**
* cr_om_parser_parse_buf:
*@a_this: the current instance of #CROMParser.
*@a_buf: the in memory buffer to parse.
*@a_len: the length of the in memory buffer in number of bytes.
*@a_enc: the encoding of the in memory buffer.
*@a_result: out parameter the resulting style sheet
*
*Parses the content of an in memory buffer.
*
*Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
{
}
&sac_handler);
if (result)
}
return status;
}
/**
* cr_om_parser_simply_parse_buf:
*@a_buf: the css2 in memory buffer.
*@a_len: the length of the in memory buffer.
*@a_enc: the encoding of the in memory buffer.
*@a_result: out parameter. The resulting css2 style sheet.
*
*The simpler way to parse an in memory css2 buffer.
*
*Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
enum CREncoding a_enc,
CRStyleSheet ** a_result)
{
if (!parser) {
cr_utils_trace_info ("Could not create om parser");
cr_utils_trace_info ("System possibly out of memory");
return CR_ERROR;
}
if (parser) {
}
return status;
}
/**
* cr_om_parser_parse_file:
*@a_this: the current instance of the cssom parser.
*@a_file_uri: the uri of the file.
*(only local file paths are suppported so far)
*@a_enc: the encoding of the file.
*@a_result: out parameter. A pointer
*the build css object model.
*
*Parses a css2 stylesheet contained
*in a file.
*
* Returns CR_OK upon succesful completion, an error code otherwise.
*/
enum CRStatus
const guchar * a_file_uri,
{
(a_file_uri, a_enc);
}
a_file_uri, a_enc);
&sac_handler);
if (result)
}
return status;
}
/**
* cr_om_parser_simply_parse_file:
*@a_file_path: the css2 local file path.
*@a_enc: the file encoding.
*@a_result: out parameter. The returned css stylesheet.
*Must be freed by the caller using cr_stylesheet_destroy.
*
*The simpler method to parse a css2 file.
*
*Returns CR_OK upon successfull completion, an error code otherwise.
*Note that this method uses cr_om_parser_parse_file() so both methods
*have the same return values.
*/
enum CRStatus
enum CREncoding a_enc,
CRStyleSheet ** a_result)
{
if (!parser) {
cr_utils_trace_info ("Could not allocate om parser");
cr_utils_trace_info ("System may be out of memory");
return CR_ERROR;
}
if (parser) {
}
return status;
}
/**
* cr_om_parser_parse_paths_to_cascade:
*@a_this: the current instance of #CROMParser
*@a_author_path: the path to the author stylesheet
*@a_user_path: the path to the user stylesheet
*@a_ua_path: the path to the User Agent stylesheet
*@a_encoding: the encoding of the sheets.
*@a_result: out parameter. The resulting cascade if the parsing
*was okay
*
*Parses three sheets located by their paths and build a cascade
*
*Returns CR_OK upon successful completion, an error code otherwise
*/
enum CRStatus
const guchar * a_author_path,
const guchar * a_user_path,
enum CREncoding a_encoding,
{
/*0->author sheet, 1->user sheet, 2->UA sheet */
gint i = 0;
for (i = 0; i < 3; i++) {
a_encoding, &sheets[i]);
if (sheets[i]) {
cr_stylesheet_unref (sheets[i]);
}
continue;
}
}
if (!result) {
for (i = 0; i < 3; i++) {
cr_stylesheet_unref (sheets[i]);
sheets[i] = 0;
}
return CR_ERROR;
}
return CR_OK;
}
/**
* cr_om_parser_simply_parse_paths_to_cascade:
*@a_author_path: the path to the author stylesheet
*@a_user_path: the path to the user stylesheet
*@a_ua_path: the path to the User Agent stylesheet
*@a_encoding: the encoding of the sheets.
*@a_result: out parameter. The resulting cascade if the parsing
*was okay
*
*Parses three sheets located by their paths and build a cascade
*
*Returns CR_OK upon successful completion, an error code otherwise
*/
enum CRStatus
const guchar * a_user_path,
enum CREncoding a_encoding,
{
if (!parser) {
cr_utils_trace_info ("could not allocated om parser");
cr_utils_trace_info ("System may be out of memory");
return CR_ERROR;
}
if (parser) {
}
return status;
}
/**
* cr_om_parser_destroy:
*@a_this: the current instance of #CROMParser.
*
*Destructor of the #CROMParser.
*/
void
{
}
}
if (a_this) {
}
}