|
|
|
@ -16,10 +16,10 @@
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <libdjvu/miniexp.h>
|
|
|
|
|
#include <libdjvu/ddjvuapi.h>
|
|
|
|
|
|
|
|
|
|
#include "string.h"
|
|
|
|
|
#include "blitbuffer.h"
|
|
|
|
|
#include "drawcontext.h"
|
|
|
|
|
#include "djvu.h"
|
|
|
|
@ -27,7 +27,6 @@
|
|
|
|
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct DjvuDocument {
|
|
|
|
|
ddjvu_context_t *context;
|
|
|
|
|
ddjvu_document_t *doc_ref;
|
|
|
|
@ -41,7 +40,6 @@ typedef struct DjvuPage {
|
|
|
|
|
DjvuDocument *doc;
|
|
|
|
|
} DjvuPage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int handle(lua_State *L, ddjvu_context_t *ctx, int wait)
|
|
|
|
|
{
|
|
|
|
|
const ddjvu_message_t *msg;
|
|
|
|
@ -83,7 +81,7 @@ static int openDocument(lua_State *L) {
|
|
|
|
|
return luaL_error(L, "cannot create context");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("## cache_size = %d\n", cache_size);
|
|
|
|
|
//printf("## cache_size = %d\n", cache_size);
|
|
|
|
|
ddjvu_cache_set_size(doc->context, (unsigned long)cache_size);
|
|
|
|
|
|
|
|
|
|
doc->doc_ref = ddjvu_document_create_by_filename_utf8(doc->context, filename, TRUE);
|
|
|
|
@ -108,7 +106,7 @@ static int openDocument(lua_State *L) {
|
|
|
|
|
static int closeDocument(lua_State *L) {
|
|
|
|
|
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
|
|
|
|
|
|
|
|
|
|
// should be save if called twice
|
|
|
|
|
// should be safe if called twice
|
|
|
|
|
if (doc->doc_ref != NULL) {
|
|
|
|
|
ddjvu_document_release(doc->doc_ref);
|
|
|
|
|
doc->doc_ref = NULL;
|
|
|
|
@ -170,7 +168,6 @@ static int walkTableOfContent(lua_State *L, miniexp_t r, int *count, int depth)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int getTableOfContent(lua_State *L) {
|
|
|
|
|
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
|
|
|
|
|
miniexp_t r;
|
|
|
|
@ -515,14 +512,14 @@ static int drawPage(lua_State *L) {
|
|
|
|
|
static int getCacheSize(lua_State *L) {
|
|
|
|
|
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
|
|
|
|
|
unsigned long size = ddjvu_cache_get_size(doc->context);
|
|
|
|
|
printf("## ddjvu_cache_get_size = %d\n", size);
|
|
|
|
|
//printf("## ddjvu_cache_get_size = %d\n", (int)size);
|
|
|
|
|
lua_pushnumber(L, size);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int cleanCache(lua_State *L) {
|
|
|
|
|
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
|
|
|
|
|
printf("## ddjvu_cache_clear\n");
|
|
|
|
|
//printf("## ddjvu_cache_clear\n");
|
|
|
|
|
ddjvu_cache_clear(doc->context);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|