mirror of https://github.com/koreader/koreader
Step #2 factoring out the frontend code
parent
364bf96f7a
commit
1f2fb33674
@ -1,5 +0,0 @@
|
||||
The include file "einkfb.h" is distributed with Amazons Linux kernel sources
|
||||
for the Kindle. It has no further copyright notice, so it's assumed to be
|
||||
released under the GPLv2 originally. Under the "any later version" clause, it
|
||||
should be OK to include it in this GPLv3 application.
|
||||
|
@ -1,399 +0,0 @@
|
||||
#ifndef _EINKFB_H
|
||||
#define _EINKFB_H
|
||||
|
||||
#define EINK_1BPP 1
|
||||
#define EINK_2BPP 2
|
||||
#define EINK_4BPP 4
|
||||
#define EINK_8BPP 8
|
||||
#define EINK_BPP_MAX EINK_8BPP
|
||||
|
||||
#define EINK_WHITE 0x00 // For whacking all the pixels in a...
|
||||
#define EINK_BLACK 0xFF // ...byte (8, 4, 2, or 1) at once.
|
||||
|
||||
// Replace EINK_WHITE & EINK_BLACK with the following macros.
|
||||
//
|
||||
#define eink_white(b) EINK_WHITE
|
||||
#define eink_black(b) EINK_BLACK
|
||||
|
||||
// For pixels (at bytes at a time) other than white/black, the following holds.
|
||||
//
|
||||
#define eink_pixels(b, p) (p)
|
||||
|
||||
#define EINK_ORIENT_LANDSCAPE 1
|
||||
#define EINK_ORIENT_PORTRAIT 0
|
||||
|
||||
#define BPP_SIZE(r, b) (((r)*(b))/8)
|
||||
#define BPP_MAX(b) (1 << (b))
|
||||
|
||||
#define U_IN_RANGE(n, m, M) ((((n) == 0) && ((m) == 0)) || (((n) > (m)) && ((n) <= (M))))
|
||||
#define IN_RANGE(n, m, M) (((n) >= (m)) && ((n) <= (M)))
|
||||
|
||||
#define ORIENTATION(x, y) (((y) > (x)) ? EINK_ORIENT_PORTRAIT : EINK_ORIENT_LANDSCAPE)
|
||||
|
||||
struct raw_image_t
|
||||
{
|
||||
int xres, // image's width, in pixels
|
||||
yres, // image's height
|
||||
bpp; // image's pixel (bit) depth
|
||||
|
||||
__u8 start[]; // actual start of image
|
||||
};
|
||||
typedef struct raw_image_t raw_image_t;
|
||||
|
||||
struct image_t
|
||||
{
|
||||
int xres, // image's visual width, in pixels
|
||||
xlen, // image's actual width, used for rowbyte & memory size calculations
|
||||
yres, // image's height
|
||||
bpp; // image's pixel (bit) depth
|
||||
|
||||
__u8 *start; // pointer to start of image
|
||||
};
|
||||
typedef struct image_t image_t;
|
||||
|
||||
#define INIT_IMAGE_T() { 0, 0, 0, 0, NULL }
|
||||
|
||||
enum splash_screen_type
|
||||
{
|
||||
// Simple (non-composite) splash screens.
|
||||
//
|
||||
//splash_screen_powering_off = 0, // Deprecated.
|
||||
//splash_screen_powering_on, // Deprecated.
|
||||
|
||||
//splash_screen_powering_off_wireless, // Deprecated.
|
||||
//splash_screen_powering_on_wireless, // Deprecated.
|
||||
|
||||
//splash_screen_exit, // Deprecated.
|
||||
splash_screen_logo = 5,
|
||||
|
||||
//splash_screen_usb_internal, // Deprecated.
|
||||
//splash_screen_usb_external, // Deprecated.
|
||||
//splash_screen_usb, // Deprecated.
|
||||
|
||||
//splash_screen_sleep, // Deprecated.
|
||||
//splash_screen_update, // Deprecated.
|
||||
|
||||
//num_splash_screens, // Deprecated.
|
||||
|
||||
// Composite splash screens & messages.
|
||||
//
|
||||
//splash_screen_drivemode_0, // Deprecated.
|
||||
//splash_screen_drivemode_1, // Deprecated.
|
||||
//splash_screen_drivemode_2, // Deprecated.
|
||||
//splash_screen_drivemode_3, // Deprecated.
|
||||
|
||||
splash_screen_power_off_clear_screen = 16,// Message: clear screen and power down controller.
|
||||
//splash_screen_screen_saver_picture, // Deprecated.
|
||||
|
||||
splash_screen_shim_picture = 18, // Message: shim wants a picture displayed.
|
||||
|
||||
splash_screen_lowbatt, // Picture: Not composite, post-legacy ordering (Mario only).
|
||||
splash_screen_reboot, // Picture: Composite (not used on Fiona).
|
||||
|
||||
splash_screen_update_initial, // Composite software-update screens.
|
||||
splash_screen_update_success, //
|
||||
splash_screen_update_failure, //
|
||||
splash_screen_update_failure_no_wait, //
|
||||
|
||||
splash_screen_repair_needed, // More composite screens.
|
||||
splash_screen_boot, //
|
||||
|
||||
splash_screen_invalid = -1
|
||||
};
|
||||
typedef enum splash_screen_type splash_screen_type;
|
||||
|
||||
// Alias some of the legacy enumerations for Mario.
|
||||
//
|
||||
#define splash_screen_usb_recovery_util ((splash_screen_type)8) // splash_screen_usb
|
||||
|
||||
struct power_override_t
|
||||
{
|
||||
u_int cmd;
|
||||
u_long arg;
|
||||
};
|
||||
typedef struct power_override_t power_override_t;
|
||||
|
||||
enum fx_type
|
||||
{
|
||||
// Deprecated from the HAL, but still supported by the Shim.
|
||||
//
|
||||
fx_mask = 11, // Only for use with update_area_t's non-NULL buffer which_fx.
|
||||
fx_buf_is_mask = 14, // Same as fx_mask, but doesn't require a doubling (i.e., the buffer & mask are the same).
|
||||
|
||||
fx_none = -1, // No legacy-FX to apply.
|
||||
|
||||
// Screen-update FX, supported by HAL.
|
||||
//
|
||||
fx_flash = 20, // Only for use with update_area_t (for faking a flashing update).
|
||||
fx_invert = 21, // Only for use with update_area_t (only inverts output data).
|
||||
|
||||
fx_update_partial = 0, // eInk GU/PU/MU-style (non-flashing) update.
|
||||
fx_update_full = 1 // eInk GC-style (slower, flashing) update.
|
||||
};
|
||||
typedef enum fx_type fx_type;
|
||||
|
||||
// The only valid legacy-FX types for area updates are fx_mask and fx_buf_is_mask.
|
||||
//
|
||||
#define UPDATE_AREA_FX(f) \
|
||||
((fx_mask == (f)) || \
|
||||
(fx_buf_is_mask == (f)))
|
||||
|
||||
// The default ("none") for area updates is partial (non-flashing); full (flashing) updates
|
||||
// are for FX and such (i.e., explicit completion is desired).
|
||||
//
|
||||
#define UPDATE_AREA_PART(f) \
|
||||
((fx_none == (f)) || \
|
||||
(fx_update_partial == (f)))
|
||||
|
||||
#define UPDATE_AREA_FULL(f) \
|
||||
(UPDATE_AREA_FX(f) || \
|
||||
(fx_update_full == (f)))
|
||||
|
||||
#define UPDATE_AREA_MODE(f) \
|
||||
(UPDATE_AREA_FULL(f) ? fx_update_full \
|
||||
: fx_update_partial)
|
||||
|
||||
// For use with the FBIO_EINK_UPDATE_DISPLAY ioctl.
|
||||
//
|
||||
#define UPDATE_PART(f) \
|
||||
(fx_update_partial == (f))
|
||||
#define UPDATE_FULL(f) \
|
||||
(fx_update_full == (f))
|
||||
#define UPDATE_MODE(f) \
|
||||
(UPDATE_FULL(f) ? fx_update_full \
|
||||
: fx_update_partial)
|
||||
|
||||
struct rect_t
|
||||
{
|
||||
// Note: The bottom-right (x2, y2) coordinate is actually such that (x2 - x1) and (y2 - y1)
|
||||
// are xres and yres, respectively, when normally xres and yres would be
|
||||
// (x2 - x1) + 1 and (y2 - y1) + 1, respectively.
|
||||
//
|
||||
int x1, y1, x2, y2;
|
||||
};
|
||||
typedef struct rect_t rect_t;
|
||||
|
||||
#define INIT_RECT_T() { 0, 0, 0, 0 }
|
||||
#define MAX_EXCLUDE_RECTS 8
|
||||
|
||||
struct fx_t
|
||||
{
|
||||
fx_type update_mode, // Screen-update FX: fx_update_full | fx_update_partial.
|
||||
which_fx; // Shim (legacy) FX.
|
||||
|
||||
int num_exclude_rects; // 0..MAX_EXCLUDE_RECTS.
|
||||
rect_t exclude_rects[MAX_EXCLUDE_RECTS];
|
||||
};
|
||||
typedef struct fx_t fx_t;
|
||||
|
||||
#define INIT_FX_T() \
|
||||
{ fx_update_partial, fx_none, 0, { \
|
||||
INIT_RECT_T(), \
|
||||
INIT_RECT_T(), \
|
||||
INIT_RECT_T(), \
|
||||
INIT_RECT_T(), \
|
||||
INIT_RECT_T(), \
|
||||
INIT_RECT_T(), \
|
||||
INIT_RECT_T(), \
|
||||
INIT_RECT_T()} }
|
||||
|
||||
struct update_area_t
|
||||
{
|
||||
// Note: The bottom-right (x2, y2) coordinate is actually such that (x2 - x1) and (y2 - y1)
|
||||
// are xres and yres, respectively, when normally xres and yres would be
|
||||
// (x2 - x1) + 1 and (y2 - y1) + 1, respectively.
|
||||
//
|
||||
int x1, y1, // Top-left...
|
||||
x2, y2; // ...bottom-right.
|
||||
|
||||
fx_type which_fx; // FX to use.
|
||||
|
||||
__u8 *buffer; // If NULL, extract from framebuffer, top-left to bottom-right, by rowbytes.
|
||||
};
|
||||
typedef struct update_area_t update_area_t;
|
||||
|
||||
#define INIT_UPDATE_AREA_T() { 0, 0, 0, 0, fx_none, NULL }
|
||||
|
||||
struct progressbar_xy_t
|
||||
{
|
||||
int x, y; // Top-left corner of progressbar's position (ignores x for now).
|
||||
};
|
||||
typedef struct progressbar_xy_t progressbar_xy_t;
|
||||
|
||||
enum screen_saver_t
|
||||
{
|
||||
screen_saver_invalid = 0,
|
||||
screen_saver_valid
|
||||
};
|
||||
typedef enum screen_saver_t screen_saver_t;
|
||||
|
||||
enum orientation_t
|
||||
{
|
||||
orientation_portrait,
|
||||
orientation_portrait_upside_down,
|
||||
orientation_landscape,
|
||||
orientation_landscape_upside_down
|
||||
};
|
||||
typedef enum orientation_t orientation_t;
|
||||
|
||||
#define num_orientations (orientation_landscape_upside_down + 1)
|
||||
|
||||
#define ORIENTATION_PORTRAIT(o) \
|
||||
((orientation_portrait == (o)) || (orientation_portrait_upside_down == (o)))
|
||||
|
||||
#define ORIENTATION_LANDSCAPE(o) \
|
||||
((orientation_landscape == (o)) || (orientation_landscape_upside_down == (o)))
|
||||
|
||||
#define ORIENTATION_SAME(o1, o2) \
|
||||
((ORIENTATION_PORTRAIT(o1) && ORIENTATION_PORTRAIT(o2)) || \
|
||||
(ORIENTATION_LANDSCAPE(o1) && ORIENTATION_LANDSCAPE(o2)))
|
||||
|
||||
enum einkfb_events_t
|
||||
{
|
||||
einkfb_event_update_display = 0, // FBIO_EINK_UPDATE_DISPLAY
|
||||
einkfb_event_update_display_area, // FBIO_EINK_UPDATE_DISPLAY_AREA
|
||||
|
||||
einkfb_event_blank_display, // FBIOBLANK (fb.h)
|
||||
einkfb_event_rotate_display, // FBIO_EINK_SET_DISPLAY_ORIENTATION
|
||||
|
||||
einkfb_event_null = -1
|
||||
};
|
||||
typedef enum einkfb_events_t einkfb_events_t;
|
||||
|
||||
struct einkfb_event_t
|
||||
{
|
||||
einkfb_events_t event; // Not all einkfb_events_t use all of the einkfb_event_t fields.
|
||||
|
||||
fx_type update_mode; // Screen-update FX: fx_update_full | fx_update_partial.
|
||||
|
||||
// Note: The bottom-right (x2, y2) coordinate is actually such that (x2 - x1) and (y2 - y1)
|
||||
// are xres and yres, respectively, when normally xres and yres would be
|
||||
// (x2 - x1) + 1 and (y2 - y1) + 1, respectively.
|
||||
//
|
||||
int x1, y1, // Top-left...
|
||||
x2, y2; // ...bottom-right.
|
||||
|
||||
orientation_t orientation; // Display rotated into this orientation.
|
||||
};
|
||||
typedef struct einkfb_event_t einkfb_event_t;
|
||||
|
||||
enum reboot_behavior_t
|
||||
{
|
||||
reboot_screen_asis,
|
||||
reboot_screen_clear,
|
||||
reboot_screen_splash
|
||||
};
|
||||
typedef enum reboot_behavior_t reboot_behavior_t;
|
||||
|
||||
enum progressbar_badge_t
|
||||
{
|
||||
progressbar_badge_success,
|
||||
progressbar_badge_failure,
|
||||
|
||||
progressbar_badge_none
|
||||
};
|
||||
typedef enum progressbar_badge_t progressbar_badge_t;
|
||||
|
||||
enum sleep_behavior_t
|
||||
{
|
||||
sleep_behavior_allow_sleep,
|
||||
sleep_behavior_prevent_sleep
|
||||
};
|
||||
typedef enum sleep_behavior_t sleep_behavior_t;
|
||||
|
||||
#define EINK_FRAME_BUFFER "/dev/fb/0"
|
||||
|
||||
#define SIZEOF_EINK_EVENT sizeof(einkfb_event_t)
|
||||
#define EINK_EVENTS "/dev/misc/eink_events"
|
||||
|
||||
#define EINK_ROTATE_FILE "/sys/devices/platform/eink_fb.0/send_fake_rotate"
|
||||
#define EINK_ROTATE_FILE_LEN 1
|
||||
#define ORIENT_PORTRAIT orientation_portrait
|
||||
#define ORIENT_PORTRAIT_UPSIDE_DOWN orientation_portrait_upside_down
|
||||
#define ORIENT_LANDSCAPE orientation_landscape
|
||||
#define ORIENT_LANDSCAPE_UPSIDE_DOWN orientation_landscape_upside_down
|
||||
#define ORIENT_ASIS (-1)
|
||||
|
||||
#define EINK_USID_FILE "/var/local/eink/usid"
|
||||
|
||||
#define EINK_CLEAR_SCREEN 0
|
||||
#define EINK_CLEAR_BUFFER 1
|
||||
|
||||
#define FBIO_EINK_SCREEN_CLEAR FBIO_EINK_CLEAR_SCREEN, EINK_CLEAR_SCREEN
|
||||
#define FBIO_EINK_BUFFER_CLEAR FBIO_EINK_CLEAR_SCREEN, EINK_CLEAR_BUFFER
|
||||
|
||||
#define FBIO_MIN_SCREEN splash_screen_powering_off
|
||||
#define FBIO_MAX_SCREEN num_splash_screens
|
||||
#define FBIO_SCREEN_IN_RANGE(s) \
|
||||
((FBIO_MIN_SCREEN <= (s)) && (FBIO_MAX_SCREEN > (s)))
|
||||
|
||||
#define FBIO_MAGIC_NUMBER 'F'
|
||||
|
||||
// Implemented in the eInk HAL.
|
||||
//
|
||||
#define FBIO_EINK_UPDATE_DISPLAY _IO(FBIO_MAGIC_NUMBER, 0xdb) // 0x46db (fx_type)
|
||||
#define FBIO_EINK_UPDATE_DISPLAY_AREA _IO(FBIO_MAGIC_NUMBER, 0xdd) // 0x46dd (update_area_t *)
|
||||
|
||||
#define FBIO_EINK_RESTORE_DISPLAY _IO(FBIO_MAGIC_NUMBER, 0xef) // 0x46ef (fx_type)
|
||||
|
||||
#define FBIO_EINK_SET_REBOOT_BEHAVIOR _IO(FBIO_MAGIC_NUMBER, 0xe9) // 0x46e9 (reboot_behavior_t)
|
||||
#define FBIO_EINK_GET_REBOOT_BEHAVIOR _IO(FBIO_MAGIC_NUMBER, 0xed) // 0x46ed (reboot_behavior_t *)
|
||||
|
||||
#define FBIO_EINK_SET_DISPLAY_ORIENTATION _IO(FBIO_MAGIC_NUMBER, 0xf0) // 0x46f0 (orientation_t)
|
||||
#define FBIO_EINK_GET_DISPLAY_ORIENTATION _IO(FBIO_MAGIC_NUMBER, 0xf1) // 0x46f1 (orientation_t *)
|
||||
|
||||
#define FBIO_EINK_SET_SLEEP_BEHAVIOR _IO(FBIO_MAGIC_NUMBER, 0xf2) // 0x46f2 (sleep_behavior_t)
|
||||
#define FBIO_EINK_GET_SLEEP_BEHAVIOR _IO(FBIO_MAGIC_NUMBER, 0xf3) // 0x46f3 (sleep_behavior_t *)
|
||||
|
||||
// Implemented in the eInk Shim.
|
||||
//
|
||||
#define FBIO_EINK_UPDATE_DISPLAY_FX _IO(FBIO_MAGIC_NUMBER, 0xe4) // 0x46e4 (fx_t *)
|
||||
#define FBIO_EINK_SPLASH_SCREEN _IO(FBIO_MAGIC_NUMBER, 0xdc) // 0x46dc (splash_screen_type)
|
||||
#define FBIO_EINK_SPLASH_SCREEN_SLEEP _IO(FBIO_MAGIC_NUMBER, 0xe0) // 0x46e0 (splash_screen_type)
|
||||
#define FBIO_EINK_OFF_CLEAR_SCREEN _IO(FBIO_MAGIC_NUMBER, 0xdf) // 0x46df (EINK_CLEAR_SCREEN || EINK_CLEAR_BUFFER)
|
||||
#define FBIO_EINK_CLEAR_SCREEN _IO(FBIO_MAGIC_NUMBER, 0xe1) // 0x46e1 (no args)
|
||||
#define FBIO_EINK_POWER_OVERRIDE _IO(FBIO_MAGIC_NUMBER, 0xe3) // 0x46e3 (power_override_t *)
|
||||
|
||||
#define FBIO_EINK_PROGRESSBAR _IO(FBIO_MAGIC_NUMBER, 0xea) // 0x46ea (int: 0..100 -> draw progressbar || !(0..100) -> clear progressbar)
|
||||
#define FBIO_EINK_PROGRESSBAR_SET_XY _IO(FBIO_MAGIC_NUMBER, 0xeb) // 0x46eb (progressbar_xy_t *)
|
||||
#define FBIO_EINK_PROGRESSBAR_BADGE _IO(FBIO_MAGIC_NUMBER, 0xec) // 0x46ec (progressbar_badge_t);
|
||||
#define FBIO_EINK_PROGRESSBAR_BACKGROUND _IO(FBIO_MAGIC_NUMBER, 0xf4) // 0x46f4 (int: EINKFB_WHITE || EINKFB_BLACK)
|
||||
|
||||
// Deprecated from the HAL & Shim.
|
||||
//
|
||||
//#define FBIO_EINK_UPDATE_DISPLAY_ASYNC _IO(FBIO_MAGIC_NUMBER, 0xde) // 0x46de (fx_type: fx_update_full || fx_update_partial)
|
||||
//#define FBIO_EINK_FAKE_PNLCD _IO(FBIO_MAGIC_NUMBER, 0xe8) // 0x46e8 (char *)
|
||||
|
||||
// For use with /proc/eink_fb/update_display.
|
||||
//
|
||||
#define PROC_EINK_UPDATE_DISPLAY_CLS 0 // FBIO_EINK_CLEAR_SCREEN
|
||||
#define PROC_EINK_UPDATE_DISPLAY_PART 1 // FBIO_EINK_UPDATE_DISPLAY(fx_update_partial)
|
||||
#define PROC_EINK_UPDATE_DISPLAY_FULL 2 // FBIO_EINK_UPDATE_DISPLAY(fx_update_full)
|
||||
#define PROC_EINK_UPDATE_DISPLAY_AREA 3 // FBIO_EINK_UPDATE_DISPLAY_AREA
|
||||
//#define PROC_EINK_UPDATE_DISPLAY_REST 4 // FBIO_EINK_RESTORE_SCREEN
|
||||
#define PROC_EINK_UPDATE_DISPLAY_SCRN 5 // FBIO_EINK_SPLASH_SCREEN
|
||||
#define PROC_EINK_UPDATE_DISPLAY_OVRD 6 // FBIO_EINK_FPOW_OVERRIDE
|
||||
#define PROC_EINK_UPDATE_DISPLAY_FX 7 // FBIO_EINK_UPDATE_DISPLAY_FX
|
||||
//#define PROC_EINK_UPDATE_DISPLAY_SYNC 8 // FBIO_EINK_SYNC_BUFFERS
|
||||
//#define PROC_EINK_UPDATE_DISPLAY_PNLCD 9 // FBIO_EINK_FAKE_PNLCD
|
||||
#define PROC_EINK_SET_REBOOT_BEHAVIOR 10 // FBIO_EINK_SET_REBOOT_BEHAVIOR
|
||||
#define PROC_EINK_SET_PROGRESSBAR_XY 11 // FBIO_EINK_PROGRESSBAR_SET_XY
|
||||
#define PROC_EINK_UPDATE_DISPLAY_SCRN_SLP 12 // FBIO_EINK_SPLASH_SCREEN_SLEEP
|
||||
#define PROC_EINK_PROGRESSBAR_BADGE 13 // FBIO_EINK_PROGRESSBAR_BADGE
|
||||
#define PROC_EINK_SET_DISPLAY_ORIENTATION 14 // FBIO_EINK_SET_DISPLAY_ORIENTATION
|
||||
#define PROC_EINK_RESTORE_DISPLAY 15 // FBIO_EINK_RESTORE_DISPLAY
|
||||
#define PROC_EINK_SET_SLEEP_BEHAVIOR 16 // FBIO_EINK_SET_SLEEP_BEHAVIOR
|
||||
#define PROC_EINK_PROGRESSBAR_BACKGROUND 17 // FBIO_EINK_PROGRESSBAR_BACKGROUND
|
||||
#define PROC_EINK_UPDATE_DISPLAY_WHICH 18 // FBIO_EINK_UPDATE_DISPLAY
|
||||
|
||||
//#define PROC_EINK_FAKE_PNLCD_TEST 100 // Programmatically drive FBIO_EINK_FAKE_PNLCD (not implemented).
|
||||
#define PROC_EINK_GRAYSCALE_TEST 101 // Fills display with white-to-black ramp at current bit depth.
|
||||
|
||||
// Inter-module/inter-driver eink ioctl access.
|
||||
//
|
||||
extern int fiona_eink_ioctl_stub(unsigned int cmd, unsigned long arg);
|
||||
|
||||
#define eink_sys_ioctl(cmd, arg) (get_fb_ioctl() ? (*get_fb_ioctl())((unsigned int)cmd, (unsigned long)arg) \
|
||||
: fiona_eink_ioctl_stub((unsigned int)cmd, (unsigned long)arg))
|
||||
|
||||
#endif // _EINKFB_H
|
@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
|
||||
*
|
||||
* - Modified by houqp, added mxcfb_update_data struct from GeekMaster's
|
||||
* video player, refer to:
|
||||
* http://www.mobileread.com/forums/showthread.php?t=177455&page=10
|
||||
*
|
||||
* - Modified mxcfb_alt_buffer_data struct according to include/linux/mxcfb.h
|
||||
* from Kindle 5.3.0 firmware. Thanks to eureka@mobileread.
|
||||
* http://www.mobileread.com/forums/showpost.php?p=2337118&postcount=818
|
||||
*
|
||||
*
|
||||
* The code contained herein is licensed under the GNU Lesser General
|
||||
* Public License. You may obtain a copy of the GNU Lesser General
|
||||
* Public License Version 2.1 or later at the following locations:
|
||||
*
|
||||
* http://www.opensource.org/licenses/lgpl-license.html
|
||||
* http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* @file arch-mxc/ mxcfb.h
|
||||
*
|
||||
* @brief Global header file for the MXC Frame buffer
|
||||
*
|
||||
* @ingroup Framebuffer
|
||||
*/
|
||||
|
||||
#ifndef __ASM_ARCH_MXCFB_H__
|
||||
#define __ASM_ARCH_MXCFB_H__
|
||||
|
||||
//#include <linux/fb.h>
|
||||
|
||||
#define FB_SYNC_OE_LOW_ACT 0x80000000
|
||||
#define FB_SYNC_CLK_LAT_FALL 0x40000000
|
||||
#define FB_SYNC_DATA_INVERT 0x20000000
|
||||
#define FB_SYNC_CLK_IDLE_EN 0x10000000
|
||||
#define FB_SYNC_SHARP_MODE 0x08000000
|
||||
#define FB_SYNC_SWAP_RGB 0x04000000
|
||||
|
||||
struct mxcfb_gbl_alpha {
|
||||
int enable;
|
||||
int alpha;
|
||||
};
|
||||
|
||||
struct mxcfb_loc_alpha {
|
||||
int enable;
|
||||
int alpha_in_pixel;
|
||||
unsigned long alpha_phy_addr0;
|
||||
unsigned long alpha_phy_addr1;
|
||||
};
|
||||
|
||||
struct mxcfb_color_key {
|
||||
int enable;
|
||||
__u32 color_key;
|
||||
};
|
||||
|
||||
struct mxcfb_pos {
|
||||
__u16 x;
|
||||
__u16 y;
|
||||
};
|
||||
|
||||
struct mxcfb_gamma {
|
||||
int enable;
|
||||
int constk[16];
|
||||
int slopek[16];
|
||||
};
|
||||
|
||||
struct mxcfb_rect {
|
||||
__u32 top;
|
||||
__u32 left;
|
||||
__u32 width;
|
||||
__u32 height;
|
||||
};
|
||||
|
||||
#define GRAYSCALE_8BIT 0x1
|
||||
#define GRAYSCALE_8BIT_INVERTED 0x2
|
||||
|
||||
#define AUTO_UPDATE_MODE_REGION_MODE 0
|
||||
#define AUTO_UPDATE_MODE_AUTOMATIC_MODE 1
|
||||
|
||||
#define UPDATE_SCHEME_SNAPSHOT 0
|
||||
#define UPDATE_SCHEME_QUEUE 1
|
||||
#define UPDATE_SCHEME_QUEUE_AND_MERGE 2
|
||||
|
||||
#define UPDATE_MODE_PARTIAL 0x0
|
||||
#define UPDATE_MODE_FULL 0x1
|
||||
|
||||
#define WAVEFORM_MODE_AUTO 257
|
||||
|
||||
#define TEMP_USE_AMBIENT 0x1000
|
||||
|
||||
#define EPDC_FLAG_ENABLE_INVERSION 0x01
|
||||
#define EPDC_FLAG_FORCE_MONOCHROME 0x02
|
||||
#define EPDC_FLAG_USE_ALT_BUFFER 0x100
|
||||
|
||||
#define FB_POWERDOWN_DISABLE -1
|
||||
#define FB_TEMP_AUTO_UPDATE_DISABLE -1
|
||||
|
||||
struct mxcfb_alt_buffer_data {
|
||||
/* virt_addr is not included in amazon's source */
|
||||
/* void *virt_addr; */
|
||||
__u32 phys_addr;
|
||||
__u32 width; /* width of entire buffer */
|
||||
__u32 height; /* height of entire buffer */
|
||||
struct mxcfb_rect alt_update_region; /* region within buffer to update */
|
||||
};
|
||||
|
||||
struct mxcfb_update_data {
|
||||
struct mxcfb_rect update_region;
|
||||
__u32 waveform_mode;
|
||||
__u32 update_mode;
|
||||
__u32 update_marker;
|
||||
__u32 hist_bw_waveform_mode;
|
||||
__u32 hist_gray_waveform_mode;
|
||||
int temp;
|
||||
uint flags;
|
||||
struct mxcfb_alt_buffer_data alt_buffer_data;
|
||||
};
|
||||
typedef struct mxcfb_update_data mxcfb_update_data;
|
||||
|
||||
/* this is only used in kindle firmware 5.0, later version (5.1) has changed
|
||||
* the struct to mxcfb_update_data (see above) */
|
||||
struct mxcfb_update_data_50x {
|
||||
struct mxcfb_rect update_region;
|
||||
__u32 waveform_mode;
|
||||
__u32 update_mode;
|
||||
__u32 update_marker;
|
||||
int temp;
|
||||
uint flags;
|
||||
struct mxcfb_alt_buffer_data alt_buffer_data;
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure used to define waveform modes for driver
|
||||
* Needed for driver to perform auto-waveform selection
|
||||
*/
|
||||
struct mxcfb_waveform_modes {
|
||||
int mode_init;
|
||||
int mode_du;
|
||||
int mode_gc4;
|
||||
int mode_gc8;
|
||||
int mode_gc16;
|
||||
int mode_gc32;
|
||||
};
|
||||
|
||||
#define MXCFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t)
|
||||
#define MXCFB_SET_GBL_ALPHA _IOW('F', 0x21, struct mxcfb_gbl_alpha)
|
||||
#define MXCFB_SET_CLR_KEY _IOW('F', 0x22, struct mxcfb_color_key)
|
||||
#define MXCFB_SET_OVERLAY_POS _IOWR('F', 0x24, struct mxcfb_pos)
|
||||
#define MXCFB_GET_FB_IPU_CHAN _IOR('F', 0x25, u_int32_t)
|
||||
#define MXCFB_SET_LOC_ALPHA _IOWR('F', 0x26, struct mxcfb_loc_alpha)
|
||||
#define MXCFB_SET_LOC_ALP_BUF _IOW('F', 0x27, unsigned long)
|
||||
#define MXCFB_SET_GAMMA _IOW('F', 0x28, struct mxcfb_gamma)
|
||||
#define MXCFB_GET_FB_IPU_DI _IOR('F', 0x29, u_int32_t)
|
||||
#define MXCFB_GET_DIFMT _IOR('F', 0x2A, u_int32_t)
|
||||
#define MXCFB_GET_FB_BLANK _IOR('F', 0x2B, u_int32_t)
|
||||
#define MXCFB_SET_DIFMT _IOW('F', 0x2C, u_int32_t)
|
||||
|
||||
/* IOCTLs for E-ink panel updates */
|
||||
#define MXCFB_SET_WAVEFORM_MODES _IOW('F', 0x2B, struct mxcfb_waveform_modes)
|
||||
#define MXCFB_SET_TEMPERATURE _IOW('F', 0x2C, int32_t)
|
||||
#define MXCFB_SET_AUTO_UPDATE_MODE _IOW('F', 0x2D, __u32)
|
||||
#define MXCFB_SEND_UPDATE_50X _IOW('F', 0x2E, struct mxcfb_update_data_50x)
|
||||
#define MXCFB_WAIT_FOR_UPDATE_COMPLETE _IOW('F', 0x2F, __u32)
|
||||
#define MXCFB_SET_PWRDOWN_DELAY _IOW('F', 0x30, int32_t)
|
||||
#define MXCFB_GET_PWRDOWN_DELAY _IOR('F', 0x31, int32_t)
|
||||
#define MXCFB_SET_UPDATE_SCHEME _IOW('F', 0x32, __u32)
|
||||
#define MXCFB_GET_PMIC_TEMPERATURE _IOR('F', 0x32, int32_t)
|
||||
#define MXCFB_SET_BORDER_MODE _IOR('F', 0x33, int32_t)
|
||||
#define MXCFB_SET_EPD_PWR0_CTRL _IOR('F', 0x34, int32_t)
|
||||
#define MXCFB_SET_EPD_PWR2_CTRL _IOR('F', 0x35, int32_t)
|
||||
#define MXCFB_SET_TEMP_AUTO_UPDATE_PERIOD _IOR('F', 0x36, int32_t)
|
||||
#define MXCFB_SET_MERGE_ON_WAVEFORM_MISMATCH _IOW('F', 0x37, int32_t)
|
||||
|
||||
/* IOCTLs for E-ink panel updates, kindle firmware version >= 5.1 */
|
||||
#define MXCFB_SEND_UPDATE _IOW('F', 0x2E, struct mxcfb_update_data)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
extern struct fb_videomode mxcfb_modedb[];
|
||||
extern int mxcfb_modedb_sz;
|
||||
|
||||
enum {
|
||||
MXCFB_REFRESH_OFF,
|
||||
MXCFB_REFRESH_AUTO,
|
||||
MXCFB_REFRESH_PARTIAL,
|
||||
};
|
||||
|
||||
int mxcfb_set_refresh_mode(struct fb_info *fbi, int mode,
|
||||
struct mxcfb_rect *update_region);
|
||||
|
||||
int mxc_elcdif_frame_addr_setup(dma_addr_t phys);
|
||||
#endif /* __KERNEL__ */
|
||||
#endif
|
@ -1,96 +0,0 @@
|
||||
|
||||
PROJECT(kpvcrlib)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
SET(MUPDF_DIR ../mupdf)
|
||||
SET(MUPDF_3RDPARTY_DIR ${MUPDF_DIR}/thirdparty)
|
||||
SET(CR_3RDPARTY_DIR crengine/thirdparty)
|
||||
SET(CRE_DIR crengine/crengine)
|
||||
|
||||
SET(CR3_PNG 1)
|
||||
#SET(CR3_JPEG 1)
|
||||
|
||||
SET(FREETYPE_INCLUDE_DIRS ${MUPDF_3RDPARTY_DIR}/freetype/include)
|
||||
#SET(FREETYPE_INCLUDE_DIRS ${CR_3RDPARTY_DIR}/freetype/include)
|
||||
SET(ANTIWORD_INCLUDE_DIR ${CR_3RDPARTY_DIR}/antiword)
|
||||
SET(CHM_INCLUDE_DIRS ${CR_3RDPARTY_DIR}/chmlib)
|
||||
SET(PNG_INCLUDE_DIR ${CR_3RDPARTY_DIR}/libpng)
|
||||
SET(ZLIB_INCLUDE_DIR ${MUPDF_3RDPARTY_DIR}/zlib)
|
||||
#SET(ZLIB_INCLUDE_DIR ${CR_3RDPARTY_DIR}/zlib)
|
||||
SET(JPEGLIB_INCLUDE_DIR ${MUPDF_3RDPARTY_DIR}/jpeg)
|
||||
#SET(JPEGLIB_INCLUDE_DIR ${CR_3RDPARTY_DIR}/libjpeg)
|
||||
SET(JCONFIG_INCLUDE_DIR ${MUPDF_DIR}/scripts)
|
||||
SET(CREGINE_INCLUDE_DIR ${CRE_DIR}/include)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${JCONFIG_INCLUDE_DIR}
|
||||
${FREETYPE_INCLUDE_DIRS}
|
||||
${ANTIWORD_INCLUDE_DIR}
|
||||
${CHM_INCLUDE_DIRS}
|
||||
${PNG_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${JPEGLIB_INCLUDE_DIR}
|
||||
${CREGINE_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(-DLINUX=1 -D_LINUX=1 -DUSE_FONTCONFIG=0 -DUSE_FREETYPE=1 -DCR3_PATCH=1 -DNDEBUG=1)
|
||||
|
||||
|
||||
message("Will build patched LIBCHM library")
|
||||
ADD_DEFINITIONS(-DCHM_SUPPORT_ENABLED=1)
|
||||
ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/chmlib)
|
||||
|
||||
message("Will build patched LIBPNG library")
|
||||
ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/libpng)
|
||||
|
||||
#message("Will build patched JPEGLIB library")
|
||||
#ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/libjpeg)
|
||||
|
||||
message("Will build patched ANTIWORD library")
|
||||
ADD_DEFINITIONS(-DENABLE_ANTIWORD=1)
|
||||
ADD_DEFINITIONS(-DCR3_ANTIWORD_PATCH=1)
|
||||
ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/antiword)
|
||||
|
||||
message("Will build crengine library")
|
||||
#SET(GUI kpv)
|
||||
#ADD_SUBDIRECTORY(crengine/crengine)
|
||||
|
||||
ADD_DEFINITIONS(-DHAVE_PROTOTYPES)
|
||||
ADD_DEFINITIONS(-DHAVE_UNSIGNED_CHAR)
|
||||
ADD_DEFINITIONS(-Dmain=xxxmain)
|
||||
SET (CRENGINE_SOURCES
|
||||
${CRE_DIR}/src/cp_stats.cpp
|
||||
${CRE_DIR}/src/lvstring.cpp
|
||||
${CRE_DIR}/src/props.cpp
|
||||
${CRE_DIR}/src/lstridmap.cpp
|
||||
${CRE_DIR}/src/rtfimp.cpp
|
||||
${CRE_DIR}/src/lvmemman.cpp
|
||||
${CRE_DIR}/src/lvstyles.cpp
|
||||
${CRE_DIR}/src/crtxtenc.cpp
|
||||
${CRE_DIR}/src/lvtinydom.cpp
|
||||
${CRE_DIR}/src/lvstream.cpp
|
||||
${CRE_DIR}/src/lvxml.cpp
|
||||
${CRE_DIR}/src/chmfmt.cpp
|
||||
${CRE_DIR}/src/epubfmt.cpp
|
||||
${CRE_DIR}/src/pdbfmt.cpp
|
||||
${CRE_DIR}/src/wordfmt.cpp
|
||||
${CRE_DIR}/src/lvstsheet.cpp
|
||||
${CRE_DIR}/src/txtselector.cpp
|
||||
${CRE_DIR}/src/crtest.cpp
|
||||
${CRE_DIR}/src/lvbmpbuf.cpp
|
||||
${CRE_DIR}/src/lvfnt.cpp
|
||||
${CRE_DIR}/src/hyphman.cpp
|
||||
${CRE_DIR}/src/lvfntman.cpp
|
||||
${CRE_DIR}/src/lvimg.cpp
|
||||
${CRE_DIR}/src/crskin.cpp
|
||||
${CRE_DIR}/src/lvdrawbuf.cpp
|
||||
${CRE_DIR}/src/lvdocview.cpp
|
||||
${CRE_DIR}/src/lvpagesplitter.cpp
|
||||
${CRE_DIR}/src/lvtextfm.cpp
|
||||
${CRE_DIR}/src/lvrend.cpp
|
||||
${CRE_DIR}/src/wolutil.cpp
|
||||
${CRE_DIR}/src/hist.cpp
|
||||
${CRE_DIR}/src/cri18n.cpp
|
||||
)
|
||||
ADD_LIBRARY(crengine SHARED ${CRENGINE_SOURCES})
|
||||
|
@ -1,74 +0,0 @@
|
||||
body { text-align: left; text-indent: 0px }
|
||||
p { text-align: justify; text-indent: 2em; margin-top:0em; margin-bottom: 0em }
|
||||
|
||||
empty-line { height: 1em }
|
||||
|
||||
hr { height: 1px; /* background-color: #808080; */ margin-top: 0.5em; margin-bottom: 0.5em }
|
||||
|
||||
sub { vertical-align: sub; font-size: 70% }
|
||||
sup { vertical-align: super; font-size: 70% }
|
||||
strong, b { font-weight: bold }
|
||||
emphasis, i { font-style: italic }
|
||||
|
||||
a { text-decoration: underline }
|
||||
a[type="note"] { vertical-align: super; font-size: 70%; text-decoration: none }
|
||||
|
||||
image { text-align: center; text-indent: 0px }
|
||||
p image { display: inline }
|
||||
|
||||
title p, subtitle p, h1 p, h2 p, h3 p, h4 p, h5 p, h6 p { text-align: center; text-indent: 0px }
|
||||
cite p, epigraph p { text-align: left; text-indent: 0px }
|
||||
v { text-align: left; text-indent: 0px }
|
||||
|
||||
stanza + stanza { margin-top: 1em; }
|
||||
stanza { margin-left: 30%; text-align: left; font-style: italic }
|
||||
poem { margin-top: 1em; margin-bottom: 1em; text-indent: 0px }
|
||||
text-author { font-weight: bold; font-style: italic; margin-left: 5%}
|
||||
epigraph { margin-left: 25%; margin-right: 1em; text-align: left; text-indent:
|
||||
1px; font-style: italic; margin-top: 15px; margin-bottom: 25px }
|
||||
cite { font-style: italic; margin-left: 5%; margin-right: 5%; text-align: justify;
|
||||
margin-top: 20px; margin-bottom: 20px }
|
||||
|
||||
title, h1, h2 { text-align: center; text-indent: 0px; font-weight: bold; hyphenate: none;
|
||||
page-break-before: always; page-break-inside: avoid; page-break-after: avoid; }
|
||||
subtitle, h3, h4, h5, h6 { text-align: center; text-indent: 0px; font-weight: bold;
|
||||
hyphenate: none; page-break-inside: avoid; page-break-after: avoid; }
|
||||
title { font-size: 110%; margin-top: 0.7em; margin-bottom: 0.5em }
|
||||
subtitle { font-style: italic; margin-top: 0.3em; margin-bottom: 0.3em }
|
||||
h1 { font-size: 150% }
|
||||
h2 { font-size: 140% }
|
||||
h3 { font-size: 130% }
|
||||
h4 { font-size: 120% }
|
||||
h5 { font-size: 110% }
|
||||
|
||||
|
||||
table { font-size: 80% }
|
||||
td, th { text-indent: 0px; padding: 3px }
|
||||
th { font-weight: bold; /* background-color: #DDD */ }
|
||||
table > caption { text-indent: 0px; padding: 4px; /* background-color: #EEE */ }
|
||||
|
||||
code, pre { display: block; white-space: pre; text-align: left;
|
||||
font-family: "Droid Sans Mono", monospace; text-align: left }
|
||||
|
||||
body[name="notes"] { font-size: 70%; }
|
||||
body[name="notes"] section title { display: run-in; text-align: left; font-size: 110%;
|
||||
font-weight: bold; page-break-before: auto; page-break-inside: auto;
|
||||
page-break-after: auto; }
|
||||
body[name="notes"] section title p { display: inline }
|
||||
|
||||
description { display: block; }
|
||||
title-info { display: block; }
|
||||
annotation { margin-left: 5%; margin-right: 5%; font-size: 80%; font-style: italic;
|
||||
text-align: justify; text-indent: 2em }
|
||||
date { display: block; font-size: 80%; font-style: italic; text-align: center }
|
||||
genre { display: none; }
|
||||
author { display: none; }
|
||||
book-title { display: none; }
|
||||
keywords { display: none; }
|
||||
lang { display: none; }
|
||||
src-lang { display: none; }
|
||||
translator { display: none; }
|
||||
document-info { display: none; }
|
||||
publish-info { display: none; }
|
||||
custom-info { display: none; }
|
||||
coverpage { display: none }
|
@ -1,14 +0,0 @@
|
||||
diff --git a/crengine/src/lvdocview.cpp b/crengine/src/lvdocview.cpp
|
||||
index e7a355a..e1178de 100755
|
||||
--- a/crengine/src/lvdocview.cpp
|
||||
+++ b/crengine/src/lvdocview.cpp
|
||||
@@ -4539,7 +4539,8 @@ void LVDocView::getCurrentPageLinks(ldomXRangeList & list) {
|
||||
if (_list[i]->getStart().getNode() == elem)
|
||||
return true; // don't add, duplicate found!
|
||||
}
|
||||
- _list.add(new ldomXRange(elem->getChildNode(0)));
|
||||
+ ldomNode * node = elem->getChildNode(0);
|
||||
+ if ( node ) _list.add(new ldomXRange(node));
|
||||
}
|
||||
return true;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
--- lvrend.cpp 2012-04-24 10:27:33.000000000 +0800
|
||||
+++ lvrend-patched.cpp 2012-04-24 10:27:28.000000000 +0800
|
||||
@@ -1902,7 +1902,8 @@
|
||||
UPDATE_STYLE_FIELD( font_style, css_fs_inherit );
|
||||
UPDATE_STYLE_FIELD( font_weight, css_fw_inherit );
|
||||
UPDATE_STYLE_FIELD( font_family, css_ff_inherit );
|
||||
- UPDATE_STYLE_FIELD( font_name, "" );
|
||||
+ //UPDATE_STYLE_FIELD( font_name, "" );
|
||||
+ pstyle->font_name = parent_font.get()->getTypeFace();
|
||||
UPDATE_LEN_FIELD( font_size );
|
||||
//UPDATE_LEN_FIELD( text_indent );
|
||||
spreadParent( pstyle->text_indent, parent_style->text_indent );
|
@ -1,86 +0,0 @@
|
||||
Index: CREDITS
|
||||
===================================================================
|
||||
--- CREDITS (revision 0)
|
||||
+++ CREDITS (working copy)
|
||||
@@ -0,0 +1 @@
|
||||
+Taken from http://code.google.com/p/popen-noshell/
|
||||
|
||||
Property changes on: CREDITS
|
||||
___________________________________________________________________
|
||||
Added: svn:keywords
|
||||
## -0,0 +1 ##
|
||||
+Id
|
||||
\ No newline at end of property
|
||||
Index: Makefile
|
||||
===================================================================
|
||||
--- Makefile (revision 0)
|
||||
+++ Makefile (working copy)
|
||||
@@ -0,0 +1,17 @@
|
||||
+SRCS=popen_noshell.c
|
||||
+
|
||||
+OBJS:=$(SRCS:%.c=%.o)
|
||||
+
|
||||
+%.o: %.c
|
||||
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
|
||||
+
|
||||
+all: libpopen_noshell.a
|
||||
+
|
||||
+libpopen_noshell.a: $(OBJS)
|
||||
+ $(AR) rcs $@ $(OBJS)
|
||||
+
|
||||
+clean:
|
||||
+ rm -rf *.o
|
||||
+ rm -rf libpopen_noshell.a
|
||||
+
|
||||
+.PHONY: clean
|
||||
|
||||
Property changes on: Makefile
|
||||
___________________________________________________________________
|
||||
Added: svn:keywords
|
||||
## -0,0 +1 ##
|
||||
+Id
|
||||
\ No newline at end of property
|
||||
Index: popen_noshell.c
|
||||
===================================================================
|
||||
--- popen_noshell.c (revision 8)
|
||||
+++ popen_noshell.c (working copy)
|
||||
@@ -16,6 +16,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
+#ifndef _GNU_SOURCE
|
||||
+#define _GNU_SOURCE
|
||||
+#endif
|
||||
+
|
||||
#include "popen_noshell.h"
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
@@ -28,10 +32,6 @@
|
||||
#include <sys/wait.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
-
|
||||
-#ifndef _GNU_SOURCE
|
||||
-#define _GNU_SOURCE
|
||||
-#endif
|
||||
#include <sched.h>
|
||||
|
||||
/*
|
||||
@@ -249,7 +249,7 @@
|
||||
* The above malloc() + align implementation is taken from:
|
||||
* http://stackoverflow.com/questions/227897/solve-the-memory-alignment-in-c-interview-question-that-stumped-me
|
||||
*/
|
||||
-
|
||||
+
|
||||
#ifndef POPEN_NOSHELL_VALGRIND_DEBUG
|
||||
pid = clone(fn, stack_aligned, CLONE_VM | SIGCHLD, arg);
|
||||
#else
|
||||
@@ -358,7 +358,7 @@
|
||||
|
||||
pclose_arg->fp = fp;
|
||||
pclose_arg->pid = pid;
|
||||
-
|
||||
+
|
||||
return fp; // we should never end up here
|
||||
}
|
||||
|
@ -1,125 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# pdfattach --- embed specified file(s) in a specified PDF file
|
||||
# Requires pdfLaTeX and attachfile.sty package to run
|
||||
# Returns 0 on success or >0 on error
|
||||
#
|
||||
# Written by Tigran Aivazian <tigran@bibles.org.uk>
|
||||
#
|
||||
|
||||
progname=$(basename $0)
|
||||
|
||||
function escape_tex_specialchars()
|
||||
{
|
||||
local txt=$1
|
||||
local res=$(echo "$txt" | sed -e "s%_%\\\_%g" -e "s%&%\\\&%g")
|
||||
echo "$res"
|
||||
}
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "Usage: $progname -o file.pdf [-a author] file1.djvu [file2.mp3] ..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (! getopts ":o:" opt); then
|
||||
echo "$progname: Missing options." >&2
|
||||
usage
|
||||
fi
|
||||
|
||||
if ! type pdflatex > /dev/null 2>&1 ; then
|
||||
echo "$progname: pdfLaTeX program is required." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! kpsewhich attachfile.sty > /dev/null 2>&1 ; then
|
||||
echo "$progname: attachfile.sty package is required." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare outfile=""
|
||||
declare -a infiles=()
|
||||
declare -a infiles_texclean=()
|
||||
declare -a infilesize=()
|
||||
declare -i infcount=0 outfcount=0 totalsize=0
|
||||
declare author=""
|
||||
|
||||
while getopts ":o:a:" opt; do
|
||||
case $opt in
|
||||
a)
|
||||
author="$OPTARG"
|
||||
;;
|
||||
o)
|
||||
outfile=$(readlink -f "$OPTARG")
|
||||
((outfcount++))
|
||||
;;
|
||||
\?)
|
||||
echo "$progname: Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
:)
|
||||
echo "$progname: Option -$OPTARG requires an argument." >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
numargs=$#
|
||||
for ((i=1 ; i <= $numargs ; i++))
|
||||
do
|
||||
fullname=$(readlink -f "$1")
|
||||
if [ ! -r "$fullname" ] ; then
|
||||
echo "$progname: cannot access the file \"$fullname\"" >&2
|
||||
usage
|
||||
fi
|
||||
infiles[$infcount]="$fullname"
|
||||
infiles_texclean[$infcount]=$(escape_tex_specialchars $(basename "${infiles[$infcount]}"))
|
||||
infilesize[$infcount]=$(stat --print="%s" "$fullname")
|
||||
((totalsize=totalsize+${infilesize[$infcount]}))
|
||||
((infcount++))
|
||||
shift
|
||||
done
|
||||
|
||||
if ((infcount == 0)) ; then
|
||||
echo "$progname: No input file(s) specified." >&2
|
||||
usage
|
||||
fi
|
||||
|
||||
if ((outfcount != 1)) ; then
|
||||
echo "$progname: One (and only one) output file must be specified." >&2
|
||||
usage
|
||||
fi
|
||||
|
||||
workdir=$(mktemp --tmpdir -d pdfattach.XXXXXX)
|
||||
cd $workdir
|
||||
> tmp.tex
|
||||
# emit TeX preamble
|
||||
echo -E "\documentclass{book}" >> tmp.tex
|
||||
echo -E "\usepackage[margin={1mm},papersize={9cm,12cm}]{geometry}" >> tmp.tex
|
||||
echo -E "\usepackage{hyperref,attachfile}" >> tmp.tex
|
||||
if [ ! -z "$author" ] ; then
|
||||
echo -E "\AtBeginDocument{\hypersetup{pdfauthor={$author}}}" >> tmp.tex
|
||||
fi
|
||||
echo -E "\begin{document}" >> tmp.tex
|
||||
echo -E "\tolerance=10000\pagestyle{empty}\fontsize{7}{13}\selectfont" >> tmp.tex
|
||||
|
||||
# emit the list of all files
|
||||
for ((i = 0 ; i < ${#infiles[*]} ; i++));
|
||||
do
|
||||
echo -E "\noindent \hyperlink{L$i}{$((i+1))/${infcount}} \texttt{${infiles_texclean[$i]}} (${infilesize[$i]} bytes)" >> tmp.tex
|
||||
echo >> tmp.tex
|
||||
done
|
||||
echo -E "\noindent Total size $totalsize bytes\newpage" >> tmp.tex
|
||||
|
||||
# now emit all the attachments, one per page
|
||||
for ((i = 0 ; i < ${#infiles[*]} ; i++));
|
||||
do
|
||||
echo -E "\noindent\hypertarget{L$i}$((i+1))/${infcount}\\\\\texttt{${infiles_texclean[$i]}} (\textattachfile[color={0 0 0}]{${infiles[$i]}}{${infilesize[$i]} bytes})\newpage" >> tmp.tex
|
||||
done
|
||||
echo -E "\end{document}" >> tmp.tex
|
||||
pdflatex -halt-on-error tmp.tex > /dev/null && mv tmp.pdf "$outfile"
|
||||
cd - > /dev/null
|
||||
rm -rf $workdir
|
Loading…
Reference in New Issue