summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-04 23:35:45 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-04 23:35:45 +0200
commit7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2 (patch)
treeb329db03bae14fca178add9909b78b050345c140 /apps
parentefc46353676c27b24f2933dce78305796951a01e (diff)
downloadmupdf-7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2.tar.xz
Le Roi est mort, vive le Roi!
The run-together words are dead! Long live the underscores! The postscript inspired naming convention of using all run-together words has served us well, but it is now time for more readable code. In this commit I have also added the sed script, rename.sed, that I used to convert the source. Use it on your patches and application code.
Diffstat (limited to 'apps')
-rw-r--r--apps/mozilla/moz_main.c86
-rw-r--r--apps/pdfapp.c156
-rw-r--r--apps/pdfapp.h6
-rw-r--r--apps/pdfclean.c282
-rw-r--r--apps/pdfdraw.c114
-rw-r--r--apps/pdfextract.c68
-rw-r--r--apps/pdfinfo.c330
-rw-r--r--apps/pdfshow.c50
-rw-r--r--apps/win_main.c26
-rw-r--r--apps/x11_image.c14
-rw-r--r--apps/x11_main.c22
-rw-r--r--apps/xpsdraw.c77
12 files changed, 614 insertions, 617 deletions
diff --git a/apps/mozilla/moz_main.c b/apps/mozilla/moz_main.c
index b5ba7e7a..b71e4278 100644
--- a/apps/mozilla/moz_main.c
+++ b/apps/mozilla/moz_main.c
@@ -89,10 +89,10 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename)
moz->filename = filename;
moz->xref = pdf_newxref();
- error = pdf_loadxref(moz->xref, filename);
+ error = pdf_load_xref(moz->xref, filename);
if (error)
{
- error = pdf_repairxref(moz->xref, filename);
+ error = pdf_repair_xref(moz->xref, filename);
if (error)
pdfmoz_error(moz, error);
}
@@ -105,30 +105,30 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename)
if (error)
pdfmoz_error(moz, error);
- if (pdf_needspassword(moz->xref))
+ if (pdf_needs_password(moz->xref))
{
pdfmoz_warn(moz, "PDF file is encrypted and needs a password.");
}
- moz->pagecount = pdf_getpagecount(moz->xref);
+ moz->pagecount = pdf_get_page_count(moz->xref);
moz->pages = fz_malloc(sizeof(page_t) * moz->pagecount);
for (i = 0; i < moz->pagecount; i++)
{
fz_obj *pageobj;
- pageobj = pdf_getpageobject(moz->xref, i);
- moz->pages[i].obj = fz_keepobj(pageobj);
- moz->pages[i].page = nil;
- moz->pages[i].image = nil;
+ pageobj = pdf_get_page_object(moz->xref, i);
+ moz->pages[i].obj = fz_keep_obj(pageobj);
+ moz->pages[i].page = NULL;
+ moz->pages[i].image = NULL;
- obj = fz_dictgets(moz->pages[i].obj, "CropBox");
+ obj = fz_dict_gets(moz->pages[i].obj, "CropBox");
if (!obj)
- obj = fz_dictgets(moz->pages[i].obj, "MediaBox");
- bbox = fz_roundrect(pdf_torect(obj));
+ obj = fz_dict_gets(moz->pages[i].obj, "MediaBox");
+ bbox = fz_round_rect(pdf_to_rect(obj));
moz->pages[i].w = bbox.x1 - bbox.x0;
moz->pages[i].h = bbox.y1 - bbox.y0;
- rot = fz_toint(fz_dictgets(moz->pages[i].obj, "Rotate"));
+ rot = fz_to_int(fz_dict_gets(moz->pages[i].obj, "Rotate"));
if ((rot / 90) % 2)
{
int t = moz->pages[i].w;
@@ -144,17 +144,17 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename)
* TODO: move this into mupdf library
*/
- obj = fz_dictgets(moz->xref->trailer, "Root");
- moz->xref->root = fz_resolveindirect(obj);
+ obj = fz_dict_gets(moz->xref->trailer, "Root");
+ moz->xref->root = fz_resolve_indirect(obj);
if (!moz->xref->root)
pdfmoz_error(moz, fz_throw("syntaxerror: missing Root object"));
if (moz->xref->root)
- fz_keepobj(moz->xref->root);
+ fz_keep_obj(moz->xref->root);
- obj = fz_dictgets(moz->xref->trailer, "Info");
- moz->xref->info = fz_resolveindirect(obj);
+ obj = fz_dict_gets(moz->xref->trailer, "Info");
+ moz->xref->info = fz_resolve_indirect(obj);
if (moz->xref->info)
- fz_keepobj(moz->xref->info);
+ fz_keep_obj(moz->xref->info);
moz->doctitle = filename;
if (strrchr(moz->doctitle, '\\'))
@@ -163,9 +163,9 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename)
moz->doctitle = strrchr(moz->doctitle, '/') + 1;
if (moz->xref->info)
{
- obj = fz_dictgets(moz->xref->info, "Title");
+ obj = fz_dict_gets(moz->xref->info, "Title");
if (obj)
- moz->doctitle = pdf_toutf8(obj);
+ moz->doctitle = pdf_to_utf8(obj);
}
/*
@@ -230,7 +230,7 @@ void pdfmoz_loadpage(pdfmoz_t *moz, int pagenum)
if (page->page)
return;
- error = pdf_loadpage(&page->page, moz->xref, page->obj);
+ error = pdf_load_page(&page->page, moz->xref, page->obj);
if (error)
pdfmoz_error(moz, error);
}
@@ -249,7 +249,7 @@ void pdfmoz_drawpage(pdfmoz_t *moz, int pagenum)
bbox = fz_transformaabb(ctm, page->page->mediabox);
error = fz_rendertree(&page->image, moz->rast, page->page->tree,
- ctm, fz_roundrect(bbox), 1);
+ ctm, fz_round_rect(bbox), 1);
if (error)
pdfmoz_error(moz, error);
}
@@ -257,14 +257,14 @@ void pdfmoz_drawpage(pdfmoz_t *moz, int pagenum)
void pdfmoz_gotouri(pdfmoz_t *moz, fz_obj *uri)
{
char buf[2048];
- memcpy(buf, fz_tostrbuf(uri), fz_tostrlen(uri));
- buf[fz_tostrlen(uri)] = 0;
+ memcpy(buf, fz_to_str_buf(uri), fz_to_str_len(uri));
+ buf[fz_to_str_len(uri)] = 0;
NPN_GetURL(moz->inst, buf, "_blank");
}
int pdfmoz_getpagenum(pdfmoz_t *moz, fz_obj *obj)
{
- return pdf_findpageobject(moz->xref, obj);
+ return pdf_find_page_object(moz->xref, obj);
}
void pdfmoz_gotopage(pdfmoz_t *moz, fz_obj *obj)
@@ -272,7 +272,7 @@ void pdfmoz_gotopage(pdfmoz_t *moz, fz_obj *obj)
int page;
int i, y = 0;
- page = pdf_findpageobject(moz->xref, obj);
+ page = pdf_find_page_object(moz->xref, obj);
for (i = 0; i < page; i++)
y += moz->pages[i].px;
@@ -311,9 +311,9 @@ void pdfmoz_onmouse(pdfmoz_t *moz, int x, int y, int click)
p.y = y + moz->pages[pi].image->y - py;
ctm = pdfmoz_pagectm(moz, pi);
- ctm = fz_invertmatrix(ctm);
+ ctm = fz_invert_matrix(ctm);
- p = fz_transformpoint(ctm, p);
+ p = fz_transform_point(ctm, p);
for (link = moz->pages[pi].page->links; link; link = link->next)
{
@@ -327,21 +327,21 @@ void pdfmoz_onmouse(pdfmoz_t *moz, int x, int y, int click)
SetCursor(moz->hand);
if (click)
{
- if (link->kind == PDF_LURI)
+ if (link->kind == PDF_LINK_URI)
pdfmoz_gotouri(moz, link->dest);
- else if (link->kind == PDF_LGOTO)
+ else if (link->kind == PDF_LINK_GOTO)
pdfmoz_gotopage(moz, link->dest);
return;
}
else
{
- if (fz_isstring(link->dest))
+ if (fz_is_string(link->dest))
{
- memcpy(buf, fz_tostrbuf(link->dest), fz_tostrlen(link->dest));
- buf[fz_tostrlen(link->dest)] = 0;
+ memcpy(buf, fz_to_str_buf(link->dest), fz_to_str_len(link->dest));
+ buf[fz_to_str_len(link->dest)] = 0;
NPN_Status(moz->inst, buf);
}
- else if (fz_isindirect(link->dest))
+ else if (fz_is_indirect(link->dest))
{
sprintf(buf, "Go to page %d",
pdfmoz_getpagenum(moz, link->dest) + 1);
@@ -462,15 +462,15 @@ MozWinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (moz->pages[i].page)
{
pdf_droppage(moz->pages[i].page);
- moz->pages[i].page = nil;
+ moz->pages[i].page = NULL;
}
}
if (i < moz->scrollpage - 1 || i > moz->scrollpage + 3)
{
if (moz->pages[i].image)
{
- fz_droppixmap(moz->pages[i].image);
- moz->pages[i].image = nil;
+ fz_drop_pixmap(moz->pages[i].image);
+ moz->pages[i].image = NULL;
}
}
}
@@ -555,8 +555,8 @@ MozWinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (moz->pages[i].image)
{
- fz_droppixmap(moz->pages[i].image);
- moz->pages[i].image = nil;
+ fz_drop_pixmap(moz->pages[i].image);
+ moz->pages[i].image = NULL;
}
si.nMax += moz->pages[i].px;
@@ -708,11 +708,11 @@ NPP_Destroy(NPP inst, NPSavedData **saved)
for (i = 0; i < moz->pagecount; i++)
{
if (moz->pages[i].obj)
- fz_dropobj(moz->pages[i].obj);
+ fz_drop_obj(moz->pages[i].obj);
if (moz->pages[i].page)
pdf_droppage(moz->pages[i].page);
if (moz->pages[i].image)
- fz_droppixmap(moz->pages[i].image);
+ fz_drop_pixmap(moz->pages[i].image);
}
fz_free(moz->pages);
@@ -722,7 +722,7 @@ NPP_Destroy(NPP inst, NPSavedData **saved)
if (moz->xref->store)
{
pdf_dropstore(moz->xref->store);
- moz->xref->store = nil;
+ moz->xref->store = NULL;
}
pdf_closexref(moz->xref);
@@ -839,5 +839,3 @@ NPP_Shutdown(void)
{
// MSG("NPP_Shutdown");
}
-
-
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index bebb8088..277bdbf0 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -108,8 +108,8 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd)
* Open PDF and load xref table
*/
- file = fz_openfd(fd);
- error = pdf_openxrefwithstream(&app->xref, file, nil);
+ file = fz_open_fd(fd);
+ error = pdf_open_xref_with_stream(&app->xref, file, NULL);
if (error)
pdfapp_error(app, fz_rethrow(error, "cannot open document '%s'", filename));
fz_close(file);
@@ -118,15 +118,15 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd)
* Handle encrypted PDF files
*/
- if (pdf_needspassword(app->xref))
+ if (pdf_needs_password(app->xref))
{
- int okay = pdf_authenticatepassword(app->xref, password);
+ int okay = pdf_authenticate_password(app->xref, password);
while (!okay)
{
password = winpassword(app, filename);
if (!password)
exit(1);
- okay = pdf_authenticatepassword(app->xref, password);
+ okay = pdf_authenticate_password(app->xref, password);
if (!okay)
pdfapp_warn(app, "Invalid password.");
}
@@ -136,30 +136,30 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd)
* Load meta information
*/
- app->outline = pdf_loadoutline(app->xref);
+ app->outline = pdf_load_outline(app->xref);
app->doctitle = filename;
if (strrchr(app->doctitle, '\\'))
app->doctitle = strrchr(app->doctitle, '\\') + 1;
if (strrchr(app->doctitle, '/'))
app->doctitle = strrchr(app->doctitle, '/') + 1;
- info = fz_dictgets(app->xref->trailer, "Info");
+ info = fz_dict_gets(app->xref->trailer, "Info");
if (info)
{
- obj = fz_dictgets(info, "Title");
+ obj = fz_dict_gets(info, "Title");
if (obj)
- app->doctitle = pdf_toutf8(obj);
+ app->doctitle = pdf_to_utf8(obj);
}
/*
* Start at first page
*/
- error = pdf_loadpagetree(app->xref);
+ error = pdf_load_page_tree(app->xref);
if (error)
pdfapp_error(app, fz_rethrow(error, "cannot load page tree"));
- app->pagecount = pdf_getpagecount(app->xref);
+ app->pagecount = pdf_get_page_count(app->xref);
}
static void pdfapp_open_xps(pdfapp_t *app, char *filename, int fd)
@@ -185,7 +185,7 @@ void pdfapp_open(pdfapp_t *app, char *filename, int fd)
else
pdfapp_open_pdf(app, filename, fd);
- app->cache = fz_newglyphcache();
+ app->cache = fz_new_glyph_cache();
app->shrinkwrap = 1;
if (app->pageno < 1)
@@ -206,25 +206,25 @@ void pdfapp_open(pdfapp_t *app, char *filename, int fd)
void pdfapp_close(pdfapp_t *app)
{
if (app->cache)
- fz_freeglyphcache(app->cache);
- app->cache = nil;
+ fz_free_glyph_cache(app->cache);
+ app->cache = NULL;
if (app->image)
- fz_droppixmap(app->image);
- app->image = nil;
+ fz_drop_pixmap(app->image);
+ app->image = NULL;
if (app->outline)
- pdf_freeoutline(app->outline);
- app->outline = nil;
+ pdf_free_outline(app->outline);
+ app->outline = NULL;
if (app->xref)
{
if (app->xref->store)
- pdf_freestore(app->xref->store);
- app->xref->store = nil;
+ pdf_free_store(app->xref->store);
+ app->xref->store = NULL;
- pdf_freexref(app->xref);
- app->xref = nil;
+ pdf_free_xref(app->xref);
+ app->xref = NULL;
}
if (app->xps)
@@ -233,7 +233,7 @@ void pdfapp_close(pdfapp_t *app)
app->xps = NULL;
}
- fz_flushwarnings();
+ fz_flush_warnings();
}
static fz_matrix pdfapp_viewctm(pdfapp_t *app)
@@ -280,8 +280,8 @@ static void pdfapp_loadpage_pdf(pdfapp_t *app)
fz_device *mdev;
fz_obj *obj;
- obj = pdf_getpageobject(app->xref, app->pageno);
- error = pdf_loadpage(&page, app->xref, obj);
+ obj = pdf_get_page_object(app->xref, app->pageno);
+ error = pdf_load_page(&page, app->xref, obj);
if (error)
pdfapp_error(app, error);
@@ -291,19 +291,19 @@ static void pdfapp_loadpage_pdf(pdfapp_t *app)
page->links = NULL;
/* Create display list */
- app->page_list = fz_newdisplaylist();
- mdev = fz_newlistdevice(app->page_list);
- error = pdf_runpage(app->xref, page, mdev, fz_identity);
+ app->page_list = fz_new_display_list();
+ mdev = fz_new_list_device(app->page_list);
+ error = pdf_run_page(app->xref, page, mdev, fz_identity);
if (error)
{
error = fz_rethrow(error, "cannot draw page %d in '%s'", app->pageno, app->doctitle);
pdfapp_error(app, error);
}
- fz_freedevice(mdev);
+ fz_free_device(mdev);
- pdf_freepage(page);
+ pdf_free_page(page);
- pdf_agestore(app->xref->store, 3);
+ pdf_age_store(app->xref->store, 3);
}
static void pdfapp_loadpage_xps(pdfapp_t *app)
@@ -323,12 +323,12 @@ static void pdfapp_loadpage_xps(pdfapp_t *app)
app->page_links = NULL;
/* Create display list */
- app->page_list = fz_newdisplaylist();
- mdev = fz_newlistdevice(app->page_list);
+ app->page_list = fz_new_display_list();
+ mdev = fz_new_list_device(app->page_list);
app->xps->dev = mdev;
xps_parse_fixed_page(app->xps, fz_identity, page);
- app->xps->dev = nil;
- fz_freedevice(mdev);
+ app->xps->dev = NULL;
+ fz_free_device(mdev);
xps_free_page(app->xps, page);
}
@@ -347,11 +347,11 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
if (loadpage)
{
if (app->page_list)
- fz_freedisplaylist(app->page_list);
+ fz_free_display_list(app->page_list);
if (app->page_text)
- fz_freetextspan(app->page_text);
+ fz_free_text_span(app->page_text);
if (app->page_links)
- pdf_freelink(app->page_links);
+ pdf_free_link(app->page_links);
if (app->xref)
pdfapp_loadpage_pdf(app);
@@ -363,10 +363,10 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
app->hitlen = 0;
/* Extract text */
- app->page_text = fz_newtextspan();
- tdev = fz_newtextdevice(app->page_text);
- fz_executedisplaylist(app->page_list, tdev, fz_identity, fz_infinitebbox);
- fz_freedevice(tdev);
+ app->page_text = fz_new_text_span();
+ tdev = fz_new_text_device(app->page_text);
+ fz_execute_display_list(app->page_list, tdev, fz_identity, fz_infinite_bbox);
+ fz_free_device(tdev);
}
if (drawpage)
@@ -376,24 +376,24 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
wintitle(app, buf);
ctm = pdfapp_viewctm(app);
- bbox = fz_roundrect(fz_transformrect(ctm, app->page_bbox));
+ bbox = fz_round_rect(fz_transform_rect(ctm, app->page_bbox));
/* Draw */
if (app->image)
- fz_droppixmap(app->image);
+ fz_drop_pixmap(app->image);
if (app->grayscale)
- colorspace = fz_devicegray;
+ colorspace = fz_device_gray;
else
#ifdef _WIN32
- colorspace = fz_devicebgr;
+ colorspace = fz_device_bgr;
#else
- colorspace = fz_devicergb;
+ colorspace = fz_device_rgb;
#endif
- app->image = fz_newpixmapwithrect(colorspace, bbox);
- fz_clearpixmapwithcolor(app->image, 255);
- idev = fz_newdrawdevice(app->cache, app->image);
- fz_executedisplaylist(app->page_list, idev, ctm, bbox);
- fz_freedevice(idev);
+ app->image = fz_new_pixmap_with_rect(colorspace, bbox);
+ fz_clear_pixmap_with_color(app->image, 255);
+ idev = fz_new_draw_device(app->cache, app->image);
+ fz_execute_display_list(app->page_list, idev, ctm, bbox);
+ fz_free_device(idev);
}
if (repaint)
@@ -421,15 +421,15 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
wincursor(app, ARROW);
}
- fz_flushwarnings();
+ fz_flush_warnings();
}
static void pdfapp_gotouri(pdfapp_t *app, fz_obj *uri)
{
char *buf;
- buf = fz_malloc(fz_tostrlen(uri) + 1);
- memcpy(buf, fz_tostrbuf(uri), fz_tostrlen(uri));
- buf[fz_tostrlen(uri)] = 0;
+ buf = fz_malloc(fz_to_str_len(uri) + 1);
+ memcpy(buf, fz_to_str_buf(uri), fz_to_str_len(uri));
+ buf[fz_to_str_len(uri)] = 0;
winopenuri(app, buf);
fz_free(buf);
}
@@ -438,7 +438,7 @@ static void pdfapp_gotopage(pdfapp_t *app, fz_obj *obj)
{
int page;
- page = pdf_findpageobject(app->xref, obj);
+ page = pdf_find_page_object(app->xref, obj);
if (app->histlen + 1 == 256)
{
@@ -450,7 +450,7 @@ static void pdfapp_gotopage(pdfapp_t *app, fz_obj *obj)
pdfapp_showpage(app, 1, 1, 1);
}
-static inline fz_bbox bboxcharat(fz_textspan *span, int idx)
+static inline fz_bbox bboxcharat(fz_text_span *span, int idx)
{
int ofs = 0;
while (span)
@@ -460,13 +460,13 @@ static inline fz_bbox bboxcharat(fz_textspan *span, int idx)
if (span->eol)
{
if (idx == ofs + span->len)
- return fz_emptybbox;
+ return fz_empty_bbox;
ofs ++;
}
ofs += span->len;
span = span->next;
}
- return fz_emptybbox;
+ return fz_empty_bbox;
}
void pdfapp_inverthit(pdfapp_t *app)
@@ -478,29 +478,29 @@ void pdfapp_inverthit(pdfapp_t *app)
if (app->hit < 0)
return;
- hitbox = fz_emptybbox;
+ hitbox = fz_empty_bbox;
ctm = pdfapp_viewctm(app);
for (i = app->hit; i < app->hit + app->hitlen; i++)
{
bbox = bboxcharat(app->page_text, i);
- if (fz_isemptyrect(bbox))
+ if (fz_is_empty_rect(bbox))
{
- if (!fz_isemptyrect(hitbox))
- pdfapp_invert(app, fz_transformbbox(ctm, hitbox));
- hitbox = fz_emptybbox;
+ if (!fz_is_empty_rect(hitbox))
+ pdfapp_invert(app, fz_transform_bbox(ctm, hitbox));
+ hitbox = fz_empty_bbox;
}
else
{
- hitbox = fz_unionbbox(hitbox, bbox);
+ hitbox = fz_union_bbox(hitbox, bbox);
}
}
- if (!fz_isemptyrect(hitbox))
- pdfapp_invert(app, fz_transformbbox(ctm, hitbox));
+ if (!fz_is_empty_rect(hitbox))
+ pdfapp_invert(app, fz_transform_bbox(ctm, hitbox));
}
-static inline int charat(fz_textspan *span, int idx)
+static inline int charat(fz_text_span *span, int idx)
{
int ofs = 0;
while (span)
@@ -519,7 +519,7 @@ static inline int charat(fz_textspan *span, int idx)
return 0;
}
-static int textlen(fz_textspan *span)
+static int textlen(fz_text_span *span)
{
int len = 0;
while (span)
@@ -532,7 +532,7 @@ static int textlen(fz_textspan *span)
return len;
}
-static int match(char *s, fz_textspan *span, int n)
+static int match(char *s, fz_text_span *span, int n)
{
int orig = n;
int c;
@@ -951,9 +951,9 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
p.y = y - app->pany + app->image->y;
ctm = pdfapp_viewctm(app);
- ctm = fz_invertmatrix(ctm);
+ ctm = fz_invert_matrix(ctm);
- p = fz_transformpoint(ctm, p);
+ p = fz_transform_point(ctm, p);
for (link = app->page_links; link; link = link->next)
{
@@ -967,10 +967,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
wincursor(app, HAND);
if (btn == 1 && state == 1)
{
- if (link->kind == PDF_LURI)
+ if (link->kind == PDF_LINK_URI)
pdfapp_gotouri(app, link->dest);
- else if (link->kind == PDF_LGOTO)
- pdfapp_gotopage(app, fz_arrayget(link->dest, 0)); /* [ pageobj ... ] */
+ else if (link->kind == PDF_LINK_GOTO)
+ pdfapp_gotopage(app, fz_array_get(link->dest, 0)); /* [ pageobj ... ] */
return;
}
}
@@ -1067,7 +1067,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
{
fz_bbox hitbox;
fz_matrix ctm;
- fz_textspan *span;
+ fz_text_span *span;
int c, i, p;
int seen;
@@ -1085,7 +1085,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
for (i = 0; i < span->len; i++)
{
- hitbox = fz_transformbbox(ctm, span->text[i].bbox);
+ hitbox = fz_transform_bbox(ctm, span->text[i].bbox);
c = span->text[i].c;
if (c < 32)
c = '?';
diff --git a/apps/pdfapp.h b/apps/pdfapp.h
index dda637db..feb0a8ce 100644
--- a/apps/pdfapp.h
+++ b/apps/pdfapp.h
@@ -34,7 +34,7 @@ struct pdfapp_s
xps_context *xps;
int pagecount;
- fz_glyphcache *cache;
+ fz_glyph_cache *cache;
/* current view params */
int resolution;
@@ -46,8 +46,8 @@ struct pdfapp_s
int pageno;
fz_rect page_bbox;
float page_rotate;
- fz_displaylist *page_list;
- fz_textspan *page_text;
+ fz_display_list *page_list;
+ fz_text_span *page_text;
pdf_link *page_links;
/* snapback history */
diff --git a/apps/pdfclean.c b/apps/pdfclean.c
index 2be479aa..67c7809c 100644
--- a/apps/pdfclean.c
+++ b/apps/pdfclean.c
@@ -12,24 +12,24 @@
#include "fitz.h"
#include "mupdf.h"
-static FILE *out = nil;
+static FILE *out = NULL;
-static char *uselist = nil;
-static int *ofslist = nil;
-static int *genlist = nil;
-static int *renumbermap = nil;
+static char *uselist = NULL;
+static int *ofslist = NULL;
+static int *genlist = NULL;
+static int *renumbermap = NULL;
static int dogarbage = 0;
static int doexpand = 0;
static int doascii = 0;
-static pdf_xref *xref = nil;
+static pdf_xref *xref = NULL;
void die(fz_error error)
{
fz_catch(error, "aborting");
if (xref)
- pdf_freexref(xref);
+ pdf_free_xref(xref);
exit(1);
}
@@ -57,22 +57,22 @@ static void sweepobj(fz_obj *obj)
{
int i;
- if (fz_isindirect(obj))
+ if (fz_is_indirect(obj))
sweepref(obj);
- else if (fz_isdict(obj))
- for (i = 0; i < fz_dictlen(obj); i++)
- sweepobj(fz_dictgetval(obj, i));
+ else if (fz_is_dict(obj))
+ for (i = 0; i < fz_dict_len(obj); i++)
+ sweepobj(fz_dict_get_val(obj, i));
- else if (fz_isarray(obj))
- for (i = 0; i < fz_arraylen(obj); i++)
- sweepobj(fz_arrayget(obj, i));
+ else if (fz_is_array(obj))
+ for (i = 0; i < fz_array_len(obj); i++)
+ sweepobj(fz_array_get(obj, i));
}
static void sweepref(fz_obj *obj)
{
- int num = fz_tonum(obj);
- int gen = fz_togen(obj);
+ int num = fz_to_num(obj);
+ int gen = fz_to_gen(obj);
if (num < 0 || num >= xref->len)
return;
@@ -82,18 +82,18 @@ static void sweepref(fz_obj *obj)
uselist[num] = 1;
/* Bake in /Length in stream objects */
- if (pdf_isstream(xref, num, gen))
+ if (pdf_is_stream(xref, num, gen))
{
- fz_obj *len = fz_dictgets(obj, "Length");
- if (fz_isindirect(len))
+ fz_obj *len = fz_dict_gets(obj, "Length");
+ if (fz_is_indirect(len))
{
- uselist[fz_tonum(len)] = 0;
- len = fz_resolveindirect(len);
- fz_dictputs(obj, "Length", len);
+ uselist[fz_to_num(len)] = 0;
+ len = fz_resolve_indirect(len);
+ fz_dict_puts(obj, "Length", len);
}
}
- sweepobj(fz_resolveindirect(obj));
+ sweepobj(fz_resolve_indirect(obj));
}
/*
@@ -117,17 +117,17 @@ static void removeduplicateobjs(void)
/*
* Comparing stream objects data contents would take too long.
*
- * pdf_isstream calls pdf_cacheobject and ensures
+ * pdf_is_stream calls pdf_cache_object and ensures
* that the xref table has the objects loaded.
*/
- if (pdf_isstream(xref, num, 0) || pdf_isstream(xref, other, 0))
+ if (pdf_is_stream(xref, num, 0) || pdf_is_stream(xref, other, 0))
continue;
a = xref->table[num].obj;
b = xref->table[other].obj;
- a = fz_resolveindirect(a);
- b = fz_resolveindirect(b);
+ a = fz_resolve_indirect(a);
+ b = fz_resolve_indirect(b);
if (fz_objcmp(a, b))
continue;
@@ -177,17 +177,17 @@ static void renumberobj(fz_obj *obj)
{
int i;
- if (fz_isdict(obj))
+ if (fz_is_dict(obj))
{
- for (i = 0; i < fz_dictlen(obj); i++)
+ for (i = 0; i < fz_dict_len(obj); i++)
{
- fz_obj *key = fz_dictgetkey(obj, i);
- fz_obj *val = fz_dictgetval(obj, i);
- if (fz_isindirect(val))
+ fz_obj *key = fz_dict_get_key(obj, i);
+ fz_obj *val = fz_dict_get_val(obj, i);
+ if (fz_is_indirect(val))
{
- val = fz_newindirect(renumbermap[fz_tonum(val)], 0, xref);
- fz_dictput(obj, key, val);
- fz_dropobj(val);
+ val = fz_new_indirect(renumbermap[fz_to_num(val)], 0, xref);
+ fz_dict_put(obj, key, val);
+ fz_drop_obj(val);
}
else
{
@@ -196,16 +196,16 @@ static void renumberobj(fz_obj *obj)
}
}
- else if (fz_isarray(obj))
+ else if (fz_is_array(obj))
{
- for (i = 0; i < fz_arraylen(obj); i++)
+ for (i = 0; i < fz_array_len(obj); i++)
{
- fz_obj *val = fz_arrayget(obj, i);
- if (fz_isindirect(val))
+ fz_obj *val = fz_array_get(obj, i);
+ if (fz_is_indirect(val))
{
- val = fz_newindirect(renumbermap[fz_tonum(val)], 0, xref);
- fz_arrayput(obj, i, val);
- fz_dropobj(val);
+ val = fz_new_indirect(renumbermap[fz_to_num(val)], 0, xref);
+ fz_array_put(obj, i, val);
+ fz_drop_obj(val);
}
else
{
@@ -217,7 +217,7 @@ static void renumberobj(fz_obj *obj)
static void renumberobjs(void)
{
- pdf_xrefentry *oldxref;
+ pdf_xref_entry *oldxref;
int newlen;
int num;
@@ -227,11 +227,11 @@ static void renumberobjs(void)
{
fz_obj *obj = xref->table[num].obj;
- if (fz_isindirect(obj))
+ if (fz_is_indirect(obj))
{
- obj = fz_newindirect(renumbermap[fz_tonum(obj)], 0, xref);
- pdf_updateobject(xref, num, 0, obj);
- fz_dropobj(obj);
+ obj = fz_new_indirect(renumbermap[fz_to_num(obj)], 0, xref);
+ pdf_update_object(xref, num, 0, obj);
+ fz_drop_obj(obj);
}
else
{
@@ -241,7 +241,7 @@ static void renumberobjs(void)
/* Create new table for the reordered, compacted xref */
oldxref = xref->table;
- xref->table = fz_calloc(xref->len, sizeof(pdf_xrefentry));
+ xref->table = fz_calloc(xref->len, sizeof(pdf_xref_entry));
xref->table[0] = oldxref[0];
/* Move used objects into the new compacted xref */
@@ -257,7 +257,7 @@ static void renumberobjs(void)
else
{
if (oldxref[num].obj)
- fz_dropobj(oldxref[num].obj);
+ fz_drop_obj(oldxref[num].obj);
}
}
@@ -281,25 +281,25 @@ static void retainpages(int argc, char **argv)
fz_obj *oldroot, *root, *pages, *kids, *countobj, *parent;
/* Load the old page tree */
- error = pdf_loadpagetree(xref);
+ error = pdf_load_page_tree(xref);
if (error)
die(fz_rethrow(error, "cannot load page tree"));
/* Keep only pages/type entry to avoid references to unretained pages */
- oldroot = fz_dictgets(xref->trailer, "Root");
- pages = fz_dictgets(oldroot, "Pages");
+ oldroot = fz_dict_gets(xref->trailer, "Root");
+ pages = fz_dict_gets(oldroot, "Pages");
- root = fz_newdict(2);
- fz_dictputs(root, "Type", fz_dictgets(oldroot, "Type"));
- fz_dictputs(root, "Pages", fz_dictgets(oldroot, "Pages"));
+ root = fz_new_dict(2);
+ fz_dict_puts(root, "Type", fz_dict_gets(oldroot, "Type"));
+ fz_dict_puts(root, "Pages", fz_dict_gets(oldroot, "Pages"));
- pdf_updateobject(xref, fz_tonum(oldroot), fz_togen(oldroot), root);
+ pdf_update_object(xref, fz_to_num(oldroot), fz_to_gen(oldroot), root);
- fz_dropobj(root);
+ fz_drop_obj(root);
/* Create a new kids array with only the pages we want to keep */
- parent = fz_newindirect(fz_tonum(pages), fz_togen(pages), xref);
- kids = fz_newarray(1);
+ parent = fz_new_indirect(fz_to_num(pages), fz_to_gen(pages), xref);
+ kids = fz_new_array(1);
/* Retain pages specified */
while (argc - fz_optind)
@@ -314,7 +314,7 @@ static void retainpages(int argc, char **argv)
dash = strchr(spec, '-');
if (dash == spec)
- spage = epage = pdf_getpagecount(xref);
+ spage = epage = pdf_get_page_count(xref);
else
spage = epage = atoi(spec);
@@ -323,7 +323,7 @@ static void retainpages(int argc, char **argv)
if (strlen(dash) > 1)
epage = atoi(dash + 1);
else
- epage = pdf_getpagecount(xref);
+ epage = pdf_get_page_count(xref);
}
if (spage > epage)
@@ -331,18 +331,18 @@ static void retainpages(int argc, char **argv)
if (spage < 1)
spage = 1;
- if (epage > pdf_getpagecount(xref))
- epage = pdf_getpagecount(xref);
+ if (epage > pdf_get_page_count(xref))
+ epage = pdf_get_page_count(xref);
for (page = spage; page <= epage; page++)
{
- fz_obj *pageobj = pdf_getpageobject(xref, page);
- fz_obj *pageref = pdf_getpageref(xref, page);
+ fz_obj *pageobj = pdf_get_page_object(xref, page);
+ fz_obj *pageref = pdf_get_page_ref(xref, page);
- fz_dictputs(pageobj, "Parent", parent);
+ fz_dict_puts(pageobj, "Parent", parent);
/* Store page object in new kids array */
- fz_arraypush(kids, pageref);
+ fz_array_push(kids, pageref);
}
spec = fz_strsep(&pagelist, ",");
@@ -351,14 +351,14 @@ static void retainpages(int argc, char **argv)
fz_optind++;
}
- fz_dropobj(parent);
+ fz_drop_obj(parent);
/* Update page count and kids array */
- countobj = fz_newint(fz_arraylen(kids));
- fz_dictputs(pages, "Count", countobj);
- fz_dropobj(countobj);
- fz_dictputs(pages, "Kids", kids);
- fz_dropobj(kids);
+ countobj = fz_new_int(fz_array_len(kids));
+ fz_dict_puts(pages, "Count", countobj);
+ fz_drop_obj(countobj);
+ fz_dict_puts(pages, "Kids", kids);
+ fz_drop_obj(kids);
}
/*
@@ -375,10 +375,10 @@ static void preloadobjstms(void)
{
if (xref->table[num].type == 'o')
{
- error = pdf_loadobject(&obj, xref, num, 0);
+ error = pdf_load_object(&obj, xref, num, 0);
if (error)
die(error);
- fz_dropobj(obj);
+ fz_drop_obj(obj);
}
}
}
@@ -409,7 +409,7 @@ static fz_buffer *hexbuf(unsigned char *p, int n)
fz_buffer *buf;
int x = 0;
- buf = fz_newbuffer(n * 2 + (n / 32) + 2);
+ buf = fz_new_buffer(n * 2 + (n / 32) + 2);
while (n--)
{
@@ -434,46 +434,46 @@ static void addhexfilter(fz_obj *dict)
fz_obj *f, *dp, *newf, *newdp;
fz_obj *ahx, *nullobj;
- ahx = fz_newname("ASCIIHexDecode");
- nullobj = fz_newnull();
- newf = newdp = nil;
+ ahx = fz_new_name("ASCIIHexDecode");
+ nullobj = fz_new_null();
+ newf = newdp = NULL;
- f = fz_dictgets(dict, "Filter");
- dp = fz_dictgets(dict, "DecodeParms");
+ f = fz_dict_gets(dict, "Filter");
+ dp = fz_dict_gets(dict, "DecodeParms");
- if (fz_isname(f))
+ if (fz_is_name(f))
{
- newf = fz_newarray(2);
- fz_arraypush(newf, ahx);
- fz_arraypush(newf, f);
+ newf = fz_new_array(2);
+ fz_array_push(newf, ahx);
+ fz_array_push(newf, f);
f = newf;
- if (fz_isdict(dp))
+ if (fz_is_dict(dp))
{
- newdp = fz_newarray(2);
- fz_arraypush(newdp, nullobj);
- fz_arraypush(newdp, dp);
+ newdp = fz_new_array(2);
+ fz_array_push(newdp, nullobj);
+ fz_array_push(newdp, dp);
dp = newdp;
}
}
- else if (fz_isarray(f))
+ else if (fz_is_array(f))
{
- fz_arrayinsert(f, ahx);
- if (fz_isarray(dp))
- fz_arrayinsert(dp, nullobj);
+ fz_array_insert(f, ahx);
+ if (fz_is_array(dp))
+ fz_array_insert(dp, nullobj);
}
else
f = ahx;
- fz_dictputs(dict, "Filter", f);
+ fz_dict_puts(dict, "Filter", f);
if (dp)
- fz_dictputs(dict, "DecodeParms", dp);
+ fz_dict_puts(dict, "DecodeParms", dp);
- fz_dropobj(ahx);
- fz_dropobj(nullobj);
+ fz_drop_obj(ahx);
+ fz_drop_obj(nullobj);
if (newf)
- fz_dropobj(newf);
+ fz_drop_obj(newf);
if (newdp)
- fz_dropobj(newdp);
+ fz_drop_obj(newdp);
}
static void copystream(fz_obj *obj, int num, int gen)
@@ -482,30 +482,30 @@ static void copystream(fz_obj *obj, int num, int gen)
fz_buffer *buf, *tmp;
fz_obj *newlen;
- error = pdf_loadrawstream(&buf, xref, num, gen);
+ error = pdf_load_raw_stream(&buf, xref, num, gen);
if (error)
die(error);
if (doascii && isbinarystream(buf))
{
tmp = hexbuf(buf->data, buf->len);
- fz_dropbuffer(buf);
+ fz_drop_buffer(buf);
buf = tmp;
addhexfilter(obj);
- newlen = fz_newint(buf->len);
- fz_dictputs(obj, "Length", newlen);
- fz_dropobj(newlen);
+ newlen = fz_new_int(buf->len);
+ fz_dict_puts(obj, "Length", newlen);
+ fz_drop_obj(newlen);
}
fprintf(out, "%d %d obj\n", num, gen);
- fz_fprintobj(out, obj, !doexpand);
+ fz_fprint_obj(out, obj, !doexpand);
fprintf(out, "stream\n");
fwrite(buf->data, 1, buf->len, out);
fprintf(out, "endstream\nendobj\n\n");
- fz_dropbuffer(buf);
+ fz_drop_buffer(buf);
}
static void expandstream(fz_obj *obj, int num, int gen)
@@ -514,33 +514,33 @@ static void expandstream(fz_obj *obj, int num, int gen)
fz_buffer *buf, *tmp;
fz_obj *newlen;
- error = pdf_loadstream(&buf, xref, num, gen);
+ error = pdf_load_stream(&buf, xref, num, gen);
if (error)
die(error);
- fz_dictdels(obj, "Filter");
- fz_dictdels(obj, "DecodeParms");
+ fz_dict_dels(obj, "Filter");
+ fz_dict_dels(obj, "DecodeParms");
if (doascii && isbinarystream(buf))
{
tmp = hexbuf(buf->data, buf->len);
- fz_dropbuffer(buf);
+ fz_drop_buffer(buf);
buf = tmp;
addhexfilter(obj);
}
- newlen = fz_newint(buf->len);
- fz_dictputs(obj, "Length", newlen);
- fz_dropobj(newlen);
+ newlen = fz_new_int(buf->len);
+ fz_dict_puts(obj, "Length", newlen);
+ fz_drop_obj(newlen);
fprintf(out, "%d %d obj\n", num, gen);
- fz_fprintobj(out, obj, !doexpand);
+ fz_fprint_obj(out, obj, !doexpand);
fprintf(out, "stream\n");
fwrite(buf->data, 1, buf->len, out);
fprintf(out, "endstream\nendobj\n\n");
- fz_dropbuffer(buf);
+ fz_drop_buffer(buf);
}
static void writeobject(int num, int gen)
@@ -549,43 +549,43 @@ static void writeobject(int num, int gen)
fz_obj *obj;
fz_obj *type;
- error = pdf_loadobject(&obj, xref, num, gen);
+ error = pdf_load_object(&obj, xref, num, gen);
if (error)
die(error);
/* skip ObjStm and XRef objects */
- if (fz_isdict(obj))
+ if (fz_is_dict(obj))
{
- type = fz_dictgets(obj, "Type");
- if (fz_isname(type) && !strcmp(fz_toname(type), "ObjStm"))
+ type = fz_dict_gets(obj, "Type");
+ if (fz_is_name(type) && !strcmp(fz_to_name(type), "ObjStm"))
{
uselist[num] = 0;
- fz_dropobj(obj);
+ fz_drop_obj(obj);
return;
}
- if (fz_isname(type) && !strcmp(fz_toname(type), "XRef"))
+ if (fz_is_name(type) && !strcmp(fz_to_name(type), "XRef"))
{
uselist[num] = 0;
- fz_dropobj(obj);
+ fz_drop_obj(obj);
return;
}
}
- if (!pdf_isstream(xref, num, gen))
+ if (!pdf_is_stream(xref, num, gen))
{
fprintf(out, "%d %d obj\n", num, gen);
- fz_fprintobj(out, obj, !doexpand);
+ fz_fprint_obj(out, obj, !doexpand);
fprintf(out, "endobj\n\n");
}
else
{
- if (doexpand && !pdf_isjpximage(obj))
+ if (doexpand && !pdf_is_jpx_image(obj))
expandstream(obj, num, gen);
else
copystream(obj, num, gen);
}
- fz_dropobj(obj);
+ fz_drop_obj(obj);
}
static void writexref(void)
@@ -607,29 +607,29 @@ static void writexref(void)
}
fprintf(out, "\n");
- trailer = fz_newdict(5);
+ trailer = fz_new_dict(5);
- obj = fz_newint(xref->len);
- fz_dictputs(trailer, "Size", obj);
- fz_dropobj(obj);
+ obj = fz_new_int(xref->len);
+ fz_dict_puts(trailer, "Size", obj);
+ fz_drop_obj(obj);
- obj = fz_dictgets(xref->trailer, "Info");
+ obj = fz_dict_gets(xref->trailer, "Info");
if (obj)
- fz_dictputs(trailer, "Info", obj);
+ fz_dict_puts(trailer, "Info", obj);
- obj = fz_dictgets(xref->trailer, "Root");
+ obj = fz_dict_gets(xref->trailer, "Root");
if (obj)
- fz_dictputs(trailer, "Root", obj);
+ fz_dict_puts(trailer, "Root", obj);
- obj = fz_dictgets(xref->trailer, "ID");
+ obj = fz_dict_gets(xref->trailer, "ID");
if (obj)
- fz_dictputs(trailer, "ID", obj);
+ fz_dict_puts(trailer, "ID", obj);
fprintf(out, "trailer\n");
- fz_fprintobj(out, trailer, !doexpand);
+ fz_fprint_obj(out, trailer, !doexpand);
fprintf(out, "\n");
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
fprintf(out, "startxref\n%d\n%%%%EOF\n", startxref);
}
@@ -710,7 +710,7 @@ int main(int argc, char **argv)
if (argc - fz_optind > 0)
subset = 1;
- error = pdf_openxref(&xref, infile, password);
+ error = pdf_open_xref(&xref, infile, password);
if (error)
die(fz_rethrow(error, "cannot open input file '%s'", infile));
@@ -767,9 +767,9 @@ int main(int argc, char **argv)
fz_free(genlist);
fz_free(renumbermap);
- pdf_freexref(xref);
+ pdf_free_xref(xref);
- fz_flushwarnings();
+ fz_flush_warnings();
return 0;
}
diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c
index 3de0a80c..f15fdfb4 100644
--- a/apps/pdfdraw.c
+++ b/apps/pdfdraw.c
@@ -11,7 +11,7 @@
#include <sys/time.h>
#endif
-char *output = nil;
+char *output = NULL;
float resolution = 72;
float rotation = 0;
@@ -23,7 +23,7 @@ int savealpha = 0;
int uselist = 1;
fz_colorspace *colorspace;
-fz_glyphcache *glyphcache;
+fz_glyph_cache *glyphcache;
char *filename;
struct {
@@ -66,10 +66,10 @@ static int gettime(void)
struct timeval now;
if (once)
{
- gettimeofday(&first, nil);
+ gettimeofday(&first, NULL);
once = 0;
}
- gettimeofday(&now, nil);
+ gettimeofday(&now, NULL);
return (now.tv_sec - first.tv_sec) * 1000 + (now.tv_usec - first.tv_usec) / 1000;
}
@@ -89,7 +89,7 @@ static void drawpage(pdf_xref *xref, int pagenum)
fz_error error;
fz_obj *pageobj;
pdf_page *page;
- fz_displaylist *list;
+ fz_display_list *list;
fz_device *dev;
int start;
@@ -98,51 +98,51 @@ static void drawpage(pdf_xref *xref, int pagenum)
start = gettime();
}
- pageobj = pdf_getpageobject(xref, pagenum);
- error = pdf_loadpage(&page, xref, pageobj);
+ pageobj = pdf_get_page_object(xref, pagenum);
+ error = pdf_load_page(&page, xref, pageobj);
if (error)
die(fz_rethrow(error, "cannot load page %d in file '%s'", pagenum, filename));
- list = nil;
+ list = NULL;
if (uselist)
{
- list = fz_newdisplaylist();
- dev = fz_newlistdevice(list);
- error = pdf_runpage(xref, page, dev, fz_identity);
+ list = fz_new_display_list();
+ dev = fz_new_list_device(list);
+ error = pdf_run_page(xref, page, dev, fz_identity);
if (error)
die(fz_rethrow(error, "cannot draw page %d in file '%s'", pagenum, filename));
- fz_freedevice(dev);
+ fz_free_device(dev);
}
if (showxml)
{
- dev = fz_newtracedevice();
+ dev = fz_new_trace_device();
printf("<page number=\"%d\">\n", pagenum);
if (list)
- fz_executedisplaylist(list, dev, fz_identity, fz_infinitebbox);
+ fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox);
else
- pdf_runpage(xref, page, dev, fz_identity);
+ pdf_run_page(xref, page, dev, fz_identity);
printf("</page>\n");
- fz_freedevice(dev);
+ fz_free_device(dev);
}
if (showtext)
{
- fz_textspan *text = fz_newtextspan();
- dev = fz_newtextdevice(text);
+ fz_text_span *text = fz_new_text_span();
+ dev = fz_new_text_device(text);
if (list)
- fz_executedisplaylist(list, dev, fz_identity, fz_infinitebbox);
+ fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox);
else
- pdf_runpage(xref, page, dev, fz_identity);
- fz_freedevice(dev);
+ pdf_run_page(xref, page, dev, fz_identity);
+ fz_free_device(dev);
printf("[Page %d]\n", pagenum);
if (showtext > 1)
- fz_debugtextspanxml(text);
+ fz_debug_text_span_xml(text);
else
- fz_debugtextspan(text);
+ fz_debug_text_span(text);
printf("\n");
- fz_freetextspan(text);
+ fz_free_text_span(text);
}
if (showmd5 || showtime)
@@ -160,34 +160,34 @@ static void drawpage(pdf_xref *xref, int pagenum)
ctm = fz_concat(ctm, fz_scale(zoom, -zoom));
ctm = fz_concat(ctm, fz_rotate(page->rotate));
ctm = fz_concat(ctm, fz_rotate(rotation));
- bbox = fz_roundrect(fz_transformrect(ctm, page->mediabox));
+ bbox = fz_round_rect(fz_transform_rect(ctm, page->mediabox));
/* TODO: banded rendering and multi-page ppm */
- pix = fz_newpixmapwithrect(colorspace, bbox);
+ pix = fz_new_pixmap_with_rect(colorspace, bbox);
if (savealpha)
- fz_clearpixmap(pix);
+ fz_clear_pixmap(pix);
else
- fz_clearpixmapwithcolor(pix, 255);
+ fz_clear_pixmap_with_color(pix, 255);
- dev = fz_newdrawdevice(glyphcache, pix);
+ dev = fz_new_draw_device(glyphcache, pix);
if (list)
- fz_executedisplaylist(list, dev, ctm, bbox);
+ fz_execute_display_list(list, dev, ctm, bbox);
else
- pdf_runpage(xref, page, dev, ctm);
- fz_freedevice(dev);
+ pdf_run_page(xref, page, dev, ctm);
+ fz_free_device(dev);
if (output)
{
char buf[512];
sprintf(buf, output, pagenum);
if (strstr(output, ".pgm") || strstr(output, ".ppm") || strstr(output, ".pnm"))
- fz_writepnm(pix, buf);
+ fz_write_pnm(pix, buf);
else if (strstr(output, ".pam"))
- fz_writepam(pix, buf, savealpha);
+ fz_write_pam(pix, buf, savealpha);
else if (strstr(output, ".png"))
- fz_writepng(pix, buf, savealpha);
+ fz_write_png(pix, buf, savealpha);
}
if (showmd5)
@@ -196,22 +196,22 @@ static void drawpage(pdf_xref *xref, int pagenum)
unsigned char digest[16];
int i;
- fz_md5init(&md5);
- fz_md5update(&md5, pix->samples, pix->w * pix->h * pix->n);
- fz_md5final(&md5, digest);
+ fz_md5_init(&md5);
+ fz_md5_update(&md5, pix->samples, pix->w * pix->h * pix->n);
+ fz_md5_final(&md5, digest);
printf(" ");
for (i = 0; i < 16; i++)
printf("%02x", digest[i]);
}
- fz_droppixmap(pix);
+ fz_drop_pixmap(pix);
}
if (list)
- fz_freedisplaylist(list);
+ fz_free_display_list(list);
- pdf_freepage(page);
+ pdf_free_page(page);
if (showtime)
{
@@ -237,9 +237,9 @@ static void drawpage(pdf_xref *xref, int pagenum)
if (showmd5 || showtime)
printf("\n");
- pdf_agestore(xref->store, 3);
+ pdf_age_store(xref->store, 3);
- fz_flushwarnings();
+ fz_flush_warnings();
}
static void drawrange(pdf_xref *xref, char *range)
@@ -253,7 +253,7 @@ static void drawrange(pdf_xref *xref, char *range)
dash = strchr(spec, '-');
if (dash == spec)
- spage = epage = pdf_getpagecount(xref);
+ spage = epage = pdf_get_page_count(xref);
else
spage = epage = atoi(spec);
@@ -262,11 +262,11 @@ static void drawrange(pdf_xref *xref, char *range)
if (strlen(dash) > 1)
epage = atoi(dash + 1);
else
- epage = pdf_getpagecount(xref);
+ epage = pdf_get_page_count(xref);
}
- spage = CLAMP(spage, 1, pdf_getpagecount(xref));
- epage = CLAMP(epage, 1, pdf_getpagecount(xref));
+ spage = CLAMP(spage, 1, pdf_get_page_count(xref));
+ epage = CLAMP(epage, 1, pdf_get_page_count(xref));
if (spage < epage)
for (page = spage; page <= epage; page++)
@@ -320,15 +320,15 @@ int main(int argc, char **argv)
if (accelerate)
fz_accelerate();
- glyphcache = fz_newglyphcache();
+ glyphcache = fz_new_glyph_cache();
- colorspace = fz_devicergb;
+ colorspace = fz_device_rgb;
if (grayscale)
- colorspace = fz_devicegray;
+ colorspace = fz_device_gray;
if (output && strstr(output, ".pgm"))
- colorspace = fz_devicegray;
+ colorspace = fz_device_gray;
if (output && strstr(output, ".ppm"))
- colorspace = fz_devicergb;
+ colorspace = fz_device_rgb;
timing.count = 0;
timing.total = 0;
@@ -344,11 +344,11 @@ int main(int argc, char **argv)
{
filename = argv[fz_optind++];
- error = pdf_openxref(&xref, filename, password);
+ error = pdf_open_xref(&xref, filename, password);
if (error)
die(fz_rethrow(error, "cannot open document: %s", filename));
- error = pdf_loadpagetree(xref);
+ error = pdf_load_page_tree(xref);
if (error)
die(fz_rethrow(error, "cannot load page tree: %s", filename));
@@ -363,7 +363,7 @@ int main(int argc, char **argv)
if (showxml)
printf("</document>\n");
- pdf_freexref(xref);
+ pdf_free_xref(xref);
}
if (showtime)
@@ -374,9 +374,9 @@ int main(int argc, char **argv)
printf("slowest page %d: %dms\n", timing.maxpage, timing.max);
}
- fz_freeglyphcache(glyphcache);
+ fz_free_glyph_cache(glyphcache);
- fz_flushwarnings();
+ fz_flush_warnings();
return 0;
}
diff --git a/apps/pdfextract.c b/apps/pdfextract.c
index 1d01b4d5..45185cee 100644
--- a/apps/pdfextract.c
+++ b/apps/pdfextract.c
@@ -5,14 +5,14 @@
#include "fitz.h"
#include "mupdf.h"
-static pdf_xref *xref = nil;
+static pdf_xref *xref = NULL;
static int dorgb = 0;
void die(fz_error error)
{
fz_catch(error, "aborting");
if (xref)
- pdf_freexref(xref);
+ pdf_free_xref(xref);
exit(1);
}
@@ -26,14 +26,14 @@ static void usage(void)
static int isimage(fz_obj *obj)
{
- fz_obj *type = fz_dictgets(obj, "Subtype");
- return fz_isname(type) && !strcmp(fz_toname(type), "Image");
+ fz_obj *type = fz_dict_gets(obj, "Subtype");
+ return fz_is_name(type) && !strcmp(fz_to_name(type), "Image");
}
static int isfontdesc(fz_obj *obj)
{
- fz_obj *type = fz_dictgets(obj, "Type");
- return fz_isname(type) && !strcmp(fz_toname(type), "FontDescriptor");
+ fz_obj *type = fz_dict_gets(obj, "Type");
+ return fz_is_name(type) && !strcmp(fz_to_name(type), "FontDescriptor");
}
static void saveimage(int num)
@@ -43,20 +43,20 @@ static void saveimage(int num)
fz_obj *ref;
char name[1024];
- ref = fz_newindirect(num, 0, xref);
+ ref = fz_new_indirect(num, 0, xref);
/* TODO: detect DCTD and save as jpeg */
- error = pdf_loadimage(&img, xref, ref);
+ error = pdf_load_image(&img, xref, ref);
if (error)
die(error);
- if (dorgb && img->colorspace && img->colorspace != fz_devicergb)
+ if (dorgb && img->colorspace && img->colorspace != fz_device_rgb)
{
fz_pixmap *temp;
- temp = fz_newpixmap(fz_devicergb, img->x, img->y, img->w, img->h);
- fz_convertpixmap(img, temp);
- fz_droppixmap(img);
+ temp = fz_new_pixmap(fz_device_rgb, img->x, img->y, img->w, img->h);
+ fz_convert_pixmap(img, temp);
+ fz_drop_pixmap(img);
img = temp;
}
@@ -64,17 +64,17 @@ static void saveimage(int num)
{
sprintf(name, "img-%04d.png", num);
printf("extracting image %s\n", name);
- fz_writepng(img, name, 0);
+ fz_write_png(img, name, 0);
}
else
{
sprintf(name, "img-%04d.pam", num);
printf("extracting image %s\n", name);
- fz_writepam(img, name, 0);
+ fz_write_pam(img, name, 0);
}
- fz_droppixmap(img);
- fz_dropobj(ref);
+ fz_drop_pixmap(img);
+ fz_drop_obj(ref);
}
static void savefont(fz_obj *dict, int num)
@@ -83,41 +83,41 @@ static void savefont(fz_obj *dict, int num)
char name[1024];
char *subtype;
fz_buffer *buf;
- fz_obj *stream = nil;
+ fz_obj *stream = NULL;
fz_obj *obj;
char *ext = "";
FILE *f;
char *fontname = "font";
int n;
- obj = fz_dictgets(dict, "FontName");
+ obj = fz_dict_gets(dict, "FontName");
if (obj)
- fontname = fz_toname(obj);
+ fontname = fz_to_name(obj);
- obj = fz_dictgets(dict, "FontFile");
+ obj = fz_dict_gets(dict, "FontFile");
if (obj)
{
stream = obj;
ext = "pfa";
}
- obj = fz_dictgets(dict, "FontFile2");
+ obj = fz_dict_gets(dict, "FontFile2");
if (obj)
{
stream = obj;
ext = "ttf";
}
- obj = fz_dictgets(dict, "FontFile3");
+ obj = fz_dict_gets(dict, "FontFile3");
if (obj)
{
stream = obj;
- obj = fz_dictgets(obj, "Subtype");
- if (obj && !fz_isname(obj))
+ obj = fz_dict_gets(obj, "Subtype");
+ if (obj && !fz_is_name(obj))
die(fz_throw("Invalid font descriptor subtype"));
- subtype = fz_toname(obj);
+ subtype = fz_to_name(obj);
if (!strcmp(subtype, "Type1C"))
ext = "cff";
else if (!strcmp(subtype, "CIDFontType0C"))
@@ -132,9 +132,9 @@ static void savefont(fz_obj *dict, int num)
return;
}
- buf = fz_newbuffer(0);
+ buf = fz_new_buffer(0);
- error = pdf_loadstream(&buf, xref, fz_tonum(stream), fz_togen(stream));
+ error = pdf_load_stream(&buf, xref, fz_to_num(stream), fz_to_gen(stream));
if (error)
die(error);
@@ -142,7 +142,7 @@ static void savefont(fz_obj *dict, int num)
printf("extracting font %s\n", name);
f = fopen(name, "wb");
- if (f == nil)
+ if (f == NULL)
die(fz_throw("Error creating font file"));
n = fwrite(buf->data, 1, buf->len, f);
@@ -152,7 +152,7 @@ static void savefont(fz_obj *dict, int num)
if (fclose(f) < 0)
die(fz_throw("Error closing font file"));
- fz_dropbuffer(buf);
+ fz_drop_buffer(buf);
}
static void showobject(int num)
@@ -163,7 +163,7 @@ static void showobject(int num)
if (!xref)
die(fz_throw("no file specified"));
- error = pdf_loadobject(&obj, xref, num, 0);
+ error = pdf_load_object(&obj, xref, num, 0);
if (error)
die(error);
@@ -172,7 +172,7 @@ static void showobject(int num)
else if (isfontdesc(obj))
savefont(obj, num);
- fz_dropobj(obj);
+ fz_drop_obj(obj);
}
int main(int argc, char **argv)
@@ -196,7 +196,7 @@ int main(int argc, char **argv)
usage();
infile = argv[fz_optind++];
- error = pdf_openxref(&xref, infile, password);
+ error = pdf_open_xref(&xref, infile, password);
if (error)
die(fz_rethrow(error, "cannot open input file '%s'", infile));
@@ -214,9 +214,9 @@ int main(int argc, char **argv)
}
}
- pdf_freexref(xref);
+ pdf_free_xref(xref);
- fz_flushwarnings();
+ fz_flush_warnings();
return 0;
}
diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c
index e85ac00a..fcc2cb38 100644
--- a/apps/pdfinfo.c
+++ b/apps/pdfinfo.c
@@ -80,19 +80,19 @@ struct info
} u;
};
-static struct info *dim = nil;
+static struct info *dim = NULL;
static int dims = 0;
-static struct info *font = nil;
+static struct info *font = NULL;
static int fonts = 0;
-static struct info *image = nil;
+static struct info *image = NULL;
static int images = 0;
-static struct info *shading = nil;
+static struct info *shading = NULL;
static int shadings = 0;
-static struct info *pattern = nil;
+static struct info *pattern = NULL;
static int patterns = 0;
-static struct info *form = nil;
+static struct info *form = NULL;
static int forms = 0;
-static struct info *psobj = nil;
+static struct info *psobj = NULL;
static int psobjs = 0;
void closexref(void)
@@ -100,8 +100,8 @@ void closexref(void)
int i;
if (xref)
{
- pdf_freexref(xref);
- xref = nil;
+ pdf_free_xref(xref);
+ xref = NULL;
}
if (dim)
@@ -109,56 +109,56 @@ void closexref(void)
for (i = 0; i < dims; i++)
fz_free(dim[i].u.dim.bbox);
fz_free(dim);
- dim = nil;
+ dim = NULL;
dims = 0;
}
if (font)
{
fz_free(font);
- font = nil;
+ font = NULL;
fonts = 0;
}
if (image)
{
fz_free(image);
- image = nil;
+ image = NULL;
images = 0;
}
if (shading)
{
fz_free(shading);
- shading = nil;
+ shading = NULL;
shadings = 0;
}
if (pattern)
{
fz_free(pattern);
- pattern = nil;
+ pattern = NULL;
patterns = 0;
}
if (form)
{
fz_free(form);
- form = nil;
+ form = NULL;
forms = 0;
}
if (psobj)
{
fz_free(psobj);
- psobj = nil;
+ psobj = NULL;
psobjs = 0;
}
if (xref && xref->store)
{
- pdf_freestore(xref->store);
- xref->store = nil;
+ pdf_free_store(xref->store);
+ xref->store = NULL;
}
}
@@ -184,18 +184,18 @@ showglobalinfo(void)
printf("\nPDF-%d.%d\n", xref->version / 10, xref->version % 10);
- obj = fz_dictgets(xref->trailer, "Info");
+ obj = fz_dict_gets(xref->trailer, "Info");
if (obj)
{
- printf("Info object (%d %d R):\n", fz_tonum(obj), fz_togen(obj));
- fz_debugobj(fz_resolveindirect(obj));
+ printf("Info object (%d %d R):\n", fz_to_num(obj), fz_to_gen(obj));
+ fz_debug_obj(fz_resolve_indirect(obj));
}
- obj = fz_dictgets(xref->trailer, "Encrypt");
+ obj = fz_dict_gets(xref->trailer, "Encrypt");
if (obj)
{
- printf("\nEncryption object (%d %d R):\n", fz_tonum(obj), fz_togen(obj));
- fz_debugobj(fz_resolveindirect(obj));
+ printf("\nEncryption object (%d %d R):\n", fz_to_num(obj), fz_to_gen(obj));
+ fz_debug_obj(fz_resolve_indirect(obj));
}
printf("\nPages: %d\n\n", pagecount);
@@ -208,11 +208,11 @@ gatherdimensions(int page, fz_obj *pageref, fz_obj *pageobj)
fz_obj *obj;
int j;
- obj = fz_dictgets(pageobj, "MediaBox");
- if (!fz_isarray(obj))
+ obj = fz_dict_gets(pageobj, "MediaBox");
+ if (!fz_is_array(obj))
return;
- bbox = pdf_torect(obj);
+ bbox = pdf_to_rect(obj);
for (j = 0; j < dims; j++)
if (!memcmp(dim[j].u.dim.bbox, &bbox, sizeof (fz_rect)))
@@ -238,25 +238,25 @@ gatherfonts(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
{
int i;
- for (i = 0; i < fz_dictlen(dict); i++)
+ for (i = 0; i < fz_dict_len(dict); i++)
{
- fz_obj *fontdict = nil;
- fz_obj *subtype = nil;
- fz_obj *basefont = nil;
- fz_obj *name = nil;
+ fz_obj *fontdict = NULL;
+ fz_obj *subtype = NULL;
+ fz_obj *basefont = NULL;
+ fz_obj *name = NULL;
int k;
- fontdict = fz_dictgetval(dict, i);
- if (!fz_isdict(fontdict))
+ fontdict = fz_dict_get_val(dict, i);
+ if (!fz_is_dict(fontdict))
{
- fz_warn("not a font dict (%d %d R)", fz_tonum(fontdict), fz_togen(fontdict));
+ fz_warn("not a font dict (%d %d R)", fz_to_num(fontdict), fz_to_gen(fontdict));
continue;
}
- subtype = fz_dictgets(fontdict, "Subtype");
- basefont = fz_dictgets(fontdict, "BaseFont");
- if (!basefont || fz_isnull(basefont))
- name = fz_dictgets(fontdict, "Name");
+ subtype = fz_dict_gets(fontdict, "Subtype");
+ basefont = fz_dict_gets(fontdict, "BaseFont");
+ if (!basefont || fz_is_null(basefont))
+ name = fz_dict_gets(fontdict, "Name");
for (k = 0; k < fonts; k++)
if (!fz_objcmp(font[k].u.font.obj, fontdict))
@@ -282,49 +282,49 @@ gatherimages(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
{
int i;
- for (i = 0; i < fz_dictlen(dict); i++)
+ for (i = 0; i < fz_dict_len(dict); i++)
{
fz_obj *imagedict;
fz_obj *type;
fz_obj *width;
fz_obj *height;
- fz_obj *bpc = nil;
- fz_obj *filter = nil;
- fz_obj *cs = nil;
+ fz_obj *bpc = NULL;
+ fz_obj *filter = NULL;
+ fz_obj *cs = NULL;
fz_obj *altcs;
int k;
- imagedict = fz_dictgetval(dict, i);
- if (!fz_isdict(imagedict))
+ imagedict = fz_dict_get_val(dict, i);
+ if (!fz_is_dict(imagedict))
{
- fz_warn("not an image dict (%d %d R)", fz_tonum(imagedict), fz_togen(imagedict));
+ fz_warn("not an image dict (%d %d R)", fz_to_num(imagedict), fz_to_gen(imagedict));
continue;
}
- type = fz_dictgets(imagedict, "Subtype");
- if (strcmp(fz_toname(type), "Image"))
+ type = fz_dict_gets(imagedict, "Subtype");
+ if (strcmp(fz_to_name(type), "Image"))
continue;
- filter = fz_dictgets(imagedict, "Filter");
+ filter = fz_dict_gets(imagedict, "Filter");
- altcs = nil;
- cs = fz_dictgets(imagedict, "ColorSpace");
- if (fz_isarray(cs))
+ altcs = NULL;
+ cs = fz_dict_gets(imagedict, "ColorSpace");
+ if (fz_is_array(cs))
{
fz_obj *cses = cs;
- cs = fz_arrayget(cses, 0);
- if (fz_isname(cs) && (!strcmp(fz_toname(cs), "DeviceN") || !strcmp(fz_toname(cs), "Separation")))
+ cs = fz_array_get(cses, 0);
+ if (fz_is_name(cs) && (!strcmp(fz_to_name(cs), "DeviceN") || !strcmp(fz_to_name(cs), "Separation")))
{
- altcs = fz_arrayget(cses, 2);
- if (fz_isarray(altcs))
- altcs = fz_arrayget(altcs, 0);
+ altcs = fz_array_get(cses, 2);
+ if (fz_is_array(altcs))
+ altcs = fz_array_get(altcs, 0);
}
}
- width = fz_dictgets(imagedict, "Width");
- height = fz_dictgets(imagedict, "Height");
- bpc = fz_dictgets(imagedict, "BitsPerComponent");
+ width = fz_dict_gets(imagedict, "Width");
+ height = fz_dict_gets(imagedict, "Height");
+ bpc = fz_dict_gets(imagedict, "BitsPerComponent");
for (k = 0; k < images; k++)
if (!fz_objcmp(image[k].u.image.obj, imagedict))
@@ -354,7 +354,7 @@ gatherforms(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
{
int i;
- for (i = 0; i < fz_dictlen(dict); i++)
+ for (i = 0; i < fz_dict_len(dict); i++)
{
fz_obj *xobjdict;
fz_obj *type;
@@ -364,24 +364,24 @@ gatherforms(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
fz_obj *reference;
int k;
- xobjdict = fz_dictgetval(dict, i);
- if (!fz_isdict(xobjdict))
+ xobjdict = fz_dict_get_val(dict, i);
+ if (!fz_is_dict(xobjdict))
{
- fz_warn("not a xobject dict (%d %d R)", fz_tonum(xobjdict), fz_togen(xobjdict));
+ fz_warn("not a xobject dict (%d %d R)", fz_to_num(xobjdict), fz_to_gen(xobjdict));
continue;
}
- type = fz_dictgets(xobjdict, "Subtype");
- if (strcmp(fz_toname(type), "Form"))
+ type = fz_dict_gets(xobjdict, "Subtype");
+ if (strcmp(fz_to_name(type), "Form"))
continue;
- subtype = fz_dictgets(xobjdict, "Subtype2");
- if (!strcmp(fz_toname(subtype), "PS"))
+ subtype = fz_dict_gets(xobjdict, "Subtype2");
+ if (!strcmp(fz_to_name(subtype), "PS"))
continue;
- group = fz_dictgets(xobjdict, "Group");
- groupsubtype = fz_dictgets(group, "S");
- reference = fz_dictgets(xobjdict, "Ref");
+ group = fz_dict_gets(xobjdict, "Group");
+ groupsubtype = fz_dict_gets(group, "S");
+ reference = fz_dict_gets(xobjdict, "Ref");
for (k = 0; k < forms; k++)
if (!fz_objcmp(form[k].u.form.obj, xobjdict))
@@ -407,24 +407,24 @@ gatherpsobjs(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
{
int i;
- for (i = 0; i < fz_dictlen(dict); i++)
+ for (i = 0; i < fz_dict_len(dict); i++)
{
fz_obj *xobjdict;
fz_obj *type;
fz_obj *subtype;
int k;
- xobjdict = fz_dictgetval(dict, i);
- if (!fz_isdict(xobjdict))
+ xobjdict = fz_dict_get_val(dict, i);
+ if (!fz_is_dict(xobjdict))
{
- fz_warn("not a xobject dict (%d %d R)", fz_tonum(xobjdict), fz_togen(xobjdict));
+ fz_warn("not a xobject dict (%d %d R)", fz_to_num(xobjdict), fz_to_gen(xobjdict));
continue;
}
- type = fz_dictgets(xobjdict, "Subtype");
- subtype = fz_dictgets(xobjdict, "Subtype2");
- if (strcmp(fz_toname(type), "PS") &&
- (strcmp(fz_toname(type), "Form") || strcmp(fz_toname(subtype), "PS")))
+ type = fz_dict_gets(xobjdict, "Subtype");
+ subtype = fz_dict_gets(xobjdict, "Subtype2");
+ if (strcmp(fz_to_name(type), "PS") &&
+ (strcmp(fz_to_name(type), "Form") || strcmp(fz_to_name(subtype), "PS")))
continue;
for (k = 0; k < psobjs; k++)
@@ -449,24 +449,24 @@ gathershadings(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
{
int i;
- for (i = 0; i < fz_dictlen(dict); i++)
+ for (i = 0; i < fz_dict_len(dict); i++)
{
fz_obj *shade;
fz_obj *type;
int k;
- shade = fz_dictgetval(dict, i);
- if (!fz_isdict(shade))
+ shade = fz_dict_get_val(dict, i);
+ if (!fz_is_dict(shade))
{
- fz_warn("not a shading dict (%d %d R)", fz_tonum(shade), fz_togen(shade));
+ fz_warn("not a shading dict (%d %d R)", fz_to_num(shade), fz_to_gen(shade));
continue;
}
- type = fz_dictgets(shade, "ShadingType");
- if (!fz_isint(type) || fz_toint(type) < 1 || fz_toint(type) > 7)
+ type = fz_dict_gets(shade, "ShadingType");
+ if (!fz_is_int(type) || fz_to_int(type) < 1 || fz_to_int(type) > 7)
{
- fz_warn("not a shading type (%d %d R)", fz_tonum(shade), fz_togen(shade));
- type = nil;
+ fz_warn("not a shading type (%d %d R)", fz_to_num(shade), fz_to_gen(shade));
+ type = NULL;
}
for (k = 0; k < shadings; k++)
@@ -492,48 +492,48 @@ gatherpatterns(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
{
int i;
- for (i = 0; i < fz_dictlen(dict); i++)
+ for (i = 0; i < fz_dict_len(dict); i++)
{
fz_obj *patterndict;
fz_obj *type;
- fz_obj *paint = nil;
- fz_obj *tiling = nil;
- fz_obj *shading = nil;
+ fz_obj *paint = NULL;
+ fz_obj *tiling = NULL;
+ fz_obj *shading = NULL;
int k;
- patterndict = fz_dictgetval(dict, i);
- if (!fz_isdict(patterndict))
+ patterndict = fz_dict_get_val(dict, i);
+ if (!fz_is_dict(patterndict))
{
- fz_warn("not a pattern dict (%d %d R)", fz_tonum(patterndict), fz_togen(patterndict));
+ fz_warn("not a pattern dict (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict));
continue;
}
- type = fz_dictgets(patterndict, "PatternType");
- if (!fz_isint(type) || fz_toint(type) < 1 || fz_toint(type) > 2)
+ type = fz_dict_gets(patterndict, "PatternType");
+ if (!fz_is_int(type) || fz_to_int(type) < 1 || fz_to_int(type) > 2)
{
- fz_warn("not a pattern type (%d %d R)", fz_tonum(patterndict), fz_togen(patterndict));
- type = nil;
+ fz_warn("not a pattern type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict));
+ type = NULL;
}
- if (fz_toint(type) == 1)
+ if (fz_to_int(type) == 1)
{
- paint = fz_dictgets(patterndict, "PaintType");
- if (!fz_isint(paint) || fz_toint(paint) < 1 || fz_toint(paint) > 2)
+ paint = fz_dict_gets(patterndict, "PaintType");
+ if (!fz_is_int(paint) || fz_to_int(paint) < 1 || fz_to_int(paint) > 2)
{
- fz_warn("not a pattern paint type (%d %d R)", fz_tonum(patterndict), fz_togen(patterndict));
- paint = nil;
+ fz_warn("not a pattern paint type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict));
+ paint = NULL;
}
- tiling = fz_dictgets(patterndict, "TilingType");
- if (!fz_isint(tiling) || fz_toint(tiling) < 1 || fz_toint(tiling) > 3)
+ tiling = fz_dict_gets(patterndict, "TilingType");
+ if (!fz_is_int(tiling) || fz_to_int(tiling) < 1 || fz_to_int(tiling) > 3)
{
- fz_warn("not a pattern tiling type (%d %d R)", fz_tonum(patterndict), fz_togen(patterndict));
- tiling = nil;
+ fz_warn("not a pattern tiling type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict));
+ tiling = NULL;
}
}
else
{
- shading = fz_dictgets(patterndict, "Shading");
+ shading = fz_dict_gets(patterndict, "Shading");
}
for (k = 0; k < patterns; k++)
@@ -569,56 +569,56 @@ gatherresourceinfo(int page, fz_obj *rsrc)
fz_obj *subrsrc;
int i;
- pageobj = pdf_getpageobject(xref, page);
- pageref = pdf_getpageref(xref, page);
+ pageobj = pdf_get_page_object(xref, page);
+ pageref = pdf_get_page_ref(xref, page);
if (!pageobj)
die(fz_throw("cannot retrieve info from page %d", page));
- font = fz_dictgets(rsrc, "Font");
+ font = fz_dict_gets(rsrc, "Font");
if (font)
{
gatherfonts(page, pageref, pageobj, font);
- for (i = 0; i < fz_dictlen(font); i++)
+ for (i = 0; i < fz_dict_len(font); i++)
{
- fz_obj *obj = fz_dictgetval(font, i);
+ fz_obj *obj = fz_dict_get_val(font, i);
- subrsrc = fz_dictgets(obj, "Resources");
+ subrsrc = fz_dict_gets(obj, "Resources");
if (subrsrc && fz_objcmp(rsrc, subrsrc))
gatherresourceinfo(page, subrsrc);
}
}
- xobj = fz_dictgets(rsrc, "XObject");
+ xobj = fz_dict_gets(rsrc, "XObject");
if (xobj)
{
gatherimages(page, pageref, pageobj, xobj);
gatherforms(page, pageref, pageobj, xobj);
gatherpsobjs(page, pageref, pageobj, xobj);
- for (i = 0; i < fz_dictlen(xobj); i++)
+ for (i = 0; i < fz_dict_len(xobj); i++)
{
- fz_obj *obj = fz_dictgetval(xobj, i);
- subrsrc = fz_dictgets(obj, "Resources");
+ fz_obj *obj = fz_dict_get_val(xobj, i);
+ subrsrc = fz_dict_gets(obj, "Resources");
if (subrsrc && fz_objcmp(rsrc, subrsrc))
gatherresourceinfo(page, subrsrc);
}
}
- shade = fz_dictgets(rsrc, "Shading");
+ shade = fz_dict_gets(rsrc, "Shading");
if (shade)
gathershadings(page, pageref, pageobj, shade);
- pattern = fz_dictgets(rsrc, "Pattern");
+ pattern = fz_dict_gets(rsrc, "Pattern");
if (pattern)
{
gatherpatterns(page, pageref, pageobj, pattern);
- for (i = 0; i < fz_dictlen(pattern); i++)
+ for (i = 0; i < fz_dict_len(pattern); i++)
{
- fz_obj *obj = fz_dictgetval(pattern, i);
- subrsrc = fz_dictgets(obj, "Resources");
+ fz_obj *obj = fz_dict_get_val(pattern, i);
+ subrsrc = fz_dict_gets(obj, "Resources");
if (subrsrc && fz_objcmp(rsrc, subrsrc))
gatherresourceinfo(page, subrsrc);
}
@@ -632,15 +632,15 @@ gatherpageinfo(int page)
fz_obj *pageref;
fz_obj *rsrc;
- pageobj = pdf_getpageobject(xref, page);
- pageref = pdf_getpageref(xref, page);
+ pageobj = pdf_get_page_object(xref, page);
+ pageref = pdf_get_page_ref(xref, page);
if (!pageobj)
die(fz_throw("cannot retrieve info from page %d", page));
gatherdimensions(page, pageref, pageobj);
- rsrc = fz_dictgets(pageobj, "Resources");
+ rsrc = fz_dict_gets(pageobj, "Resources");
gatherresourceinfo(page, rsrc);
}
@@ -659,7 +659,7 @@ printinfo(char *filename, int show, int page)
{
printf(PAGE_FMT "[ %g %g %g %g ]\n",
dim[i].page,
- fz_tonum(dim[i].pageref), fz_togen(dim[i].pageref),
+ fz_to_num(dim[i].pageref), fz_to_gen(dim[i].pageref),
dim[i].u.dim.bbox->x0,
dim[i].u.dim.bbox->y0,
dim[i].u.dim.bbox->x1,
@@ -675,10 +675,10 @@ printinfo(char *filename, int show, int page)
{
printf(PAGE_FMT "%s '%s' (%d %d R)\n",
font[i].page,
- fz_tonum(font[i].pageref), fz_togen(font[i].pageref),
- fz_toname(font[i].u.font.subtype),
- fz_toname(font[i].u.font.name),
- fz_tonum(font[i].u.font.obj), fz_togen(font[i].u.font.obj));
+ fz_to_num(font[i].pageref), fz_to_gen(font[i].pageref),
+ fz_to_name(font[i].u.font.subtype),
+ fz_to_name(font[i].u.font.name),
+ fz_to_num(font[i].u.font.obj), fz_to_gen(font[i].u.font.obj));
}
printf("\n");
}
@@ -688,31 +688,31 @@ printinfo(char *filename, int show, int page)
printf("Images (%d):\n", images);
for (i = 0; i < images; i++)
{
- char *cs = nil;
- char *altcs = nil;
+ char *cs = NULL;
+ char *altcs = NULL;
printf(PAGE_FMT "[ ",
image[i].page,
- fz_tonum(image[i].pageref), fz_togen(image[i].pageref));
+ fz_to_num(image[i].pageref), fz_to_gen(image[i].pageref));
- if (fz_isarray(image[i].u.image.filter))
- for (j = 0; j < fz_arraylen(image[i].u.image.filter); j++)
+ if (fz_is_array(image[i].u.image.filter))
+ for (j = 0; j < fz_array_len(image[i].u.image.filter); j++)
{
- fz_obj *obj = fz_arrayget(image[i].u.image.filter, j);
- char *filter = fz_strdup(fz_toname(obj));
+ fz_obj *obj = fz_array_get(image[i].u.image.filter, j);
+ char *filter = fz_strdup(fz_to_name(obj));
if (strstr(filter, "Decode"))
*(strstr(filter, "Decode")) = '\0';
printf("%s%s",
filter,
- j == fz_arraylen(image[i].u.image.filter) - 1 ? "" : " ");
+ j == fz_array_len(image[i].u.image.filter) - 1 ? "" : " ");
fz_free(filter);
}
else if (image[i].u.image.filter)
{
fz_obj *obj = image[i].u.image.filter;
- char *filter = fz_strdup(fz_toname(obj));
+ char *filter = fz_strdup(fz_to_name(obj));
if (strstr(filter, "Decode"))
*(strstr(filter, "Decode")) = '\0';
@@ -725,7 +725,7 @@ printinfo(char *filename, int show, int page)
if (image[i].u.image.cs)
{
- cs = fz_strdup(fz_toname(image[i].u.image.cs));
+ cs = fz_strdup(fz_to_name(image[i].u.image.cs));
if (!strncmp(cs, "Device", 6))
{
@@ -744,7 +744,7 @@ printinfo(char *filename, int show, int page)
}
if (image[i].u.image.altcs)
{
- altcs = fz_strdup(fz_toname(image[i].u.image.altcs));
+ altcs = fz_strdup(fz_to_name(image[i].u.image.altcs));
if (!strncmp(altcs, "Device", 6))
{
@@ -763,13 +763,13 @@ printinfo(char *filename, int show, int page)
}
printf(" ] %dx%d %dbpc %s%s%s (%d %d R)\n",
- fz_toint(image[i].u.image.width),
- fz_toint(image[i].u.image.height),
- image[i].u.image.bpc ? fz_toint(image[i].u.image.bpc) : 1,
+ fz_to_int(image[i].u.image.width),
+ fz_to_int(image[i].u.image.height),
+ image[i].u.image.bpc ? fz_to_int(image[i].u.image.bpc) : 1,
image[i].u.image.cs ? cs : "ImageMask",
image[i].u.image.altcs ? " " : "",
image[i].u.image.altcs ? altcs : "",
- fz_tonum(image[i].u.image.obj), fz_togen(image[i].u.image.obj));
+ fz_to_num(image[i].u.image.obj), fz_to_gen(image[i].u.image.obj));
fz_free(cs);
fz_free(altcs);
@@ -796,9 +796,9 @@ printinfo(char *filename, int show, int page)
printf(PAGE_FMT "%s (%d %d R)\n",
shading[i].page,
- fz_tonum(shading[i].pageref), fz_togen(shading[i].pageref),
- shadingtype[fz_toint(shading[i].u.shading.type)],
- fz_tonum(shading[i].u.shading.obj), fz_togen(shading[i].u.shading.obj));
+ fz_to_num(shading[i].pageref), fz_to_gen(shading[i].pageref),
+ shadingtype[fz_to_int(shading[i].u.shading.type)],
+ fz_to_num(shading[i].u.shading.obj), fz_to_gen(shading[i].u.shading.obj));
}
printf("\n");
}
@@ -808,7 +808,7 @@ printinfo(char *filename, int show, int page)
printf("Patterns (%d):\n", patterns);
for (i = 0; i < patterns; i++)
{
- if (fz_toint(pattern[i].u.pattern.type) == 1)
+ if (fz_to_int(pattern[i].u.pattern.type) == 1)
{
char *painttype[] =
{
@@ -826,18 +826,18 @@ printinfo(char *filename, int show, int page)
printf(PAGE_FMT "Tiling %s %s (%d %d R)\n",
pattern[i].page,
- fz_tonum(pattern[i].pageref), fz_togen(pattern[i].pageref),
- painttype[fz_toint(pattern[i].u.pattern.paint)],
- tilingtype[fz_toint(pattern[i].u.pattern.tiling)],
- fz_tonum(pattern[i].u.pattern.obj), fz_togen(pattern[i].u.pattern.obj));
+ fz_to_num(pattern[i].pageref), fz_to_gen(pattern[i].pageref),
+ painttype[fz_to_int(pattern[i].u.pattern.paint)],
+ tilingtype[fz_to_int(pattern[i].u.pattern.tiling)],
+ fz_to_num(pattern[i].u.pattern.obj), fz_to_gen(pattern[i].u.pattern.obj));
}
else
{
printf(PAGE_FMT "Shading %d %d R (%d %d R)\n",
pattern[i].page,
- fz_tonum(pattern[i].pageref), fz_togen(pattern[i].pageref),
- fz_tonum(pattern[i].u.pattern.shading), fz_togen(pattern[i].u.pattern.shading),
- fz_tonum(pattern[i].u.pattern.obj), fz_togen(pattern[i].u.pattern.obj));
+ fz_to_num(pattern[i].pageref), fz_to_gen(pattern[i].pageref),
+ fz_to_num(pattern[i].u.pattern.shading), fz_to_gen(pattern[i].u.pattern.shading),
+ fz_to_num(pattern[i].u.pattern.obj), fz_to_gen(pattern[i].u.pattern.obj));
}
}
printf("\n");
@@ -850,12 +850,12 @@ printinfo(char *filename, int show, int page)
{
printf(PAGE_FMT "Form%s%s%s%s (%d %d R)\n",
form[i].page,
- fz_tonum(form[i].pageref), fz_togen(form[i].pageref),
+ fz_to_num(form[i].pageref), fz_to_gen(form[i].pageref),
form[i].u.form.groupsubtype ? " " : "",
- form[i].u.form.groupsubtype ? fz_toname(form[i].u.form.groupsubtype) : "",
+ form[i].u.form.groupsubtype ? fz_to_name(form[i].u.form.groupsubtype) : "",
form[i].u.form.groupsubtype ? " Group" : "",
form[i].u.form.reference ? " Reference" : "",
- fz_tonum(form[i].u.form.obj), fz_togen(form[i].u.form.obj));
+ fz_to_num(form[i].u.form.obj), fz_to_gen(form[i].u.form.obj));
}
printf("\n");
}
@@ -867,8 +867,8 @@ printinfo(char *filename, int show, int page)
{
printf(PAGE_FMT "(%d %d R)\n",
psobj[i].page,
- fz_tonum(psobj[i].pageref), fz_togen(psobj[i].pageref),
- fz_tonum(psobj[i].u.form.obj), fz_togen(psobj[i].u.form.obj));
+ fz_to_num(psobj[i].pageref), fz_to_gen(psobj[i].pageref),
+ fz_to_num(psobj[i].u.form.obj), fz_to_gen(psobj[i].u.form.obj));
}
printf("\n");
}
@@ -981,14 +981,14 @@ int main(int argc, char **argv)
filename = argv[fz_optind];
printf("%s:\n", filename);
- error = pdf_openxref(&xref, filename, password);
+ error = pdf_open_xref(&xref, filename, password);
if (error)
die(fz_rethrow(error, "cannot open input file '%s'", filename));
- error = pdf_loadpagetree(xref);
+ error = pdf_load_page_tree(xref);
if (error)
die(fz_rethrow(error, "cannot load page tree: %s", filename));
- pagecount = pdf_getpagecount(xref);
+ pagecount = pdf_get_page_count(xref);
showglobalinfo();
state = NO_INFO_GATHERED;
diff --git a/apps/pdfshow.c b/apps/pdfshow.c
index 4eda9b81..4c834035 100644
--- a/apps/pdfshow.c
+++ b/apps/pdfshow.c
@@ -5,7 +5,7 @@
#include "fitz.h"
#include "mupdf.h"
-static pdf_xref *xref = nil;
+static pdf_xref *xref = NULL;
static int showbinary = 0;
static int showdecode = 1;
static int showcolumn;
@@ -14,7 +14,7 @@ void die(fz_error error)
{
fz_catch(error, "aborting");
if (xref)
- pdf_freexref(xref);
+ pdf_free_xref(xref);
exit(1);
}
@@ -32,7 +32,7 @@ static void showtrailer(void)
if (!xref)
die(fz_throw("no file specified"));
printf("trailer\n");
- fz_debugobj(xref->trailer);
+ fz_debug_obj(xref->trailer);
printf("\n");
}
@@ -40,7 +40,7 @@ static void showxref(void)
{
if (!xref)
die(fz_throw("no file specified"));
- pdf_debugxref(xref);
+ pdf_debug_xref(xref);
printf("\n");
}
@@ -54,18 +54,18 @@ static void showpagetree(void)
if (!xref)
die(fz_throw("no file specified"));
- if (!xref->pagelen)
+ if (!xref->page_len)
{
- error = pdf_loadpagetree(xref);
+ error = pdf_load_page_tree(xref);
if (error)
die(fz_rethrow(error, "cannot load page tree"));
}
- count = pdf_getpagecount(xref);
+ count = pdf_get_page_count(xref);
for (i = 0; i < count; i++)
{
- ref = pdf_getpageref(xref, i + 1);
- printf("page %d = %d %d R\n", i + 1, fz_tonum(ref), fz_togen(ref));
+ ref = pdf_get_page_ref(xref, i + 1);
+ printf("page %d = %d %d R\n", i + 1, fz_to_num(ref), fz_to_gen(ref));
}
printf("\n");
}
@@ -103,9 +103,9 @@ static void showstream(int num, int gen)
showcolumn = 0;
if (showdecode)
- error = pdf_openstream(&stm, xref, num, gen);
+ error = pdf_open_stream(&stm, xref, num, gen);
else
- error = pdf_openrawstream(&stm, xref, num, gen);
+ error = pdf_open_raw_stream(&stm, xref, num, gen);
if (error)
die(error);
@@ -133,11 +133,11 @@ static void showobject(int num, int gen)
if (!xref)
die(fz_throw("no file specified"));
- error = pdf_loadobject(&obj, xref, num, gen);
+ error = pdf_load_object(&obj, xref, num, gen);
if (error)
die(error);
- if (pdf_isstream(xref, num, gen))
+ if (pdf_is_stream(xref, num, gen))
{
if (showbinary)
{
@@ -146,7 +146,7 @@ static void showobject(int num, int gen)
else
{
printf("%d %d obj\n", num, gen);
- fz_debugobj(obj);
+ fz_debug_obj(obj);
printf("stream\n");
showstream(num, gen);
printf("endstream\n");
@@ -156,11 +156,11 @@ static void showobject(int num, int gen)
else
{
printf("%d %d obj\n", num, gen);
- fz_debugobj(obj);
+ fz_debug_obj(obj);
printf("endobj\n\n");
}
- fz_dropobj(obj);
+ fz_drop_obj(obj);
}
static void showgrep(char *filename)
@@ -173,26 +173,26 @@ static void showgrep(char *filename)
{
if (xref->table[i].type == 'n' || xref->table[i].type == 'o')
{
- error = pdf_loadobject(&obj, xref, i, 0);
+ error = pdf_load_object(&obj, xref, i, 0);
if (error)
die(error);
- fz_sortdict(obj);
+ fz_sort_dict(obj);
printf("%s:%d: ", filename, i);
- fz_fprintobj(stdout, obj, 1);
+ fz_fprint_obj(stdout, obj, 1);
- fz_dropobj(obj);
+ fz_drop_obj(obj);
}
}
printf("%s:trailer: ", filename);
- fz_fprintobj(stdout, xref->trailer, 1);
+ fz_fprint_obj(stdout, xref->trailer, 1);
}
int main(int argc, char **argv)
{
- char *password = nil; /* don't throw errors if encrypted */
+ char *password = NULL; /* don't throw errors if encrypted */
char *filename;
fz_error error;
int c;
@@ -212,7 +212,7 @@ int main(int argc, char **argv)
usage();
filename = argv[fz_optind++];
- error = pdf_openxref(&xref, filename, password);
+ error = pdf_open_xref(&xref, filename, password);
if (error)
die(fz_rethrow(error, "cannot open document: %s", filename));
@@ -232,9 +232,9 @@ int main(int argc, char **argv)
fz_optind++;
}
- pdf_freexref(xref);
+ pdf_free_xref(xref);
- fz_flushwarnings();
+ fz_flush_warnings();
return 0;
}
diff --git a/apps/win_main.c b/apps/win_main.c
index ae62b62b..5e513c89 100644
--- a/apps/win_main.c
+++ b/apps/win_main.c
@@ -56,9 +56,9 @@ void winerror(pdfapp_t *app, fz_error error)
fz_catch(error, "displaying error message to user");
fz_strlcpy(msgbuf, "An error has occurred.\n\n", sizeof msgbuf);
- for (i = 0; i < fz_geterrorcount(); i++)
+ for (i = 0; i < fz_get_error_count(); i++)
{
- fz_strlcat(msgbuf, fz_geterrorline(i), sizeof msgbuf);
+ fz_strlcat(msgbuf, fz_get_error_line(i), sizeof msgbuf);
fz_strlcat(msgbuf, "\n", sizeof msgbuf);
}
@@ -142,7 +142,7 @@ char *winpassword(pdfapp_t *app, char *filename)
win32error("cannot create password dialog");
if (pd_okay)
return pd_password;
- return nil;
+ return NULL;
}
INT CALLBACK
@@ -195,33 +195,33 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
SetDlgItemTextA(hwnd, 0x13, "n/a");
}
- info = fz_dictgets(xref->trailer, "Info");
+ info = fz_dict_gets(xref->trailer, "Info");
if (!info)
return TRUE;
#define SETUCS(ID) \
{ \
unsigned short *ucs; \
- ucs = pdf_toucs2(obj); \
+ ucs = pdf_to_ucs2(obj); \
SetDlgItemTextW(hwnd, ID, ucs); \
fz_free(ucs); \
}
- if ((obj = fz_dictgets(info, "Title")))
+ if ((obj = fz_dict_gets(info, "Title")))
SETUCS(0x20);
- if ((obj = fz_dictgets(info, "Author")))
+ if ((obj = fz_dict_gets(info, "Author")))
SETUCS(0x21);
- if ((obj = fz_dictgets(info, "Subject")))
+ if ((obj = fz_dict_gets(info, "Subject")))
SETUCS(0x22);
- if ((obj = fz_dictgets(info, "Keywords")))
+ if ((obj = fz_dict_gets(info, "Keywords")))
SETUCS(0x23);
- if ((obj = fz_dictgets(info, "Creator")))
+ if ((obj = fz_dict_gets(info, "Creator")))
SETUCS(0x24);
- if ((obj = fz_dictgets(info, "Producer")))
+ if ((obj = fz_dict_gets(info, "Producer")))
SETUCS(0x25);
- if ((obj = fz_dictgets(info, "CreationDate")))
+ if ((obj = fz_dict_gets(info, "CreationDate")))
SETUCS(0x26);
- if ((obj = fz_dictgets(info, "ModDate")))
+ if ((obj = fz_dict_gets(info, "ModDate")))
SETUCS(0x27);
return TRUE;
diff --git a/apps/x11_image.c b/apps/x11_image.c
index 8a331c79..9383c545 100644
--- a/apps/x11_image.c
+++ b/apps/x11_image.c
@@ -104,7 +104,7 @@ createximage(Display *dpy, Visual *vis, XShmSegmentInfo *xsi, int depth, int w,
if (!info.useshm)
goto fallback;
- img = XShmCreateImage(dpy, vis, depth, ZPixmap, nil, xsi, w, h);
+ img = XShmCreateImage(dpy, vis, depth, ZPixmap, NULL, xsi, w, h);
if (!img)
{
fprintf(stderr, "warn: could not XShmCreateImage\n");
@@ -121,7 +121,7 @@ createximage(Display *dpy, Visual *vis, XShmSegmentInfo *xsi, int depth, int w,
goto fallback;
}
- img->data = xsi->shmaddr = shmat(xsi->shmid, nil, 0);
+ img->data = xsi->shmaddr = shmat(xsi->shmid, NULL, 0);
if (img->data == (char*)-1)
{
XDestroyImage(img);
@@ -141,14 +141,14 @@ createximage(Display *dpy, Visual *vis, XShmSegmentInfo *xsi, int depth, int w,
XSync(dpy, False);
- shmctl(xsi->shmid, IPC_RMID, nil);
+ shmctl(xsi->shmid, IPC_RMID, NULL);
return img;
fallback:
info.useshm = 0;
- img = XCreateImage(dpy, vis, depth, ZPixmap, 0, nil, w, h, 32, 0);
+ img = XCreateImage(dpy, vis, depth, ZPixmap, 0, NULL, w, h, 32, 0);
if (!img)
{
fprintf(stderr, "fail: could not XCreateImage");
@@ -212,7 +212,7 @@ select_mode(void)
unsigned long rs, gs, bs;
byteorder = ImageByteOrder(info.display);
- if (fz_isbigendian())
+ if (fz_is_big_endian())
byterev = byteorder != MSBFirst;
else
byterev = byteorder != LSBFirst;
@@ -278,14 +278,14 @@ create_pool(void)
info.lastused = 0;
for (i = 0; i < POOLSIZE; i++) {
- info.pool[i] = nil;
+ info.pool[i] = NULL;
}
for (i = 0; i < POOLSIZE; i++) {
info.pool[i] = createximage(info.display,
info.visual.visual, &info.shminfo[i], info.visual.depth,
WIDTH, HEIGHT);
- if (info.pool[i] == nil) {
+ if (info.pool[i] == NULL) {
return 0;
}
}
diff --git a/apps/x11_main.c b/apps/x11_main.c
index 1e08368e..99343988 100644
--- a/apps/x11_main.c
+++ b/apps/x11_main.c
@@ -107,7 +107,7 @@ void winerror(pdfapp_t *app, fz_error error)
char *winpassword(pdfapp_t *app, char *filename)
{
char *r = password;
- password = nil;
+ password = NULL;
return r;
}
@@ -120,7 +120,7 @@ static void winopen(void)
XWMHints *wmhints;
XClassHint *classhint;
- xdpy = XOpenDisplay(nil);
+ xdpy = XOpenDisplay(NULL);
if (!xdpy)
winerror(&gapp, fz_throw("cannot open display"));
@@ -154,7 +154,7 @@ static void winopen(void)
InputOutput,
ximage_get_visual(),
0,
- nil);
+ NULL);
if (xwin == None)
winerror(&gapp, fz_throw("cannot create window"));
@@ -165,7 +165,7 @@ static void winopen(void)
mapped = 0;
- xgc = XCreateGC(xdpy, xwin, 0, nil);
+ xgc = XCreateGC(xdpy, xwin, 0, NULL);
XDefineCursor(xdpy, xwin, xcarrow);
@@ -224,9 +224,9 @@ void wintitle(pdfapp_t *app, char *s)
{
XStoreName(xdpy, xwin, s);
#ifdef X_HAVE_UTF8_STRING
- Xutf8SetWMProperties(xdpy, xwin, s, s, nil, 0, nil, nil, nil);
+ Xutf8SetWMProperties(xdpy, xwin, s, s, NULL, 0, NULL, NULL, NULL);
#else
- XmbSetWMProperties(xdpy, xwin, s, s, nil, 0, nil, nil, nil);
+ XmbSetWMProperties(xdpy, xwin, s, s, NULL, 0, NULL, NULL, NULL);
#endif
}
@@ -314,7 +314,7 @@ static void winblit(pdfapp_t *app)
{
int i = gapp.image->w*gapp.image->h;
unsigned char *color = malloc(i*4);
- if (color != nil)
+ if (color != NULL)
{
unsigned char *s = gapp.image->samples;
unsigned char *d = color;
@@ -533,9 +533,9 @@ static void winawaitevent(struct timeval *tmo, struct timeval *tmo_at)
FD_ZERO(&fds);
FD_SET(x11fd, &fds);
- if (select(x11fd + 1, &fds, nil, nil, tmo))
+ if (select(x11fd + 1, &fds, NULL, NULL, tmo))
{
- gettimeofday(&now, nil);
+ gettimeofday(&now, NULL);
timersub(tmo_at, &now, tmo);
XNextEvent(xdpy, &xevt);
}
@@ -549,7 +549,7 @@ static void winsettmo(struct timeval *tmo, struct timeval *tmo_at)
tmo->tv_sec = 2;
tmo->tv_usec = 0;
- gettimeofday(&now, nil);
+ gettimeofday(&now, NULL);
timeradd(&now, tmo, tmo_at);
}
@@ -658,7 +658,7 @@ int main(int argc, char **argv)
case KeyPress:
wasshowingpage = isshowingpage;
- len = XLookupString(&xevt.xkey, buf, sizeof buf, &keysym, nil);
+ len = XLookupString(&xevt.xkey, buf, sizeof buf, &keysym, NULL);
switch (keysym)
{
diff --git a/apps/xpsdraw.c b/apps/xpsdraw.c
index 2e30de9a..41d01c14 100644
--- a/apps/xpsdraw.c
+++ b/apps/xpsdraw.c
@@ -18,7 +18,7 @@ int savealpha = 0;
int uselist = 1;
fz_colorspace *colorspace;
-fz_glyphcache *glyphcache;
+fz_glyph_cache *glyphcache;
char *filename;
struct {
@@ -81,13 +81,13 @@ xps_run_page(xps_context *ctx, xps_page *page, fz_device *dev, fz_matrix ctm)
{
ctx->dev = dev;
xps_parse_fixed_page(ctx, ctm, page);
- ctx->dev = nil;
+ ctx->dev = NULL;
}
static void drawpage(xps_context *ctx, int pagenum)
{
xps_page *page;
- fz_displaylist *list;
+ fz_display_list *list;
fz_device *dev;
int start;
@@ -100,44 +100,44 @@ static void drawpage(xps_context *ctx, int pagenum)
if (!page)
die(fz_throw("cannot load page %d in file '%s'", pagenum, filename));
- list = nil;
+ list = NULL;
if (uselist)
{
- list = fz_newdisplaylist();
- dev = fz_newlistdevice(list);
+ list = fz_new_display_list();
+ dev = fz_new_list_device(list);
xps_run_page(ctx, page, dev, fz_identity);
- fz_freedevice(dev);
+ fz_free_device(dev);
}
if (showxml)
{
- dev = fz_newtracedevice();
+ dev = fz_new_trace_device();
printf("<page number=\"%d\">\n", pagenum);
if (list)
- fz_executedisplaylist(list, dev, fz_identity, fz_infinitebbox);
+ fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox);
else
xps_run_page(ctx, page, dev, fz_identity);
printf("</page>\n");
- fz_freedevice(dev);
+ fz_free_device(dev);
}
if (showtext)
{
- fz_textspan *text = fz_newtextspan();
- dev = fz_newtextdevice(text);
+ fz_text_span *text = fz_new_text_span();
+ dev = fz_new_text_device(text);
if (list)
- fz_executedisplaylist(list, dev, fz_identity, fz_infinitebbox);
+ fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox);
else
xps_run_page(ctx, page, dev, fz_identity);
- fz_freedevice(dev);
+ fz_free_device(dev);
printf("[Page %d]\n", pagenum);
if (showtext > 1)
- fz_debugtextspanxml(text);
+ fz_debug_text_span_xml(text);
else
- fz_debugtextspan(text);
+ fz_debug_text_span(text);
printf("\n");
- fz_freetextspan(text);
+ fz_free_text_span(text);
}
if (showmd5 || showtime)
@@ -158,34 +158,34 @@ static void drawpage(xps_context *ctx, int pagenum)
zoom = resolution / 96;
ctm = fz_translate(0, -page->height);
ctm = fz_concat(ctm, fz_scale(zoom, zoom));
- bbox = fz_roundrect(fz_transformrect(ctm, rect));
+ bbox = fz_round_rect(fz_transform_rect(ctm, rect));
/* TODO: banded rendering and multi-page ppm */
- pix = fz_newpixmapwithrect(colorspace, bbox);
+ pix = fz_new_pixmap_with_rect(colorspace, bbox);
if (savealpha)
- fz_clearpixmap(pix);
+ fz_clear_pixmap(pix);
else
- fz_clearpixmapwithcolor(pix, 255);
+ fz_clear_pixmap_with_color(pix, 255);
- dev = fz_newdrawdevice(glyphcache, pix);
+ dev = fz_new_draw_device(glyphcache, pix);
if (list)
- fz_executedisplaylist(list, dev, ctm, bbox);
+ fz_execute_display_list(list, dev, ctm, bbox);
else
xps_run_page(ctx, page, dev, ctm);
- fz_freedevice(dev);
+ fz_free_device(dev);
if (output)
{
char buf[512];
sprintf(buf, output, pagenum);
if (strstr(output, ".pgm") || strstr(output, ".ppm") || strstr(output, ".pnm"))
- fz_writepnm(pix, buf);
+ fz_write_pnm(pix, buf);
else if (strstr(output, ".pam"))
- fz_writepam(pix, buf, savealpha);
+ fz_write_pam(pix, buf, savealpha);
else if (strstr(output, ".png"))
- fz_writepng(pix, buf, savealpha);
+ fz_write_png(pix, buf, savealpha);
}
if (showmd5)
@@ -194,20 +194,20 @@ static void drawpage(xps_context *ctx, int pagenum)
unsigned char digest[16];
int i;
- fz_md5init(&md5);
- fz_md5update(&md5, pix->samples, pix->w * pix->h * pix->n);
- fz_md5final(&md5, digest);
+ fz_md5_init(&md5);
+ fz_md5_update(&md5, pix->samples, pix->w * pix->h * pix->n);
+ fz_md5_final(&md5, digest);
printf(" ");
for (i = 0; i < 16; i++)
printf("%02x", digest[i]);
}
- fz_droppixmap(pix);
+ fz_drop_pixmap(pix);
}
if (list)
- fz_freedisplaylist(list);
+ fz_free_display_list(list);
if (showtime)
{
@@ -234,7 +234,6 @@ static void drawpage(xps_context *ctx, int pagenum)
printf("\n");
}
-
static void drawrange(xps_context *ctx, char *range)
{
int page, spage, epage;
@@ -310,15 +309,15 @@ int main(int argc, char **argv)
if (accelerate)
fz_accelerate();
- glyphcache = fz_newglyphcache();
+ glyphcache = fz_new_glyph_cache();
- colorspace = fz_devicergb;
+ colorspace = fz_device_rgb;
if (grayscale)
- colorspace = fz_devicegray;
+ colorspace = fz_device_gray;
if (output && strstr(output, ".pgm"))
- colorspace = fz_devicegray;
+ colorspace = fz_device_gray;
if (output && strstr(output, ".ppm"))
- colorspace = fz_devicergb;
+ colorspace = fz_device_rgb;
timing.count = 0;
timing.total = 0;
@@ -361,7 +360,7 @@ int main(int argc, char **argv)
printf("slowest page %d: %dms\n", timing.maxpage, timing.max);
}
- fz_freeglyphcache(glyphcache);
+ fz_free_glyph_cache(glyphcache);
return 0;
}