summaryrefslogtreecommitdiff
path: root/src/yelp-page.h
blob: f4428fad96aefab88816290ea50ab872ef98ecf6 (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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
 * Copyright (C) 2006 Brent Smith  <gnome@nextreality.net>
 * Copyright (C) 2007 Shaun McCance  <shaunm@gnome.org>
 *
 * This program 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 2 of the
 * License, 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.
 *
 * You should have received a copy of the GNU 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.
 *
 * Authors: Brent Smith  <gnome@nextreality.net>
 *          Shaun McCance  <shaunm@gnome.org>
 */

#ifndef __YELP_PAGE_H__
#define __YELP_PAGE_H__

#include <glib.h>

#include "yelp-error.h"

G_BEGIN_DECLS

typedef enum {
    YELP_PAGE_MIME_HTML,
    YELP_PAGE_MIME_XHTML
} YelpPageMime;

typedef enum {
    YELP_PAGE_SOURCE_STRING,
    YELP_PAGE_SOURCE_FILE
} YelpPageSource;

typedef struct _YelpPage YelpPage;

/* This needs to be right here to compile. */
#include "yelp-document.h"

struct _YelpPage {
    YelpDocument   *document;
    YelpPageSource  source;
    YelpPageMime    mime;

    gchar  *title;

    /* Do not free content.  The string is owned by the YelpDocument,
     * and it does some internal reference counting to make sure it's
     * only reed when it's no longer referenced.  These strings are
     * just too big to strdup all over the place.
     */
    gchar  *content;
    gsize   content_len;
    gsize   content_offset;

    gchar  *id;
    gchar  *prev_id;
    gchar  *next_id;
    gchar  *up_id;
    gchar  *root_id;
};

YelpPage *    yelp_page_new_string   (YelpDocument  *document,
				      gchar         *id,
				      const gchar   *content,
				      YelpPageMime   mime);

GIOStatus     yelp_page_read         (YelpPage      *page,
				      gchar         *buffer,
				      gsize          count,
				      gsize         *bytes_read,
				      YelpError    **error);

void          yelp_page_free         (YelpPage      *page);

G_END_DECLS

#endif