Tuesday, December 26, 2006

Reading eBooks

So I have some .lit eBooks that I find are for Microsoft Reader. That requires a .NET Passport account, so I'm not using that.

Is there an eBook reader for Linux? Yes! It's called OpenBerg.


Oh, that doesn't work with Firefox 2. So let's try openclit. There's no package for openclit, so it looks like I'm forced to compile it:

First, you need libtommath (available from math.libtomcrypt.com).

I also need to compile libtommath. So by my math that's two programs I must compile.

$ make
cc -I./ -Wall -W -Wshadow -Wsign-compare -O3 -funroll-loops -fomit-frame-pointer -c -o bncore.o bncore.c
In file included from bncore.c:1:
./tommath.h:18:19: error: stdio.h: No such file or directory
./tommath.h:19:20: error: string.h: No such file or directory
./tommath.h:20:20: error: stdlib.h: No such file or directory
./tommath.h:21:19: error: ctype.h: No such file or directory
In file included from /usr/lib/gcc/i486-linux-gnu/4.1.2/include/syslimits.h:7,
from /usr/lib/gcc/i486-linux-gnu/4.1.2/include/limits.h:11,
from ./tommath.h:22,
from bncore.c:1:
/usr/lib/gcc/i486-linux-gnu/4.1.2/include/limits.h:122:61: error: limits.h: No such file or directory
In file included from bncore.c:1:
./tommath.h:537: error: expected declaration specifiers or ‘...’ before ‘FILE’
./tommath.h:538: error: expected declaration specifiers or ‘...’ before ‘FILE’
make: *** [bncore.o] Error 1

It turns out that I get this error because linux-libc-dev isn't installed. I sudo aptitude install libc6-dev and continue.

...
a - bn_mp_sqrt.o
a - bn_mp_is_square.o
a - bn_mp_init_set.o
a - bn_mp_init_set_int.o
a - bn_mp_invmod_slow.o
a - bn_mp_prime_rabin_miller_trials.o
a - bn_mp_to_signed_bin_n.o
a - bn_mp_to_unsigned_bin_n.o
ar: unable to rename 'libtommath.a' reason: Operation not permitted
make: *** [libtommath.a] Error 1

SSHFS strikes again. This time I compile libtommath locally. It wants to install into /usr, but I hate that and manually edit the makefile to install it to ~/pro.

install -d -g wheel -o root ~/pro/lib
install: invalid group `wheel'
make: *** [install] Error 1

Why does this need to be in the group for sudo? There is no documentation so I'll assume I can run it in userland. I have to edit the makefile again.

ifndef INSTALL_GROUP
GROUP=usergroup

$ make install
install -d -g usergroup -o root ~/pro/lib
install: cannot change owner and/or group of `~/pro': Operation not permitted
make: *** [install] Error 1

I edit the makefile again.

ifndef INSTALL_USER
USER=user

And the installation finishes. It's now time to compile openclit.

