michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Simple replacement for hnjalloc.h from libhyphen-2.x, to use moz_x* memory michael@0: * allocation functions. Note that the hyphen.c code does *NOT* check for michael@0: * NULL from memory (re)allocation, so it is essential that we use the michael@0: * "infallible" moz_x* variants here. michael@0: */ michael@0: michael@0: #include "mozilla/mozalloc.h" michael@0: michael@0: #define hnj_malloc(size) moz_xmalloc(size) michael@0: #define hnj_realloc(p, size) moz_xrealloc(p, size) michael@0: #define hnj_free(p) moz_free(p) michael@0: michael@0: /* michael@0: * To enable us to load hyphenation dictionaries from arbitrary resource URIs, michael@0: * not just through file paths using stdio, we override the (few) stdio APIs michael@0: * that hyphen.c uses and provide our own reimplementation that calls Gecko michael@0: * i/o methods. michael@0: */ michael@0: michael@0: #include /* ensure stdio.h is loaded before our macros */ michael@0: michael@0: #undef FILE michael@0: #define FILE hnjFile michael@0: michael@0: #define fopen(path,mode) hnjFopen(path,mode) michael@0: #define fclose(file) hnjFclose(file) michael@0: #define fgets(buf,count,file) hnjFgets(buf,count,file) michael@0: michael@0: typedef struct hnjFile_ hnjFile; michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: hnjFile* hnjFopen(const char* aURISpec, const char* aMode); michael@0: michael@0: int hnjFclose(hnjFile* f); michael@0: michael@0: char* hnjFgets(char* s, int n, hnjFile* f); michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: