|
|
|
@ -121,29 +121,29 @@ static int getNumberOfPages(lua_State *L) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int walkTableOfContent(lua_State *L, miniexp_t r, int *count, int depth) {
|
|
|
|
|
depth++;
|
|
|
|
|
depth++;
|
|
|
|
|
|
|
|
|
|
miniexp_t lista = miniexp_cdr(r); // go inside bookmars in the list
|
|
|
|
|
miniexp_t lista = miniexp_cdr(r); // go inside bookmars in the list
|
|
|
|
|
|
|
|
|
|
int length = miniexp_length(r);
|
|
|
|
|
int counter = 0;
|
|
|
|
|
char page_number[6];
|
|
|
|
|
int length = miniexp_length(r);
|
|
|
|
|
int counter = 0;
|
|
|
|
|
char page_number[6];
|
|
|
|
|
|
|
|
|
|
while(counter < length-1) {
|
|
|
|
|
lua_pushnumber(L, *count);
|
|
|
|
|
lua_newtable(L);
|
|
|
|
|
lua_pushstring(L, "page");
|
|
|
|
|
while(counter < length-1) {
|
|
|
|
|
lua_pushnumber(L, *count);
|
|
|
|
|
lua_newtable(L);
|
|
|
|
|
lua_pushstring(L, "page");
|
|
|
|
|
|
|
|
|
|
strcpy(page_number,miniexp_to_str(miniexp_car(miniexp_cdr(miniexp_nth(counter, lista)))));
|
|
|
|
|
strcpy(page_number,miniexp_to_str(miniexp_car(miniexp_cdr(miniexp_nth(counter, lista)))));
|
|
|
|
|
|
|
|
|
|
page_number[0]= '0'; //page numbers appear as #11, set # to 0 so strtol works
|
|
|
|
|
page_number[0]= '0'; //page numbers appear as #11, set # to 0 so strtol works
|
|
|
|
|
|
|
|
|
|
// printf("string: %i:\n", strtol(page_number,NULL, 10));
|
|
|
|
|
// printf("string: %i:\n", strtol(page_number,NULL, 10));
|
|
|
|
|
|
|
|
|
|
lua_pushnumber(L, strtol(page_number,NULL, 10));
|
|
|
|
|
lua_settable(L, -3);
|
|
|
|
|
lua_pushnumber(L, strtol(page_number,NULL, 10));
|
|
|
|
|
lua_settable(L, -3);
|
|
|
|
|
|
|
|
|
|
lua_pushstring(L, "depth");
|
|
|
|
|
lua_pushstring(L, "depth");
|
|
|
|
|
lua_pushnumber(L, depth);
|
|
|
|
|
lua_settable(L, -3);
|
|
|
|
|
lua_pushstring(L, "title");
|
|
|
|
@ -155,15 +155,15 @@ static int walkTableOfContent(lua_State *L, miniexp_t r, int *count, int depth)
|
|
|
|
|
lua_settable(L, -3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(*count)++;
|
|
|
|
|
(*count)++;
|
|
|
|
|
|
|
|
|
|
if (miniexp_length(miniexp_cdr(miniexp_nth(counter, lista))) > 1) {
|
|
|
|
|
walkTableOfContent(L, miniexp_cdr(miniexp_nth(counter,lista)), count, depth);
|
|
|
|
|
}
|
|
|
|
|
counter++;
|
|
|
|
|
if (miniexp_length(miniexp_cdr(miniexp_nth(counter, lista))) > 1) {
|
|
|
|
|
walkTableOfContent(L, miniexp_cdr(miniexp_nth(counter,lista)), count, depth);
|
|
|
|
|
}
|
|
|
|
|
counter++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -172,11 +172,11 @@ static int getTableOfContent(lua_State *L) {
|
|
|
|
|
|
|
|
|
|
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
|
|
|
|
|
/*ol = djvu_load_outline(doc->doc_ref);*/
|
|
|
|
|
miniexp_t r;
|
|
|
|
|
while ((r=ddjvu_document_get_outline(doc->doc_ref))==miniexp_dummy)
|
|
|
|
|
handle(L, doc->context, True);
|
|
|
|
|
miniexp_t r;
|
|
|
|
|
while ((r=ddjvu_document_get_outline(doc->doc_ref))==miniexp_dummy)
|
|
|
|
|
handle(L, doc->context, True);
|
|
|
|
|
|
|
|
|
|
//printf("lista: %s\n", miniexp_to_str(miniexp_car(miniexp_nth(1, miniexp_cdr(r)))));
|
|
|
|
|
//printf("lista: %s\n", miniexp_to_str(miniexp_car(miniexp_nth(1, miniexp_cdr(r)))));
|
|
|
|
|
|
|
|
|
|
lua_newtable(L);
|
|
|
|
|
walkTableOfContent(L, r, &count, 0);
|
|
|
|
|