Create a private header

This commit is contained in:
Přemysl Eric Janouch 2013-05-08 20:59:40 +02:00
parent febff16ed4
commit 5b7af35cfa
2 changed files with 80 additions and 54 deletions

65
src/stardict-private.h Normal file
View File

@ -0,0 +1,65 @@
/*
* stardict-private.h: internal StarDict API
*
* Copyright (c) 2013, Přemysl Janouch <p.janouch@gmail.com>
* All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#ifndef STARDICTPRIVATE_H
#define STARDICTPRIVATE_H
/** Describes a single entry in the dictionary index. */
typedef struct stardict_index_entry StardictIndexEntry;
/** Describes a single entry in the synonyms index. */
typedef struct stardict_synonym_entry StardictSynonymEntry;
typedef enum stardict_version StardictVersion;
enum stardict_version { SD_VERSION_2_4_2, SD_VERSION_3_0_0 };
struct stardict_info
{
gchar * path;
StardictVersion version;
gchar * book_name;
gulong word_count;
gulong syn_word_count;
gulong idx_filesize;
gulong idx_offset_bits;
gchar * author;
gchar * email;
gchar * website;
gchar * description;
gchar * date;
gchar * same_type_sequence;
};
struct stardict_index_entry
{
gchar * name; //!< The word in utf-8
guint64 data_offset; //!< Offset of the definition
guint32 data_size; //!< Size of the definition
};
struct stardict_synonym_entry
{
gchar * word; //!< A synonymous word
guint32 original_word; //!< The original word's index
};
#endif /* ! STARDICTPRIVATE_H */

View File

@ -27,62 +27,9 @@
#include <gio/gio.h>
#include "stardict.h"
#include "stardict-private.h"
/** Describes a single entry in the dictionary index. */
typedef struct stardict_index_entry StardictIndexEntry;
/** Describes a single entry in the synonyms index. */
typedef struct stardict_synonym_entry StardictSynonymEntry;
/** Helper class for reading .ifo files. */
typedef struct ifo_reader IfoReader;
typedef enum stardict_version StardictVersion;
enum stardict_version { SD_VERSION_2_4_2, SD_VERSION_3_0_0 };
struct stardict_info
{
gchar * path;
StardictVersion version;
gchar * book_name;
gulong word_count;
gulong syn_word_count;
gulong idx_filesize;
gulong idx_offset_bits;
gchar * author;
gchar * email;
gchar * website;
gchar * description;
gchar * date;
gchar * same_type_sequence;
};
struct stardict_index_entry
{
gchar * name; //!< The word in utf-8
guint64 data_offset; //!< Offset of the definition
guint32 data_size; //!< Size of the definition
};
struct stardict_synonym_entry
{
gchar * word; //!< A synonymous word
guint32 original_word; //!< The original word's index
};
struct ifo_reader
{
gchar * data; //!< File data terminated with \0
gchar * data_end; //!< Where the final \0 char. is
gchar * start; //!< Start of the current token
gchar * key; //!< The key (points into @a data)
gchar * value; //!< The value (points into @a data)
};
// --- Utilities ---------------------------------------------------------------
/** Read the whole stream into a byte array. */
@ -159,6 +106,20 @@ stardict_error_quark (void)
// --- IFO reader --------------------------------------------------------------
/** Helper class for reading .ifo files. */
typedef struct ifo_reader IfoReader;
struct ifo_reader
{
gchar * data; //!< File data terminated with \0
gchar * data_end; //!< Where the final \0 char. is
gchar * start; //!< Start of the current token
gchar * key; //!< The key (points into @a data)
gchar * value; //!< The value (points into @a data)
};
static gboolean
ifo_reader_init (IfoReader *ir, const gchar *path, GError **error)
{