hexdump.c: In function ‘hexdump’:
hexdump.c:37: warning: implicit declaration of function ‘memset’
hexdump.c:37: warning: incompatible implicit declaration of built-in function ‘memset’
cc -funsigned-char -Wall -O2 -I ../libtommath-0.30/ -I ../lib -I ../lib/des -I . -c -o drm5.o drm5.c
drm5.c:38:21: error: tommath.h: No such file or directory
drm5.c: In function ‘get_next_key’:
drm5.c:116: warning: pointer targets in assignment differ in signedness
drm5.c:117: warning: pointer targets in passing argument 1 of ‘read_whole_file’ differ in signedness
drm5.c:122: warning: pointer targets in assignment differ in signedness
drm5.c:123: warning: pointer targets in passing argument 1 of ‘read_whole_file’ differ in signedness
drm5.c:144: warning: pointer targets in passing argument 2 of ‘strcpy’ differ in signedness
drm5.c:145: warning: pointer targets in passing argument 2 of ‘strcpy’ differ in signedness
drm5.c:168: warning: pointer targets in passing argument 2 of ‘strcpy’ differ in signedness
drm5.c:169: warning: pointer targets in passing argument 2 of ‘strcpy’ differ in signedness
drm5.c: In function ‘ms_base64_decode’:
drm5.c:185: warning: pointer targets in assignment differ in signedness
drm5.c: In function ‘get_element’:
drm5.c:267: warning: implicit declaration of function ‘isalnum’
drm5.c: At top level:
drm5.c:295: error: expected ‘)’ before ‘*’ token
drm5.c: In function ‘drm5_handle_key’:
drm5.c:342: error: ‘mp_int’ undeclared (first use in this function)
drm5.c:342: error: (Each undeclared identifier is reported only once
drm5.c:342: error: for each function it appears in.)
drm5.c:342: error: expected ‘;’ before ‘c’
drm5.c:376: warning: implicit declaration of function ‘mp_init’
drm5.c:376: error: ‘c’ undeclared (first use in this function)
drm5.c:377: error: ‘p’ undeclared (first use in this function)
drm5.c:378: error: ‘mod’ undeclared (first use in this function)
drm5.c:379: error: ‘d’ undeclared (first use in this function)
drm5.c:380: warning: implicit declaration of function ‘mp_read_radix’
drm5.c:382: warning: implicit declaration of function ‘mp_read_unsigned_bin’
drm5.c:383: warning: implicit declaration of function ‘mp_exptmod’
drm5.c:384: warning: implicit declaration of function ‘my_mp_to_unsigned_bin’
drm5.c:426: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘__builtin_strcmp’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘__builtin_strcmp’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘__builtin_strcmp’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘__builtin_strcmp’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘strncmp’ differ in signedness
make: *** [drm5.o] Error 1

openclit looks for tommath.h in other directories. So I change the CFLAGS line
in the Makefile to:

CFLAGS=-funsigned-char -Wall -O2 -I ../libtommath-0.30/ -I ../lib -I ../lib/des -I . -I ~/pro/include

gcc -o clit clit.o hexdump.o drm5.o explode.o transmute.o display.o utils.o manifest.o ../lib/openclit.a ../libtommath-0.30/libtommath.a
gcc: ../libtommath-0.30/libtommath.a: No such file or directory
make: *** [clit] Error 1

I have to edit the Makefile again to point it to the correct path for libtommath.

$ ./clit
+---[ ConvertLIT (Version 1.8) ]---------------[ Copyright (c) 2002,2003 ]---
ConvertLIT comes with ABSOLUTELY NO WARRANTY; for details
see the COPYING file or visit "http://www.gnu.org/license/gpl.html".
This is free software, and you are welcome to redistribute it under
certain conditions. See the GPL license for details.

This program has three modes of operation:
First, is ** EXPLOSION **, or the expanding of a .LIT file into an
OEBPS compliant package.
To explode, you type: clit \
For Example:
clit ebook-propietary.lit ebook-oebps\
If the directory does not exist, you MUST put a trailing \ or / after it!

To disable creating multiple subdirectories, use the "-d" flag.

Second, is the DOWNCONVERTING of a .LIT file down to "Sealed",
or DRM1 format for reading on handheld devices.
To downconvert, you type: clit
For Example:
clit "drm5 ebook.lit" ebook-open.lit

Third, is the INSCRIBING of a .LIT file which allows you to label
your ebooks. This is very similar to downconverting, you just add
a third argument: clit
For example:
clit ebook.lit inscribed.lit "the Library of Basil Frankweiler"

DRM5 is supported if you have a "keys.txt" file that contains
the private key(s) for your passport(s) in either the CLIT program
directory or the current directory.
Use the -k flag to force the location of your keys.txt

This is a tool for **YOUR OWN FAIR USE** and not for stealing
other people's ebooks.

Please do not use this program to distrbute illegal copies of ebooks.
... that would make Baby Jesus sad.

We can now convert my eBooks to something Linux can understand.



A text file...

1 comment:

Unknown said...

Thanks a lot, didn't notice the README that comes with convertlit, so I was ready to give up when it asked for libtommath and that wasn't in any Ubuntu repository either.

By the way you can talk old Firefox plugins into trying to work with new versions - just extract them (XPI = ZIP), edit the maxVersion in install.rdf, zip them again and rename as .xpi

That said, there's no guarantee they will work - just that you can install them. The funny thing is that OpenBerg requires convertlit though ;-)