summaryrefslogtreecommitdiff
path: root/pdf
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 /pdf
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 'pdf')
-rw-r--r--pdf/cmapdump.c18
-rw-r--r--pdf/fontdump.c1
-rw-r--r--pdf/mupdf.h444
-rw-r--r--pdf/pdf_annot.c172
-rw-r--r--pdf/pdf_build.c432
-rw-r--r--pdf/pdf_cmap.c128
-rw-r--r--pdf/pdf_cmap_load.c94
-rw-r--r--pdf/pdf_cmap_parse.c236
-rw-r--r--pdf/pdf_cmap_table.c2
-rw-r--r--pdf/pdf_colorspace.c270
-rw-r--r--pdf/pdf_crypt.c336
-rw-r--r--pdf/pdf_debug.c12
-rw-r--r--pdf/pdf_font.c628
-rw-r--r--pdf/pdf_fontagl.c34
-rw-r--r--pdf/pdf_fontenc.c20
-rw-r--r--pdf/pdf_fontfile.c74
-rw-r--r--pdf/pdf_fontmtx.c60
-rw-r--r--pdf/pdf_function.c954
-rw-r--r--pdf/pdf_image.c164
-rw-r--r--pdf/pdf_interpret.c628
-rw-r--r--pdf/pdf_lex.c172
-rw-r--r--pdf/pdf_nametree.c106
-rw-r--r--pdf/pdf_outline.c74
-rw-r--r--pdf/pdf_page.c164
-rw-r--r--pdf/pdf_pagetree.c128
-rw-r--r--pdf/pdf_parse.c354
-rw-r--r--pdf/pdf_pattern.c60
-rw-r--r--pdf/pdf_repair.c234
-rw-r--r--pdf/pdf_shade.c530
-rw-r--r--pdf/pdf_store.c118
-rw-r--r--pdf/pdf_stream.c198
-rw-r--r--pdf/pdf_type3.c102
-rw-r--r--pdf/pdf_unicode.c52
-rw-r--r--pdf/pdf_xobject.c76
-rw-r--r--pdf/pdf_xref.c368
35 files changed, 3721 insertions, 3722 deletions
diff --git a/pdf/cmapdump.c b/pdf/cmapdump.c
index c609058c..94f3c140 100644
--- a/pdf/cmapdump.c
+++ b/pdf/cmapdump.c
@@ -75,11 +75,11 @@ main(int argc, char **argv)
strcpy(name, realname);
clean(name);
- fi = fz_openfile(argv[i]);
+ fi = fz_open_file(argv[i]);
if (!fi)
fz_throw("cmapdump: could not open input file '%s'\n", argv[i]);
- error = pdf_parsecmap(&cmap, fi);
+ error = pdf_parse_cmap(&cmap, fi);
if (error)
{
fz_catch(error, "cmapdump: could not parse input cmap '%s'\n", argv[i]);
@@ -96,7 +96,7 @@ main(int argc, char **argv)
if (k % 4 == 0)
fprintf(fo, "\n");
fprintf(fo, "{%d,%d,%d},",
- cmap->ranges[k].low, cmap->ranges[k].extentflags, cmap->ranges[k].offset);
+ cmap->ranges[k].low, cmap->ranges[k].extent_flags, cmap->ranges[k].offset);
}
fprintf(fo, "\n};\n\n");
@@ -119,18 +119,18 @@ main(int argc, char **argv)
fprintf(fo, "pdf_cmap pdf_cmap_%s = {\n", name);
fprintf(fo, "\t-1, ");
- fprintf(fo, "\"%s\", ", cmap->cmapname);
- fprintf(fo, "\"%s\", 0, ", cmap->usecmapname);
+ fprintf(fo, "\"%s\", ", cmap->cmap_name);
+ fprintf(fo, "\"%s\", 0, ", cmap->usecmap_name);
fprintf(fo, "%d, ", cmap->wmode);
- fprintf(fo, "%d,\n\t{ ", cmap->ncspace);
- if (cmap->ncspace == 0)
+ fprintf(fo, "%d,\n\t{ ", cmap->codespace_len);
+ if (cmap->codespace_len == 0)
{
fprintf(fo, "{0,0,0},");
}
- for (k = 0; k < cmap->ncspace; k++)
+ for (k = 0; k < cmap->codespace_len; k++)
{
fprintf(fo, "{%d,%d,%d},",
- cmap->cspace[k].n, cmap->cspace[k].low, cmap->cspace[k].high);
+ cmap->codespace[k].n, cmap->codespace[k].low, cmap->codespace[k].high);
}
fprintf(fo, " },\n");
diff --git a/pdf/fontdump.c b/pdf/fontdump.c
index b40558dd..37572bea 100644
--- a/pdf/fontdump.c
+++ b/pdf/fontdump.c
@@ -23,7 +23,6 @@ hexdump(FILE *fo, FILE *fi)
return n;
}
-
int
main(int argc, char **argv)
{
diff --git a/pdf/mupdf.h b/pdf/mupdf.h
index 4184a59f..96ac2da3 100644
--- a/pdf/mupdf.h
+++ b/pdf/mupdf.h
@@ -7,12 +7,12 @@
typedef struct pdf_xref_s pdf_xref;
-void pdf_logxref(char *fmt, ...);
-void pdf_logrsrc(char *fmt, ...);
-void pdf_logfont(char *fmt, ...);
-void pdf_logimage(char *fmt, ...);
-void pdf_logshade(char *fmt, ...);
-void pdf_logpage(char *fmt, ...);
+void pdf_log_xref(char *fmt, ...);
+void pdf_log_rsrc(char *fmt, ...);
+void pdf_log_font(char *fmt, ...);
+void pdf_log_image(char *fmt, ...);
+void pdf_log_shade(char *fmt, ...);
+void pdf_log_page(char *fmt, ...);
/*
* tokenizer and low-level object parser
@@ -20,32 +20,32 @@ void pdf_logpage(char *fmt, ...);
enum
{
- PDF_TERROR, PDF_TEOF,
- PDF_TOARRAY, PDF_TCARRAY,
- PDF_TODICT, PDF_TCDICT,
- PDF_TOBRACE, PDF_TCBRACE,
- PDF_TNAME, PDF_TINT, PDF_TREAL, PDF_TSTRING, PDF_TKEYWORD,
- PDF_TR, PDF_TTRUE, PDF_TFALSE, PDF_TNULL,
- PDF_TOBJ, PDF_TENDOBJ,
- PDF_TSTREAM, PDF_TENDSTREAM,
- PDF_TXREF, PDF_TTRAILER, PDF_TSTARTXREF,
- PDF_NTOKENS
+ PDF_TOK_ERROR, PDF_TOK_EOF,
+ PDF_TOK_OPEN_ARRAY, PDF_TOK_CLOSE_ARRAY,
+ PDF_TOK_OPEN_DICT, PDF_TOK_CLOSE_DICT,
+ PDF_TOK_OPEN_BRACE, PDF_TOK_CLOSE_BRACE,
+ PDF_TOK_NAME, PDF_TOK_INT, PDF_TOK_REAL, PDF_TOK_STRING, PDF_TOK_KEYWORD,
+ PDF_TOK_R, PDF_TOK_TRUE, PDF_TOK_FALSE, PDF_TOK_NULL,
+ PDF_TOK_OBJ, PDF_TOK_ENDOBJ,
+ PDF_TOK_STREAM, PDF_TOK_ENDSTREAM,
+ PDF_TOK_XREF, PDF_TOK_TRAILER, PDF_TOK_STARTXREF,
+ PDF_NUM_TOKENS
};
/* lex.c */
fz_error pdf_lex(int *tok, fz_stream *f, char *buf, int n, int *len);
/* parse.c */
-fz_error pdf_parsearray(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap);
-fz_error pdf_parsedict(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap);
-fz_error pdf_parsestmobj(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap);
-fz_error pdf_parseindobj(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap, int *num, int *gen, int *stmofs);
+fz_error pdf_parse_array(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap);
+fz_error pdf_parse_dict(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap);
+fz_error pdf_parse_stm_obj(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap);
+fz_error pdf_parse_ind_obj(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap, int *num, int *gen, int *stm_ofs);
-fz_rect pdf_torect(fz_obj *array);
-fz_matrix pdf_tomatrix(fz_obj *array);
-char *pdf_toutf8(fz_obj *src);
-unsigned short *pdf_toucs2(fz_obj *src);
-fz_obj *pdf_toutf8name(fz_obj *src);
+fz_rect pdf_to_rect(fz_obj *array);
+fz_matrix pdf_to_matrix(fz_obj *array);
+char *pdf_to_utf8(fz_obj *src);
+unsigned short *pdf_to_ucs2(fz_obj *src);
+fz_obj *pdf_to_utf8_name(fz_obj *src);
/*
* Encryption
@@ -63,7 +63,7 @@ fz_obj *pdf_toutf8name(fz_obj *src);
#define PDF_DEFAULT_PERM_FLAGS 0xfffc
typedef struct pdf_crypt_s pdf_crypt;
-typedef struct pdf_cryptfilter_s pdf_cryptfilter;
+typedef struct pdf_crypt_filter_s pdf_crypt_filter;
enum
{
@@ -74,7 +74,7 @@ enum
PDF_CRYPT_UNKNOWN,
};
-struct pdf_cryptfilter_s
+struct pdf_crypt_filter_s
{
int method;
int length;
@@ -82,14 +82,14 @@ struct pdf_cryptfilter_s
struct pdf_crypt_s
{
- unsigned char idstring[32];
- int idlength;
+ unsigned char id_string[32];
+ int id_length;
int v;
int length;
fz_obj *cf;
- pdf_cryptfilter stmf;
- pdf_cryptfilter strf;
+ pdf_crypt_filter stmf;
+ pdf_crypt_filter strf;
int r;
unsigned char o[48];
@@ -97,35 +97,35 @@ struct pdf_crypt_s
unsigned char oe[32];
unsigned char ue[32];
int p;
- int encryptmetadata;
+ int encrypt_metadata;
unsigned char key[32]; /* decryption key generated from password */
};
/* crypt.c */
-fz_error pdf_newcrypt(pdf_crypt **cp, fz_obj *enc, fz_obj *id);
-void pdf_freecrypt(pdf_crypt *crypt);
+fz_error pdf_new_crypt(pdf_crypt **cp, fz_obj *enc, fz_obj *id);
+void pdf_free_crypt(pdf_crypt *crypt);
-fz_error pdf_parsecryptfilter(pdf_cryptfilter *cf, fz_obj *dict, int defaultlength);
-fz_stream *pdf_opencrypt(fz_stream *chain, pdf_crypt *crypt, pdf_cryptfilter *cf, int num, int gen);
-void pdf_cryptobj(pdf_crypt *crypt, fz_obj *obj, int num, int gen);
+fz_error pdf_parse_crypt_filter(pdf_crypt_filter *cf, fz_obj *dict, int defaultlength);
+fz_stream *pdf_open_crypt(fz_stream *chain, pdf_crypt *crypt, pdf_crypt_filter *cf, int num, int gen);
+void pdf_crypt_obj(pdf_crypt *crypt, fz_obj *obj, int num, int gen);
-int pdf_needspassword(pdf_xref *xref);
-int pdf_authenticatepassword(pdf_xref *xref, char *pw);
+int pdf_needs_password(pdf_xref *xref);
+int pdf_authenticate_password(pdf_xref *xref, char *pw);
-void pdf_debugcrypt(pdf_crypt *crypt);
+void pdf_debug_crypt(pdf_crypt *crypt);
/*
* xref and object / stream api
*/
-typedef struct pdf_xrefentry_s pdf_xrefentry;
+typedef struct pdf_xref_entry_s pdf_xref_entry;
-struct pdf_xrefentry_s
+struct pdf_xref_entry_s
{
int ofs; /* file offset / objstm object number */
int gen; /* generation / objstm index */
- int stmofs; /* on-disk stream */
+ int stm_ofs; /* on-disk stream */
fz_obj *obj; /* stored/cached object */
int type; /* 0=unset (f)ree i(n)use (o)bjstm */
};
@@ -135,45 +135,45 @@ struct pdf_xref_s
fz_stream *file;
int version;
int startxref;
- int filesize;
+ int file_size;
pdf_crypt *crypt;
fz_obj *trailer;
int len;
- pdf_xrefentry *table;
+ pdf_xref_entry *table;
- int pagelen;
- int pagecap;
- fz_obj **pageobjs;
- fz_obj **pagerefs;
+ int page_len;
+ int page_cap;
+ fz_obj **page_objs;
+ fz_obj **page_refs;
struct pdf_store_s *store;
char scratch[65536];
};
-fz_obj *pdf_resolveindirect(fz_obj *ref);
-fz_error pdf_cacheobject(pdf_xref *, int num, int gen);
-fz_error pdf_loadobject(fz_obj **objp, pdf_xref *, int num, int gen);
-void pdf_updateobject( pdf_xref *xref, int num, int gen, fz_obj *newobj);
+fz_obj *pdf_resolve_indirect(fz_obj *ref);
+fz_error pdf_cache_object(pdf_xref *, int num, int gen);
+fz_error pdf_load_object(fz_obj **objp, pdf_xref *, int num, int gen);
+void pdf_update_object( pdf_xref *xref, int num, int gen, fz_obj *newobj);
-int pdf_isstream(pdf_xref *xref, int num, int gen);
-fz_stream *pdf_openinlinestream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length);
-fz_error pdf_loadrawstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen);
-fz_error pdf_loadstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen);
-fz_error pdf_openrawstream(fz_stream **stmp, pdf_xref *, int num, int gen);
-fz_error pdf_openstream(fz_stream **stmp, pdf_xref *, int num, int gen);
-fz_error pdf_openstreamat(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stmofs);
+int pdf_is_stream(pdf_xref *xref, int num, int gen);
+fz_stream *pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length);
+fz_error pdf_load_raw_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen);
+fz_error pdf_load_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen);
+fz_error pdf_open_raw_stream(fz_stream **stmp, pdf_xref *, int num, int gen);
+fz_error pdf_open_stream(fz_stream **stmp, pdf_xref *, int num, int gen);
+fz_error pdf_open_stream_at(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stm_ofs);
-fz_error pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password);
-fz_error pdf_openxref(pdf_xref **xrefp, char *filename, char *password);
-void pdf_freexref(pdf_xref *);
+fz_error pdf_open_xref_with_stream(pdf_xref **xrefp, fz_stream *file, char *password);
+fz_error pdf_open_xref(pdf_xref **xrefp, char *filename, char *password);
+void pdf_free_xref(pdf_xref *);
/* private */
-fz_error pdf_repairxref(pdf_xref *xref, char *buf, int bufsize);
-fz_error pdf_repairobjstms(pdf_xref *xref);
-void pdf_debugxref(pdf_xref *);
-void pdf_resizexref(pdf_xref *xref, int newcap);
+fz_error pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize);
+fz_error pdf_repair_obj_stms(pdf_xref *xref);
+void pdf_debug_xref(pdf_xref *);
+void pdf_resize_xref(pdf_xref *xref, int newcap);
/*
* Resource store
@@ -181,14 +181,14 @@ void pdf_resizexref(pdf_xref *xref, int newcap);
typedef struct pdf_store_s pdf_store;
-pdf_store *pdf_newstore(void);
-void pdf_freestore(pdf_store *store);
-void pdf_debugstore(pdf_store *store);
+pdf_store *pdf_new_store(void);
+void pdf_free_store(pdf_store *store);
+void pdf_debug_store(pdf_store *store);
-void pdf_storeitem(pdf_store *store, void *keepfn, void *dropfn, fz_obj *key, void *val);
-void *pdf_finditem(pdf_store *store, void *dropfn, fz_obj *key);
-void pdf_removeitem(pdf_store *store, void *dropfn, fz_obj *key);
-void pdf_agestore(pdf_store *store, int maxage);
+void pdf_store_item(pdf_store *store, void *keepfn, void *dropfn, fz_obj *key, void *val);
+void *pdf_find_item(pdf_store *store, void *dropfn, fz_obj *key);
+void pdf_remove_item(pdf_store *store, void *dropfn, fz_obj *key);
+void pdf_age_store(pdf_store *store, int maxage);
/*
* Functions
@@ -196,17 +196,17 @@ void pdf_agestore(pdf_store *store, int maxage);
typedef struct pdf_function_s pdf_function;
-fz_error pdf_loadfunction(pdf_function **func, pdf_xref *xref, fz_obj *ref);
-void pdf_evalfunction(pdf_function *func, float *in, int inlen, float *out, int outlen);
-pdf_function *pdf_keepfunction(pdf_function *func);
-void pdf_dropfunction(pdf_function *func);
+fz_error pdf_load_function(pdf_function **func, pdf_xref *xref, fz_obj *ref);
+void pdf_eval_function(pdf_function *func, float *in, int inlen, float *out, int outlen);
+pdf_function *pdf_keep_function(pdf_function *func);
+void pdf_drop_function(pdf_function *func);
/*
* Colorspace
*/
-fz_error pdf_loadcolorspace(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj);
-fz_pixmap *pdf_expandindexedpixmap(fz_pixmap *src);
+fz_error pdf_load_colorspace(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj);
+fz_pixmap *pdf_expand_indexed_pixmap(fz_pixmap *src);
/*
* Pattern
@@ -226,15 +226,15 @@ struct pdf_pattern_s
fz_buffer *contents;
};
-fz_error pdf_loadpattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *obj);
-pdf_pattern *pdf_keeppattern(pdf_pattern *pat);
-void pdf_droppattern(pdf_pattern *pat);
+fz_error pdf_load_pattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *obj);
+pdf_pattern *pdf_keep_pattern(pdf_pattern *pat);
+void pdf_drop_pattern(pdf_pattern *pat);
/*
* Shading
*/
-fz_error pdf_loadshading(fz_shade **shadep, pdf_xref *xref, fz_obj *obj);
+fz_error pdf_load_shading(fz_shade **shadep, pdf_xref *xref, fz_obj *obj);
/*
* XObject
@@ -255,17 +255,17 @@ struct pdf_xobject_s
fz_buffer *contents;
};
-fz_error pdf_loadxobject(pdf_xobject **xobjp, pdf_xref *xref, fz_obj *obj);
-pdf_xobject *pdf_keepxobject(pdf_xobject *xobj);
-void pdf_dropxobject(pdf_xobject *xobj);
+fz_error pdf_load_xobject(pdf_xobject **xobjp, pdf_xref *xref, fz_obj *obj);
+pdf_xobject *pdf_keep_xobject(pdf_xobject *xobj);
+void pdf_drop_xobject(pdf_xobject *xobj);
/*
* Image
*/
-fz_error pdf_loadinlineimage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file);
-fz_error pdf_loadimage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *obj);
-int pdf_isjpximage(fz_obj *dict);
+fz_error pdf_load_inline_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file);
+fz_error pdf_load_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *obj);
+int pdf_is_jpx_image(fz_obj *dict);
/*
* CMap
@@ -282,27 +282,27 @@ struct pdf_range_s
/* Next, we pack 2 fields into the same unsigned short. Top 14 bits
* are the extent, bottom 2 bits are flags: single, range, table,
* multi */
- unsigned short extentflags;
+ unsigned short extent_flags;
unsigned short offset; /* range-delta or table-index */
};
struct pdf_cmap_s
{
int refs;
- char cmapname[32];
+ char cmap_name[32];
- char usecmapname[32];
+ char usecmap_name[32];
pdf_cmap *usecmap;
int wmode;
- int ncspace;
+ int codespace_len;
struct
{
unsigned short n;
unsigned short low;
unsigned short high;
- } cspace[40];
+ } codespace[40];
int rlen, rcap;
pdf_range *ranges;
@@ -311,50 +311,50 @@ struct pdf_cmap_s
unsigned short *table;
};
-extern pdf_cmap *pdf_cmaptable[]; /* list of builtin system cmaps */
+extern pdf_cmap *pdf_cmap_table[]; /* list of builtin system cmaps */
-pdf_cmap *pdf_newcmap(void);
-pdf_cmap *pdf_keepcmap(pdf_cmap *cmap);
-void pdf_dropcmap(pdf_cmap *cmap);
+pdf_cmap *pdf_new_cmap(void);
+pdf_cmap *pdf_keep_cmap(pdf_cmap *cmap);
+void pdf_drop_cmap(pdf_cmap *cmap);
-void pdf_debugcmap(pdf_cmap *cmap);
-int pdf_getwmode(pdf_cmap *cmap);
-void pdf_setwmode(pdf_cmap *cmap, int wmode);
-void pdf_setusecmap(pdf_cmap *cmap, pdf_cmap *usecmap);
+void pdf_debug_cmap(pdf_cmap *cmap);
+int pdf_get_wmode(pdf_cmap *cmap);
+void pdf_set_wmode(pdf_cmap *cmap, int wmode);
+void pdf_set_usecmap(pdf_cmap *cmap, pdf_cmap *usecmap);
-void pdf_addcodespace(pdf_cmap *cmap, int low, int high, int n);
-void pdf_maprangetotable(pdf_cmap *cmap, int low, int *map, int len);
-void pdf_maprangetorange(pdf_cmap *cmap, int srclo, int srchi, int dstlo);
-void pdf_maponetomany(pdf_cmap *cmap, int one, int *many, int len);
-void pdf_sortcmap(pdf_cmap *cmap);
+void pdf_add_codespace(pdf_cmap *cmap, int low, int high, int n);
+void pdf_map_range_to_table(pdf_cmap *cmap, int low, int *map, int len);
+void pdf_map_range_to_range(pdf_cmap *cmap, int srclo, int srchi, int dstlo);
+void pdf_map_one_to_many(pdf_cmap *cmap, int one, int *many, int len);
+void pdf_sort_cmap(pdf_cmap *cmap);
-int pdf_lookupcmap(pdf_cmap *cmap, int cpt);
-int pdf_lookupcmapfull(pdf_cmap *cmap, int cpt, int *out);
-unsigned char *pdf_decodecmap(pdf_cmap *cmap, unsigned char *s, int *cpt);
+int pdf_lookup_cmap(pdf_cmap *cmap, int cpt);
+int pdf_lookup_cmap_full(pdf_cmap *cmap, int cpt, int *out);
+unsigned char *pdf_decode_cmap(pdf_cmap *cmap, unsigned char *s, int *cpt);
-pdf_cmap *pdf_newidentitycmap(int wmode, int bytes);
-fz_error pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file);
-fz_error pdf_loadembeddedcmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *ref);
-fz_error pdf_loadsystemcmap(pdf_cmap **cmapp, char *name);
+pdf_cmap *pdf_new_identity_cmap(int wmode, int bytes);
+fz_error pdf_parse_cmap(pdf_cmap **cmapp, fz_stream *file);
+fz_error pdf_load_embedded_cmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *ref);
+fz_error pdf_load_system_cmap(pdf_cmap **cmapp, char *name);
/*
* Font
*/
-void pdf_loadencoding(char **estrings, char *encoding);
-int pdf_lookupagl(char *name);
-char **pdf_lookupaglnames(int ucs);
+void pdf_load_encoding(char **estrings, char *encoding);
+int pdf_lookup_agl(char *name);
+char **pdf_lookup_agl_names(int ucs);
-extern const unsigned short pdf_docencoding[256];
-extern const char * const pdf_macroman[256];
-extern const char * const pdf_macexpert[256];
-extern const char * const pdf_winansi[256];
+extern const unsigned short pdf_doc_encoding[256];
+extern const char * const pdf_mac_roman[256];
+extern const char * const pdf_mac_expert[256];
+extern const char * const pdf_win_ansi[256];
extern const char * const pdf_standard[256];
extern const char * const pdf_expert[256];
extern const char * const pdf_symbol[256];
extern const char * const pdf_zapfdingbats[256];
-typedef struct pdf_fontdesc_s pdf_fontdesc;
+typedef struct pdf_font_desc_s pdf_font_desc;
typedef struct pdf_hmtx_s pdf_hmtx;
typedef struct pdf_vmtx_s pdf_vmtx;
@@ -374,7 +374,7 @@ struct pdf_vmtx_s
short w;
};
-struct pdf_fontdesc_s
+struct pdf_font_desc_s
{
int refs;
@@ -382,32 +382,32 @@ struct pdf_fontdesc_s
/* FontDescriptor */
int flags;
- float italicangle;
+ float italic_angle;
float ascent;
float descent;
- float capheight;
- float xheight;
- float missingwidth;
+ float cap_height;
+ float x_height;
+ float missing_width;
/* Encoding (CMap) */
pdf_cmap *encoding;
- pdf_cmap *tottfcmap;
- int ncidtogid;
- unsigned short *cidtogid;
+ pdf_cmap *to_ttf_cmap;
+ int cid_to_gid_len;
+ unsigned short *cid_to_gid;
/* ToUnicode */
- pdf_cmap *tounicode;
- int ncidtoucs;
- unsigned short *cidtoucs;
+ pdf_cmap *to_unicode;
+ int cid_to_ucs_len;
+ unsigned short *cid_to_ucs;
/* Metrics (given in the PDF file) */
int wmode;
- int nhmtx, hmtxcap;
+ int hmtx_len, hmtx_cap;
pdf_hmtx dhmtx;
pdf_hmtx *hmtx;
- int nvmtx, vmtxcap;
+ int vmtx_len, vmtx_cap;
pdf_vmtx dvmtx;
pdf_vmtx *vmtx;
@@ -415,35 +415,35 @@ struct pdf_fontdesc_s
};
/* fontmtx.c */
-void pdf_setfontwmode(pdf_fontdesc *font, int wmode);
-void pdf_setdefaulthmtx(pdf_fontdesc *font, int w);
-void pdf_setdefaultvmtx(pdf_fontdesc *font, int y, int w);
-void pdf_addhmtx(pdf_fontdesc *font, int lo, int hi, int w);
-void pdf_addvmtx(pdf_fontdesc *font, int lo, int hi, int x, int y, int w);
-void pdf_endhmtx(pdf_fontdesc *font);
-void pdf_endvmtx(pdf_fontdesc *font);
-pdf_hmtx pdf_gethmtx(pdf_fontdesc *font, int cid);
-pdf_vmtx pdf_getvmtx(pdf_fontdesc *font, int cid);
+void pdf_set_font_wmode(pdf_font_desc *font, int wmode);
+void pdf_set_default_hmtx(pdf_font_desc *font, int w);
+void pdf_set_default_vmtx(pdf_font_desc *font, int y, int w);
+void pdf_add_hmtx(pdf_font_desc *font, int lo, int hi, int w);
+void pdf_add_vmtx(pdf_font_desc *font, int lo, int hi, int x, int y, int w);
+void pdf_end_hmtx(pdf_font_desc *font);
+void pdf_end_vmtx(pdf_font_desc *font);
+pdf_hmtx pdf_get_hmtx(pdf_font_desc *font, int cid);
+pdf_vmtx pdf_get_vmtx(pdf_font_desc *font, int cid);
/* unicode.c */
-fz_error pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm);
+fz_error pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm);
/* fontfile.c */
-fz_error pdf_loadbuiltinfont(pdf_fontdesc *font, char *basefont);
-fz_error pdf_loadembeddedfont(pdf_fontdesc *font, pdf_xref *xref, fz_obj *stmref);
-fz_error pdf_loadsystemfont(pdf_fontdesc *font, char *basefont, char *collection);
+fz_error pdf_load_builtin_font(pdf_font_desc *font, char *basefont);
+fz_error pdf_load_embedded_font(pdf_font_desc *font, pdf_xref *xref, fz_obj *stmref);
+fz_error pdf_load_system_font(pdf_font_desc *font, char *basefont, char *collection);
/* type3.c */
-fz_error pdf_loadtype3font(pdf_fontdesc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj);
+fz_error pdf_load_type3_font(pdf_font_desc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj);
/* font.c */
-int pdf_fontcidtogid(pdf_fontdesc *fontdesc, int cid);
-fz_error pdf_loadfontdescriptor(pdf_fontdesc *font, pdf_xref *xref, fz_obj *desc, char *collection, char *basefont);
-fz_error pdf_loadfont(pdf_fontdesc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj);
-pdf_fontdesc *pdf_newfontdesc(void);
-pdf_fontdesc *pdf_keepfont(pdf_fontdesc *fontdesc);
-void pdf_dropfont(pdf_fontdesc *font);
-void pdf_debugfont(pdf_fontdesc *fontdesc);
+int pdf_font_cid_to_gid(pdf_font_desc *fontdesc, int cid);
+fz_error pdf_load_font_descriptor(pdf_font_desc *font, pdf_xref *xref, fz_obj *desc, char *collection, char *basefont);
+fz_error pdf_load_font(pdf_font_desc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj);
+pdf_font_desc *pdf_new_font_desc(void);
+pdf_font_desc *pdf_keep_font(pdf_font_desc *fontdesc);
+void pdf_drop_font(pdf_font_desc *font);
+void pdf_debug_font(pdf_font_desc *fontdesc);
/*
* Interactive features
@@ -453,18 +453,18 @@ typedef struct pdf_link_s pdf_link;
typedef struct pdf_annot_s pdf_annot;
typedef struct pdf_outline_s pdf_outline;
-typedef enum pdf_linkkind_e
+typedef enum pdf_link_kind_e
{
- PDF_LGOTO = 0,
- PDF_LURI,
- PDF_LLAUNCH,
- PDF_LNAMED,
- PDF_LACTION,
-} pdf_linkkind;
+ PDF_LINK_GOTO = 0,
+ PDF_LINK_URI,
+ PDF_LINK_LAUNCH,
+ PDF_LINK_NAMED,
+ PDF_LINK_ACTION,
+} pdf_link_kind;
struct pdf_link_s
{
- pdf_linkkind kind;
+ pdf_link_kind kind;
fz_rect rect;
fz_obj *dest;
pdf_link *next;
@@ -488,20 +488,20 @@ struct pdf_outline_s
pdf_outline *next;
};
-fz_obj *pdf_lookupdest(pdf_xref *xref, fz_obj *needle);
-fz_obj *pdf_lookupname(pdf_xref *xref, char *which, fz_obj *needle);
-fz_obj *pdf_loadnametree(pdf_xref *xref, char *which);
+fz_obj *pdf_lookup_dest(pdf_xref *xref, fz_obj *needle);
+fz_obj *pdf_lookup_name(pdf_xref *xref, char *which, fz_obj *needle);
+fz_obj *pdf_load_name_tree(pdf_xref *xref, char *which);
-pdf_outline *pdf_loadoutline(pdf_xref *xref);
-void pdf_debugoutline(pdf_outline *outline, int level);
-void pdf_freeoutline(pdf_outline *outline);
+pdf_outline *pdf_load_outline(pdf_xref *xref);
+void pdf_debug_outline(pdf_outline *outline, int level);
+void pdf_free_outline(pdf_outline *outline);
-pdf_link *pdf_loadlink(pdf_xref *xref, fz_obj *dict);
-void pdf_loadlinks(pdf_link **, pdf_xref *, fz_obj *annots);
-void pdf_freelink(pdf_link *link);
+pdf_link *pdf_load_link(pdf_xref *xref, fz_obj *dict);
+void pdf_load_links(pdf_link **, pdf_xref *, fz_obj *annots);
+void pdf_free_link(pdf_link *link);
-void pdf_loadannots(pdf_annot **, pdf_xref *, fz_obj *annots);
-void pdf_freeannot(pdf_annot *link);
+void pdf_load_annots(pdf_annot **, pdf_xref *, fz_obj *annots);
+void pdf_free_annot(pdf_annot *link);
/*
* Page tree, pages and related objects
@@ -521,15 +521,15 @@ struct pdf_page_s
};
/* pagetree.c */
-fz_error pdf_loadpagetree(pdf_xref *xref);
-int pdf_getpagecount(pdf_xref *xref);
-fz_obj *pdf_getpageobject(pdf_xref *xref, int p);
-fz_obj *pdf_getpageref(pdf_xref *xref, int p);
-int pdf_findpageobject(pdf_xref *xref, fz_obj *pageobj);
+fz_error pdf_load_page_tree(pdf_xref *xref);
+int pdf_get_page_count(pdf_xref *xref);
+fz_obj *pdf_get_page_object(pdf_xref *xref, int p);
+fz_obj *pdf_get_page_ref(pdf_xref *xref, int p);
+int pdf_find_page_object(pdf_xref *xref, fz_obj *pageobj);
/* page.c */
-fz_error pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *ref);
-void pdf_freepage(pdf_page *page);
+fz_error pdf_load_page(pdf_page **pagep, pdf_xref *xref, fz_obj *ref);
+void pdf_free_page(pdf_page *page);
/*
* content stream parsing
@@ -541,16 +541,16 @@ typedef struct pdf_csi_s pdf_csi;
enum
{
- PDF_MFILL,
- PDF_MSTROKE,
+ PDF_FILL,
+ PDF_STROKE,
};
enum
{
- PDF_MNONE,
- PDF_MCOLOR,
- PDF_MPATTERN,
- PDF_MSHADE,
+ PDF_MAT_NONE,
+ PDF_MAT_COLOR,
+ PDF_MAT_PATTERN,
+ PDF_MAT_SHADE,
};
struct pdf_material_s
@@ -566,21 +566,21 @@ struct pdf_material_s
struct pdf_gstate_s
{
fz_matrix ctm;
- int clipdepth;
+ int clip_depth;
/* path stroking */
- fz_strokestate strokestate;
+ fz_stroke_state stroke_state;
/* materials */
pdf_material stroke;
pdf_material fill;
/* text state */
- float charspace;
- float wordspace;
+ float char_space;
+ float word_space;
float scale;
float leading;
- pdf_fontdesc *font;
+ pdf_font_desc *font;
float size;
int render;
float rise;
@@ -588,8 +588,8 @@ struct pdf_gstate_s
/* transparency */
fz_blendmode blendmode;
pdf_xobject *softmask;
- fz_matrix softmaskctm;
- float softmaskbc[FZ_MAXCOLORS];
+ fz_matrix softmask_ctm;
+ float softmask_bc[FZ_MAX_COLORS];
int luminosity;
};
@@ -605,56 +605,56 @@ struct pdf_csi_s
fz_obj *obj;
char name[256];
unsigned char string[256];
- int stringlen;
+ int string_len;
float stack[32];
int top;
int xbalance;
- int intext;
- int inarray;
+ int in_text;
+ int in_array;
/* path object state */
fz_path *path;
int clip;
- int clipevenodd;
+ int clip_even_odd;
/* text object state */
fz_text *text;
fz_matrix tlm;
fz_matrix tm;
- int textmode;
+ int text_mode;
int accumulate;
/* graphics state */
- fz_matrix topctm;
+ fz_matrix top_ctm;
pdf_gstate gstate[64];
int gtop;
};
/* build.c */
-void pdf_initgstate(pdf_gstate *gs, fz_matrix ctm);
-void pdf_setcolorspace(pdf_csi *csi, int what, fz_colorspace *cs);
-void pdf_setcolor(pdf_csi *csi, int what, float *v);
-void pdf_setpattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v);
-void pdf_setshade(pdf_csi *csi, int what, fz_shade *shade);
-void pdf_showpath(pdf_csi*, int close, int fill, int stroke, int evenodd);
-void pdf_showspace(pdf_csi *csi, float tadj);
-void pdf_showstring(pdf_csi *csi, unsigned char *buf, int len);
-void pdf_showtext(pdf_csi*, fz_obj *text);
-void pdf_flushtext(pdf_csi*);
-void pdf_showimage(pdf_csi*, fz_pixmap *image);
-void pdf_showshade(pdf_csi*, fz_shade *shade);
+void pdf_init_gstate(pdf_gstate *gs, fz_matrix ctm);
+void pdf_set_colorspace(pdf_csi *csi, int what, fz_colorspace *cs);
+void pdf_set_color(pdf_csi *csi, int what, float *v);
+void pdf_set_pattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v);
+void pdf_set_shade(pdf_csi *csi, int what, fz_shade *shade);
+void pdf_show_path(pdf_csi*, int close, int fill, int stroke, int even_odd);
+void pdf_show_space(pdf_csi *csi, float tadj);
+void pdf_show_string(pdf_csi *csi, unsigned char *buf, int len);
+void pdf_show_text(pdf_csi*, fz_obj *text);
+void pdf_flush_text(pdf_csi*);
+void pdf_show_image(pdf_csi*, fz_pixmap *image);
+void pdf_show_shade(pdf_csi*, fz_shade *shade);
/* interpret.c */
void pdf_gsave(pdf_csi *csi);
void pdf_grestore(pdf_csi *csi);
-fz_error pdf_runcsibuffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents);
-fz_error pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform);
-fz_error pdf_runpagewithtarget(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *target);
-fz_error pdf_runpage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm);
-fz_error pdf_runglyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm);
-
-pdf_material *pdf_keepmaterial(pdf_material *mat);
-pdf_material *pdf_dropmaterial(pdf_material *mat);
+fz_error pdf_run_csi_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents);
+fz_error pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform);
+fz_error pdf_run_page_with_usage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *target);
+fz_error pdf_run_page(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm);
+fz_error pdf_run_glyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm);
+
+pdf_material *pdf_keep_material(pdf_material *mat);
+pdf_material *pdf_drop_material(pdf_material *mat);
#endif
diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c
index c2c67b62..39ac9d2a 100644
--- a/pdf/pdf_annot.c
+++ b/pdf/pdf_annot.c
@@ -2,145 +2,145 @@
#include "mupdf.h"
void
-pdf_freelink(pdf_link *link)
+pdf_free_link(pdf_link *link)
{
if (link->next)
- pdf_freelink(link->next);
+ pdf_free_link(link->next);
if (link->dest)
- fz_dropobj(link->dest);
+ fz_drop_obj(link->dest);
fz_free(link);
}
static fz_obj *
-resolvedest(pdf_xref *xref, fz_obj *dest)
+resolve_dest(pdf_xref *xref, fz_obj *dest)
{
- if (fz_isname(dest) || fz_isstring(dest))
+ if (fz_is_name(dest) || fz_is_string(dest))
{
- dest = pdf_lookupdest(xref, dest);
- return resolvedest(xref, dest);
+ dest = pdf_lookup_dest(xref, dest);
+ return resolve_dest(xref, dest);
}
- else if (fz_isarray(dest))
+ else if (fz_is_array(dest))
{
return dest;
}
- else if (fz_isdict(dest))
+ else if (fz_is_dict(dest))
{
- dest = fz_dictgets(dest, "D");
- return resolvedest(xref, dest);
+ dest = fz_dict_gets(dest, "D");
+ return resolve_dest(xref, dest);
}
- else if (fz_isindirect(dest))
+ else if (fz_is_indirect(dest))
return dest;
- return nil;
+ return NULL;
}
pdf_link *
-pdf_loadlink(pdf_xref *xref, fz_obj *dict)
+pdf_load_link(pdf_xref *xref, fz_obj *dict)
{
fz_obj *dest;
fz_obj *action;
fz_obj *obj;
fz_rect bbox;
- pdf_linkkind kind;
+ pdf_link_kind kind;
- pdf_logpage("load link {\n");
+ pdf_log_page("load link {\n");
- dest = nil;
+ dest = NULL;
- obj = fz_dictgets(dict, "Rect");
+ obj = fz_dict_gets(dict, "Rect");
if (obj)
{
- bbox = pdf_torect(obj);
- pdf_logpage("rect [%g %g %g %g]\n",
+ bbox = pdf_to_rect(obj);
+ pdf_log_page("rect [%g %g %g %g]\n",
bbox.x0, bbox.y0,
bbox.x1, bbox.y1);
}
else
- bbox = fz_emptyrect;
+ bbox = fz_empty_rect;
- obj = fz_dictgets(dict, "Dest");
+ obj = fz_dict_gets(dict, "Dest");
if (obj)
{
- kind = PDF_LGOTO;
- dest = resolvedest(xref, obj);
- pdf_logpage("dest (%d %d R)\n", fz_tonum(dest), fz_togen(dest));
+ kind = PDF_LINK_GOTO;
+ dest = resolve_dest(xref, obj);
+ pdf_log_page("dest (%d %d R)\n", fz_to_num(dest), fz_to_gen(dest));
}
- action = fz_dictgets(dict, "A");
+ action = fz_dict_gets(dict, "A");
if (action)
{
- obj = fz_dictgets(action, "S");
- if (fz_isname(obj) && !strcmp(fz_toname(obj), "GoTo"))
+ obj = fz_dict_gets(action, "S");
+ if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "GoTo"))
{
- kind = PDF_LGOTO;
- dest = resolvedest(xref, fz_dictgets(action, "D"));
- pdf_logpage("action goto (%d %d R)\n", fz_tonum(dest), fz_togen(dest));
+ kind = PDF_LINK_GOTO;
+ dest = resolve_dest(xref, fz_dict_gets(action, "D"));
+ pdf_log_page("action goto (%d %d R)\n", fz_to_num(dest), fz_to_gen(dest));
}
- else if (fz_isname(obj) && !strcmp(fz_toname(obj), "URI"))
+ else if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "URI"))
{
- kind = PDF_LURI;
- dest = fz_dictgets(action, "URI");
- pdf_logpage("action uri %s\n", fz_tostrbuf(dest));
+ kind = PDF_LINK_URI;
+ dest = fz_dict_gets(action, "URI");
+ pdf_log_page("action uri %s\n", fz_to_str_buf(dest));
}
- else if (fz_isname(obj) && !strcmp(fz_toname(obj), "Launch"))
+ else if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Launch"))
{
- kind = PDF_LLAUNCH;
- dest = fz_dictgets(action, "F");
- pdf_logpage("action %s (%d %d R)\n", fz_toname(obj), fz_tonum(dest), fz_togen(dest));
+ kind = PDF_LINK_LAUNCH;
+ dest = fz_dict_gets(action, "F");
+ pdf_log_page("action %s (%d %d R)\n", fz_to_name(obj), fz_to_num(dest), fz_to_gen(dest));
}
- else if (fz_isname(obj) && !strcmp(fz_toname(obj), "Named"))
+ else if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Named"))
{
- kind = PDF_LNAMED;
- dest = fz_dictgets(action, "N");
- pdf_logpage("action %s (%d %d R)\n", fz_toname(obj), fz_tonum(dest), fz_togen(dest));
+ kind = PDF_LINK_NAMED;
+ dest = fz_dict_gets(action, "N");
+ pdf_log_page("action %s (%d %d R)\n", fz_to_name(obj), fz_to_num(dest), fz_to_gen(dest));
}
- else if (fz_isname(obj) && (!strcmp(fz_toname(obj), "GoToR")))
+ else if (fz_is_name(obj) && (!strcmp(fz_to_name(obj), "GoToR")))
{
- kind = PDF_LACTION;
+ kind = PDF_LINK_ACTION;
dest = action;
- pdf_logpage("action %s (%d %d R)\n", fz_toname(obj), fz_tonum(dest), fz_togen(dest));
+ pdf_log_page("action %s (%d %d R)\n", fz_to_name(obj), fz_to_num(dest), fz_to_gen(dest));
}
else
{
- pdf_logpage("unhandled link action, ignoring link\n");
- dest = nil;
+ pdf_log_page("unhandled link action, ignoring link\n");
+ dest = NULL;
}
}
- pdf_logpage("}\n");
+ pdf_log_page("}\n");
if (dest)
{
pdf_link *link = fz_malloc(sizeof(pdf_link));
link->kind = kind;
link->rect = bbox;
- link->dest = fz_keepobj(dest);
- link->next = nil;
+ link->dest = fz_keep_obj(dest);
+ link->next = NULL;
return link;
}
- return nil;
+ return NULL;
}
void
-pdf_loadlinks(pdf_link **linkp, pdf_xref *xref, fz_obj *annots)
+pdf_load_links(pdf_link **linkp, pdf_xref *xref, fz_obj *annots)
{
pdf_link *link, *head, *tail;
fz_obj *obj;
int i;
- head = tail = nil;
- link = nil;
+ head = tail = NULL;
+ link = NULL;
- pdf_logpage("load link annotations {\n");
+ pdf_log_page("load link annotations {\n");
- for (i = 0; i < fz_arraylen(annots); i++)
+ for (i = 0; i < fz_array_len(annots); i++)
{
- obj = fz_arrayget(annots, i);
- link = pdf_loadlink(xref, obj);
+ obj = fz_array_get(annots, i);
+ link = pdf_load_link(xref, obj);
if (link)
{
if (!head)
@@ -153,32 +153,32 @@ pdf_loadlinks(pdf_link **linkp, pdf_xref *xref, fz_obj *annots)
}
}
- pdf_logpage("}\n");
+ pdf_log_page("}\n");
*linkp = head;
}
void
-pdf_freeannot(pdf_annot *annot)
+pdf_free_annot(pdf_annot *annot)
{
if (annot->next)
- pdf_freeannot(annot->next);
+ pdf_free_annot(annot->next);
if (annot->ap)
- pdf_dropxobject(annot->ap);
+ pdf_drop_xobject(annot->ap);
if (annot->obj)
- fz_dropobj(annot->obj);
+ fz_drop_obj(annot->obj);
fz_free(annot);
}
static void
-pdf_transformannot(pdf_annot *annot)
+pdf_transform_annot(pdf_annot *annot)
{
fz_matrix matrix = annot->ap->matrix;
fz_rect bbox = annot->ap->bbox;
fz_rect rect = annot->rect;
float w, h, x, y;
- bbox = fz_transformrect(matrix, bbox);
+ bbox = fz_transform_rect(matrix, bbox);
w = (rect.x1 - rect.x0) / (bbox.x1 - bbox.x0);
h = (rect.y1 - rect.y0) / (bbox.y1 - bbox.y0);
x = rect.x0 - bbox.x0;
@@ -187,7 +187,7 @@ pdf_transformannot(pdf_annot *annot)
}
void
-pdf_loadannots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots)
+pdf_load_annots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots)
{
pdf_annot *annot, *head, *tail;
fz_obj *obj, *ap, *as, *n, *rect;
@@ -195,29 +195,29 @@ pdf_loadannots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots)
fz_error error;
int i;
- head = tail = nil;
- annot = nil;
+ head = tail = NULL;
+ annot = NULL;
- pdf_logpage("load appearance annotations {\n");
+ pdf_log_page("load appearance annotations {\n");
- for (i = 0; i < fz_arraylen(annots); i++)
+ for (i = 0; i < fz_array_len(annots); i++)
{
- obj = fz_arrayget(annots, i);
+ obj = fz_array_get(annots, i);
- rect = fz_dictgets(obj, "Rect");
- ap = fz_dictgets(obj, "AP");
- as = fz_dictgets(obj, "AS");
- if (fz_isdict(ap))
+ rect = fz_dict_gets(obj, "Rect");
+ ap = fz_dict_gets(obj, "AP");
+ as = fz_dict_gets(obj, "AS");
+ if (fz_is_dict(ap))
{
- n = fz_dictgets(ap, "N"); /* normal state */
+ n = fz_dict_gets(ap, "N"); /* normal state */
/* lookup current state in sub-dictionary */
- if (!pdf_isstream(xref, fz_tonum(n), fz_togen(n)))
- n = fz_dictget(n, as);
+ if (!pdf_is_stream(xref, fz_to_num(n), fz_to_gen(n)))
+ n = fz_dict_get(n, as);
- if (pdf_isstream(xref, fz_tonum(n), fz_togen(n)))
+ if (pdf_is_stream(xref, fz_to_num(n), fz_to_gen(n)))
{
- error = pdf_loadxobject(&form, xref, n);
+ error = pdf_load_xobject(&form, xref, n);
if (error)
{
fz_catch(error, "ignoring broken annotation");
@@ -225,12 +225,12 @@ pdf_loadannots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots)
}
annot = fz_malloc(sizeof(pdf_annot));
- annot->obj = fz_keepobj(obj);
- annot->rect = pdf_torect(rect);
+ annot->obj = fz_keep_obj(obj);
+ annot->rect = pdf_to_rect(rect);
annot->ap = form;
- annot->next = nil;
+ annot->next = NULL;
- pdf_transformannot(annot);
+ pdf_transform_annot(annot);
if (annot)
{
@@ -246,7 +246,7 @@ pdf_loadannots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots)
}
}
- pdf_logpage("}\n");
+ pdf_log_page("}\n");
*annotp = head;
}
diff --git a/pdf/pdf_build.c b/pdf/pdf_build.c
index 616f1c86..6908da1a 100644
--- a/pdf/pdf_build.c
+++ b/pdf/pdf_build.c
@@ -4,62 +4,62 @@
#define TILE
void
-pdf_initgstate(pdf_gstate *gs, fz_matrix ctm)
+pdf_init_gstate(pdf_gstate *gs, fz_matrix ctm)
{
gs->ctm = ctm;
- gs->clipdepth = 0;
-
- gs->strokestate.linewidth = 1;
- gs->strokestate.linecap = 0;
- gs->strokestate.linejoin = 0;
- gs->strokestate.miterlimit = 10;
- gs->strokestate.dashphase = 0;
- gs->strokestate.dashlen = 0;
- memset(gs->strokestate.dashlist, 0, sizeof(gs->strokestate.dashlist));
-
- gs->stroke.kind = PDF_MCOLOR;
- gs->stroke.colorspace = fz_keepcolorspace(fz_devicegray);
+ gs->clip_depth = 0;
+
+ gs->stroke_state.linewidth = 1;
+ gs->stroke_state.linecap = 0;
+ gs->stroke_state.linejoin = 0;
+ gs->stroke_state.miterlimit = 10;
+ gs->stroke_state.dash_phase = 0;
+ gs->stroke_state.dash_len = 0;
+ memset(gs->stroke_state.dash_list, 0, sizeof(gs->stroke_state.dash_list));
+
+ gs->stroke.kind = PDF_MAT_COLOR;
+ gs->stroke.colorspace = fz_keep_colorspace(fz_device_gray);
gs->stroke.v[0] = 0;
- gs->stroke.pattern = nil;
- gs->stroke.shade = nil;
+ gs->stroke.pattern = NULL;
+ gs->stroke.shade = NULL;
gs->stroke.alpha = 1;
- gs->fill.kind = PDF_MCOLOR;
- gs->fill.colorspace = fz_keepcolorspace(fz_devicegray);
+ gs->fill.kind = PDF_MAT_COLOR;
+ gs->fill.colorspace = fz_keep_colorspace(fz_device_gray);
gs->fill.v[0] = 0;
- gs->fill.pattern = nil;
- gs->fill.shade = nil;
+ gs->fill.pattern = NULL;
+ gs->fill.shade = NULL;
gs->fill.alpha = 1;
- gs->charspace = 0;
- gs->wordspace = 0;
+ gs->char_space = 0;
+ gs->word_space = 0;
gs->scale = 1;
gs->leading = 0;
- gs->font = nil;
+ gs->font = NULL;
gs->size = -1;
gs->render = 0;
gs->rise = 0;
- gs->blendmode = FZ_BNORMAL;
- gs->softmask = nil;
- gs->softmaskctm = fz_identity;
+ gs->blendmode = FZ_BLEND_NORMAL;
+ gs->softmask = NULL;
+ gs->softmask_ctm = fz_identity;
gs->luminosity = 0;
}
void
-pdf_setcolorspace(pdf_csi *csi, int what, fz_colorspace *colorspace)
+pdf_set_colorspace(pdf_csi *csi, int what, fz_colorspace *colorspace)
{
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
- mat = what == PDF_MFILL ? &gs->fill : &gs->stroke;
+ mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
- fz_dropcolorspace(mat->colorspace);
+ fz_drop_colorspace(mat->colorspace);
- mat->kind = PDF_MCOLOR;
- mat->colorspace = fz_keepcolorspace(colorspace);
+ mat->kind = PDF_MAT_COLOR;
+ mat->colorspace = fz_keep_colorspace(colorspace);
mat->v[0] = 0;
mat->v[1] = 0;
@@ -68,20 +68,20 @@ pdf_setcolorspace(pdf_csi *csi, int what, fz_colorspace *colorspace)
}
void
-pdf_setcolor(pdf_csi *csi, int what, float *v)
+pdf_set_color(pdf_csi *csi, int what, float *v)
{
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
int i;
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
- mat = what == PDF_MFILL ? &gs->fill : &gs->stroke;
+ mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
switch (mat->kind)
{
- case PDF_MPATTERN:
- case PDF_MCOLOR:
+ case PDF_MAT_PATTERN:
+ case PDF_MAT_COLOR:
if (!strcmp(mat->colorspace->name, "Lab"))
{
mat->v[0] = v[0] / 100;
@@ -97,62 +97,62 @@ pdf_setcolor(pdf_csi *csi, int what, float *v)
}
static void
-pdf_unsetpattern(pdf_csi *csi, int what)
+pdf_unset_pattern(pdf_csi *csi, int what)
{
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
- mat = what == PDF_MFILL ? &gs->fill : &gs->stroke;
- if (mat->kind == PDF_MPATTERN)
+ mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
+ if (mat->kind == PDF_MAT_PATTERN)
{
if (mat->pattern)
- pdf_droppattern(mat->pattern);
- mat->pattern = nil;
- mat->kind = PDF_MCOLOR;
+ pdf_drop_pattern(mat->pattern);
+ mat->pattern = NULL;
+ mat->kind = PDF_MAT_COLOR;
}
}
void
-pdf_setpattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v)
+pdf_set_pattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v)
{
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
- mat = what == PDF_MFILL ? &gs->fill : &gs->stroke;
+ mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
if (mat->pattern)
- pdf_droppattern(mat->pattern);
+ pdf_drop_pattern(mat->pattern);
- mat->kind = PDF_MPATTERN;
+ mat->kind = PDF_MAT_PATTERN;
if (pat)
- mat->pattern = pdf_keeppattern(pat);
+ mat->pattern = pdf_keep_pattern(pat);
else
- mat->pattern = nil;
+ mat->pattern = NULL;
if (v)
- pdf_setcolor(csi, what, v);
+ pdf_set_color(csi, what, v);
}
void
-pdf_setshade(pdf_csi *csi, int what, fz_shade *shade)
+pdf_set_shade(pdf_csi *csi, int what, fz_shade *shade)
{
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
- mat = what == PDF_MFILL ? &gs->fill : &gs->stroke;
+ mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
if (mat->shade)
- fz_dropshade(mat->shade);
+ fz_drop_shade(mat->shade);
- mat->kind = PDF_MSHADE;
- mat->shade = fz_keepshade(shade);
+ mat->kind = PDF_MAT_SHADE;
+ mat->shade = fz_keep_shade(shade);
}
static void
-pdf_showpattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
+pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
{
pdf_gstate *gstate;
fz_matrix ptm, invptm;
@@ -166,60 +166,60 @@ pdf_showpattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
if (pat->ismask)
{
- pdf_unsetpattern(csi, PDF_MFILL);
- pdf_unsetpattern(csi, PDF_MSTROKE);
- if (what == PDF_MFILL)
+ pdf_unset_pattern(csi, PDF_FILL);
+ pdf_unset_pattern(csi, PDF_STROKE);
+ if (what == PDF_FILL)
{
- pdf_dropmaterial(&gstate->stroke);
- pdf_keepmaterial(&gstate->fill);
+ pdf_drop_material(&gstate->stroke);
+ pdf_keep_material(&gstate->fill);
gstate->stroke = gstate->fill;
}
- if (what == PDF_MSTROKE)
+ if (what == PDF_STROKE)
{
- pdf_dropmaterial(&gstate->fill);
- pdf_keepmaterial(&gstate->stroke);
+ pdf_drop_material(&gstate->fill);
+ pdf_keep_material(&gstate->stroke);
gstate->fill = gstate->stroke;
}
}
else
{
// TODO: unset only the current fill/stroke or both?
- pdf_unsetpattern(csi, what);
+ pdf_unset_pattern(csi, what);
}
/* don't apply softmasks to objects in the pattern as well */
if (gstate->softmask)
{
- pdf_dropxobject(gstate->softmask);
- gstate->softmask = nil;
+ pdf_drop_xobject(gstate->softmask);
+ gstate->softmask = NULL;
}
- ptm = fz_concat(pat->matrix, csi->topctm);
- invptm = fz_invertmatrix(ptm);
+ ptm = fz_concat(pat->matrix, csi->top_ctm);
+ invptm = fz_invert_matrix(ptm);
/* patterns are painted using the ctm in effect at the beginning of the content stream */
/* get bbox of shape in pattern space for stamping */
- area = fz_transformrect(invptm, area);
+ area = fz_transform_rect(invptm, area);
x0 = floorf(area.x0 / pat->xstep);
y0 = floorf(area.y0 / pat->ystep);
x1 = ceilf(area.x1 / pat->xstep);
y1 = ceilf(area.y1 / pat->ystep);
- oldtopctm = csi->topctm;
+ oldtopctm = csi->top_ctm;
oldtop = csi->gtop;
#ifdef TILE
if ((x1 - x0) * (y1 - y0) > 0)
{
- csi->dev->begintile(csi->dev->user, area, pat->bbox, pat->xstep, pat->ystep, ptm);
+ csi->dev->begin_tile(csi->dev->user, area, pat->bbox, pat->xstep, pat->ystep, ptm);
gstate->ctm = ptm;
- csi->topctm = gstate->ctm;
- error = pdf_runcsibuffer(csi, pat->resources, pat->contents);
+ csi->top_ctm = gstate->ctm;
+ error = pdf_run_csi_buffer(csi, pat->resources, pat->contents);
if (error)
fz_catch(error, "cannot render pattern tile");
while (oldtop < csi->gtop)
pdf_grestore(csi);
- csi->dev->endtile(csi->dev->user);
+ csi->dev->end_tile(csi->dev->user);
}
#else
{
@@ -229,8 +229,8 @@ pdf_showpattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
for (x = x0; x < x1; x++)
{
gstate->ctm = fz_concat(fz_translate(x * pat->xstep, y * pat->ystep), ptm);
- csi->topctm = gstate->ctm;
- error = pdf_runcsibuffer(csi, pat->resources, pat->contents);
+ csi->top_ctm = gstate->ctm;
+ error = pdf_run_csi_buffer(csi, pat->resources, pat->contents);
while (oldtop < csi->gtop)
pdf_grestore(csi);
if (error)
@@ -244,13 +244,13 @@ pdf_showpattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
cleanup:
#endif
- csi->topctm = oldtopctm;
+ csi->top_ctm = oldtopctm;
pdf_grestore(csi);
}
static void
-pdf_begingroup(pdf_csi *csi, fz_rect bbox)
+pdf_begin_group(pdf_csi *csi, fz_rect bbox)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_error error;
@@ -258,164 +258,164 @@ pdf_begingroup(pdf_csi *csi, fz_rect bbox)
if (gstate->softmask)
{
pdf_xobject *softmask = gstate->softmask;
- fz_rect bbox = fz_transformrect(gstate->ctm, softmask->bbox);
+ fz_rect bbox = fz_transform_rect(gstate->ctm, softmask->bbox);
- gstate->softmask = nil;
+ gstate->softmask = NULL;
- csi->dev->beginmask(csi->dev->user, bbox, gstate->luminosity,
- softmask->colorspace, gstate->softmaskbc);
- error = pdf_runxobject(csi, nil, softmask, fz_identity);
+ csi->dev->begin_mask(csi->dev->user, bbox, gstate->luminosity,
+ softmask->colorspace, gstate->softmask_bc);
+ error = pdf_run_xobject(csi, NULL, softmask, fz_identity);
if (error)
fz_catch(error, "cannot run softmask");
- csi->dev->endmask(csi->dev->user);
+ csi->dev->end_mask(csi->dev->user);
gstate->softmask = softmask;
}
- if (gstate->blendmode != FZ_BNORMAL)
- csi->dev->begingroup(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1);
+ if (gstate->blendmode != FZ_BLEND_NORMAL)
+ csi->dev->begin_group(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1);
}
static void
-pdf_endgroup(pdf_csi *csi)
+pdf_end_group(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- if (gstate->blendmode != FZ_BNORMAL)
- csi->dev->endgroup(csi->dev->user);
+ if (gstate->blendmode != FZ_BLEND_NORMAL)
+ csi->dev->end_group(csi->dev->user);
if (gstate->softmask)
- csi->dev->popclip(csi->dev->user);
+ csi->dev->pop_clip(csi->dev->user);
}
void
-pdf_showshade(pdf_csi *csi, fz_shade *shd)
+pdf_show_shade(pdf_csi *csi, fz_shade *shd)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_rect bbox;
- bbox = fz_boundshade(shd, gstate->ctm);
+ bbox = fz_bound_shade(shd, gstate->ctm);
- pdf_begingroup(csi, bbox);
+ pdf_begin_group(csi, bbox);
- csi->dev->fillshade(csi->dev->user, shd, gstate->ctm, gstate->fill.alpha);
+ csi->dev->fill_shade(csi->dev->user, shd, gstate->ctm, gstate->fill.alpha);
- pdf_endgroup(csi);
+ pdf_end_group(csi);
}
void
-pdf_showimage(pdf_csi *csi, fz_pixmap *image)
+pdf_show_image(pdf_csi *csi, fz_pixmap *image)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_rect bbox;
- bbox = fz_transformrect(gstate->ctm, fz_unitrect);
+ bbox = fz_transform_rect(gstate->ctm, fz_unit_rect);
if (image->mask)
{
/* apply blend group even though we skip the softmask */
- if (gstate->blendmode != FZ_BNORMAL)
- csi->dev->begingroup(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1);
- csi->dev->clipimagemask(csi->dev->user, image->mask, gstate->ctm);
+ if (gstate->blendmode != FZ_BLEND_NORMAL)
+ csi->dev->begin_group(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1);
+ csi->dev->clip_image_mask(csi->dev->user, image->mask, gstate->ctm);
}
else
- pdf_begingroup(csi, bbox);
+ pdf_begin_group(csi, bbox);
if (!image->colorspace)
{
switch (gstate->fill.kind)
{
- case PDF_MNONE:
+ case PDF_MAT_NONE:
break;
- case PDF_MCOLOR:
- csi->dev->fillimagemask(csi->dev->user, image, gstate->ctm,
+ case PDF_MAT_COLOR:
+ csi->dev->fill_image_mask(csi->dev->user, image, gstate->ctm,
gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha);
break;
- case PDF_MPATTERN:
+ case PDF_MAT_PATTERN:
if (gstate->fill.pattern)
{
- csi->dev->clipimagemask(csi->dev->user, image, gstate->ctm);
- pdf_showpattern(csi, gstate->fill.pattern, bbox, PDF_MFILL);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_image_mask(csi->dev->user, image, gstate->ctm);
+ pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
- case PDF_MSHADE:
+ case PDF_MAT_SHADE:
if (gstate->fill.shade)
{
- csi->dev->clipimagemask(csi->dev->user, image, gstate->ctm);
- csi->dev->fillshade(csi->dev->user, gstate->fill.shade, gstate->ctm, gstate->fill.alpha);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_image_mask(csi->dev->user, image, gstate->ctm);
+ csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, gstate->ctm, gstate->fill.alpha);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
}
}
else
{
- csi->dev->fillimage(csi->dev->user, image, gstate->ctm, gstate->fill.alpha);
+ csi->dev->fill_image(csi->dev->user, image, gstate->ctm, gstate->fill.alpha);
}
if (image->mask)
{
- csi->dev->popclip(csi->dev->user);
- if (gstate->blendmode != FZ_BNORMAL)
- csi->dev->endgroup(csi->dev->user);
+ csi->dev->pop_clip(csi->dev->user);
+ if (gstate->blendmode != FZ_BLEND_NORMAL)
+ csi->dev->end_group(csi->dev->user);
}
else
- pdf_endgroup(csi);
+ pdf_end_group(csi);
}
void
-pdf_showpath(pdf_csi *csi, int doclose, int dofill, int dostroke, int evenodd)
+pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_path *path;
fz_rect bbox;
path = csi->path;
- csi->path = fz_newpath();
+ csi->path = fz_new_path();
if (doclose)
fz_closepath(path);
if (dostroke)
- bbox = fz_boundpath(path, &gstate->strokestate, gstate->ctm);
+ bbox = fz_bound_path(path, &gstate->stroke_state, gstate->ctm);
else
- bbox = fz_boundpath(path, nil, gstate->ctm);
+ bbox = fz_bound_path(path, NULL, gstate->ctm);
if (csi->clip)
{
- gstate->clipdepth++;
- csi->dev->clippath(csi->dev->user, path, evenodd, gstate->ctm);
+ gstate->clip_depth++;
+ csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm);
csi->clip = 0;
}
- pdf_begingroup(csi, bbox);
+ pdf_begin_group(csi, bbox);
if (dofill)
{
switch (gstate->fill.kind)
{
- case PDF_MNONE:
+ case PDF_MAT_NONE:
break;
- case PDF_MCOLOR:
- csi->dev->fillpath(csi->dev->user, path, evenodd, gstate->ctm,
+ case PDF_MAT_COLOR:
+ csi->dev->fill_path(csi->dev->user, path, even_odd, gstate->ctm,
gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha);
break;
- case PDF_MPATTERN:
+ case PDF_MAT_PATTERN:
if (gstate->fill.pattern)
{
- csi->dev->clippath(csi->dev->user, path, evenodd, gstate->ctm);
- pdf_showpattern(csi, gstate->fill.pattern, bbox, PDF_MFILL);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm);
+ pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
- case PDF_MSHADE:
+ case PDF_MAT_SHADE:
if (gstate->fill.shade)
{
- csi->dev->clippath(csi->dev->user, path, evenodd, gstate->ctm);
- csi->dev->fillshade(csi->dev->user, gstate->fill.shade, csi->topctm, gstate->fill.alpha);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm);
+ csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
}
@@ -425,38 +425,38 @@ pdf_showpath(pdf_csi *csi, int doclose, int dofill, int dostroke, int evenodd)
{
switch (gstate->stroke.kind)
{
- case PDF_MNONE:
+ case PDF_MAT_NONE:
break;
- case PDF_MCOLOR:
- csi->dev->strokepath(csi->dev->user, path, &gstate->strokestate, gstate->ctm,
+ case PDF_MAT_COLOR:
+ csi->dev->stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm,
gstate->stroke.colorspace, gstate->stroke.v, gstate->stroke.alpha);
break;
- case PDF_MPATTERN:
+ case PDF_MAT_PATTERN:
if (gstate->stroke.pattern)
{
- csi->dev->clipstrokepath(csi->dev->user, path, &gstate->strokestate, gstate->ctm);
- pdf_showpattern(csi, gstate->stroke.pattern, bbox, PDF_MFILL);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm);
+ pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
- case PDF_MSHADE:
+ case PDF_MAT_SHADE:
if (gstate->stroke.shade)
{
- csi->dev->clipstrokepath(csi->dev->user, path, &gstate->strokestate, gstate->ctm);
- csi->dev->fillshade(csi->dev->user, gstate->stroke.shade, csi->topctm, gstate->stroke.alpha);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm);
+ csi->dev->fill_shade(csi->dev->user, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
}
}
- pdf_endgroup(csi);
+ pdf_end_group(csi);
- fz_freepath(path);
+ fz_free_path(path);
}
void
-pdf_flushtext(pdf_csi *csi)
+pdf_flush_text(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_text *text;
@@ -469,10 +469,10 @@ pdf_flushtext(pdf_csi *csi)
if (!csi->text)
return;
text = csi->text;
- csi->text = nil;
+ csi->text = NULL;
dofill = dostroke = doclip = doinvisible = 0;
- switch (csi->textmode)
+ switch (csi->text_mode)
{
case 0: dofill = 1; break;
case 1: dostroke = 1; break;
@@ -484,18 +484,18 @@ pdf_flushtext(pdf_csi *csi)
case 7: doclip = 1; break;
}
- bbox = fz_boundtext(text, gstate->ctm);
+ bbox = fz_bound_text(text, gstate->ctm);
- pdf_begingroup(csi, bbox);
+ pdf_begin_group(csi, bbox);
if (doinvisible)
- csi->dev->ignoretext(csi->dev->user, text, gstate->ctm);
+ csi->dev->ignore_text(csi->dev->user, text, gstate->ctm);
if (doclip)
{
if (csi->accumulate < 2)
- gstate->clipdepth++;
- csi->dev->cliptext(csi->dev->user, text, gstate->ctm, csi->accumulate);
+ gstate->clip_depth++;
+ csi->dev->clip_text(csi->dev->user, text, gstate->ctm, csi->accumulate);
csi->accumulate = 2;
}
@@ -503,26 +503,26 @@ pdf_flushtext(pdf_csi *csi)
{
switch (gstate->fill.kind)
{
- case PDF_MNONE:
+ case PDF_MAT_NONE:
break;
- case PDF_MCOLOR:
- csi->dev->filltext(csi->dev->user, text, gstate->ctm,
+ case PDF_MAT_COLOR:
+ csi->dev->fill_text(csi->dev->user, text, gstate->ctm,
gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha);
break;
- case PDF_MPATTERN:
+ case PDF_MAT_PATTERN:
if (gstate->fill.pattern)
{
- csi->dev->cliptext(csi->dev->user, text, gstate->ctm, 0);
- pdf_showpattern(csi, gstate->fill.pattern, bbox, PDF_MFILL);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_text(csi->dev->user, text, gstate->ctm, 0);
+ pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
- case PDF_MSHADE:
+ case PDF_MAT_SHADE:
if (gstate->fill.shade)
{
- csi->dev->cliptext(csi->dev->user, text, gstate->ctm, 0);
- csi->dev->fillshade(csi->dev->user, gstate->fill.shade, csi->topctm, gstate->fill.alpha);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_text(csi->dev->user, text, gstate->ctm, 0);
+ csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
}
@@ -532,41 +532,41 @@ pdf_flushtext(pdf_csi *csi)
{
switch (gstate->stroke.kind)
{
- case PDF_MNONE:
+ case PDF_MAT_NONE:
break;
- case PDF_MCOLOR:
- csi->dev->stroketext(csi->dev->user, text, &gstate->strokestate, gstate->ctm,
+ case PDF_MAT_COLOR:
+ csi->dev->stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm,
gstate->stroke.colorspace, gstate->stroke.v, gstate->stroke.alpha);
break;
- case PDF_MPATTERN:
+ case PDF_MAT_PATTERN:
if (gstate->stroke.pattern)
{
- csi->dev->clipstroketext(csi->dev->user, text, &gstate->strokestate, gstate->ctm);
- pdf_showpattern(csi, gstate->stroke.pattern, bbox, PDF_MFILL);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm);
+ pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
- case PDF_MSHADE:
+ case PDF_MAT_SHADE:
if (gstate->stroke.shade)
{
- csi->dev->clipstroketext(csi->dev->user, text, &gstate->strokestate, gstate->ctm);
- csi->dev->fillshade(csi->dev->user, gstate->stroke.shade, csi->topctm, gstate->stroke.alpha);
- csi->dev->popclip(csi->dev->user);
+ csi->dev->clip_stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm);
+ csi->dev->fill_shade(csi->dev->user, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha);
+ csi->dev->pop_clip(csi->dev->user);
}
break;
}
}
- pdf_endgroup(csi);
+ pdf_end_group(csi);
- fz_freetext(text);
+ fz_free_text(text);
}
static void
-pdf_showglyph(pdf_csi *csi, int cid)
+pdf_show_glyph(pdf_csi *csi, int cid)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- pdf_fontdesc *fontdesc = gstate->font;
+ pdf_font_desc *fontdesc = gstate->font;
fz_matrix tsm, trm;
float w0, w1, tx, ty;
pdf_hmtx h;
@@ -584,11 +584,11 @@ pdf_showglyph(pdf_csi *csi, int cid)
tsm.f = gstate->rise;
ucslen = 0;
- if (fontdesc->tounicode)
- ucslen = pdf_lookupcmapfull(fontdesc->tounicode, cid, ucsbuf);
- if (ucslen == 0 && cid < fontdesc->ncidtoucs)
+ if (fontdesc->to_unicode)
+ ucslen = pdf_lookup_cmap_full(fontdesc->to_unicode, cid, ucsbuf);
+ if (ucslen == 0 && cid < fontdesc->cid_to_ucs_len)
{
- ucsbuf[0] = fontdesc->cidtoucs[cid];
+ ucsbuf[0] = fontdesc->cid_to_ucs[cid];
ucslen = 1;
}
if (ucslen == 0 || (ucslen == 1 && ucsbuf[0] == 0))
@@ -597,11 +597,11 @@ pdf_showglyph(pdf_csi *csi, int cid)
ucslen = 1;
}
- gid = pdf_fontcidtogid(fontdesc, cid);
+ gid = pdf_font_cid_to_gid(fontdesc, cid);
if (fontdesc->wmode == 1)
{
- v = pdf_getvmtx(fontdesc, cid);
+ v = pdf_get_vmtx(fontdesc, cid);
tsm.e -= v.x * gstate->size * 0.001f;
tsm.f -= v.y * gstate->size * 0.001f;
}
@@ -616,44 +616,44 @@ pdf_showglyph(pdf_csi *csi, int cid)
fabsf(trm.b - csi->text->trm.b) > FLT_EPSILON ||
fabsf(trm.c - csi->text->trm.c) > FLT_EPSILON ||
fabsf(trm.d - csi->text->trm.d) > FLT_EPSILON ||
- gstate->render != csi->textmode)
+ gstate->render != csi->text_mode)
{
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
- csi->text = fz_newtext(fontdesc->font, trm, fontdesc->wmode);
+ csi->text = fz_new_text(fontdesc->font, trm, fontdesc->wmode);
csi->text->trm.e = 0;
csi->text->trm.f = 0;
- csi->textmode = gstate->render;
+ csi->text_mode = gstate->render;
}
/* add glyph to textobject */
- fz_addtext(csi->text, gid, ucsbuf[0], trm.e, trm.f);
+ fz_add_text(csi->text, gid, ucsbuf[0], trm.e, trm.f);
/* add filler glyphs for one-to-many unicode mapping */
for (i = 1; i < ucslen; i++)
- fz_addtext(csi->text, -1, ucsbuf[i], trm.e, trm.f);
+ fz_add_text(csi->text, -1, ucsbuf[i], trm.e, trm.f);
if (fontdesc->wmode == 0)
{
- h = pdf_gethmtx(fontdesc, cid);
+ h = pdf_get_hmtx(fontdesc, cid);
w0 = h.w * 0.001f;
- tx = (w0 * gstate->size + gstate->charspace) * gstate->scale;
+ tx = (w0 * gstate->size + gstate->char_space) * gstate->scale;
csi->tm = fz_concat(fz_translate(tx, 0), csi->tm);
}
if (fontdesc->wmode == 1)
{
w1 = v.w * 0.001f;
- ty = w1 * gstate->size + gstate->charspace;
+ ty = w1 * gstate->size + gstate->char_space;
csi->tm = fz_concat(fz_translate(0, ty), csi->tm);
}
}
void
-pdf_showspace(pdf_csi *csi, float tadj)
+pdf_show_space(pdf_csi *csi, float tadj)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- pdf_fontdesc *fontdesc = gstate->font;
+ pdf_font_desc *fontdesc = gstate->font;
if (!fontdesc)
{
@@ -668,10 +668,10 @@ pdf_showspace(pdf_csi *csi, float tadj)
}
void
-pdf_showstring(pdf_csi *csi, unsigned char *buf, int len)
+pdf_show_string(pdf_csi *csi, unsigned char *buf, int len)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- pdf_fontdesc *fontdesc = gstate->font;
+ pdf_font_desc *fontdesc = gstate->font;
unsigned char *end = buf + len;
int cpt, cid;
@@ -683,36 +683,36 @@ pdf_showstring(pdf_csi *csi, unsigned char *buf, int len)
while (buf < end)
{
- buf = pdf_decodecmap(fontdesc->encoding, buf, &cpt);
- cid = pdf_lookupcmap(fontdesc->encoding, cpt);
+ buf = pdf_decode_cmap(fontdesc->encoding, buf, &cpt);
+ cid = pdf_lookup_cmap(fontdesc->encoding, cpt);
if (cid >= 0)
- pdf_showglyph(csi, cid);
+ pdf_show_glyph(csi, cid);
else
fz_warn("cannot encode character with code point %#x", cpt);
if (cpt == 32)
- pdf_showspace(csi, gstate->wordspace);
+ pdf_show_space(csi, gstate->word_space);
}
}
void
-pdf_showtext(pdf_csi *csi, fz_obj *text)
+pdf_show_text(pdf_csi *csi, fz_obj *text)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
int i;
- if (fz_isarray(text))
+ if (fz_is_array(text))
{
- for (i = 0; i < fz_arraylen(text); i++)
+ for (i = 0; i < fz_array_len(text); i++)
{
- fz_obj *item = fz_arrayget(text, i);
- if (fz_isstring(item))
- pdf_showstring(csi, (unsigned char *)fz_tostrbuf(item), fz_tostrlen(item));
+ fz_obj *item = fz_array_get(text, i);
+ if (fz_is_string(item))
+ pdf_show_string(csi, (unsigned char *)fz_to_str_buf(item), fz_to_str_len(item));
else
- pdf_showspace(csi, - fz_toreal(item) * gstate->size * 0.001f);
+ pdf_show_space(csi, - fz_to_real(item) * gstate->size * 0.001f);
}
}
- else if (fz_isstring(text))
+ else if (fz_is_string(text))
{
- pdf_showstring(csi, (unsigned char *)fz_tostrbuf(text), fz_tostrlen(text));
+ pdf_show_string(csi, (unsigned char *)fz_to_str_buf(text), fz_to_str_len(text));
}
}
diff --git a/pdf/pdf_cmap.c b/pdf/pdf_cmap.c
index aab6bd60..a526dc4e 100644
--- a/pdf/pdf_cmap.c
+++ b/pdf/pdf_cmap.c
@@ -18,43 +18,43 @@
#include "fitz.h"
#include "mupdf.h"
-/* Macros for accessing the combined extentflags field */
-#define pdf_range_high(r) ((r)->low + ((r)->extentflags >> 2))
-#define pdf_range_flags(r) ((r)->extentflags & 3)
-#define pdf_range_set_high(r, h) ((r)->extentflags = (((r)->extentflags & 3) | ((h - (r)->low) << 2)))
-#define pdf_range_set_flags(r, f) ((r)->extentflags = (((r)->extentflags & ~3) | f))
+/* Macros for accessing the combined extent_flags field */
+#define pdf_range_high(r) ((r)->low + ((r)->extent_flags >> 2))
+#define pdf_range_flags(r) ((r)->extent_flags & 3)
+#define pdf_range_set_high(r, h) ((r)->extent_flags = (((r)->extent_flags & 3) | ((h - (r)->low) << 2)))
+#define pdf_range_set_flags(r, f) ((r)->extent_flags = (((r)->extent_flags & ~3) | f))
/*
* Allocate, destroy and simple parameters.
*/
pdf_cmap *
-pdf_newcmap(void)
+pdf_new_cmap(void)
{
pdf_cmap *cmap;
cmap = fz_malloc(sizeof(pdf_cmap));
cmap->refs = 1;
- strcpy(cmap->cmapname, "");
- strcpy(cmap->usecmapname, "");
- cmap->usecmap = nil;
+ strcpy(cmap->cmap_name, "");
+ strcpy(cmap->usecmap_name, "");
+ cmap->usecmap = NULL;
cmap->wmode = 0;
- cmap->ncspace = 0;
+ cmap->codespace_len = 0;
cmap->rlen = 0;
cmap->rcap = 0;
- cmap->ranges = nil;
+ cmap->ranges = NULL;
cmap->tlen = 0;
cmap->tcap = 0;
- cmap->table = nil;
+ cmap->table = NULL;
return cmap;
}
pdf_cmap *
-pdf_keepcmap(pdf_cmap *cmap)
+pdf_keep_cmap(pdf_cmap *cmap)
{
if (cmap->refs >= 0)
cmap->refs ++;
@@ -62,14 +62,14 @@ pdf_keepcmap(pdf_cmap *cmap)
}
void
-pdf_dropcmap(pdf_cmap *cmap)
+pdf_drop_cmap(pdf_cmap *cmap)
{
if (cmap->refs >= 0)
{
if (--cmap->refs == 0)
{
if (cmap->usecmap)
- pdf_dropcmap(cmap->usecmap);
+ pdf_drop_cmap(cmap->usecmap);
fz_free(cmap->ranges);
fz_free(cmap->table);
fz_free(cmap);
@@ -78,52 +78,52 @@ pdf_dropcmap(pdf_cmap *cmap)
}
void
-pdf_setusecmap(pdf_cmap *cmap, pdf_cmap *usecmap)
+pdf_set_usecmap(pdf_cmap *cmap, pdf_cmap *usecmap)
{
int i;
if (cmap->usecmap)
- pdf_dropcmap(cmap->usecmap);
- cmap->usecmap = pdf_keepcmap(usecmap);
+ pdf_drop_cmap(cmap->usecmap);
+ cmap->usecmap = pdf_keep_cmap(usecmap);
- if (cmap->ncspace == 0)
+ if (cmap->codespace_len == 0)
{
- cmap->ncspace = usecmap->ncspace;
- for (i = 0; i < usecmap->ncspace; i++)
- cmap->cspace[i] = usecmap->cspace[i];
+ cmap->codespace_len = usecmap->codespace_len;
+ for (i = 0; i < usecmap->codespace_len; i++)
+ cmap->codespace[i] = usecmap->codespace[i];
}
}
int
-pdf_getwmode(pdf_cmap *cmap)
+pdf_get_wmode(pdf_cmap *cmap)
{
return cmap->wmode;
}
void
-pdf_setwmode(pdf_cmap *cmap, int wmode)
+pdf_set_wmode(pdf_cmap *cmap, int wmode)
{
cmap->wmode = wmode;
}
void
-pdf_debugcmap(pdf_cmap *cmap)
+pdf_debug_cmap(pdf_cmap *cmap)
{
int i, k, n;
- printf("cmap $%p /%s {\n", (void *) cmap, cmap->cmapname);
+ printf("cmap $%p /%s {\n", (void *) cmap, cmap->cmap_name);
- if (cmap->usecmapname[0])
- printf("\tusecmap /%s\n", cmap->usecmapname);
+ if (cmap->usecmap_name[0])
+ printf("\tusecmap /%s\n", cmap->usecmap_name);
if (cmap->usecmap)
printf("\tusecmap $%p\n", (void *) cmap->usecmap);
printf("\twmode %d\n", cmap->wmode);
printf("\tcodespaces {\n");
- for (i = 0; i < cmap->ncspace; i++)
+ for (i = 0; i < cmap->codespace_len; i++)
{
- printf("\t\t<%x> <%x>\n", cmap->cspace[i].low, cmap->cspace[i].high);
+ printf("\t\t<%x> <%x>\n", cmap->codespace[i].low, cmap->codespace[i].high);
}
printf("\t}\n");
@@ -155,29 +155,29 @@ pdf_debugcmap(pdf_cmap *cmap)
/*
* Add a codespacerange section.
- * These ranges are used by pdf_decodecmap to decode
+ * These ranges are used by pdf_decode_cmap to decode
* multi-byte encoded strings.
*/
void
-pdf_addcodespace(pdf_cmap *cmap, int low, int high, int n)
+pdf_add_codespace(pdf_cmap *cmap, int low, int high, int n)
{
- if (cmap->ncspace + 1 == nelem(cmap->cspace))
+ if (cmap->codespace_len + 1 == nelem(cmap->codespace))
{
fz_warn("assert: too many code space ranges");
return;
}
- cmap->cspace[cmap->ncspace].n = n;
- cmap->cspace[cmap->ncspace].low = low;
- cmap->cspace[cmap->ncspace].high = high;
- cmap->ncspace ++;
+ cmap->codespace[cmap->codespace_len].n = n;
+ cmap->codespace[cmap->codespace_len].low = low;
+ cmap->codespace[cmap->codespace_len].high = high;
+ cmap->codespace_len ++;
}
/*
* Add an integer to the table.
*/
static void
-addtable(pdf_cmap *cmap, int value)
+add_table(pdf_cmap *cmap, int value)
{
if (cmap->tlen + 1 > cmap->tcap)
{
@@ -191,13 +191,13 @@ addtable(pdf_cmap *cmap, int value)
* Add a range.
*/
static void
-addrange(pdf_cmap *cmap, int low, int high, int flag, int offset)
+add_range(pdf_cmap *cmap, int low, int high, int flag, int offset)
{
/* If the range is too large to be represented, split it */
if (high - low > 0x3fff)
{
- addrange(cmap, low, low+0x3fff, flag, offset);
- addrange(cmap, low+0x3fff, high, flag, offset+0x3fff);
+ add_range(cmap, low, low+0x3fff, flag, offset);
+ add_range(cmap, low+0x3fff, high, flag, offset+0x3fff);
return;
}
if (cmap->rlen + 1 > cmap->rcap)
@@ -216,36 +216,36 @@ addrange(pdf_cmap *cmap, int low, int high, int flag, int offset)
* Add a range-to-table mapping.
*/
void
-pdf_maprangetotable(pdf_cmap *cmap, int low, int *table, int len)
+pdf_map_range_to_table(pdf_cmap *cmap, int low, int *table, int len)
{
int i;
int high = low + len;
int offset = cmap->tlen;
for (i = 0; i < len; i++)
- addtable(cmap, table[i]);
- addrange(cmap, low, high, PDF_CMAP_TABLE, offset);
+ add_table(cmap, table[i]);
+ add_range(cmap, low, high, PDF_CMAP_TABLE, offset);
}
/*
* Add a range of contiguous one-to-one mappings (ie 1..5 maps to 21..25)
*/
void
-pdf_maprangetorange(pdf_cmap *cmap, int low, int high, int offset)
+pdf_map_range_to_range(pdf_cmap *cmap, int low, int high, int offset)
{
- addrange(cmap, low, high, high - low == 0 ? PDF_CMAP_SINGLE : PDF_CMAP_RANGE, offset);
+ add_range(cmap, low, high, high - low == 0 ? PDF_CMAP_SINGLE : PDF_CMAP_RANGE, offset);
}
/*
* Add a single one-to-many mapping.
*/
void
-pdf_maponetomany(pdf_cmap *cmap, int low, int *values, int len)
+pdf_map_one_to_many(pdf_cmap *cmap, int low, int *values, int len)
{
int offset, i;
if (len == 1)
{
- addrange(cmap, low, low, PDF_CMAP_SINGLE, values[0]);
+ add_range(cmap, low, low, PDF_CMAP_SINGLE, values[0]);
return;
}
@@ -256,10 +256,10 @@ pdf_maponetomany(pdf_cmap *cmap, int low, int *values, int len)
}
offset = cmap->tlen;
- addtable(cmap, len);
+ add_table(cmap, len);
for (i = 0; i < len; i++)
- addtable(cmap, values[i]);
- addrange(cmap, low, low, PDF_CMAP_MULTI, offset);
+ add_table(cmap, values[i]);
+ add_range(cmap, low, low, PDF_CMAP_MULTI, offset);
}
/*
@@ -274,7 +274,7 @@ static int cmprange(const void *va, const void *vb)
}
void
-pdf_sortcmap(pdf_cmap *cmap)
+pdf_sort_cmap(pdf_cmap *cmap)
{
pdf_range *a; /* last written range on output */
pdf_range *b; /* current range examined on input */
@@ -312,7 +312,7 @@ pdf_sortcmap(pdf_cmap *cmap)
else if (pdf_range_flags(a) == PDF_CMAP_TABLE && pdf_range_flags(b) == PDF_CMAP_SINGLE)
{
pdf_range_set_high(a, pdf_range_high(b));
- addtable(cmap, b->offset);
+ add_table(cmap, b->offset);
}
/* LR -> LR */
@@ -336,8 +336,8 @@ pdf_sortcmap(pdf_cmap *cmap)
{
pdf_range_set_flags(a, PDF_CMAP_TABLE);
pdf_range_set_high(a, pdf_range_high(b));
- addtable(cmap, a->offset);
- addtable(cmap, b->offset);
+ add_table(cmap, a->offset);
+ add_table(cmap, b->offset);
a->offset = cmap->tlen - 2;
}
@@ -345,7 +345,7 @@ pdf_sortcmap(pdf_cmap *cmap)
else if (pdf_range_flags(a) == PDF_CMAP_TABLE && pdf_range_flags(b) == PDF_CMAP_SINGLE)
{
pdf_range_set_high(a, pdf_range_high(b));
- addtable(cmap, b->offset);
+ add_table(cmap, b->offset);
}
/* XX -> XX */
@@ -370,7 +370,7 @@ pdf_sortcmap(pdf_cmap *cmap)
* Lookup the mapping of a codepoint.
*/
int
-pdf_lookupcmap(pdf_cmap *cmap, int cpt)
+pdf_lookup_cmap(pdf_cmap *cmap, int cpt)
{
int l = 0;
int r = cmap->rlen - 1;
@@ -395,13 +395,13 @@ pdf_lookupcmap(pdf_cmap *cmap, int cpt)
}
if (cmap->usecmap)
- return pdf_lookupcmap(cmap->usecmap, cpt);
+ return pdf_lookup_cmap(cmap->usecmap, cpt);
return -1;
}
int
-pdf_lookupcmapfull(pdf_cmap *cmap, int cpt, int *out)
+pdf_lookup_cmap_full(pdf_cmap *cmap, int cpt, int *out)
{
int i, k, n;
int l = 0;
@@ -439,7 +439,7 @@ pdf_lookupcmapfull(pdf_cmap *cmap, int cpt, int *out)
}
if (cmap->usecmap)
- return pdf_lookupcmapfull(cmap->usecmap, cpt, out);
+ return pdf_lookup_cmap_full(cmap->usecmap, cpt, out);
return 0;
}
@@ -449,7 +449,7 @@ pdf_lookupcmapfull(pdf_cmap *cmap, int cpt, int *out)
* multi-byte encoded string.
*/
unsigned char *
-pdf_decodecmap(pdf_cmap *cmap, unsigned char *buf, int *cpt)
+pdf_decode_cmap(pdf_cmap *cmap, unsigned char *buf, int *cpt)
{
int k, n, c;
@@ -457,11 +457,11 @@ pdf_decodecmap(pdf_cmap *cmap, unsigned char *buf, int *cpt)
for (n = 0; n < 4; n++)
{
c = (c << 8) | buf[n];
- for (k = 0; k < cmap->ncspace; k++)
+ for (k = 0; k < cmap->codespace_len; k++)
{
- if (cmap->cspace[k].n == n + 1)
+ if (cmap->codespace[k].n == n + 1)
{
- if (c >= cmap->cspace[k].low && c <= cmap->cspace[k].high)
+ if (c >= cmap->codespace[k].low && c <= cmap->codespace[k].high)
{
*cpt = c;
return buf + n + 1;
diff --git a/pdf/pdf_cmap_load.c b/pdf/pdf_cmap_load.c
index eae52d8d..f6ea4bf8 100644
--- a/pdf/pdf_cmap_load.c
+++ b/pdf/pdf_cmap_load.c
@@ -5,75 +5,75 @@
* Load CMap stream in PDF file
*/
fz_error
-pdf_loadembeddedcmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *stmobj)
+pdf_load_embedded_cmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *stmobj)
{
fz_error error = fz_okay;
- fz_stream *file = nil;
- pdf_cmap *cmap = nil;
+ fz_stream *file = NULL;
+ pdf_cmap *cmap = NULL;
pdf_cmap *usecmap;
fz_obj *wmode;
fz_obj *obj;
- if ((*cmapp = pdf_finditem(xref->store, pdf_dropcmap, stmobj)))
+ if ((*cmapp = pdf_find_item(xref->store, pdf_drop_cmap, stmobj)))
{
- pdf_keepcmap(*cmapp);
+ pdf_keep_cmap(*cmapp);
return fz_okay;
}
- pdf_logfont("load embedded cmap (%d %d R) {\n", fz_tonum(stmobj), fz_togen(stmobj));
+ pdf_log_font("load embedded cmap (%d %d R) {\n", fz_to_num(stmobj), fz_to_gen(stmobj));
- error = pdf_openstream(&file, xref, fz_tonum(stmobj), fz_togen(stmobj));
+ error = pdf_open_stream(&file, xref, fz_to_num(stmobj), fz_to_gen(stmobj));
if (error)
{
- error = fz_rethrow(error, "cannot open cmap stream (%d %d R)", fz_tonum(stmobj), fz_togen(stmobj));
+ error = fz_rethrow(error, "cannot open cmap stream (%d %d R)", fz_to_num(stmobj), fz_to_gen(stmobj));
goto cleanup;
}
- error = pdf_parsecmap(&cmap, file);
+ error = pdf_parse_cmap(&cmap, file);
if (error)
{
- error = fz_rethrow(error, "cannot parse cmap stream (%d %d R)", fz_tonum(stmobj), fz_togen(stmobj));
+ error = fz_rethrow(error, "cannot parse cmap stream (%d %d R)", fz_to_num(stmobj), fz_to_gen(stmobj));
goto cleanup;
}
fz_close(file);
- wmode = fz_dictgets(stmobj, "WMode");
- if (fz_isint(wmode))
+ wmode = fz_dict_gets(stmobj, "WMode");
+ if (fz_is_int(wmode))
{
- pdf_logfont("wmode %d\n", wmode);
- pdf_setwmode(cmap, fz_toint(wmode));
+ pdf_log_font("wmode %d\n", wmode);
+ pdf_set_wmode(cmap, fz_to_int(wmode));
}
- obj = fz_dictgets(stmobj, "UseCMap");
- if (fz_isname(obj))
+ obj = fz_dict_gets(stmobj, "UseCMap");
+ if (fz_is_name(obj))
{
- pdf_logfont("usecmap /%s\n", fz_toname(obj));
- error = pdf_loadsystemcmap(&usecmap, fz_toname(obj));
+ pdf_log_font("usecmap /%s\n", fz_to_name(obj));
+ error = pdf_load_system_cmap(&usecmap, fz_to_name(obj));
if (error)
{
- error = fz_rethrow(error, "cannot load system usecmap '%s'", fz_toname(obj));
+ error = fz_rethrow(error, "cannot load system usecmap '%s'", fz_to_name(obj));
goto cleanup;
}
- pdf_setusecmap(cmap, usecmap);
- pdf_dropcmap(usecmap);
+ pdf_set_usecmap(cmap, usecmap);
+ pdf_drop_cmap(usecmap);
}
- else if (fz_isindirect(obj))
+ else if (fz_is_indirect(obj))
{
- pdf_logfont("usecmap (%d %d R)\n", fz_tonum(obj), fz_togen(obj));
- error = pdf_loadembeddedcmap(&usecmap, xref, obj);
+ pdf_log_font("usecmap (%d %d R)\n", fz_to_num(obj), fz_to_gen(obj));
+ error = pdf_load_embedded_cmap(&usecmap, xref, obj);
if (error)
{
- error = fz_rethrow(error, "cannot load embedded usecmap (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ error = fz_rethrow(error, "cannot load embedded usecmap (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
goto cleanup;
}
- pdf_setusecmap(cmap, usecmap);
- pdf_dropcmap(usecmap);
+ pdf_set_usecmap(cmap, usecmap);
+ pdf_drop_cmap(usecmap);
}
- pdf_logfont("}\n");
+ pdf_log_font("}\n");
- pdf_storeitem(xref->store, pdf_keepcmap, pdf_dropcmap, stmobj, cmap);
+ pdf_store_item(xref->store, pdf_keep_cmap, pdf_drop_cmap, stmobj, cmap);
*cmapp = cmap;
return fz_okay;
@@ -82,7 +82,7 @@ cleanup:
if (file)
fz_close(file);
if (cmap)
- pdf_dropcmap(cmap);
+ pdf_drop_cmap(cmap);
return error; /* already rethrown */
}
@@ -90,14 +90,14 @@ cleanup:
* Create an Identity-* CMap (for both 1 and 2-byte encodings)
*/
pdf_cmap *
-pdf_newidentitycmap(int wmode, int bytes)
+pdf_new_identity_cmap(int wmode, int bytes)
{
- pdf_cmap *cmap = pdf_newcmap();
- sprintf(cmap->cmapname, "Identity-%c", wmode ? 'V' : 'H');
- pdf_addcodespace(cmap, 0x0000, 0xffff, bytes);
- pdf_maprangetorange(cmap, 0x0000, 0xffff, 0);
- pdf_sortcmap(cmap);
- pdf_setwmode(cmap, wmode);
+ pdf_cmap *cmap = pdf_new_cmap();
+ sprintf(cmap->cmap_name, "Identity-%c", wmode ? 'V' : 'H');
+ pdf_add_codespace(cmap, 0x0000, 0xffff, bytes);
+ pdf_map_range_to_range(cmap, 0x0000, 0xffff, 0);
+ pdf_sort_cmap(cmap);
+ pdf_set_wmode(cmap, wmode);
return cmap;
}
@@ -105,31 +105,31 @@ pdf_newidentitycmap(int wmode, int bytes)
* Load predefined CMap from system.
*/
fz_error
-pdf_loadsystemcmap(pdf_cmap **cmapp, char *cmapname)
+pdf_load_system_cmap(pdf_cmap **cmapp, char *cmap_name)
{
fz_error error;
pdf_cmap *usecmap;
pdf_cmap *cmap;
int i;
- pdf_logfont("loading system cmap %s\n", cmapname);
+ pdf_log_font("loading system cmap %s\n", cmap_name);
- for (i = 0; pdf_cmaptable[i]; i++)
+ for (i = 0; pdf_cmap_table[i]; i++)
{
- if (!strcmp(cmapname, pdf_cmaptable[i]->cmapname))
+ if (!strcmp(cmap_name, pdf_cmap_table[i]->cmap_name))
{
- cmap = pdf_cmaptable[i];
- if (cmap->usecmapname[0] && !cmap->usecmap)
+ cmap = pdf_cmap_table[i];
+ if (cmap->usecmap_name[0] && !cmap->usecmap)
{
- error = pdf_loadsystemcmap(&usecmap, cmap->usecmapname);
+ error = pdf_load_system_cmap(&usecmap, cmap->usecmap_name);
if (error)
- return fz_rethrow(error, "cannot load usecmap: %s", cmap->usecmapname);
- pdf_setusecmap(cmap, usecmap);
+ return fz_rethrow(error, "cannot load usecmap: %s", cmap->usecmap_name);
+ pdf_set_usecmap(cmap, usecmap);
}
*cmapp = cmap;
return fz_okay;
}
}
- return fz_throw("no builtin cmap file: %s", cmapname);
+ return fz_throw("no builtin cmap file: %s", cmap_name);
}
diff --git a/pdf/pdf_cmap_parse.c b/pdf/pdf_cmap_parse.c
index d899af0e..edd97de8 100644
--- a/pdf/pdf_cmap_parse.c
+++ b/pdf/pdf_cmap_parse.c
@@ -7,40 +7,40 @@
enum
{
- TUSECMAP = PDF_NTOKENS,
- TBEGINCODESPACERANGE,
- TENDCODESPACERANGE,
- TBEGINBFCHAR,
- TENDBFCHAR,
- TBEGINBFRANGE,
- TENDBFRANGE,
- TBEGINCIDCHAR,
- TENDCIDCHAR,
- TBEGINCIDRANGE,
- TENDCIDRANGE,
- TENDCMAP
+ TOK_USECMAP = PDF_NUM_TOKENS,
+ TOK_BEGIN_CODESPACE_RANGE,
+ TOK_END_CODESPACE_RANGE,
+ TOK_BEGIN_BF_CHAR,
+ TOK_END_BF_CHAR,
+ TOK_BEGIN_BF_RANGE,
+ TOK_END_BF_RANGE,
+ TOK_BEGIN_CID_CHAR,
+ TOK_END_CID_CHAR,
+ TOK_BEGIN_CID_RANGE,
+ TOK_END_CID_RANGE,
+ TOK_END_CMAP
};
static int
-pdf_cmaptokenfromkeyword(char *key)
+pdf_cmap_token_from_keyword(char *key)
{
- if (!strcmp(key, "usecmap")) return TUSECMAP;
- if (!strcmp(key, "begincodespacerange")) return TBEGINCODESPACERANGE;
- if (!strcmp(key, "endcodespacerange")) return TENDCODESPACERANGE;
- if (!strcmp(key, "beginbfchar")) return TBEGINBFCHAR;
- if (!strcmp(key, "endbfchar")) return TENDBFCHAR;
- if (!strcmp(key, "beginbfrange")) return TBEGINBFRANGE;
- if (!strcmp(key, "endbfrange")) return TENDBFRANGE;
- if (!strcmp(key, "begincidchar")) return TBEGINCIDCHAR;
- if (!strcmp(key, "endcidchar")) return TENDCIDCHAR;
- if (!strcmp(key, "begincidrange")) return TBEGINCIDRANGE;
- if (!strcmp(key, "endcidrange")) return TENDCIDRANGE;
- if (!strcmp(key, "endcmap")) return TENDCMAP;
- return PDF_TKEYWORD;
+ if (!strcmp(key, "usecmap")) return TOK_USECMAP;
+ if (!strcmp(key, "begincodespacerange")) return TOK_BEGIN_CODESPACE_RANGE;
+ if (!strcmp(key, "endcodespacerange")) return TOK_END_CODESPACE_RANGE;
+ if (!strcmp(key, "beginbfchar")) return TOK_BEGIN_BF_CHAR;
+ if (!strcmp(key, "endbfchar")) return TOK_END_BF_CHAR;
+ if (!strcmp(key, "beginbfrange")) return TOK_BEGIN_BF_RANGE;
+ if (!strcmp(key, "endbfrange")) return TOK_END_BF_RANGE;
+ if (!strcmp(key, "begincidchar")) return TOK_BEGIN_CID_CHAR;
+ if (!strcmp(key, "endcidchar")) return TOK_END_CID_CHAR;
+ if (!strcmp(key, "begincidrange")) return TOK_BEGIN_CID_RANGE;
+ if (!strcmp(key, "endcidrange")) return TOK_END_CID_RANGE;
+ if (!strcmp(key, "endcmap")) return TOK_END_CMAP;
+ return PDF_TOK_KEYWORD;
}
static int
-pdf_codefromstring(char *buf, int len)
+pdf_code_from_string(char *buf, int len)
{
int a = 0;
while (len--)
@@ -49,7 +49,7 @@ pdf_codefromstring(char *buf, int len)
}
static fz_error
-pdf_lexcmap(int *tok, fz_stream *file, char *buf, int n, int *sl)
+pdf_lex_cmap(int *tok, fz_stream *file, char *buf, int n, int *sl)
{
fz_error error;
@@ -57,26 +57,26 @@ pdf_lexcmap(int *tok, fz_stream *file, char *buf, int n, int *sl)
if (error)
return fz_rethrow(error, "cannot parse cmap token");
- if (*tok == PDF_TKEYWORD)
- *tok = pdf_cmaptokenfromkeyword(buf);
+ if (*tok == PDF_TOK_KEYWORD)
+ *tok = pdf_cmap_token_from_keyword(buf);
return fz_okay;
}
static fz_error
-pdf_parsecmapname(pdf_cmap *cmap, fz_stream *file)
+pdf_parse_cmap_name(pdf_cmap *cmap, fz_stream *file)
{
fz_error error;
char buf[256];
int tok;
int len;
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == PDF_TNAME)
- fz_strlcpy(cmap->cmapname, buf, sizeof(cmap->cmapname));
+ if (tok == PDF_TOK_NAME)
+ fz_strlcpy(cmap->cmap_name, buf, sizeof(cmap->cmap_name));
else
fz_warn("expected name after CMapName in cmap");
@@ -84,19 +84,19 @@ pdf_parsecmapname(pdf_cmap *cmap, fz_stream *file)
}
static fz_error
-pdf_parsewmode(pdf_cmap *cmap, fz_stream *file)
+pdf_parse_wmode(pdf_cmap *cmap, fz_stream *file)
{
fz_error error;
char buf[256];
int tok;
int len;
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == PDF_TINT)
- pdf_setwmode(cmap, atoi(buf));
+ if (tok == PDF_TOK_INT)
+ pdf_set_wmode(cmap, atoi(buf));
else
fz_warn("expected integer after WMode in cmap");
@@ -104,7 +104,7 @@ pdf_parsewmode(pdf_cmap *cmap, fz_stream *file)
}
static fz_error
-pdf_parsecodespacerange(pdf_cmap *cmap, fz_stream *file)
+pdf_parse_codespace_range(pdf_cmap *cmap, fz_stream *file)
{
fz_error error;
char buf[256];
@@ -114,23 +114,23 @@ pdf_parsecodespacerange(pdf_cmap *cmap, fz_stream *file)
while (1)
{
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == TENDCODESPACERANGE)
+ if (tok == TOK_END_CODESPACE_RANGE)
return fz_okay;
- else if (tok == PDF_TSTRING)
+ else if (tok == PDF_TOK_STRING)
{
- lo = pdf_codefromstring(buf, len);
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ lo = pdf_code_from_string(buf, len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == PDF_TSTRING)
+ if (tok == PDF_TOK_STRING)
{
- hi = pdf_codefromstring(buf, len);
- pdf_addcodespace(cmap, lo, hi, len);
+ hi = pdf_code_from_string(buf, len);
+ pdf_add_codespace(cmap, lo, hi, len);
}
else break;
}
@@ -142,7 +142,7 @@ pdf_parsecodespacerange(pdf_cmap *cmap, fz_stream *file)
}
static fz_error
-pdf_parsecidrange(pdf_cmap *cmap, fz_stream *file)
+pdf_parse_cid_range(pdf_cmap *cmap, fz_stream *file)
{
fz_error error;
char buf[256];
@@ -152,40 +152,40 @@ pdf_parsecidrange(pdf_cmap *cmap, fz_stream *file)
while (1)
{
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == TENDCIDRANGE)
+ if (tok == TOK_END_CID_RANGE)
return fz_okay;
- else if (tok != PDF_TSTRING)
+ else if (tok != PDF_TOK_STRING)
return fz_throw("expected string or endcidrange");
- lo = pdf_codefromstring(buf, len);
+ lo = pdf_code_from_string(buf, len);
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok != PDF_TSTRING)
+ if (tok != PDF_TOK_STRING)
return fz_throw("expected string");
- hi = pdf_codefromstring(buf, len);
+ hi = pdf_code_from_string(buf, len);
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok != PDF_TINT)
+ if (tok != PDF_TOK_INT)
return fz_throw("expected integer");
dst = atoi(buf);
- pdf_maprangetorange(cmap, lo, hi, dst);
+ pdf_map_range_to_range(cmap, lo, hi, dst);
}
}
static fz_error
-pdf_parsecidchar(pdf_cmap *cmap, fz_stream *file)
+pdf_parse_cid_char(pdf_cmap *cmap, fz_stream *file)
{
fz_error error;
char buf[256];
@@ -195,32 +195,32 @@ pdf_parsecidchar(pdf_cmap *cmap, fz_stream *file)
while (1)
{
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == TENDCIDCHAR)
+ if (tok == TOK_END_CID_CHAR)
return fz_okay;
- else if (tok != PDF_TSTRING)
+ else if (tok != PDF_TOK_STRING)
return fz_throw("expected string or endcidchar");
- src = pdf_codefromstring(buf, len);
+ src = pdf_code_from_string(buf, len);
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok != PDF_TINT)
+ if (tok != PDF_TOK_INT)
return fz_throw("expected integer");
dst = atoi(buf);
- pdf_maprangetorange(cmap, src, src, dst);
+ pdf_map_range_to_range(cmap, src, src, dst);
}
}
static fz_error
-pdf_parsebfrangearray(pdf_cmap *cmap, fz_stream *file, int lo, int hi)
+pdf_parse_bf_range_array(pdf_cmap *cmap, fz_stream *file, int lo, int hi)
{
fz_error error;
char buf[256];
@@ -231,23 +231,23 @@ pdf_parsebfrangearray(pdf_cmap *cmap, fz_stream *file, int lo, int hi)
while (1)
{
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == PDF_TCARRAY)
+ if (tok == PDF_TOK_CLOSE_ARRAY)
return fz_okay;
/* Note: does not handle [ /Name /Name ... ] */
- else if (tok != PDF_TSTRING)
+ else if (tok != PDF_TOK_STRING)
return fz_throw("expected string or ]");
if (len / 2)
{
for (i = 0; i < len / 2; i++)
- dst[i] = pdf_codefromstring(buf + i * 2, 2);
+ dst[i] = pdf_code_from_string(buf + i * 2, 2);
- pdf_maponetomany(cmap, lo, dst, len / 2);
+ pdf_map_one_to_many(cmap, lo, dst, len / 2);
}
lo ++;
@@ -255,7 +255,7 @@ pdf_parsebfrangearray(pdf_cmap *cmap, fz_stream *file, int lo, int hi)
}
static fz_error
-pdf_parsebfrange(pdf_cmap *cmap, fz_stream *file)
+pdf_parse_bf_range(pdf_cmap *cmap, fz_stream *file)
{
fz_error error;
char buf[256];
@@ -265,36 +265,36 @@ pdf_parsebfrange(pdf_cmap *cmap, fz_stream *file)
while (1)
{
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == TENDBFRANGE)
+ if (tok == TOK_END_BF_RANGE)
return fz_okay;
- else if (tok != PDF_TSTRING)
+ else if (tok != PDF_TOK_STRING)
return fz_throw("expected string or endbfrange");
- lo = pdf_codefromstring(buf, len);
+ lo = pdf_code_from_string(buf, len);
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok != PDF_TSTRING)
+ if (tok != PDF_TOK_STRING)
return fz_throw("expected string");
- hi = pdf_codefromstring(buf, len);
+ hi = pdf_code_from_string(buf, len);
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == PDF_TSTRING)
+ if (tok == PDF_TOK_STRING)
{
if (len == 2)
{
- dst = pdf_codefromstring(buf, len);
- pdf_maprangetorange(cmap, lo, hi, dst);
+ dst = pdf_code_from_string(buf, len);
+ pdf_map_range_to_range(cmap, lo, hi, dst);
}
else
{
@@ -304,21 +304,21 @@ pdf_parsebfrange(pdf_cmap *cmap, fz_stream *file)
if (len / 2)
{
for (i = 0; i < len / 2; i++)
- dststr[i] = pdf_codefromstring(buf + i * 2, 2);
+ dststr[i] = pdf_code_from_string(buf + i * 2, 2);
while (lo <= hi)
{
dststr[i-1] ++;
- pdf_maponetomany(cmap, lo, dststr, i);
+ pdf_map_one_to_many(cmap, lo, dststr, i);
lo ++;
}
}
}
}
- else if (tok == PDF_TOARRAY)
+ else if (tok == PDF_TOK_OPEN_ARRAY)
{
- error = pdf_parsebfrangearray(cmap, file, lo, hi);
+ error = pdf_parse_bf_range_array(cmap, file, lo, hi);
if (error)
return fz_rethrow(error, "cannot map bfrange");
}
@@ -331,7 +331,7 @@ pdf_parsebfrange(pdf_cmap *cmap, fz_stream *file)
}
static fz_error
-pdf_parsebfchar(pdf_cmap *cmap, fz_stream *file)
+pdf_parse_bf_char(pdf_cmap *cmap, fz_stream *file)
{
fz_error error;
char buf[256];
@@ -343,36 +343,36 @@ pdf_parsebfchar(pdf_cmap *cmap, fz_stream *file)
while (1)
{
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
- if (tok == TENDBFCHAR)
+ if (tok == TOK_END_BF_CHAR)
return fz_okay;
- else if (tok != PDF_TSTRING)
+ else if (tok != PDF_TOK_STRING)
return fz_throw("expected string or endbfchar");
- src = pdf_codefromstring(buf, len);
+ src = pdf_code_from_string(buf, len);
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
return fz_rethrow(error, "syntaxerror in cmap");
/* Note: does not handle /dstName */
- if (tok != PDF_TSTRING)
+ if (tok != PDF_TOK_STRING)
return fz_throw("expected string");
if (len / 2)
{
for (i = 0; i < len / 2; i++)
- dst[i] = pdf_codefromstring(buf + i * 2, 2);
- pdf_maponetomany(cmap, src, dst, i);
+ dst[i] = pdf_code_from_string(buf + i * 2, 2);
+ pdf_map_one_to_many(cmap, src, dst, i);
}
}
}
fz_error
-pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
+pdf_parse_cmap(pdf_cmap **cmapp, fz_stream *file)
{
fz_error error;
pdf_cmap *cmap;
@@ -381,27 +381,27 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
int tok;
int len;
- cmap = pdf_newcmap();
+ cmap = pdf_new_cmap();
strcpy(key, ".notdef");
while (1)
{
- error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len);
+ error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len);
if (error)
{
error = fz_rethrow(error, "syntaxerror in cmap");
goto cleanup;
}
- if (tok == PDF_TEOF || tok == TENDCMAP)
+ if (tok == PDF_TOK_EOF || tok == TOK_END_CMAP)
break;
- else if (tok == PDF_TNAME)
+ else if (tok == PDF_TOK_NAME)
{
if (!strcmp(buf, "CMapName"))
{
- error = pdf_parsecmapname(cmap, file);
+ error = pdf_parse_cmap_name(cmap, file);
if (error)
{
error = fz_rethrow(error, "syntaxerror in cmap after CMapName");
@@ -410,7 +410,7 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
}
else if (!strcmp(buf, "WMode"))
{
- error = pdf_parsewmode(cmap, file);
+ error = pdf_parse_wmode(cmap, file);
if (error)
{
error = fz_rethrow(error, "syntaxerror in cmap after WMode");
@@ -421,14 +421,14 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
fz_strlcpy(key, buf, sizeof key);
}
- else if (tok == TUSECMAP)
+ else if (tok == TOK_USECMAP)
{
- fz_strlcpy(cmap->usecmapname, key, sizeof(cmap->usecmapname));
+ fz_strlcpy(cmap->usecmap_name, key, sizeof(cmap->usecmap_name));
}
- else if (tok == TBEGINCODESPACERANGE)
+ else if (tok == TOK_BEGIN_CODESPACE_RANGE)
{
- error = pdf_parsecodespacerange(cmap, file);
+ error = pdf_parse_codespace_range(cmap, file);
if (error)
{
error = fz_rethrow(error, "syntaxerror in cmap codespacerange");
@@ -436,9 +436,9 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
}
}
- else if (tok == TBEGINBFCHAR)
+ else if (tok == TOK_BEGIN_BF_CHAR)
{
- error = pdf_parsebfchar(cmap, file);
+ error = pdf_parse_bf_char(cmap, file);
if (error)
{
error = fz_rethrow(error, "syntaxerror in cmap bfchar");
@@ -446,9 +446,9 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
}
}
- else if (tok == TBEGINCIDCHAR)
+ else if (tok == TOK_BEGIN_CID_CHAR)
{
- error = pdf_parsecidchar(cmap, file);
+ error = pdf_parse_cid_char(cmap, file);
if (error)
{
error = fz_rethrow(error, "syntaxerror in cmap cidchar");
@@ -456,9 +456,9 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
}
}
- else if (tok == TBEGINBFRANGE)
+ else if (tok == TOK_BEGIN_BF_RANGE)
{
- error = pdf_parsebfrange(cmap, file);
+ error = pdf_parse_bf_range(cmap, file);
if (error)
{
error = fz_rethrow(error, "syntaxerror in cmap bfrange");
@@ -466,9 +466,9 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
}
}
- else if (tok == TBEGINCIDRANGE)
+ else if (tok == TOK_BEGIN_CID_RANGE)
{
- error = pdf_parsecidrange(cmap, file);
+ error = pdf_parse_cid_range(cmap, file);
if (error)
{
error = fz_rethrow(error, "syntaxerror in cmap cidrange");
@@ -479,12 +479,12 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file)
/* ignore everything else */
}
- pdf_sortcmap(cmap);
+ pdf_sort_cmap(cmap);
*cmapp = cmap;
return fz_okay;
cleanup:
- pdf_dropcmap(cmap);
+ pdf_drop_cmap(cmap);
return error; /* already rethrown */
}
diff --git a/pdf/pdf_cmap_table.c b/pdf/pdf_cmap_table.c
index a1f61365..1413de25 100644
--- a/pdf/pdf_cmap_table.c
+++ b/pdf/pdf_cmap_table.c
@@ -158,7 +158,7 @@ extern pdf_cmap pdf_cmap_Adobe_GB1_UCS2;
extern pdf_cmap pdf_cmap_Adobe_Japan1_UCS2;
extern pdf_cmap pdf_cmap_Adobe_Korea1_UCS2;
-pdf_cmap *pdf_cmaptable[] =
+pdf_cmap *pdf_cmap_table[] =
{
#ifndef NOCJK
&pdf_cmap_Adobe_CNS1_0,
diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c
index 6203e1bb..11316fbe 100644
--- a/pdf/pdf_colorspace.c
+++ b/pdf/pdf_colorspace.c
@@ -4,19 +4,19 @@
/* ICCBased */
static fz_error
-loadiccbased(fz_colorspace **csp, pdf_xref *xref, fz_obj *dict)
+load_icc_based(fz_colorspace **csp, pdf_xref *xref, fz_obj *dict)
{
int n;
- pdf_logrsrc("load ICCBased\n");
+ pdf_log_rsrc("load ICCBased\n");
- n = fz_toint(fz_dictgets(dict, "N"));
+ n = fz_to_int(fz_dict_gets(dict, "N"));
switch (n)
{
- case 1: *csp = fz_devicegray; return fz_okay;
- case 3: *csp = fz_devicergb; return fz_okay;
- case 4: *csp = fz_devicecmyk; return fz_okay;
+ case 1: *csp = fz_device_gray; return fz_okay;
+ case 3: *csp = fz_device_rgb; return fz_okay;
+ case 4: *csp = fz_device_cmyk; return fz_okay;
}
return fz_throw("syntaxerror: ICCBased must have 1, 3 or 4 components");
@@ -39,7 +39,7 @@ static inline float invg(float x)
}
static void
-labtoxyz(fz_colorspace *cs, float *lab, float *xyz)
+lab_to_xyz(fz_colorspace *cs, float *lab, float *xyz)
{
/* input is in range (0..100, -128..127, -128..127) not (0..1, 0..1, 0..1) */
float lstar, astar, bstar, l, m, n;
@@ -55,7 +55,7 @@ labtoxyz(fz_colorspace *cs, float *lab, float *xyz)
}
static void
-xyztolab(fz_colorspace *cs, float *xyz, float *lab)
+xyz_to_lab(fz_colorspace *cs, float *xyz, float *lab)
{
float lstar, astar, bstar;
float yyn = xyz[1];
@@ -70,8 +70,8 @@ xyztolab(fz_colorspace *cs, float *xyz, float *lab)
lab[2] = bstar;
}
-static fz_colorspace kdevicelab = { -1, "Lab", 3, labtoxyz, xyztolab };
-static fz_colorspace *fz_devicelab = &kdevicelab;
+static fz_colorspace k_device_lab = { -1, "Lab", 3, lab_to_xyz, xyz_to_lab };
+static fz_colorspace *fz_device_lab = &k_device_lab;
/* Separation and DeviceN */
@@ -82,69 +82,69 @@ struct separation
};
static void
-separationtoxyz(fz_colorspace *cs, float *color, float *xyz)
+separation_to_xyz(fz_colorspace *cs, float *color, float *xyz)
{
struct separation *sep = cs->data;
- float alt[FZ_MAXCOLORS];
- pdf_evalfunction(sep->tint, color, cs->n, alt, sep->base->n);
- sep->base->toxyz(sep->base, alt, xyz);
+ float alt[FZ_MAX_COLORS];
+ pdf_eval_function(sep->tint, color, cs->n, alt, sep->base->n);
+ sep->base->to_xyz(sep->base, alt, xyz);
}
static void
-freeseparation(fz_colorspace *cs)
+free_separation(fz_colorspace *cs)
{
struct separation *sep = cs->data;
- fz_dropcolorspace(sep->base);
- pdf_dropfunction(sep->tint);
+ fz_drop_colorspace(sep->base);
+ pdf_drop_function(sep->tint);
fz_free(sep);
}
static fz_error
-loadseparation(fz_colorspace **csp, pdf_xref *xref, fz_obj *array)
+load_separation(fz_colorspace **csp, pdf_xref *xref, fz_obj *array)
{
fz_error error;
fz_colorspace *cs;
struct separation *sep;
- fz_obj *nameobj = fz_arrayget(array, 1);
- fz_obj *baseobj = fz_arrayget(array, 2);
- fz_obj *tintobj = fz_arrayget(array, 3);
+ fz_obj *nameobj = fz_array_get(array, 1);
+ fz_obj *baseobj = fz_array_get(array, 2);
+ fz_obj *tintobj = fz_array_get(array, 3);
fz_colorspace *base;
pdf_function *tint;
int n;
- pdf_logrsrc("load Separation {\n");
+ pdf_log_rsrc("load Separation {\n");
- if (fz_isarray(nameobj))
- n = fz_arraylen(nameobj);
+ if (fz_is_array(nameobj))
+ n = fz_array_len(nameobj);
else
n = 1;
- if (n > FZ_MAXCOLORS)
+ if (n > FZ_MAX_COLORS)
return fz_throw("too many components in colorspace");
- pdf_logrsrc("n = %d\n", n);
+ pdf_log_rsrc("n = %d\n", n);
- error = pdf_loadcolorspace(&base, xref, baseobj);
+ error = pdf_load_colorspace(&base, xref, baseobj);
if (error)
- return fz_rethrow(error, "cannot load base colorspace (%d %d R)", fz_tonum(baseobj), fz_togen(baseobj));
+ return fz_rethrow(error, "cannot load base colorspace (%d %d R)", fz_to_num(baseobj), fz_to_gen(baseobj));
- error = pdf_loadfunction(&tint, xref, tintobj);
+ error = pdf_load_function(&tint, xref, tintobj);
if (error)
{
- fz_dropcolorspace(base);
- return fz_rethrow(error, "cannot load tint function (%d %d R)", fz_tonum(tintobj), fz_togen(tintobj));
+ fz_drop_colorspace(base);
+ return fz_rethrow(error, "cannot load tint function (%d %d R)", fz_to_num(tintobj), fz_to_gen(tintobj));
}
sep = fz_malloc(sizeof(struct separation));
sep->base = base;
sep->tint = tint;
- cs = fz_newcolorspace(n == 1 ? "Separation" : "DeviceN", n);
- cs->toxyz = separationtoxyz;
- cs->freedata = freeseparation;
+ cs = fz_new_colorspace(n == 1 ? "Separation" : "DeviceN", n);
+ cs->to_xyz = separation_to_xyz;
+ cs->free_data = free_separation;
cs->data = sep;
- pdf_logrsrc("}\n");
+ pdf_log_rsrc("}\n");
*csp = cs;
return fz_okay;
@@ -160,30 +160,30 @@ struct indexed
};
static void
-indexedtoxyz(fz_colorspace *cs, float *color, float *xyz)
+indexed_to_xyz(fz_colorspace *cs, float *color, float *xyz)
{
struct indexed *idx = cs->data;
- float alt[FZ_MAXCOLORS];
+ float alt[FZ_MAX_COLORS];
int i, k;
i = color[0] * 255;
i = CLAMP(i, 0, idx->high);
for (k = 0; k < idx->base->n; k++)
alt[k] = idx->lookup[i * idx->base->n + k] / 255.0f;
- idx->base->toxyz(idx->base, alt, xyz);
+ idx->base->to_xyz(idx->base, alt, xyz);
}
static void
-freeindexed(fz_colorspace *cs)
+free_indexed(fz_colorspace *cs)
{
struct indexed *idx = cs->data;
if (idx->base)
- fz_dropcolorspace(idx->base);
+ fz_drop_colorspace(idx->base);
fz_free(idx->lookup);
fz_free(idx);
}
fz_pixmap *
-pdf_expandindexedpixmap(fz_pixmap *src)
+pdf_expand_indexed_pixmap(fz_pixmap *src)
{
struct indexed *idx;
fz_pixmap *dst;
@@ -191,7 +191,7 @@ pdf_expandindexedpixmap(fz_pixmap *src)
int y, x, k, n, high;
unsigned char *lookup;
- assert(src->colorspace->toxyz == indexedtoxyz);
+ assert(src->colorspace->to_xyz == indexed_to_xyz);
assert(src->n == 2);
idx = src->colorspace->data;
@@ -199,7 +199,7 @@ pdf_expandindexedpixmap(fz_pixmap *src)
lookup = idx->lookup;
n = idx->base->n;
- dst = fz_newpixmap(idx->base, src->x, src->y, src->w, src->h);
+ dst = fz_new_pixmap(idx->base, src->x, src->y, src->w, src->h);
s = src->samples;
d = dst->samples;
@@ -217,84 +217,84 @@ pdf_expandindexedpixmap(fz_pixmap *src)
}
if (src->mask)
- dst->mask = fz_keeppixmap(src->mask);
+ dst->mask = fz_keep_pixmap(src->mask);
dst->interpolate = src->interpolate;
return dst;
}
static fz_error
-loadindexed(fz_colorspace **csp, pdf_xref *xref, fz_obj *array)
+load_indexed(fz_colorspace **csp, pdf_xref *xref, fz_obj *array)
{
fz_error error;
fz_colorspace *cs;
struct indexed *idx;
- fz_obj *baseobj = fz_arrayget(array, 1);
- fz_obj *highobj = fz_arrayget(array, 2);
- fz_obj *lookup = fz_arrayget(array, 3);
+ fz_obj *baseobj = fz_array_get(array, 1);
+ fz_obj *highobj = fz_array_get(array, 2);
+ fz_obj *lookup = fz_array_get(array, 3);
fz_colorspace *base;
int i, n;
- pdf_logrsrc("load Indexed {\n");
+ pdf_log_rsrc("load Indexed {\n");
- error = pdf_loadcolorspace(&base, xref, baseobj);
+ error = pdf_load_colorspace(&base, xref, baseobj);
if (error)
- return fz_rethrow(error, "cannot load base colorspace (%d %d R)", fz_tonum(baseobj), fz_togen(baseobj));
+ return fz_rethrow(error, "cannot load base colorspace (%d %d R)", fz_to_num(baseobj), fz_to_gen(baseobj));
- pdf_logrsrc("base %s\n", base->name);
+ pdf_log_rsrc("base %s\n", base->name);
idx = fz_malloc(sizeof(struct indexed));
idx->base = base;
- idx->high = fz_toint(highobj);
+ idx->high = fz_to_int(highobj);
idx->high = CLAMP(idx->high, 0, 255);
n = base->n * (idx->high + 1);
idx->lookup = fz_malloc(n);
memset(idx->lookup, 0, n);
- cs = fz_newcolorspace("Indexed", 1);
- cs->toxyz = indexedtoxyz;
- cs->freedata = freeindexed;
+ cs = fz_new_colorspace("Indexed", 1);
+ cs->to_xyz = indexed_to_xyz;
+ cs->free_data = free_indexed;
cs->data = idx;
- if (fz_isstring(lookup) && fz_tostrlen(lookup) == n)
+ if (fz_is_string(lookup) && fz_to_str_len(lookup) == n)
{
unsigned char *buf;
- pdf_logrsrc("string lookup\n");
+ pdf_log_rsrc("string lookup\n");
- buf = (unsigned char *) fz_tostrbuf(lookup);
+ buf = (unsigned char *) fz_to_str_buf(lookup);
for (i = 0; i < n; i++)
idx->lookup[i] = buf[i];
}
- else if (fz_isindirect(lookup))
+ else if (fz_is_indirect(lookup))
{
fz_stream *file;
- pdf_logrsrc("stream lookup\n");
+ pdf_log_rsrc("stream lookup\n");
- error = pdf_openstream(&file, xref, fz_tonum(lookup), fz_togen(lookup));
+ error = pdf_open_stream(&file, xref, fz_to_num(lookup), fz_to_gen(lookup));
if (error)
{
- fz_dropcolorspace(cs);
- return fz_rethrow(error, "cannot open colorspace lookup table (%d 0 R)", fz_tonum(lookup));
+ fz_drop_colorspace(cs);
+ return fz_rethrow(error, "cannot open colorspace lookup table (%d 0 R)", fz_to_num(lookup));
}
i = fz_read(file, idx->lookup, n);
if (i < 0)
{
- fz_dropcolorspace(cs);
- return fz_throw("cannot read colorspace lookup table (%d 0 R)", fz_tonum(lookup));
+ fz_drop_colorspace(cs);
+ return fz_throw("cannot read colorspace lookup table (%d 0 R)", fz_to_num(lookup));
}
fz_close(file);
}
else
{
- fz_dropcolorspace(cs);
+ fz_drop_colorspace(cs);
return fz_throw("cannot parse colorspace lookup table");
}
- pdf_logrsrc("}\n");
+ pdf_log_rsrc("}\n");
*csp = cs;
return fz_okay;
@@ -303,113 +303,113 @@ loadindexed(fz_colorspace **csp, pdf_xref *xref, fz_obj *array)
/* Parse and create colorspace from PDF object */
static fz_error
-pdf_loadcolorspaceimp(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj)
+pdf_load_colorspace_imp(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj)
{
- if (fz_isname(obj))
+ if (fz_is_name(obj))
{
- if (!strcmp(fz_toname(obj), "Pattern"))
- *csp = fz_devicegray;
- else if (!strcmp(fz_toname(obj), "G"))
- *csp = fz_devicegray;
- else if (!strcmp(fz_toname(obj), "RGB"))
- *csp = fz_devicergb;
- else if (!strcmp(fz_toname(obj), "CMYK"))
- *csp = fz_devicecmyk;
- else if (!strcmp(fz_toname(obj), "DeviceGray"))
- *csp = fz_devicegray;
- else if (!strcmp(fz_toname(obj), "DeviceRGB"))
- *csp = fz_devicergb;
- else if (!strcmp(fz_toname(obj), "DeviceCMYK"))
- *csp = fz_devicecmyk;
+ if (!strcmp(fz_to_name(obj), "Pattern"))
+ *csp = fz_device_gray;
+ else if (!strcmp(fz_to_name(obj), "G"))
+ *csp = fz_device_gray;
+ else if (!strcmp(fz_to_name(obj), "RGB"))
+ *csp = fz_device_rgb;
+ else if (!strcmp(fz_to_name(obj), "CMYK"))
+ *csp = fz_device_cmyk;
+ else if (!strcmp(fz_to_name(obj), "DeviceGray"))
+ *csp = fz_device_gray;
+ else if (!strcmp(fz_to_name(obj), "DeviceRGB"))
+ *csp = fz_device_rgb;
+ else if (!strcmp(fz_to_name(obj), "DeviceCMYK"))
+ *csp = fz_device_cmyk;
else
- return fz_throw("unknown colorspace: %s", fz_toname(obj));
+ return fz_throw("unknown colorspace: %s", fz_to_name(obj));
return fz_okay;
}
- else if (fz_isarray(obj))
+ else if (fz_is_array(obj))
{
- fz_obj *name = fz_arrayget(obj, 0);
+ fz_obj *name = fz_array_get(obj, 0);
- if (fz_isname(name))
+ if (fz_is_name(name))
{
/* load base colorspace instead */
- if (!strcmp(fz_toname(name), "Pattern"))
+ if (!strcmp(fz_to_name(name), "Pattern"))
{
fz_error error;
- obj = fz_arrayget(obj, 1);
+ obj = fz_array_get(obj, 1);
if (!obj)
{
- *csp = fz_devicegray;
+ *csp = fz_device_gray;
return fz_okay;
}
- error = pdf_loadcolorspace(csp, xref, obj);
+ error = pdf_load_colorspace(csp, xref, obj);
if (error)
- return fz_rethrow(error, "cannot load pattern (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ return fz_rethrow(error, "cannot load pattern (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
}
- else if (!strcmp(fz_toname(name), "G"))
- *csp = fz_devicegray;
- else if (!strcmp(fz_toname(name), "RGB"))
- *csp = fz_devicergb;
- else if (!strcmp(fz_toname(name), "CMYK"))
- *csp = fz_devicecmyk;
- else if (!strcmp(fz_toname(name), "DeviceGray"))
- *csp = fz_devicegray;
- else if (!strcmp(fz_toname(name), "DeviceRGB"))
- *csp = fz_devicergb;
- else if (!strcmp(fz_toname(name), "DeviceCMYK"))
- *csp = fz_devicecmyk;
- else if (!strcmp(fz_toname(name), "CalGray"))
- *csp = fz_devicegray;
- else if (!strcmp(fz_toname(name), "CalRGB"))
- *csp = fz_devicergb;
- else if (!strcmp(fz_toname(name), "CalCMYK"))
- *csp = fz_devicecmyk;
- else if (!strcmp(fz_toname(name), "Lab"))
- *csp = fz_devicelab;
-
- else if (!strcmp(fz_toname(name), "ICCBased"))
- return loadiccbased(csp, xref, fz_arrayget(obj, 1));
-
- else if (!strcmp(fz_toname(name), "Indexed"))
- return loadindexed(csp, xref, obj);
- else if (!strcmp(fz_toname(name), "I"))
- return loadindexed(csp, xref, obj);
-
- else if (!strcmp(fz_toname(name), "Separation"))
- return loadseparation(csp, xref, obj);
-
- else if (!strcmp(fz_toname(name), "DeviceN"))
- return loadseparation(csp, xref, obj);
+ else if (!strcmp(fz_to_name(name), "G"))
+ *csp = fz_device_gray;
+ else if (!strcmp(fz_to_name(name), "RGB"))
+ *csp = fz_device_rgb;
+ else if (!strcmp(fz_to_name(name), "CMYK"))
+ *csp = fz_device_cmyk;
+ else if (!strcmp(fz_to_name(name), "DeviceGray"))
+ *csp = fz_device_gray;
+ else if (!strcmp(fz_to_name(name), "DeviceRGB"))
+ *csp = fz_device_rgb;
+ else if (!strcmp(fz_to_name(name), "DeviceCMYK"))
+ *csp = fz_device_cmyk;
+ else if (!strcmp(fz_to_name(name), "CalGray"))
+ *csp = fz_device_gray;
+ else if (!strcmp(fz_to_name(name), "CalRGB"))
+ *csp = fz_device_rgb;
+ else if (!strcmp(fz_to_name(name), "CalCMYK"))
+ *csp = fz_device_cmyk;
+ else if (!strcmp(fz_to_name(name), "Lab"))
+ *csp = fz_device_lab;
+
+ else if (!strcmp(fz_to_name(name), "ICCBased"))
+ return load_icc_based(csp, xref, fz_array_get(obj, 1));
+
+ else if (!strcmp(fz_to_name(name), "Indexed"))
+ return load_indexed(csp, xref, obj);
+ else if (!strcmp(fz_to_name(name), "I"))
+ return load_indexed(csp, xref, obj);
+
+ else if (!strcmp(fz_to_name(name), "Separation"))
+ return load_separation(csp, xref, obj);
+
+ else if (!strcmp(fz_to_name(name), "DeviceN"))
+ return load_separation(csp, xref, obj);
else
- return fz_throw("syntaxerror: unknown colorspace %s", fz_toname(name));
+ return fz_throw("syntaxerror: unknown colorspace %s", fz_to_name(name));
return fz_okay;
}
}
- return fz_throw("syntaxerror: could not parse color space (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ return fz_throw("syntaxerror: could not parse color space (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
}
fz_error
-pdf_loadcolorspace(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj)
+pdf_load_colorspace(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj)
{
fz_error error;
- if ((*csp = pdf_finditem(xref->store, fz_dropcolorspace, obj)))
+ if ((*csp = pdf_find_item(xref->store, fz_drop_colorspace, obj)))
{
- fz_keepcolorspace(*csp);
+ fz_keep_colorspace(*csp);
return fz_okay;
}
- error = pdf_loadcolorspaceimp(csp, xref, obj);
+ error = pdf_load_colorspace_imp(csp, xref, obj);
if (error)
- return fz_rethrow(error, "cannot load colorspace (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ return fz_rethrow(error, "cannot load colorspace (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
- pdf_storeitem(xref->store, fz_keepcolorspace, fz_dropcolorspace, obj, *csp);
+ pdf_store_item(xref->store, fz_keep_colorspace, fz_drop_colorspace, obj, *csp);
return fz_okay;
}
diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c
index 6266e188..cdf35d70 100644
--- a/pdf/pdf_crypt.c
+++ b/pdf/pdf_crypt.c
@@ -7,7 +7,7 @@
*/
fz_error
-pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
+pdf_new_crypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
{
pdf_crypt *crypt;
fz_error error;
@@ -15,38 +15,38 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
crypt = fz_malloc(sizeof(pdf_crypt));
memset(crypt, 0x00, sizeof(pdf_crypt));
- crypt->cf = nil;
+ crypt->cf = NULL;
/* Common to all security handlers (PDF 1.7 table 3.18) */
- obj = fz_dictgets(dict, "Filter");
- if (!fz_isname(obj))
+ obj = fz_dict_gets(dict, "Filter");
+ if (!fz_is_name(obj))
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("unspecified encryption handler");
}
- if (strcmp(fz_toname(obj), "Standard") != 0)
+ if (strcmp(fz_to_name(obj), "Standard") != 0)
{
- pdf_freecrypt(crypt);
- return fz_throw("unknown encryption handler: '%s'", fz_toname(obj));
+ pdf_free_crypt(crypt);
+ return fz_throw("unknown encryption handler: '%s'", fz_to_name(obj));
}
crypt->v = 0;
- obj = fz_dictgets(dict, "V");
- if (fz_isint(obj))
- crypt->v = fz_toint(obj);
+ obj = fz_dict_gets(dict, "V");
+ if (fz_is_int(obj))
+ crypt->v = fz_to_int(obj);
if (crypt->v != 1 && crypt->v != 2 && crypt->v != 4 && crypt->v != 5)
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("unknown encryption version");
}
crypt->length = 40;
if (crypt->v == 2 || crypt->v == 4)
{
- obj = fz_dictgets(dict, "Length");
- if (fz_isint(obj))
- crypt->length = fz_toint(obj);
+ obj = fz_dict_gets(dict, "Length");
+ if (fz_is_int(obj))
+ crypt->length = fz_to_int(obj);
/* work-around for pdf generators that assume length is in bytes */
if (crypt->length < 40)
@@ -54,12 +54,12 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
if (crypt->length % 8 != 0)
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("invalid encryption key length");
}
if (crypt->length > 256)
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("invalid encryption key length");
}
}
@@ -84,39 +84,39 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
crypt->strf.method = PDF_CRYPT_NONE;
crypt->strf.length = crypt->length;
- obj = fz_dictgets(dict, "CF");
- if (fz_isdict(obj))
+ obj = fz_dict_gets(dict, "CF");
+ if (fz_is_dict(obj))
{
- crypt->cf = fz_keepobj(obj);
+ crypt->cf = fz_keep_obj(obj);
- obj = fz_dictgets(dict, "StmF");
- if (fz_isname(obj))
+ obj = fz_dict_gets(dict, "StmF");
+ if (fz_is_name(obj))
{
/* should verify that it is either Identity or StdCF */
- obj = fz_dictgets(crypt->cf, fz_toname(obj));
- if (fz_isdict(obj))
+ obj = fz_dict_gets(crypt->cf, fz_to_name(obj));
+ if (fz_is_dict(obj))
{
- error = pdf_parsecryptfilter(&crypt->stmf, obj, crypt->length);
+ error = pdf_parse_crypt_filter(&crypt->stmf, obj, crypt->length);
if (error)
{
- pdf_freecrypt(crypt);
- return fz_rethrow(error, "cannot parse stream crypt filter (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ pdf_free_crypt(crypt);
+ return fz_rethrow(error, "cannot parse stream crypt filter (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
}
}
}
- obj = fz_dictgets(dict, "StrF");
- if (fz_isname(obj))
+ obj = fz_dict_gets(dict, "StrF");
+ if (fz_is_name(obj))
{
/* should verify that it is either Identity or StdCF */
- obj = fz_dictgets(crypt->cf, fz_toname(obj));
- if (fz_isdict(obj))
+ obj = fz_dict_gets(crypt->cf, fz_to_name(obj));
+ if (fz_is_dict(obj))
{
- error = pdf_parsecryptfilter(&crypt->strf, obj, crypt->length);
+ error = pdf_parse_crypt_filter(&crypt->strf, obj, crypt->length);
if (error)
{
- pdf_freecrypt(crypt);
- return fz_rethrow(error, "cannot parse string crypt filter (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ pdf_free_crypt(crypt);
+ return fz_rethrow(error, "cannot parse string crypt filter (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
}
}
}
@@ -129,84 +129,84 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
/* Standard security handler (PDF 1.7 table 3.19) */
- obj = fz_dictgets(dict, "R");
- if (fz_isint(obj))
- crypt->r = fz_toint(obj);
+ obj = fz_dict_gets(dict, "R");
+ if (fz_is_int(obj))
+ crypt->r = fz_to_int(obj);
else
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("encryption dictionary missing revision value");
}
- obj = fz_dictgets(dict, "O");
- if (fz_isstring(obj) && fz_tostrlen(obj) == 32)
- memcpy(crypt->o, fz_tostrbuf(obj), 32);
+ obj = fz_dict_gets(dict, "O");
+ if (fz_is_string(obj) && fz_to_str_len(obj) == 32)
+ memcpy(crypt->o, fz_to_str_buf(obj), 32);
/* /O and /U are supposed to be 48 bytes long for revision 5, they're often longer, though */
- else if (crypt->r == 5 && fz_isstring(obj) && fz_tostrlen(obj) >= 48)
- memcpy(crypt->o, fz_tostrbuf(obj), 48);
+ else if (crypt->r == 5 && fz_is_string(obj) && fz_to_str_len(obj) >= 48)
+ memcpy(crypt->o, fz_to_str_buf(obj), 48);
else
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("encryption dictionary missing owner password");
}
- obj = fz_dictgets(dict, "U");
- if (fz_isstring(obj) && fz_tostrlen(obj) == 32)
- memcpy(crypt->u, fz_tostrbuf(obj), 32);
- else if (fz_isstring(obj) && fz_tostrlen(obj) >= 48 && crypt->r == 5)
- memcpy(crypt->u, fz_tostrbuf(obj), 48);
+ obj = fz_dict_gets(dict, "U");
+ if (fz_is_string(obj) && fz_to_str_len(obj) == 32)
+ memcpy(crypt->u, fz_to_str_buf(obj), 32);
+ else if (fz_is_string(obj) && fz_to_str_len(obj) >= 48 && crypt->r == 5)
+ memcpy(crypt->u, fz_to_str_buf(obj), 48);
else
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("encryption dictionary missing user password");
}
- obj = fz_dictgets(dict, "P");
- if (fz_isint(obj))
- crypt->p = fz_toint(obj);
+ obj = fz_dict_gets(dict, "P");
+ if (fz_is_int(obj))
+ crypt->p = fz_to_int(obj);
else
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("encryption dictionary missing permissions value");
}
if (crypt->r == 5)
{
- obj = fz_dictgets(dict, "OE");
- if (!fz_isstring(obj) || fz_tostrlen(obj) != 32)
+ obj = fz_dict_gets(dict, "OE");
+ if (!fz_is_string(obj) || fz_to_str_len(obj) != 32)
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("encryption dictionary missing owner encryption key");
}
- memcpy(crypt->oe, fz_tostrbuf(obj), 32);
+ memcpy(crypt->oe, fz_to_str_buf(obj), 32);
- obj = fz_dictgets(dict, "UE");
- if (!fz_isstring(obj) || fz_tostrlen(obj) != 32)
+ obj = fz_dict_gets(dict, "UE");
+ if (!fz_is_string(obj) || fz_to_str_len(obj) != 32)
{
- pdf_freecrypt(crypt);
+ pdf_free_crypt(crypt);
return fz_throw("encryption dictionary missing user encryption key");
}
- memcpy(crypt->ue, fz_tostrbuf(obj), 32);
+ memcpy(crypt->ue, fz_to_str_buf(obj), 32);
}
- crypt->encryptmetadata = 1;
- obj = fz_dictgets(dict, "EncryptMetadata");
- if (fz_isbool(obj))
- crypt->encryptmetadata = fz_tobool(obj);
+ crypt->encrypt_metadata = 1;
+ obj = fz_dict_gets(dict, "EncryptMetadata");
+ if (fz_is_bool(obj))
+ crypt->encrypt_metadata = fz_to_bool(obj);
/* Extract file identifier string */
- crypt->idlength = 0;
+ crypt->id_length = 0;
- if (fz_isarray(id) && fz_arraylen(id) == 2)
+ if (fz_is_array(id) && fz_array_len(id) == 2)
{
- obj = fz_arrayget(id, 0);
- if (fz_isstring(obj))
+ obj = fz_array_get(id, 0);
+ if (fz_is_string(obj))
{
- if (fz_tostrlen(obj) <= sizeof(crypt->idstring))
+ if (fz_to_str_len(obj) <= sizeof(crypt->id_string))
{
- memcpy(crypt->idstring, fz_tostrbuf(obj), fz_tostrlen(obj));
- crypt->idlength = fz_tostrlen(obj);
+ memcpy(crypt->id_string, fz_to_str_buf(obj), fz_to_str_len(obj));
+ crypt->id_length = fz_to_str_len(obj);
}
}
}
@@ -218,9 +218,9 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
}
void
-pdf_freecrypt(pdf_crypt *crypt)
+pdf_free_crypt(pdf_crypt *crypt)
{
- if (crypt->cf) fz_dropobj(crypt->cf);
+ if (crypt->cf) fz_drop_obj(crypt->cf);
fz_free(crypt);
}
@@ -229,31 +229,31 @@ pdf_freecrypt(pdf_crypt *crypt)
*/
fz_error
-pdf_parsecryptfilter(pdf_cryptfilter *cf, fz_obj *dict, int defaultlength)
+pdf_parse_crypt_filter(pdf_crypt_filter *cf, fz_obj *dict, int defaultlength)
{
fz_obj *obj;
cf->method = PDF_CRYPT_NONE;
cf->length = defaultlength;
- obj = fz_dictgets(dict, "CFM");
- if (fz_isname(obj))
+ obj = fz_dict_gets(dict, "CFM");
+ if (fz_is_name(obj))
{
- if (!strcmp(fz_toname(obj), "None"))
+ if (!strcmp(fz_to_name(obj), "None"))
cf->method = PDF_CRYPT_NONE;
- else if (!strcmp(fz_toname(obj), "V2"))
+ else if (!strcmp(fz_to_name(obj), "V2"))
cf->method = PDF_CRYPT_RC4;
- else if (!strcmp(fz_toname(obj), "AESV2"))
+ else if (!strcmp(fz_to_name(obj), "AESV2"))
cf->method = PDF_CRYPT_AESV2;
- else if (!strcmp(fz_toname(obj), "AESV3"))
+ else if (!strcmp(fz_to_name(obj), "AESV3"))
cf->method = PDF_CRYPT_AESV3;
else
- fz_throw("unknown encryption method: %s", fz_toname(obj));
+ fz_throw("unknown encryption method: %s", fz_to_name(obj));
}
- obj = fz_dictgets(dict, "Length");
- if (fz_isint(obj))
- cf->length = fz_toint(obj);
+ obj = fz_dict_gets(dict, "Length");
+ if (fz_is_int(obj))
+ cf->length = fz_to_int(obj);
/* the length for crypt filters is supposed to be in bytes not bits */
if (cf->length < 40)
@@ -278,7 +278,7 @@ static const unsigned char padding[32] =
};
static void
-pdf_computeencryptionkey(pdf_crypt *crypt, unsigned char *password, int pwlen, unsigned char *key)
+pdf_compute_encryption_key(pdf_crypt *crypt, unsigned char *password, int pwlen, unsigned char *key)
{
unsigned char buf[32];
unsigned int p;
@@ -294,11 +294,11 @@ pdf_computeencryptionkey(pdf_crypt *crypt, unsigned char *password, int pwlen, u
memcpy(buf + pwlen, padding, 32 - pwlen);
/* Step 2 - init md5 and pass value of step 1 */
- fz_md5init(&md5);
- fz_md5update(&md5, buf, 32);
+ fz_md5_init(&md5);
+ fz_md5_update(&md5, buf, 32);
/* Step 3 - pass O value */
- fz_md5update(&md5, crypt->o, 32);
+ fz_md5_update(&md5, crypt->o, 32);
/* Step 4 - pass P value as unsigned int, low-order byte first */
p = (unsigned int) crypt->p;
@@ -306,35 +306,35 @@ pdf_computeencryptionkey(pdf_crypt *crypt, unsigned char *password, int pwlen, u
buf[1] = (p >> 8) & 0xFF;
buf[2] = (p >> 16) & 0xFF;
buf[3] = (p >> 24) & 0xFF;
- fz_md5update(&md5, buf, 4);
+ fz_md5_update(&md5, buf, 4);
/* Step 5 - pass first element of ID array */
- fz_md5update(&md5, crypt->idstring, crypt->idlength);
+ fz_md5_update(&md5, crypt->id_string, crypt->id_length);
/* Step 6 (revision 4 or greater) - if metadata is not encrypted pass 0xFFFFFFFF */
if (crypt->r >= 4)
{
- if (!crypt->encryptmetadata)
+ if (!crypt->encrypt_metadata)
{
buf[0] = 0xFF;
buf[1] = 0xFF;
buf[2] = 0xFF;
buf[3] = 0xFF;
- fz_md5update(&md5, buf, 4);
+ fz_md5_update(&md5, buf, 4);
}
}
/* Step 7 - finish the hash */
- fz_md5final(&md5, buf);
+ fz_md5_final(&md5, buf);
/* Step 8 (revision 3 or greater) - do some voodoo 50 times */
if (crypt->r >= 3)
{
for (i = 0; i < 50; i++)
{
- fz_md5init(&md5);
- fz_md5update(&md5, buf, n);
- fz_md5final(&md5, buf);
+ fz_md5_init(&md5);
+ fz_md5_update(&md5, buf, n);
+ fz_md5_final(&md5, buf);
}
}
@@ -347,7 +347,7 @@ pdf_computeencryptionkey(pdf_crypt *crypt, unsigned char *password, int pwlen, u
*/
static void
-pdf_computeencryptionkey_r5(pdf_crypt *crypt, unsigned char *password, int pwlen, int ownerkey, unsigned char *validationkey)
+pdf_compute_encryption_key_r5(pdf_crypt *crypt, unsigned char *password, int pwlen, int ownerkey, unsigned char *validationkey)
{
unsigned char buffer[128 + 8 + 48];
fz_sha256 sha256;
@@ -369,17 +369,17 @@ pdf_computeencryptionkey_r5(pdf_crypt *crypt, unsigned char *password, int pwlen
else
memcpy(buffer + pwlen, crypt->u + 32, 8);
- fz_sha256init(&sha256);
- fz_sha256update(&sha256, buffer, pwlen + 8 + (ownerkey ? 48 : 0));
- fz_sha256final(&sha256, validationkey);
+ fz_sha256_init(&sha256);
+ fz_sha256_update(&sha256, buffer, pwlen + 8 + (ownerkey ? 48 : 0));
+ fz_sha256_final(&sha256, validationkey);
/* Step 3.5/4.5 - compute file encryption key from OE/UE */
memcpy(buffer + pwlen, crypt->u + 40, 8);
- fz_sha256init(&sha256);
- fz_sha256update(&sha256, buffer, pwlen + 8);
- fz_sha256final(&sha256, buffer);
+ fz_sha256_init(&sha256);
+ fz_sha256_update(&sha256, buffer, pwlen + 8);
+ fz_sha256_final(&sha256, buffer);
// clear password buffer and use it as iv
memset(buffer + 32, 0, sizeof(buffer) - 32);
@@ -393,15 +393,15 @@ pdf_computeencryptionkey_r5(pdf_crypt *crypt, unsigned char *password, int pwlen
*/
static void
-pdf_computeuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen, unsigned char *output)
+pdf_compute_user_password(pdf_crypt *crypt, unsigned char *password, int pwlen, unsigned char *output)
{
if (crypt->r == 2)
{
fz_arc4 arc4;
- pdf_computeencryptionkey(crypt, password, pwlen, crypt->key);
- fz_arc4init(&arc4, crypt->key, crypt->length / 8);
- fz_arc4encrypt(&arc4, output, padding, 32);
+ pdf_compute_encryption_key(crypt, password, pwlen, crypt->key);
+ fz_arc4_init(&arc4, crypt->key, crypt->length / 8);
+ fz_arc4_encrypt(&arc4, output, padding, 32);
}
if (crypt->r == 3 || crypt->r == 4)
@@ -414,22 +414,22 @@ pdf_computeuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen, un
n = crypt->length / 8;
- pdf_computeencryptionkey(crypt, password, pwlen, crypt->key);
+ pdf_compute_encryption_key(crypt, password, pwlen, crypt->key);
- fz_md5init(&md5);
- fz_md5update(&md5, padding, 32);
- fz_md5update(&md5, crypt->idstring, crypt->idlength);
- fz_md5final(&md5, digest);
+ fz_md5_init(&md5);
+ fz_md5_update(&md5, padding, 32);
+ fz_md5_update(&md5, crypt->id_string, crypt->id_length);
+ fz_md5_final(&md5, digest);
- fz_arc4init(&arc4, crypt->key, n);
- fz_arc4encrypt(&arc4, output, digest, 16);
+ fz_arc4_init(&arc4, crypt->key, n);
+ fz_arc4_encrypt(&arc4, output, digest, 16);
for (x = 1; x <= 19; x++)
{
for (i = 0; i < n; i++)
xor[i] = crypt->key[i] ^ x;
- fz_arc4init(&arc4, xor, n);
- fz_arc4encrypt(&arc4, output, output, 16);
+ fz_arc4_init(&arc4, xor, n);
+ fz_arc4_encrypt(&arc4, output, output, 16);
}
memcpy(output + 16, padding, 16);
@@ -437,7 +437,7 @@ pdf_computeuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen, un
if (crypt->r == 5)
{
- pdf_computeencryptionkey_r5(crypt, password, pwlen, 0, output);
+ pdf_compute_encryption_key_r5(crypt, password, pwlen, 0, output);
}
}
@@ -449,10 +449,10 @@ pdf_computeuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen, un
*/
static int
-pdf_authenticateuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen)
+pdf_authenticate_user_password(pdf_crypt *crypt, unsigned char *password, int pwlen)
{
unsigned char output[32];
- pdf_computeuserpassword(crypt, password, pwlen, output);
+ pdf_compute_user_password(crypt, password, pwlen, output);
if (crypt->r == 2 || crypt->r == 5)
return memcmp(output, crypt->u, 32) == 0;
if (crypt->r == 3 || crypt->r == 4)
@@ -464,11 +464,11 @@ pdf_authenticateuserpassword(pdf_crypt *crypt, unsigned char *password, int pwle
* Authenticating the owner password (PDF 1.7 algorithm 3.7
* and ExtensionLevel 3 algorithm 3.12)
* Generates the user password from the owner password
- * and calls pdf_authenticateuserpassword.
+ * and calls pdf_authenticate_user_password.
*/
static int
-pdf_authenticateownerpassword(pdf_crypt *crypt, unsigned char *ownerpass, int pwlen)
+pdf_authenticate_owner_password(pdf_crypt *crypt, unsigned char *ownerpass, int pwlen)
{
unsigned char pwbuf[32];
unsigned char key[32];
@@ -482,7 +482,7 @@ pdf_authenticateownerpassword(pdf_crypt *crypt, unsigned char *ownerpass, int pw
{
/* PDF 1.7 ExtensionLevel 3 algorithm 3.12 */
- pdf_computeencryptionkey_r5(crypt, ownerpass, pwlen, 1, key);
+ pdf_compute_encryption_key_r5(crypt, ownerpass, pwlen, 1, key);
return !memcmp(key, crypt->o, 32);
}
@@ -498,26 +498,26 @@ pdf_authenticateownerpassword(pdf_crypt *crypt, unsigned char *ownerpass, int pw
memcpy(pwbuf + pwlen, padding, 32 - pwlen);
/* take md5 hash of padded password */
- fz_md5init(&md5);
- fz_md5update(&md5, pwbuf, 32);
- fz_md5final(&md5, key);
+ fz_md5_init(&md5);
+ fz_md5_update(&md5, pwbuf, 32);
+ fz_md5_final(&md5, key);
/* do some voodoo 50 times (Revision 3 or greater) */
if (crypt->r >= 3)
{
for (i = 0; i < 50; i++)
{
- fz_md5init(&md5);
- fz_md5update(&md5, key, 16);
- fz_md5final(&md5, key);
+ fz_md5_init(&md5);
+ fz_md5_update(&md5, key, 16);
+ fz_md5_final(&md5, key);
}
}
/* Step 2 (Revision 2) */
if (crypt->r == 2)
{
- fz_arc4init(&arc4, key, n);
- fz_arc4encrypt(&arc4, userpass, crypt->o, 32);
+ fz_arc4_init(&arc4, key, n);
+ fz_arc4_encrypt(&arc4, userpass, crypt->o, 32);
}
/* Step 2 (Revision 3 or greater) */
@@ -528,22 +528,22 @@ pdf_authenticateownerpassword(pdf_crypt *crypt, unsigned char *ownerpass, int pw
{
for (i = 0; i < n; i++)
xor[i] = key[i] ^ (19 - x);
- fz_arc4init(&arc4, xor, n);
- fz_arc4encrypt(&arc4, userpass, userpass, 32);
+ fz_arc4_init(&arc4, xor, n);
+ fz_arc4_encrypt(&arc4, userpass, userpass, 32);
}
}
- return pdf_authenticateuserpassword(crypt, userpass, 32);
+ return pdf_authenticate_user_password(crypt, userpass, 32);
}
int
-pdf_authenticatepassword(pdf_xref *xref, char *password)
+pdf_authenticate_password(pdf_xref *xref, char *password)
{
if (xref->crypt)
{
- if (pdf_authenticateuserpassword(xref->crypt, (unsigned char *)password, strlen(password)))
+ if (pdf_authenticate_user_password(xref->crypt, (unsigned char *)password, strlen(password)))
return 1;
- if (pdf_authenticateownerpassword(xref->crypt, (unsigned char *)password, strlen(password)))
+ if (pdf_authenticate_owner_password(xref->crypt, (unsigned char *)password, strlen(password)))
return 1;
return 0;
}
@@ -551,11 +551,11 @@ pdf_authenticatepassword(pdf_xref *xref, char *password)
}
int
-pdf_needspassword(pdf_xref *xref)
+pdf_needs_password(pdf_xref *xref)
{
if (!xref->crypt)
return 0;
- if (pdf_authenticatepassword(xref, ""))
+ if (pdf_authenticate_password(xref, ""))
return 0;
return 1;
}
@@ -570,7 +570,7 @@ pdf_needspassword(pdf_xref *xref)
*/
static int
-pdf_computeobjectkey(pdf_crypt *crypt, pdf_cryptfilter *cf, int num, int gen, unsigned char *key)
+pdf_compute_object_key(pdf_crypt *crypt, pdf_crypt_filter *cf, int num, int gen, unsigned char *key)
{
fz_md5 md5;
unsigned char message[5];
@@ -581,19 +581,19 @@ pdf_computeobjectkey(pdf_crypt *crypt, pdf_cryptfilter *cf, int num, int gen, un
return crypt->length / 8;
}
- fz_md5init(&md5);
- fz_md5update(&md5, crypt->key, crypt->length / 8);
+ fz_md5_init(&md5);
+ fz_md5_update(&md5, crypt->key, crypt->length / 8);
message[0] = (num) & 0xFF;
message[1] = (num >> 8) & 0xFF;
message[2] = (num >> 16) & 0xFF;
message[3] = (gen) & 0xFF;
message[4] = (gen >> 8) & 0xFF;
- fz_md5update(&md5, message, 5);
+ fz_md5_update(&md5, message, 5);
if (cf->method == PDF_CRYPT_AESV2)
- fz_md5update(&md5, (unsigned char *)"sAlT", 4);
+ fz_md5_update(&md5, (unsigned char *)"sAlT", 4);
- fz_md5final(&md5, key);
+ fz_md5_final(&md5, key);
if (crypt->length / 8 + 5 > 16)
return 16;
@@ -609,24 +609,24 @@ pdf_computeobjectkey(pdf_crypt *crypt, pdf_cryptfilter *cf, int num, int gen, un
*/
static void
-pdf_cryptobjimp(pdf_crypt *crypt, fz_obj *obj, unsigned char *key, int keylen)
+pdf_crypt_obj_imp(pdf_crypt *crypt, fz_obj *obj, unsigned char *key, int keylen)
{
unsigned char *s;
int i, n;
- if (fz_isindirect(obj))
+ if (fz_is_indirect(obj))
return;
- if (fz_isstring(obj))
+ if (fz_is_string(obj))
{
- s = (unsigned char *) fz_tostrbuf(obj);
- n = fz_tostrlen(obj);
+ s = (unsigned char *) fz_to_str_buf(obj);
+ n = fz_to_str_len(obj);
if (crypt->strf.method == PDF_CRYPT_RC4)
{
fz_arc4 arc4;
- fz_arc4init(&arc4, key, keylen);
- fz_arc4encrypt(&arc4, s, s, n);
+ fz_arc4_init(&arc4, key, keylen);
+ fz_arc4_encrypt(&arc4, s, s, n);
}
if (crypt->strf.method == PDF_CRYPT_AESV2 || crypt->strf.method == PDF_CRYPT_AESV3)
@@ -644,34 +644,34 @@ pdf_cryptobjimp(pdf_crypt *crypt, fz_obj *obj, unsigned char *key, int keylen)
}
}
- else if (fz_isarray(obj))
+ else if (fz_is_array(obj))
{
- n = fz_arraylen(obj);
+ n = fz_array_len(obj);
for (i = 0; i < n; i++)
{
- pdf_cryptobjimp(crypt, fz_arrayget(obj, i), key, keylen);
+ pdf_crypt_obj_imp(crypt, fz_array_get(obj, i), key, keylen);
}
}
- else if (fz_isdict(obj))
+ else if (fz_is_dict(obj))
{
- n = fz_dictlen(obj);
+ n = fz_dict_len(obj);
for (i = 0; i < n; i++)
{
- pdf_cryptobjimp(crypt, fz_dictgetval(obj, i), key, keylen);
+ pdf_crypt_obj_imp(crypt, fz_dict_get_val(obj, i), key, keylen);
}
}
}
void
-pdf_cryptobj(pdf_crypt *crypt, fz_obj *obj, int num, int gen)
+pdf_crypt_obj(pdf_crypt *crypt, fz_obj *obj, int num, int gen)
{
unsigned char key[32];
int len;
- len = pdf_computeobjectkey(crypt, &crypt->strf, num, gen, key);
+ len = pdf_compute_object_key(crypt, &crypt->strf, num, gen, key);
- pdf_cryptobjimp(crypt, obj, key, len);
+ pdf_crypt_obj_imp(crypt, obj, key, len);
}
/*
@@ -680,23 +680,23 @@ pdf_cryptobj(pdf_crypt *crypt, fz_obj *obj, int num, int gen)
* Create filter suitable for de/encrypting a stream.
*/
fz_stream *
-pdf_opencrypt(fz_stream *chain, pdf_crypt *crypt, pdf_cryptfilter *stmf, int num, int gen)
+pdf_open_crypt(fz_stream *chain, pdf_crypt *crypt, pdf_crypt_filter *stmf, int num, int gen)
{
unsigned char key[32];
int len;
- len = pdf_computeobjectkey(crypt, stmf, num, gen, key);
+ len = pdf_compute_object_key(crypt, stmf, num, gen, key);
if (stmf->method == PDF_CRYPT_RC4)
- return fz_openarc4(chain, key, len);
+ return fz_open_arc4(chain, key, len);
if (stmf->method == PDF_CRYPT_AESV2 || stmf->method == PDF_CRYPT_AESV3)
- return fz_openaesd(chain, key, len);
+ return fz_open_aesd(chain, key, len);
- return fz_opencopy(chain);
+ return fz_open_copy(chain);
}
-void pdf_debugcrypt(pdf_crypt *crypt)
+void pdf_debug_crypt(pdf_crypt *crypt)
{
int i;
diff --git a/pdf/pdf_debug.c b/pdf/pdf_debug.c
index 9d7f1f56..e2223b2d 100644
--- a/pdf/pdf_debug.c
+++ b/pdf/pdf_debug.c
@@ -72,20 +72,20 @@ static inline void pdflog(int tag, char *name, char *fmt, va_list ap)
fflush(stdout);
}
-void pdf_logxref(char *fmt, ...)
+void pdf_log_xref(char *fmt, ...)
{va_list ap;va_start(ap,fmt);pdflog(PDF_LXREF,"xref",fmt,ap);va_end(ap);}
-void pdf_logrsrc(char *fmt, ...)
+void pdf_log_rsrc(char *fmt, ...)
{va_list ap;va_start(ap,fmt);pdflog(PDF_LRSRC,"rsrc",fmt,ap);va_end(ap);}
-void pdf_logfont(char *fmt, ...)
+void pdf_log_font(char *fmt, ...)
{va_list ap;va_start(ap,fmt);pdflog(PDF_LFONT,"font",fmt,ap);va_end(ap);}
-void pdf_logimage(char *fmt, ...)
+void pdf_log_image(char *fmt, ...)
{va_list ap;va_start(ap,fmt);pdflog(PDF_LIMAGE,"imag",fmt,ap);va_end(ap);}
-void pdf_logshade(char *fmt, ...)
+void pdf_log_shade(char *fmt, ...)
{va_list ap;va_start(ap,fmt);pdflog(PDF_LSHADE,"shad",fmt,ap);va_end(ap);}
-void pdf_logpage(char *fmt, ...)
+void pdf_log_page(char *fmt, ...)
{va_list ap;va_start(ap,fmt);pdflog(PDF_LPAGE,"page",fmt,ap);va_end(ap);}
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
index 75bc141f..60d6e824 100644
--- a/pdf/pdf_font.c
+++ b/pdf/pdf_font.c
@@ -5,34 +5,34 @@
#include FT_FREETYPE_H
#include FT_XFREE86_H
-static char *basefontnames[14][7] =
+static char *base_font_names[14][7] =
{
- { "Courier", "CourierNew", "CourierNewPSMT", nil },
+ { "Courier", "CourierNew", "CourierNewPSMT", NULL },
{ "Courier-Bold", "CourierNew,Bold", "Courier,Bold",
- "CourierNewPS-BoldMT", "CourierNew-Bold", nil },
+ "CourierNewPS-BoldMT", "CourierNew-Bold", NULL },
{ "Courier-Oblique", "CourierNew,Italic", "Courier,Italic",
- "CourierNewPS-ItalicMT", "CourierNew-Italic", nil },
+ "CourierNewPS-ItalicMT", "CourierNew-Italic", NULL },
{ "Courier-BoldOblique", "CourierNew,BoldItalic", "Courier,BoldItalic",
- "CourierNewPS-BoldItalicMT", "CourierNew-BoldItalic", nil },
- { "Helvetica", "ArialMT", "Arial", nil },
+ "CourierNewPS-BoldItalicMT", "CourierNew-BoldItalic", NULL },
+ { "Helvetica", "ArialMT", "Arial", NULL },
{ "Helvetica-Bold", "Arial-BoldMT", "Arial,Bold", "Arial-Bold",
- "Helvetica,Bold", nil },
+ "Helvetica,Bold", NULL },
{ "Helvetica-Oblique", "Arial-ItalicMT", "Arial,Italic", "Arial-Italic",
- "Helvetica,Italic", "Helvetica-Italic", nil },
+ "Helvetica,Italic", "Helvetica-Italic", NULL },
{ "Helvetica-BoldOblique", "Arial-BoldItalicMT",
"Arial,BoldItalic", "Arial-BoldItalic",
- "Helvetica,BoldItalic", "Helvetica-BoldItalic", nil },
+ "Helvetica,BoldItalic", "Helvetica-BoldItalic", NULL },
{ "Times-Roman", "TimesNewRomanPSMT", "TimesNewRoman",
- "TimesNewRomanPS", nil },
+ "TimesNewRomanPS", NULL },
{ "Times-Bold", "TimesNewRomanPS-BoldMT", "TimesNewRoman,Bold",
- "TimesNewRomanPS-Bold", "TimesNewRoman-Bold", nil },
+ "TimesNewRomanPS-Bold", "TimesNewRoman-Bold", NULL },
{ "Times-Italic", "TimesNewRomanPS-ItalicMT", "TimesNewRoman,Italic",
- "TimesNewRomanPS-Italic", "TimesNewRoman-Italic", nil },
+ "TimesNewRomanPS-Italic", "TimesNewRoman-Italic", NULL },
{ "Times-BoldItalic", "TimesNewRomanPS-BoldItalicMT",
"TimesNewRoman,BoldItalic", "TimesNewRomanPS-BoldItalic",
- "TimesNewRoman-BoldItalic", nil },
- { "Symbol", nil },
- { "ZapfDingbats", nil }
+ "TimesNewRoman-BoldItalic", NULL },
+ { "Symbol", NULL },
+ { "ZapfDingbats", NULL }
};
static int isdynalab(char *name)
@@ -48,7 +48,7 @@ static int isdynalab(char *name)
return 0;
}
-static int strcmpignorespace(char *a, char *b)
+static int strcmp_ignore_space(char *a, char *b)
{
while (1)
{
@@ -67,13 +67,13 @@ static int strcmpignorespace(char *a, char *b)
}
}
-static char *cleanfontname(char *fontname)
+static char *clean_font_name(char *fontname)
{
int i, k;
for (i = 0; i < 14; i++)
- for (k = 0; basefontnames[i][k]; k++)
- if (!strcmpignorespace(basefontnames[i][k], fontname))
- return basefontnames[i][0];
+ for (k = 0; base_font_names[i][k]; k++)
+ if (!strcmp_ignore_space(base_font_names[i][k], fontname))
+ return base_font_names[i][0];
return fontname;
}
@@ -83,10 +83,10 @@ static char *cleanfontname(char *fontname)
enum { UNKNOWN, TYPE1, TRUETYPE };
-static int ftkind(FT_Face face)
+static int ft_kind(FT_Face face)
{
const char *kind = FT_Get_X11_Font_Format(face);
- pdf_logfont("ft font format %s\n", kind);
+ pdf_log_font("ft font format %s\n", kind);
if (!strcmp(kind, "TrueType"))
return TRUETYPE;
if (!strcmp(kind, "Type 1"))
@@ -98,7 +98,7 @@ static int ftkind(FT_Face face)
return UNKNOWN;
}
-static int ftcharindex(FT_Face face, int cid)
+static int ft_char_index(FT_Face face, int cid)
{
int gid = FT_Get_Char_Index(face, cid);
if (gid == 0)
@@ -106,53 +106,53 @@ static int ftcharindex(FT_Face face, int cid)
return gid;
}
-static inline int ftcidtogid(pdf_fontdesc *fontdesc, int cid)
+static inline int ft_cid_to_gid(pdf_font_desc *fontdesc, int cid)
{
- if (fontdesc->tottfcmap)
+ if (fontdesc->to_ttf_cmap)
{
- cid = pdf_lookupcmap(fontdesc->tottfcmap, cid);
- return ftcharindex(fontdesc->font->ftface, cid);
+ cid = pdf_lookup_cmap(fontdesc->to_ttf_cmap, cid);
+ return ft_char_index(fontdesc->font->ft_face, cid);
}
- if (fontdesc->cidtogid)
- return fontdesc->cidtogid[cid];
+ if (fontdesc->cid_to_gid)
+ return fontdesc->cid_to_gid[cid];
return cid;
}
int
-pdf_fontcidtogid(pdf_fontdesc *fontdesc, int cid)
+pdf_font_cid_to_gid(pdf_font_desc *fontdesc, int cid)
{
- if (fontdesc->font->ftface)
- return ftcidtogid(fontdesc, cid);
+ if (fontdesc->font->ft_face)
+ return ft_cid_to_gid(fontdesc, cid);
return cid;
}
-static int ftwidth(pdf_fontdesc *fontdesc, int cid)
+static int ft_width(pdf_font_desc *fontdesc, int cid)
{
int gid, fterr;
- gid = ftcidtogid(fontdesc, cid);
+ gid = ft_cid_to_gid(fontdesc, cid);
- fterr = FT_Load_Glyph(fontdesc->font->ftface, gid,
+ fterr = FT_Load_Glyph(fontdesc->font->ft_face, gid,
FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM);
if (fterr)
{
- fz_warn("freetype load glyph (gid %d): %s", gid, ft_errorstring(fterr));
+ fz_warn("freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
return 0;
}
- return ((FT_Face)fontdesc->font->ftface)->glyph->advance.x;
+ return ((FT_Face)fontdesc->font->ft_face)->glyph->advance.x;
}
/*
* Basic encoding tables
*/
-static int mrecode(char *name)
+static int mre_code(char *name)
{
int i;
for (i = 0; i < 256; i++)
- if (pdf_macroman[i] && !strcmp(name, pdf_macroman[i]))
+ if (pdf_mac_roman[i] && !strcmp(name, pdf_mac_roman[i]))
return i;
return -1;
}
@@ -161,69 +161,69 @@ static int mrecode(char *name)
* Create and destroy
*/
-pdf_fontdesc *
-pdf_keepfont(pdf_fontdesc *fontdesc)
+pdf_font_desc *
+pdf_keep_font(pdf_font_desc *fontdesc)
{
fontdesc->refs ++;
return fontdesc;
}
void
-pdf_dropfont(pdf_fontdesc *fontdesc)
+pdf_drop_font(pdf_font_desc *fontdesc)
{
if (fontdesc && --fontdesc->refs == 0)
{
if (fontdesc->font)
- fz_dropfont(fontdesc->font);
+ fz_drop_font(fontdesc->font);
if (fontdesc->encoding)
- pdf_dropcmap(fontdesc->encoding);
- if (fontdesc->tottfcmap)
- pdf_dropcmap(fontdesc->tottfcmap);
- if (fontdesc->tounicode)
- pdf_dropcmap(fontdesc->tounicode);
- fz_free(fontdesc->cidtogid);
- fz_free(fontdesc->cidtoucs);
+ pdf_drop_cmap(fontdesc->encoding);
+ if (fontdesc->to_ttf_cmap)
+ pdf_drop_cmap(fontdesc->to_ttf_cmap);
+ if (fontdesc->to_unicode)
+ pdf_drop_cmap(fontdesc->to_unicode);
+ fz_free(fontdesc->cid_to_gid);
+ fz_free(fontdesc->cid_to_ucs);
fz_free(fontdesc->hmtx);
fz_free(fontdesc->vmtx);
fz_free(fontdesc);
}
}
-pdf_fontdesc *
-pdf_newfontdesc(void)
+pdf_font_desc *
+pdf_new_font_desc(void)
{
- pdf_fontdesc *fontdesc;
+ pdf_font_desc *fontdesc;
- fontdesc = fz_malloc(sizeof(pdf_fontdesc));
+ fontdesc = fz_malloc(sizeof(pdf_font_desc));
fontdesc->refs = 1;
- fontdesc->font = nil;
+ fontdesc->font = NULL;
fontdesc->flags = 0;
- fontdesc->italicangle = 0;
+ fontdesc->italic_angle = 0;
fontdesc->ascent = 0;
fontdesc->descent = 0;
- fontdesc->capheight = 0;
- fontdesc->xheight = 0;
- fontdesc->missingwidth = 0;
+ fontdesc->cap_height = 0;
+ fontdesc->x_height = 0;
+ fontdesc->missing_width = 0;
- fontdesc->encoding = nil;
- fontdesc->tottfcmap = nil;
- fontdesc->ncidtogid = 0;
- fontdesc->cidtogid = nil;
+ fontdesc->encoding = NULL;
+ fontdesc->to_ttf_cmap = NULL;
+ fontdesc->cid_to_gid_len = 0;
+ fontdesc->cid_to_gid = NULL;
- fontdesc->tounicode = nil;
- fontdesc->ncidtoucs = 0;
- fontdesc->cidtoucs = nil;
+ fontdesc->to_unicode = NULL;
+ fontdesc->cid_to_ucs_len = 0;
+ fontdesc->cid_to_ucs = NULL;
fontdesc->wmode = 0;
- fontdesc->hmtxcap = 0;
- fontdesc->vmtxcap = 0;
- fontdesc->nhmtx = 0;
- fontdesc->nvmtx = 0;
- fontdesc->hmtx = nil;
- fontdesc->vmtx = nil;
+ fontdesc->hmtx_cap = 0;
+ fontdesc->vmtx_cap = 0;
+ fontdesc->hmtx_len = 0;
+ fontdesc->vmtx_len = 0;
+ fontdesc->hmtx = NULL;
+ fontdesc->vmtx = NULL;
fontdesc->dhmtx.lo = 0x0000;
fontdesc->dhmtx.hi = 0xFFFF;
@@ -245,14 +245,14 @@ pdf_newfontdesc(void)
*/
static fz_error
-loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
+load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
fz_obj *descriptor;
fz_obj *encoding;
fz_obj *widths;
- unsigned short *etable = nil;
- pdf_fontdesc *fontdesc;
+ unsigned short *etable = NULL;
+ pdf_font_desc *fontdesc;
FT_Face face;
FT_CharMap cmap;
int kind;
@@ -265,31 +265,31 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
int i, k, n;
int fterr;
- basefont = fz_toname(fz_dictgets(dict, "BaseFont"));
- fontname = cleanfontname(basefont);
+ basefont = fz_to_name(fz_dict_gets(dict, "BaseFont"));
+ fontname = clean_font_name(basefont);
/* Load font file */
- fontdesc = pdf_newfontdesc();
+ fontdesc = pdf_new_font_desc();
- pdf_logfont("load simple font (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), fontdesc);
- pdf_logfont("basefont %s -> %s\n", basefont, fontname);
+ pdf_log_font("load simple font (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), fontdesc);
+ pdf_log_font("basefont %s -> %s\n", basefont, fontname);
- descriptor = fz_dictgets(dict, "FontDescriptor");
+ descriptor = fz_dict_gets(dict, "FontDescriptor");
if (descriptor)
- error = pdf_loadfontdescriptor(fontdesc, xref, descriptor, nil, basefont);
+ error = pdf_load_font_descriptor(fontdesc, xref, descriptor, NULL, basefont);
else
- error = pdf_loadbuiltinfont(fontdesc, fontname);
+ error = pdf_load_builtin_font(fontdesc, fontname);
if (error)
goto cleanup;
/* Some chinese documents mistakenly consider WinAnsiEncoding to be codepage 936 */
if (!*fontdesc->font->name &&
- !fz_dictgets(dict, "ToUnicode") &&
- !strcmp(fz_toname(fz_dictgets(dict, "Encoding")), "WinAnsiEncoding") &&
- fz_toint(fz_dictgets(descriptor, "Flags")) == 4)
+ !fz_dict_gets(dict, "ToUnicode") &&
+ !strcmp(fz_to_name(fz_dict_gets(dict, "Encoding")), "WinAnsiEncoding") &&
+ fz_to_int(fz_dict_gets(descriptor, "Flags")) == 4)
{
- /* note: without the comma, pdf_loadfontdescriptor would prefer /FontName over /BaseFont */
+ /* note: without the comma, pdf_load_font_descriptor would prefer /FontName over /BaseFont */
char *cp936fonts[] = {
"\xCB\xCE\xCC\xE5", "SimSun,Regular",
"\xBA\xDA\xCC\xE5", "SimHei,Regular",
@@ -304,34 +304,34 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
if (cp936fonts[i])
{
fz_warn("workaround for S22PDF lying about chinese font encodings");
- pdf_dropfont(fontdesc);
- fontdesc = pdf_newfontdesc();
- error = pdf_loadfontdescriptor(fontdesc, xref, descriptor, "Adobe-GB1", cp936fonts[i+1]);
- error |= pdf_loadsystemcmap(&fontdesc->encoding, "GBK-EUC-H");
- error |= pdf_loadsystemcmap(&fontdesc->tounicode, "Adobe-GB1-UCS2");
- error |= pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-GB1-UCS2");
+ pdf_drop_font(fontdesc);
+ fontdesc = pdf_new_font_desc();
+ error = pdf_load_font_descriptor(fontdesc, xref, descriptor, "Adobe-GB1", cp936fonts[i+1]);
+ error |= pdf_load_system_cmap(&fontdesc->encoding, "GBK-EUC-H");
+ error |= pdf_load_system_cmap(&fontdesc->to_unicode, "Adobe-GB1-UCS2");
+ error |= pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-GB1-UCS2");
if (error)
return fz_rethrow(error, "cannot load font");
- face = fontdesc->font->ftface;
- kind = ftkind(face);
+ face = fontdesc->font->ft_face;
+ kind = ft_kind(face);
goto skip_encoding;
}
}
- face = fontdesc->font->ftface;
- kind = ftkind(face);
+ face = fontdesc->font->ft_face;
+ kind = ft_kind(face);
/* Encoding */
- pdf_logfont("ft name '%s' '%s'\n", face->family_name, face->style_name);
+ pdf_log_font("ft name '%s' '%s'\n", face->family_name, face->style_name);
symbolic = fontdesc->flags & 4;
if (face->num_charmaps > 0)
cmap = face->charmaps[0];
else
- cmap = nil;
+ cmap = NULL;
for (i = 0; i < face->num_charmaps; i++)
{
@@ -356,7 +356,7 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
{
fterr = FT_Set_Charmap(face, cmap);
if (fterr)
- fz_warn("freetype could not set cmap: %s", ft_errorstring(fterr));
+ fz_warn("freetype could not set cmap: %s", ft_error_string(fterr));
}
else
fz_warn("freetype could not find any cmaps");
@@ -364,38 +364,38 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
etable = fz_calloc(256, sizeof(unsigned short));
for (i = 0; i < 256; i++)
{
- estrings[i] = nil;
+ estrings[i] = NULL;
etable[i] = 0;
}
- encoding = fz_dictgets(dict, "Encoding");
+ encoding = fz_dict_gets(dict, "Encoding");
if (encoding)
{
- if (fz_isname(encoding))
- pdf_loadencoding(estrings, fz_toname(encoding));
+ if (fz_is_name(encoding))
+ pdf_load_encoding(estrings, fz_to_name(encoding));
- if (fz_isdict(encoding))
+ if (fz_is_dict(encoding))
{
fz_obj *base, *diff, *item;
- base = fz_dictgets(encoding, "BaseEncoding");
- if (fz_isname(base))
- pdf_loadencoding(estrings, fz_toname(base));
+ base = fz_dict_gets(encoding, "BaseEncoding");
+ if (fz_is_name(base))
+ pdf_load_encoding(estrings, fz_to_name(base));
else if (!fontdesc->isembedded && !symbolic)
- pdf_loadencoding(estrings, "StandardEncoding");
+ pdf_load_encoding(estrings, "StandardEncoding");
- diff = fz_dictgets(encoding, "Differences");
- if (fz_isarray(diff))
+ diff = fz_dict_gets(encoding, "Differences");
+ if (fz_is_array(diff))
{
- n = fz_arraylen(diff);
+ n = fz_array_len(diff);
k = 0;
for (i = 0; i < n; i++)
{
- item = fz_arrayget(diff, i);
- if (fz_isint(item))
- k = fz_toint(item);
- if (fz_isname(item))
- estrings[k++] = fz_toname(item);
+ item = fz_array_get(diff, i);
+ if (fz_is_int(item))
+ k = fz_to_int(item);
+ if (fz_is_name(item))
+ estrings[k++] = fz_to_name(item);
if (k < 0) k = 0;
if (k > 255) k = 255;
}
@@ -405,12 +405,12 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
/* start with the builtin encoding */
for (i = 0; i < 256; i++)
- etable[i] = ftcharindex(face, i);
+ etable[i] = ft_char_index(face, i);
/* encode by glyph name where we can */
if (kind == TYPE1)
{
- pdf_logfont("encode type1/cff by strings\n");
+ pdf_log_font("encode type1/cff by strings\n");
for (i = 0; i < 256; i++)
{
if (estrings[i])
@@ -418,8 +418,8 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
etable[i] = FT_Get_Name_Index(face, estrings[i]);
if (etable[i] == 0)
{
- int aglcode = pdf_lookupagl(estrings[i]);
- char **aglnames = pdf_lookupaglnames(aglcode);
+ int aglcode = pdf_lookup_agl(estrings[i]);
+ char **aglnames = pdf_lookup_agl_names(aglcode);
while (*aglnames)
{
etable[i] = FT_Get_Name_Index(face, *aglnames);
@@ -438,16 +438,16 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
/* Unicode cmap */
if (!symbolic && face->charmap && face->charmap->platform_id == 3)
{
- pdf_logfont("encode truetype via unicode\n");
+ pdf_log_font("encode truetype via unicode\n");
for (i = 0; i < 256; i++)
{
if (estrings[i])
{
- int aglcode = pdf_lookupagl(estrings[i]);
+ int aglcode = pdf_lookup_agl(estrings[i]);
if (!aglcode)
etable[i] = FT_Get_Name_Index(face, estrings[i]);
else
- etable[i] = ftcharindex(face, aglcode);
+ etable[i] = ft_char_index(face, aglcode);
}
}
}
@@ -455,16 +455,16 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
/* MacRoman cmap */
else if (!symbolic && face->charmap && face->charmap->platform_id == 1)
{
- pdf_logfont("encode truetype via macroman\n");
+ pdf_log_font("encode truetype via macroman\n");
for (i = 0; i < 256; i++)
{
if (estrings[i])
{
- k = mrecode(estrings[i]);
+ k = mre_code(estrings[i]);
if (k <= 0)
etable[i] = FT_Get_Name_Index(face, estrings[i]);
else
- etable[i] = ftcharindex(face, k);
+ etable[i] = ft_char_index(face, k);
}
}
}
@@ -472,14 +472,14 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
/* Symbolic cmap */
else
{
- pdf_logfont("encode truetype symbolic\n");
+ pdf_log_font("encode truetype symbolic\n");
for (i = 0; i < 256; i++)
{
if (estrings[i])
{
etable[i] = FT_Get_Name_Index(face, estrings[i]);
if (etable[i] == 0)
- etable[i] = ftcharindex(face, i);
+ etable[i] = ft_char_index(face, i);
}
}
}
@@ -494,71 +494,71 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
{
fterr = FT_Get_Glyph_Name(face, etable[i], ebuffer[i], 32);
if (fterr)
- fz_warn("freetype get glyph name (gid %d): %s", etable[i], ft_errorstring(fterr));
+ fz_warn("freetype get glyph name (gid %d): %s", etable[i], ft_error_string(fterr));
if (ebuffer[i][0])
estrings[i] = ebuffer[i];
}
else
{
- estrings[i] = (char*) pdf_winansi[i]; /* discard const */
+ estrings[i] = (char*) pdf_win_ansi[i]; /* discard const */
}
}
}
- fontdesc->encoding = pdf_newidentitycmap(0, 1);
- fontdesc->ncidtogid = 256;
- fontdesc->cidtogid = etable;
+ fontdesc->encoding = pdf_new_identity_cmap(0, 1);
+ fontdesc->cid_to_gid_len = 256;
+ fontdesc->cid_to_gid = etable;
- error = pdf_loadtounicode(fontdesc, xref, estrings, nil, fz_dictgets(dict, "ToUnicode"));
+ error = pdf_load_to_unicode(fontdesc, xref, estrings, NULL, fz_dict_gets(dict, "ToUnicode"));
if (error)
- fz_catch(error, "cannot load tounicode");
+ fz_catch(error, "cannot load to_unicode");
skip_encoding:
/* Widths */
- pdf_setdefaulthmtx(fontdesc, fontdesc->missingwidth);
+ pdf_set_default_hmtx(fontdesc, fontdesc->missing_width);
- widths = fz_dictgets(dict, "Widths");
+ widths = fz_dict_gets(dict, "Widths");
if (widths)
{
int first, last;
- first = fz_toint(fz_dictgets(dict, "FirstChar"));
- last = fz_toint(fz_dictgets(dict, "LastChar"));
+ first = fz_to_int(fz_dict_gets(dict, "FirstChar"));
+ last = fz_to_int(fz_dict_gets(dict, "LastChar"));
if (first < 0 || last > 255 || first > last)
first = last = 0;
for (i = 0; i < last - first + 1; i++)
{
- int wid = fz_toint(fz_arrayget(widths, i));
- pdf_addhmtx(fontdesc, i + first, i + first, wid);
+ int wid = fz_to_int(fz_array_get(widths, i));
+ pdf_add_hmtx(fontdesc, i + first, i + first, wid);
}
}
else
{
fterr = FT_Set_Char_Size(face, 1000, 1000, 72, 72);
if (fterr)
- fz_warn("freetype set character size: %s", ft_errorstring(fterr));
+ fz_warn("freetype set character size: %s", ft_error_string(fterr));
for (i = 0; i < 256; i++)
{
- pdf_addhmtx(fontdesc, i, i, ftwidth(fontdesc, i));
+ pdf_add_hmtx(fontdesc, i, i, ft_width(fontdesc, i));
}
}
- pdf_endhmtx(fontdesc);
+ pdf_end_hmtx(fontdesc);
- pdf_logfont("}\n");
+ pdf_log_font("}\n");
*fontdescp = fontdesc;
return fz_okay;
cleanup:
- if (etable != fontdesc->cidtogid)
+ if (etable != fontdesc->cid_to_gid)
fz_free(etable);
- pdf_dropfont(fontdesc);
- return fz_rethrow(error, "cannot load simple font (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ pdf_drop_font(fontdesc);
+ return fz_rethrow(error, "cannot load simple font (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
/*
@@ -566,12 +566,12 @@ cleanup:
*/
static fz_error
-loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *tounicode)
+load_cid_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode)
{
fz_error error;
fz_obj *widths;
fz_obj *descriptor;
- pdf_fontdesc *fontdesc;
+ pdf_font_desc *fontdesc;
FT_Face face;
int kind;
char collection[256];
@@ -582,78 +582,78 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *enco
/* Get font name and CID collection */
- basefont = fz_toname(fz_dictgets(dict, "BaseFont"));
+ basefont = fz_to_name(fz_dict_gets(dict, "BaseFont"));
{
fz_obj *cidinfo;
char tmpstr[64];
int tmplen;
- cidinfo = fz_dictgets(dict, "CIDSystemInfo");
+ cidinfo = fz_dict_gets(dict, "CIDSystemInfo");
if (!cidinfo)
return fz_throw("cid font is missing info");
- obj = fz_dictgets(cidinfo, "Registry");
- tmplen = MIN(sizeof tmpstr - 1, fz_tostrlen(obj));
- memcpy(tmpstr, fz_tostrbuf(obj), tmplen);
+ obj = fz_dict_gets(cidinfo, "Registry");
+ tmplen = MIN(sizeof tmpstr - 1, fz_to_str_len(obj));
+ memcpy(tmpstr, fz_to_str_buf(obj), tmplen);
tmpstr[tmplen] = '\0';
fz_strlcpy(collection, tmpstr, sizeof collection);
fz_strlcat(collection, "-", sizeof collection);
- obj = fz_dictgets(cidinfo, "Ordering");
- tmplen = MIN(sizeof tmpstr - 1, fz_tostrlen(obj));
- memcpy(tmpstr, fz_tostrbuf(obj), tmplen);
+ obj = fz_dict_gets(cidinfo, "Ordering");
+ tmplen = MIN(sizeof tmpstr - 1, fz_to_str_len(obj));
+ memcpy(tmpstr, fz_to_str_buf(obj), tmplen);
tmpstr[tmplen] = '\0';
fz_strlcat(collection, tmpstr, sizeof collection);
}
/* Load font file */
- fontdesc = pdf_newfontdesc();
+ fontdesc = pdf_new_font_desc();
- pdf_logfont("load cid font (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), fontdesc);
- pdf_logfont("basefont %s\n", basefont);
- pdf_logfont("collection %s\n", collection);
+ pdf_log_font("load cid font (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), fontdesc);
+ pdf_log_font("basefont %s\n", basefont);
+ pdf_log_font("collection %s\n", collection);
- descriptor = fz_dictgets(dict, "FontDescriptor");
+ descriptor = fz_dict_gets(dict, "FontDescriptor");
if (descriptor)
- error = pdf_loadfontdescriptor(fontdesc, xref, descriptor, collection, basefont);
+ error = pdf_load_font_descriptor(fontdesc, xref, descriptor, collection, basefont);
else
error = fz_throw("syntaxerror: missing font descriptor");
if (error)
goto cleanup;
- face = fontdesc->font->ftface;
- kind = ftkind(face);
+ face = fontdesc->font->ft_face;
+ kind = ft_kind(face);
/* Check for DynaLab fonts that must use hinting */
if (kind == TRUETYPE)
{
if (FT_IS_TRICKY(face) || isdynalab(fontdesc->font->name))
{
- fontdesc->font->fthint = 1;
- pdf_logfont("forced hinting for dynalab font\n");
+ fontdesc->font->ft_hint = 1;
+ pdf_log_font("forced hinting for dynalab font\n");
}
}
/* Encoding */
error = fz_okay;
- if (fz_isname(encoding))
+ if (fz_is_name(encoding))
{
- pdf_logfont("encoding /%s\n", fz_toname(encoding));
- if (!strcmp(fz_toname(encoding), "Identity-H"))
- fontdesc->encoding = pdf_newidentitycmap(0, 2);
- else if (!strcmp(fz_toname(encoding), "Identity-V"))
- fontdesc->encoding = pdf_newidentitycmap(1, 2);
+ pdf_log_font("encoding /%s\n", fz_to_name(encoding));
+ if (!strcmp(fz_to_name(encoding), "Identity-H"))
+ fontdesc->encoding = pdf_new_identity_cmap(0, 2);
+ else if (!strcmp(fz_to_name(encoding), "Identity-V"))
+ fontdesc->encoding = pdf_new_identity_cmap(1, 2);
else
- error = pdf_loadsystemcmap(&fontdesc->encoding, fz_toname(encoding));
+ error = pdf_load_system_cmap(&fontdesc->encoding, fz_to_name(encoding));
}
- else if (fz_isindirect(encoding))
+ else if (fz_is_indirect(encoding))
{
- pdf_logfont("encoding %d %d R\n", fz_tonum(encoding), fz_togen(encoding));
- error = pdf_loadembeddedcmap(&fontdesc->encoding, xref, encoding);
+ pdf_log_font("encoding %d %d R\n", fz_to_num(encoding), fz_to_gen(encoding));
+ error = pdf_load_embedded_cmap(&fontdesc->encoding, xref, encoding);
}
else
{
@@ -662,56 +662,56 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *enco
if (error)
goto cleanup;
- pdf_setfontwmode(fontdesc, pdf_getwmode(fontdesc->encoding));
- pdf_logfont("wmode %d\n", pdf_getwmode(fontdesc->encoding));
+ pdf_set_font_wmode(fontdesc, pdf_get_wmode(fontdesc->encoding));
+ pdf_log_font("wmode %d\n", pdf_get_wmode(fontdesc->encoding));
if (kind == TRUETYPE)
{
fz_obj *cidtogidmap;
- cidtogidmap = fz_dictgets(dict, "CIDToGIDMap");
- if (fz_isindirect(cidtogidmap))
+ cidtogidmap = fz_dict_gets(dict, "CIDToGIDMap");
+ if (fz_is_indirect(cidtogidmap))
{
fz_buffer *buf;
- pdf_logfont("cidtogidmap stream\n");
+ pdf_log_font("cidtogidmap stream\n");
- error = pdf_loadstream(&buf, xref, fz_tonum(cidtogidmap), fz_togen(cidtogidmap));
+ error = pdf_load_stream(&buf, xref, fz_to_num(cidtogidmap), fz_to_gen(cidtogidmap));
if (error)
goto cleanup;
- fontdesc->ncidtogid = (buf->len) / 2;
- fontdesc->cidtogid = fz_calloc(fontdesc->ncidtogid, sizeof(unsigned short));
- for (i = 0; i < fontdesc->ncidtogid; i++)
- fontdesc->cidtogid[i] = (buf->data[i * 2] << 8) + buf->data[i * 2 + 1];
+ fontdesc->cid_to_gid_len = (buf->len) / 2;
+ fontdesc->cid_to_gid = fz_calloc(fontdesc->cid_to_gid_len, sizeof(unsigned short));
+ for (i = 0; i < fontdesc->cid_to_gid_len; i++)
+ fontdesc->cid_to_gid[i] = (buf->data[i * 2] << 8) + buf->data[i * 2 + 1];
- fz_dropbuffer(buf);
+ fz_drop_buffer(buf);
}
/* if truetype font is external, cidtogidmap should not be identity */
/* so we map from cid to unicode and then map that through the (3 1) */
/* unicode cmap to get a glyph id */
- else if (fontdesc->font->ftsubstitute)
+ else if (fontdesc->font->ft_substitute)
{
- pdf_logfont("emulate ttf cidfont\n");
+ pdf_log_font("emulate ttf cidfont\n");
fterr = FT_Select_Charmap(face, ft_encoding_unicode);
if (fterr)
{
- error = fz_throw("fonterror: no unicode cmap when emulating CID font: %s", ft_errorstring(fterr));
+ error = fz_throw("fonterror: no unicode cmap when emulating CID font: %s", ft_error_string(fterr));
goto cleanup;
}
if (!strcmp(collection, "Adobe-CNS1"))
- error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-CNS1-UCS2");
+ error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-CNS1-UCS2");
else if (!strcmp(collection, "Adobe-GB1"))
- error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-GB1-UCS2");
+ error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-GB1-UCS2");
else if (!strcmp(collection, "Adobe-Japan1"))
- error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-Japan1-UCS2");
+ error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-Japan1-UCS2");
else if (!strcmp(collection, "Adobe-Japan2"))
- error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-Japan2-UCS2");
+ error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-Japan2-UCS2");
else if (!strcmp(collection, "Adobe-Korea1"))
- error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-Korea1-UCS2");
+ error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-Korea1-UCS2");
else
error = fz_okay;
@@ -723,137 +723,137 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *enco
}
}
- error = pdf_loadtounicode(fontdesc, xref, nil, collection, tounicode);
+ error = pdf_load_to_unicode(fontdesc, xref, NULL, collection, to_unicode);
if (error)
- fz_catch(error, "cannot load tounicode");
+ fz_catch(error, "cannot load to_unicode");
/* Horizontal */
dw = 1000;
- obj = fz_dictgets(dict, "DW");
+ obj = fz_dict_gets(dict, "DW");
if (obj)
- dw = fz_toint(obj);
- pdf_setdefaulthmtx(fontdesc, dw);
+ dw = fz_to_int(obj);
+ pdf_set_default_hmtx(fontdesc, dw);
- widths = fz_dictgets(dict, "W");
+ widths = fz_dict_gets(dict, "W");
if (widths)
{
int c0, c1, w;
- for (i = 0; i < fz_arraylen(widths); )
+ for (i = 0; i < fz_array_len(widths); )
{
- c0 = fz_toint(fz_arrayget(widths, i));
- obj = fz_arrayget(widths, i + 1);
- if (fz_isarray(obj))
+ c0 = fz_to_int(fz_array_get(widths, i));
+ obj = fz_array_get(widths, i + 1);
+ if (fz_is_array(obj))
{
- for (k = 0; k < fz_arraylen(obj); k++)
+ for (k = 0; k < fz_array_len(obj); k++)
{
- w = fz_toint(fz_arrayget(obj, k));
- pdf_addhmtx(fontdesc, c0 + k, c0 + k, w);
+ w = fz_to_int(fz_array_get(obj, k));
+ pdf_add_hmtx(fontdesc, c0 + k, c0 + k, w);
}
i += 2;
}
else
{
- c1 = fz_toint(obj);
- w = fz_toint(fz_arrayget(widths, i + 2));
- pdf_addhmtx(fontdesc, c0, c1, w);
+ c1 = fz_to_int(obj);
+ w = fz_to_int(fz_array_get(widths, i + 2));
+ pdf_add_hmtx(fontdesc, c0, c1, w);
i += 3;
}
}
}
- pdf_endhmtx(fontdesc);
+ pdf_end_hmtx(fontdesc);
/* Vertical */
- if (pdf_getwmode(fontdesc->encoding) == 1)
+ if (pdf_get_wmode(fontdesc->encoding) == 1)
{
int dw2y = 880;
int dw2w = -1000;
- obj = fz_dictgets(dict, "DW2");
+ obj = fz_dict_gets(dict, "DW2");
if (obj)
{
- dw2y = fz_toint(fz_arrayget(obj, 0));
- dw2w = fz_toint(fz_arrayget(obj, 1));
+ dw2y = fz_to_int(fz_array_get(obj, 0));
+ dw2w = fz_to_int(fz_array_get(obj, 1));
}
- pdf_setdefaultvmtx(fontdesc, dw2y, dw2w);
+ pdf_set_default_vmtx(fontdesc, dw2y, dw2w);
- widths = fz_dictgets(dict, "W2");
+ widths = fz_dict_gets(dict, "W2");
if (widths)
{
int c0, c1, w, x, y;
- for (i = 0; i < fz_arraylen(widths); )
+ for (i = 0; i < fz_array_len(widths); )
{
- c0 = fz_toint(fz_arrayget(widths, i));
- obj = fz_arrayget(widths, i + 1);
- if (fz_isarray(obj))
+ c0 = fz_to_int(fz_array_get(widths, i));
+ obj = fz_array_get(widths, i + 1);
+ if (fz_is_array(obj))
{
- for (k = 0; k * 3 < fz_arraylen(obj); k ++)
+ for (k = 0; k * 3 < fz_array_len(obj); k ++)
{
- w = fz_toint(fz_arrayget(obj, k * 3 + 0));
- x = fz_toint(fz_arrayget(obj, k * 3 + 1));
- y = fz_toint(fz_arrayget(obj, k * 3 + 2));
- pdf_addvmtx(fontdesc, c0 + k, c0 + k, x, y, w);
+ w = fz_to_int(fz_array_get(obj, k * 3 + 0));
+ x = fz_to_int(fz_array_get(obj, k * 3 + 1));
+ y = fz_to_int(fz_array_get(obj, k * 3 + 2));
+ pdf_add_vmtx(fontdesc, c0 + k, c0 + k, x, y, w);
}
i += 2;
}
else
{
- c1 = fz_toint(obj);
- w = fz_toint(fz_arrayget(widths, i + 2));
- x = fz_toint(fz_arrayget(widths, i + 3));
- y = fz_toint(fz_arrayget(widths, i + 4));
- pdf_addvmtx(fontdesc, c0, c1, x, y, w);
+ c1 = fz_to_int(obj);
+ w = fz_to_int(fz_array_get(widths, i + 2));
+ x = fz_to_int(fz_array_get(widths, i + 3));
+ y = fz_to_int(fz_array_get(widths, i + 4));
+ pdf_add_vmtx(fontdesc, c0, c1, x, y, w);
i += 5;
}
}
}
- pdf_endvmtx(fontdesc);
+ pdf_end_vmtx(fontdesc);
}
- pdf_logfont("}\n");
+ pdf_log_font("}\n");
*fontdescp = fontdesc;
return fz_okay;
cleanup:
- pdf_dropfont(fontdesc);
- return fz_rethrow(error, "cannot load cid font (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ pdf_drop_font(fontdesc);
+ return fz_rethrow(error, "cannot load cid font (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
static fz_error
-loadtype0(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
+load_type0_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
fz_obj *dfonts;
fz_obj *dfont;
fz_obj *subtype;
fz_obj *encoding;
- fz_obj *tounicode;
+ fz_obj *to_unicode;
- dfonts = fz_dictgets(dict, "DescendantFonts");
+ dfonts = fz_dict_gets(dict, "DescendantFonts");
if (!dfonts)
return fz_throw("cid font is missing descendant fonts");
- dfont = fz_arrayget(dfonts, 0);
+ dfont = fz_array_get(dfonts, 0);
- subtype = fz_dictgets(dfont, "Subtype");
- encoding = fz_dictgets(dict, "Encoding");
- tounicode = fz_dictgets(dict, "ToUnicode");
+ subtype = fz_dict_gets(dfont, "Subtype");
+ encoding = fz_dict_gets(dict, "Encoding");
+ to_unicode = fz_dict_gets(dict, "ToUnicode");
- if (fz_isname(subtype) && !strcmp(fz_toname(subtype), "CIDFontType0"))
- error = loadcidfont(fontdescp, xref, dfont, encoding, tounicode);
- else if (fz_isname(subtype) && !strcmp(fz_toname(subtype), "CIDFontType2"))
- error = loadcidfont(fontdescp, xref, dfont, encoding, tounicode);
+ if (fz_is_name(subtype) && !strcmp(fz_to_name(subtype), "CIDFontType0"))
+ error = load_cid_font(fontdescp, xref, dfont, encoding, to_unicode);
+ else if (fz_is_name(subtype) && !strcmp(fz_to_name(subtype), "CIDFontType2"))
+ error = load_cid_font(fontdescp, xref, dfont, encoding, to_unicode);
else
error = fz_throw("syntaxerror: unknown cid font type");
if (error)
- return fz_rethrow(error, "cannot load descendant font (%d %d R)", fz_tonum(dfont), fz_togen(dfont));
+ return fz_rethrow(error, "cannot load descendant font (%d %d R)", fz_to_num(dfont), fz_to_gen(dfont));
return fz_okay;
}
@@ -863,170 +863,170 @@ loadtype0(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict)
*/
fz_error
-pdf_loadfontdescriptor(pdf_fontdesc *fontdesc, pdf_xref *xref, fz_obj *dict, char *collection, char *basefont)
+pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *dict, char *collection, char *basefont)
{
fz_error error;
fz_obj *obj1, *obj2, *obj3, *obj;
char *fontname;
char *origname;
- pdf_logfont("load fontdescriptor {\n");
+ pdf_log_font("load fontdescriptor {\n");
if (!strchr(basefont, ',') || strchr(basefont, '+'))
- origname = fz_toname(fz_dictgets(dict, "FontName"));
+ origname = fz_to_name(fz_dict_gets(dict, "FontName"));
else
origname = basefont;
- fontname = cleanfontname(origname);
+ fontname = clean_font_name(origname);
- pdf_logfont("fontname %s -> %s\n", origname, fontname);
+ pdf_log_font("fontname %s -> %s\n", origname, fontname);
- fontdesc->flags = fz_toint(fz_dictgets(dict, "Flags"));
- fontdesc->italicangle = fz_toreal(fz_dictgets(dict, "ItalicAngle"));
- fontdesc->ascent = fz_toreal(fz_dictgets(dict, "Ascent"));
- fontdesc->descent = fz_toreal(fz_dictgets(dict, "Descent"));
- fontdesc->capheight = fz_toreal(fz_dictgets(dict, "CapHeight"));
- fontdesc->xheight = fz_toreal(fz_dictgets(dict, "XHeight"));
- fontdesc->missingwidth = fz_toreal(fz_dictgets(dict, "MissingWidth"));
+ fontdesc->flags = fz_to_int(fz_dict_gets(dict, "Flags"));
+ fontdesc->italic_angle = fz_to_real(fz_dict_gets(dict, "ItalicAngle"));
+ fontdesc->ascent = fz_to_real(fz_dict_gets(dict, "Ascent"));
+ fontdesc->descent = fz_to_real(fz_dict_gets(dict, "Descent"));
+ fontdesc->cap_height = fz_to_real(fz_dict_gets(dict, "CapHeight"));
+ fontdesc->x_height = fz_to_real(fz_dict_gets(dict, "XHeight"));
+ fontdesc->missing_width = fz_to_real(fz_dict_gets(dict, "MissingWidth"));
- pdf_logfont("flags %d\n", fontdesc->flags);
+ pdf_log_font("flags %d\n", fontdesc->flags);
- obj1 = fz_dictgets(dict, "FontFile");
- obj2 = fz_dictgets(dict, "FontFile2");
- obj3 = fz_dictgets(dict, "FontFile3");
+ obj1 = fz_dict_gets(dict, "FontFile");
+ obj2 = fz_dict_gets(dict, "FontFile2");
+ obj3 = fz_dict_gets(dict, "FontFile3");
obj = obj1 ? obj1 : obj2 ? obj2 : obj3;
if (getenv("NOFONT"))
- obj = nil;
+ obj = NULL;
- if (fz_isindirect(obj))
+ if (fz_is_indirect(obj))
{
- error = pdf_loadembeddedfont(fontdesc, xref, obj);
+ error = pdf_load_embedded_font(fontdesc, xref, obj);
if (error)
{
fz_catch(error, "ignored error when loading embedded font, attempting to load system font");
if (origname != fontname)
- error = pdf_loadbuiltinfont(fontdesc, fontname);
+ error = pdf_load_builtin_font(fontdesc, fontname);
else
- error = pdf_loadsystemfont(fontdesc, fontname, collection);
+ error = pdf_load_system_font(fontdesc, fontname, collection);
if (error)
- return fz_rethrow(error, "cannot load font descriptor (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ return fz_rethrow(error, "cannot load font descriptor (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
}
else
{
if (origname != fontname)
- error = pdf_loadbuiltinfont(fontdesc, fontname);
+ error = pdf_load_builtin_font(fontdesc, fontname);
else
- error = pdf_loadsystemfont(fontdesc, fontname, collection);
+ error = pdf_load_system_font(fontdesc, fontname, collection);
if (error)
- return fz_rethrow(error, "cannot load font descriptor (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ return fz_rethrow(error, "cannot load font descriptor (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
fz_strlcpy(fontdesc->font->name, fontname, sizeof fontdesc->font->name);
- pdf_logfont("}\n");
+ pdf_log_font("}\n");
return fz_okay;
}
static void
-pdf_makewidthtable(pdf_fontdesc *fontdesc)
+pdf_make_width_table(pdf_font_desc *fontdesc)
{
fz_font *font = fontdesc->font;
int i, k, cid, gid;
- font->widthcount = 0;
- for (i = 0; i < fontdesc->nhmtx; i++)
+ font->width_count = 0;
+ for (i = 0; i < fontdesc->hmtx_len; i++)
{
for (k = fontdesc->hmtx[i].lo; k <= fontdesc->hmtx[i].hi; k++)
{
- cid = pdf_lookupcmap(fontdesc->encoding, k);
- gid = pdf_fontcidtogid(fontdesc, cid);
- if (gid > font->widthcount)
- font->widthcount = gid;
+ cid = pdf_lookup_cmap(fontdesc->encoding, k);
+ gid = pdf_font_cid_to_gid(fontdesc, cid);
+ if (gid > font->width_count)
+ font->width_count = gid;
}
}
- font->widthcount ++;
+ font->width_count ++;
- font->widthtable = fz_calloc(font->widthcount, sizeof(int));
- memset(font->widthtable, 0, sizeof(int) * font->widthcount);
+ font->width_table = fz_calloc(font->width_count, sizeof(int));
+ memset(font->width_table, 0, sizeof(int) * font->width_count);
- for (i = 0; i < fontdesc->nhmtx; i++)
+ for (i = 0; i < fontdesc->hmtx_len; i++)
{
for (k = fontdesc->hmtx[i].lo; k <= fontdesc->hmtx[i].hi; k++)
{
- cid = pdf_lookupcmap(fontdesc->encoding, k);
- gid = pdf_fontcidtogid(fontdesc, cid);
- if (gid >= 0 && gid < font->widthcount)
- font->widthtable[gid] = fontdesc->hmtx[i].w;
+ cid = pdf_lookup_cmap(fontdesc->encoding, k);
+ gid = pdf_font_cid_to_gid(fontdesc, cid);
+ if (gid >= 0 && gid < font->width_count)
+ font->width_table[gid] = fontdesc->hmtx[i].w;
}
}
}
fz_error
-pdf_loadfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict)
+pdf_load_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict)
{
fz_error error;
char *subtype;
fz_obj *dfonts;
fz_obj *charprocs;
- if ((*fontdescp = pdf_finditem(xref->store, pdf_dropfont, dict)))
+ if ((*fontdescp = pdf_find_item(xref->store, pdf_drop_font, dict)))
{
- pdf_keepfont(*fontdescp);
+ pdf_keep_font(*fontdescp);
return fz_okay;
}
- subtype = fz_toname(fz_dictgets(dict, "Subtype"));
- dfonts = fz_dictgets(dict, "DescendantFonts");
- charprocs = fz_dictgets(dict, "CharProcs");
+ subtype = fz_to_name(fz_dict_gets(dict, "Subtype"));
+ dfonts = fz_dict_gets(dict, "DescendantFonts");
+ charprocs = fz_dict_gets(dict, "CharProcs");
if (subtype && !strcmp(subtype, "Type0"))
- error = loadtype0(fontdescp, xref, dict);
+ error = load_type0_font(fontdescp, xref, dict);
else if (subtype && !strcmp(subtype, "Type1"))
- error = loadsimplefont(fontdescp, xref, dict);
+ error = load_simple_font(fontdescp, xref, dict);
else if (subtype && !strcmp(subtype, "MMType1"))
- error = loadsimplefont(fontdescp, xref, dict);
+ error = load_simple_font(fontdescp, xref, dict);
else if (subtype && !strcmp(subtype, "TrueType"))
- error = loadsimplefont(fontdescp, xref, dict);
+ error = load_simple_font(fontdescp, xref, dict);
else if (subtype && !strcmp(subtype, "Type3"))
- error = pdf_loadtype3font(fontdescp, xref, rdb, dict);
+ error = pdf_load_type3_font(fontdescp, xref, rdb, dict);
else if (charprocs)
{
fz_warn("unknown font format, guessing type3.");
- error = pdf_loadtype3font(fontdescp, xref, rdb, dict);
+ error = pdf_load_type3_font(fontdescp, xref, rdb, dict);
}
else if (dfonts)
{
fz_warn("unknown font format, guessing type0.");
- error = loadtype0(fontdescp, xref, dict);
+ error = load_type0_font(fontdescp, xref, dict);
}
else
{
fz_warn("unknown font format, guessing type1 or truetype.");
- error = loadsimplefont(fontdescp, xref, dict);
+ error = load_simple_font(fontdescp, xref, dict);
}
if (error)
- return fz_rethrow(error, "cannot load font (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ return fz_rethrow(error, "cannot load font (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
/* Save the widths to stretch non-CJK substitute fonts */
- if ((*fontdescp)->font->ftsubstitute && !(*fontdescp)->tottfcmap)
- pdf_makewidthtable(*fontdescp);
+ if ((*fontdescp)->font->ft_substitute && !(*fontdescp)->to_ttf_cmap)
+ pdf_make_width_table(*fontdescp);
- pdf_storeitem(xref->store, pdf_keepfont, pdf_dropfont, dict, *fontdescp);
+ pdf_store_item(xref->store, pdf_keep_font, pdf_drop_font, dict, *fontdescp);
return fz_okay;
}
void
-pdf_debugfont(pdf_fontdesc *fontdesc)
+pdf_debug_font(pdf_font_desc *fontdesc)
{
int i;
printf("fontdesc {\n");
- if (fontdesc->font->ftface)
+ if (fontdesc->font->ft_face)
printf("\tfreetype font\n");
if (fontdesc->font->t3procs)
printf("\ttype3 font\n");
@@ -1035,7 +1035,7 @@ pdf_debugfont(pdf_fontdesc *fontdesc)
printf("\tDW %d\n", fontdesc->dhmtx.w);
printf("\tW {\n");
- for (i = 0; i < fontdesc->nhmtx; i++)
+ for (i = 0; i < fontdesc->hmtx_len; i++)
printf("\t\t<%04x> <%04x> %d\n",
fontdesc->hmtx[i].lo, fontdesc->hmtx[i].hi, fontdesc->hmtx[i].w);
printf("\t}\n");
@@ -1044,7 +1044,7 @@ pdf_debugfont(pdf_fontdesc *fontdesc)
{
printf("\tDW2 [%d %d]\n", fontdesc->dvmtx.y, fontdesc->dvmtx.w);
printf("\tW2 {\n");
- for (i = 0; i < fontdesc->nvmtx; i++)
+ for (i = 0; i < fontdesc->vmtx_len; i++)
printf("\t\t<%04x> <%04x> %d %d %d\n", fontdesc->vmtx[i].lo, fontdesc->vmtx[i].hi,
fontdesc->vmtx[i].x, fontdesc->vmtx[i].y, fontdesc->vmtx[i].w);
printf("\t}\n");
diff --git a/pdf/pdf_fontagl.c b/pdf/pdf_fontagl.c
index e310848b..e9a7af95 100644
--- a/pdf/pdf_fontagl.c
+++ b/pdf/pdf_fontagl.c
@@ -12,7 +12,7 @@
*/
static const struct { char *name; int ucs; }
-aglcodes[] = {
+agl_codes[] = {
{"A", 0x0041},
{"AE", 0x00C6},
{"AEacute", 0x01FC},
@@ -4297,7 +4297,7 @@ aglcodes[] = {
};
static const struct { int ucs; int ofs; }
-agldupcodes[] = {
+agl_dup_codes[] = {
{0x0020, 0},
{0x007C, 3},
{0x00A0, 6},
@@ -4678,7 +4678,7 @@ agldupcodes[] = {
{0xFEF4, 1354},
};
-static char *agldupnames[] = {
+static char *agl_dup_names[] = {
"space", "spacehackarabic", 0,
"bar", "verticalbar", 0,
"nbspace", "nonbreakingspace", 0,
@@ -5062,12 +5062,12 @@ static char *agldupnames[] = {
#include "fitz.h"
#include "mupdf.h"
-int pdf_lookupagl(char *name)
+int pdf_lookup_agl(char *name)
{
char buf[64];
char *p;
int l = 0;
- int r = nelem(aglcodes) - 1;
+ int r = nelem(agl_codes) - 1;
fz_strlcpy(buf, name, sizeof buf);
@@ -5080,40 +5080,40 @@ int pdf_lookupagl(char *name)
while (l <= r)
{
int m = (l + r) >> 1;
- int c = strcmp(buf, aglcodes[m].name);
+ int c = strcmp(buf, agl_codes[m].name);
if (c < 0)
r = m - 1;
else if (c > 0)
l = m + 1;
else
- return aglcodes[m].ucs;
+ return agl_codes[m].ucs;
}
if (strstr(buf, "uni") == buf)
- return strtol(buf + 3, nil, 16);
+ return strtol(buf + 3, NULL, 16);
else if (strstr(buf, "u") == buf)
- return strtol(buf + 1, nil, 16);
+ return strtol(buf + 1, NULL, 16);
else if (strstr(buf, "a") == buf && strlen(buf) >= 3)
- return strtol(buf + 1, nil, 10);
+ return strtol(buf + 1, NULL, 10);
return 0;
}
-static char *aglnoname[1] = { 0 };
+static char *agl_no_name[1] = { 0 };
-char **pdf_lookupaglnames(int ucs)
+char **pdf_lookup_agl_names(int ucs)
{
int l = 0;
- int r = nelem(agldupcodes) - 1;
+ int r = nelem(agl_dup_codes) - 1;
while (l <= r)
{
int m = (l + r) >> 1;
- if (ucs < agldupcodes[m].ucs)
+ if (ucs < agl_dup_codes[m].ucs)
r = m - 1;
- else if (ucs > agldupcodes[m].ucs)
+ else if (ucs > agl_dup_codes[m].ucs)
l = m + 1;
else
- return agldupnames + agldupcodes[m].ofs;
+ return agl_dup_names + agl_dup_codes[m].ofs;
}
- return aglnoname;
+ return agl_no_name;
}
diff --git a/pdf/pdf_fontenc.c b/pdf/pdf_fontenc.c
index 0f72cb6a..daa1aa27 100644
--- a/pdf/pdf_fontenc.c
+++ b/pdf/pdf_fontenc.c
@@ -1,19 +1,19 @@
#include "fitz.h"
#include "mupdf.h"
-#define _notdef nil
+#define _notdef NULL
-void pdf_loadencoding(char **estrings, char *encoding)
+void pdf_load_encoding(char **estrings, char *encoding)
{
- char **bstrings = nil;
+ char **bstrings = NULL;
int i;
if (!strcmp(encoding, "MacRomanEncoding"))
- bstrings = (char**) pdf_macroman;
+ bstrings = (char**) pdf_mac_roman;
if (!strcmp(encoding, "MacExpertEncoding"))
- bstrings = (char**) pdf_macexpert;
+ bstrings = (char**) pdf_mac_expert;
if (!strcmp(encoding, "WinAnsiEncoding"))
- bstrings = (char**) pdf_winansi;
+ bstrings = (char**) pdf_win_ansi;
if (!strcmp(encoding, "StandardEncoding"))
bstrings = (char**) pdf_standard;
@@ -22,7 +22,7 @@ void pdf_loadencoding(char **estrings, char *encoding)
estrings[i] = bstrings[i];
}
-const unsigned short pdf_docencoding[256] =
+const unsigned short pdf_doc_encoding[256] =
{
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0009, 0x000A, 0x0000, 0x0000, 0x000D, 0x0000, 0x0000,
@@ -58,7 +58,7 @@ const unsigned short pdf_docencoding[256] =
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff
};
-const char * const pdf_macroman[256] = { _notdef, _notdef,
+const char * const pdf_mac_roman[256] = { _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
@@ -98,7 +98,7 @@ const char * const pdf_macroman[256] = { _notdef, _notdef,
"Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve",
"dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron" };
-const char * const pdf_macexpert[256] = { _notdef, _notdef,
+const char * const pdf_mac_expert[256] = { _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
@@ -151,7 +151,7 @@ const char * const pdf_macexpert[256] = { _notdef, _notdef,
"msuperior", "commasuperior", "periodsuperior", "Dotaccentsmall",
"Ringsmall", _notdef, _notdef, _notdef, _notdef };
-const char * const pdf_winansi[256] = { _notdef, _notdef, _notdef,
+const char * const pdf_win_ansi[256] = { _notdef, _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
_notdef, _notdef, _notdef, _notdef, _notdef, _notdef,
diff --git a/pdf/pdf_fontfile.c b/pdf/pdf_fontfile.c
index 1fedae44..79eee737 100644
--- a/pdf/pdf_fontfile.c
+++ b/pdf/pdf_fontfile.c
@@ -37,15 +37,15 @@ extern const unsigned int pdf_font_DroidSansFallback_ttf_len;
enum
{
- FD_FIXED = 1 << 0,
+ FD_FIXED_PITCH = 1 << 0,
FD_SERIF = 1 << 1,
FD_SYMBOLIC = 1 << 2,
FD_SCRIPT = 1 << 3,
FD_NONSYMBOLIC = 1 << 5,
FD_ITALIC = 1 << 6,
- FD_ALLCAP = 1 << 16,
- FD_SMALLCAP = 1 << 17,
- FD_FORCEBOLD = 1 << 18
+ FD_ALL_CAP = 1 << 16,
+ FD_SMALL_CAP = 1 << 17,
+ FD_FORCE_BOLD = 1 << 18
};
enum { CNS, GB, Japan, Korea };
@@ -55,7 +55,7 @@ static const struct {
const char *name;
const unsigned char *cff;
const unsigned int *len;
-} basefonts[] = {
+} base_fonts[] = {
{ "Courier",
pdf_font_NimbusMonL_Regu_cff_buf,
&pdf_font_NimbusMonL_Regu_cff_len },
@@ -98,30 +98,30 @@ static const struct {
{ "ZapfDingbats",
pdf_font_Dingbats_cff_buf,
&pdf_font_Dingbats_cff_len },
- { nil, nil, nil }
+ { NULL, NULL, NULL }
};
fz_error
-pdf_loadbuiltinfont(pdf_fontdesc *fontdesc, char *fontname)
+pdf_load_builtin_font(pdf_font_desc *fontdesc, char *fontname)
{
fz_error error;
unsigned char *data;
unsigned int len;
int i;
- for (i = 0; basefonts[i].name; i++)
- if (!strcmp(fontname, basefonts[i].name))
+ for (i = 0; base_fonts[i].name; i++)
+ if (!strcmp(fontname, base_fonts[i].name))
goto found;
return fz_throw("cannot find font: '%s'", fontname);
found:
- pdf_logfont("load builtin font %s\n", fontname);
+ pdf_log_font("load builtin font %s\n", fontname);
- data = (unsigned char *) basefonts[i].cff;
- len = *basefonts[i].len;
+ data = (unsigned char *) base_fonts[i].cff;
+ len = *base_fonts[i].len;
- error = fz_newfontfrombuffer(&fontdesc->font, data, len, 0);
+ error = fz_new_font_from_memory(&fontdesc->font, data, len, 0);
if (error)
return fz_rethrow(error, "cannot load freetype font from buffer");
@@ -134,7 +134,7 @@ found:
}
static fz_error
-loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind)
+load_system_cid_font(pdf_font_desc *fontdesc, int ros, int kind)
{
#ifndef NOCJK
fz_error error;
@@ -142,13 +142,13 @@ loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind)
We only have one builtin fallback font.
We'd really like to have one for each combination of ROS and Kind.
*/
- pdf_logfont("loading builtin CJK font\n");
- error = fz_newfontfrombuffer(&fontdesc->font,
+ pdf_log_font("loading builtin CJK font\n");
+ error = fz_new_font_from_memory(&fontdesc->font,
(unsigned char *)pdf_font_DroidSansFallback_ttf_buf,
pdf_font_DroidSansFallback_ttf_len, 0);
if (error)
return fz_rethrow(error, "cannot load builtin CJK font");
- fontdesc->font->ftsubstitute = 1; /* substitute font */
+ fontdesc->font->ft_substitute = 1; /* substitute font */
return fz_okay;
#else
return fz_throw("no builtin CJK font file");
@@ -156,7 +156,7 @@ loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind)
}
fz_error
-pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection)
+pdf_load_system_font(pdf_font_desc *fontdesc, char *fontname, char *collection)
{
fz_error error;
char *name;
@@ -174,7 +174,7 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection)
if (strstr(fontname, "Oblique"))
isitalic = 1;
- if (fontdesc->flags & FD_FIXED)
+ if (fontdesc->flags & FD_FIXED_PITCH)
isfixed = 1;
if (fontdesc->flags & FD_SERIF)
isserif = 1;
@@ -182,10 +182,10 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection)
isitalic = 1;
if (fontdesc->flags & FD_SCRIPT)
isscript = 1;
- if (fontdesc->flags & FD_FORCEBOLD)
+ if (fontdesc->flags & FD_FORCE_BOLD)
isbold = 1;
- pdf_logfont("fixed-%d serif-%d italic-%d script-%d bold-%d\n",
+ pdf_log_font("fixed-%d serif-%d italic-%d script-%d bold-%d\n",
isfixed, isserif, isitalic, isscript, isbold);
if (collection)
@@ -198,15 +198,15 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection)
kind = GOTHIC;
if (!strcmp(collection, "Adobe-CNS1"))
- return loadsystemcidfont(fontdesc, CNS, kind);
+ return load_system_cid_font(fontdesc, CNS, kind);
else if (!strcmp(collection, "Adobe-GB1"))
- return loadsystemcidfont(fontdesc, GB, kind);
+ return load_system_cid_font(fontdesc, GB, kind);
else if (!strcmp(collection, "Adobe-Japan1"))
- return loadsystemcidfont(fontdesc, Japan, kind);
+ return load_system_cid_font(fontdesc, Japan, kind);
else if (!strcmp(collection, "Adobe-Japan2"))
- return loadsystemcidfont(fontdesc, Japan, kind);
+ return load_system_cid_font(fontdesc, Japan, kind);
else if (!strcmp(collection, "Adobe-Korea1"))
- return loadsystemcidfont(fontdesc, Korea, kind);
+ return load_system_cid_font(fontdesc, Korea, kind);
fz_warn("unknown cid collection: %s", collection);
}
@@ -247,38 +247,38 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection)
}
}
- error = pdf_loadbuiltinfont(fontdesc, name);
+ error = pdf_load_builtin_font(fontdesc, name);
if (error)
return fz_throw("cannot load builtin substitute font: %s", name);
/* it's a substitute font: override the metrics */
- fontdesc->font->ftsubstitute = 1;
+ fontdesc->font->ft_substitute = 1;
return fz_okay;
}
fz_error
-pdf_loadembeddedfont(pdf_fontdesc *fontdesc, pdf_xref *xref, fz_obj *stmref)
+pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *stmref)
{
fz_error error;
fz_buffer *buf;
- pdf_logfont("load embedded font\n");
+ pdf_log_font("load embedded font\n");
- error = pdf_loadstream(&buf, xref, fz_tonum(stmref), fz_togen(stmref));
+ error = pdf_load_stream(&buf, xref, fz_to_num(stmref), fz_to_gen(stmref));
if (error)
- return fz_rethrow(error, "cannot load font stream (%d %d R)", fz_tonum(stmref), fz_togen(stmref));
+ return fz_rethrow(error, "cannot load font stream (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref));
- error = fz_newfontfrombuffer(&fontdesc->font, buf->data, buf->len, 0);
+ error = fz_new_font_from_memory(&fontdesc->font, buf->data, buf->len, 0);
if (error)
{
- fz_dropbuffer(buf);
- return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_tonum(stmref), fz_togen(stmref));
+ fz_drop_buffer(buf);
+ return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref));
}
/* save the buffer so we can free it later */
- fontdesc->font->ftdata = buf->data;
- fontdesc->font->ftsize = buf->len;
+ fontdesc->font->ft_data = buf->data;
+ fontdesc->font->ft_size = buf->len;
fz_free(buf); /* only free the fz_buffer struct, not the contained data */
fontdesc->isembedded = 1;
diff --git a/pdf/pdf_fontmtx.c b/pdf/pdf_fontmtx.c
index e957125a..2fc085de 100644
--- a/pdf/pdf_fontmtx.c
+++ b/pdf/pdf_fontmtx.c
@@ -2,54 +2,54 @@
#include "mupdf.h"
void
-pdf_setfontwmode(pdf_fontdesc *font, int wmode)
+pdf_set_font_wmode(pdf_font_desc *font, int wmode)
{
font->wmode = wmode;
}
void
-pdf_setdefaulthmtx(pdf_fontdesc *font, int w)
+pdf_set_default_hmtx(pdf_font_desc *font, int w)
{
font->dhmtx.w = w;
}
void
-pdf_setdefaultvmtx(pdf_fontdesc *font, int y, int w)
+pdf_set_default_vmtx(pdf_font_desc *font, int y, int w)
{
font->dvmtx.y = y;
font->dvmtx.w = w;
}
void
-pdf_addhmtx(pdf_fontdesc *font, int lo, int hi, int w)
+pdf_add_hmtx(pdf_font_desc *font, int lo, int hi, int w)
{
- if (font->nhmtx + 1 >= font->hmtxcap)
+ if (font->hmtx_len + 1 >= font->hmtx_cap)
{
- font->hmtxcap = font->hmtxcap + 16;
- font->hmtx = fz_realloc(font->hmtx, font->hmtxcap, sizeof(pdf_hmtx));
+ font->hmtx_cap = font->hmtx_cap + 16;
+ font->hmtx = fz_realloc(font->hmtx, font->hmtx_cap, sizeof(pdf_hmtx));
}
- font->hmtx[font->nhmtx].lo = lo;
- font->hmtx[font->nhmtx].hi = hi;
- font->hmtx[font->nhmtx].w = w;
- font->nhmtx++;
+ font->hmtx[font->hmtx_len].lo = lo;
+ font->hmtx[font->hmtx_len].hi = hi;
+ font->hmtx[font->hmtx_len].w = w;
+ font->hmtx_len++;
}
void
-pdf_addvmtx(pdf_fontdesc *font, int lo, int hi, int x, int y, int w)
+pdf_add_vmtx(pdf_font_desc *font, int lo, int hi, int x, int y, int w)
{
- if (font->nvmtx + 1 >= font->vmtxcap)
+ if (font->vmtx_len + 1 >= font->vmtx_cap)
{
- font->vmtxcap = font->vmtxcap + 16;
- font->vmtx = fz_realloc(font->vmtx, font->vmtxcap, sizeof(pdf_vmtx));
+ font->vmtx_cap = font->vmtx_cap + 16;
+ font->vmtx = fz_realloc(font->vmtx, font->vmtx_cap, sizeof(pdf_vmtx));
}
- font->vmtx[font->nvmtx].lo = lo;
- font->vmtx[font->nvmtx].hi = hi;
- font->vmtx[font->nvmtx].x = x;
- font->vmtx[font->nvmtx].y = y;
- font->vmtx[font->nvmtx].w = w;
- font->nvmtx++;
+ font->vmtx[font->vmtx_len].lo = lo;
+ font->vmtx[font->vmtx_len].hi = hi;
+ font->vmtx[font->vmtx_len].x = x;
+ font->vmtx[font->vmtx_len].y = y;
+ font->vmtx[font->vmtx_len].w = w;
+ font->vmtx_len++;
}
static int cmph(const void *a0, const void *b0)
@@ -67,26 +67,26 @@ static int cmpv(const void *a0, const void *b0)
}
void
-pdf_endhmtx(pdf_fontdesc *font)
+pdf_end_hmtx(pdf_font_desc *font)
{
if (!font->hmtx)
return;
- qsort(font->hmtx, font->nhmtx, sizeof(pdf_hmtx), cmph);
+ qsort(font->hmtx, font->hmtx_len, sizeof(pdf_hmtx), cmph);
}
void
-pdf_endvmtx(pdf_fontdesc *font)
+pdf_end_vmtx(pdf_font_desc *font)
{
if (!font->vmtx)
return;
- qsort(font->vmtx, font->nvmtx, sizeof(pdf_vmtx), cmpv);
+ qsort(font->vmtx, font->vmtx_len, sizeof(pdf_vmtx), cmpv);
}
pdf_hmtx
-pdf_gethmtx(pdf_fontdesc *font, int cid)
+pdf_get_hmtx(pdf_font_desc *font, int cid)
{
int l = 0;
- int r = font->nhmtx - 1;
+ int r = font->hmtx_len - 1;
int m;
if (!font->hmtx)
@@ -108,12 +108,12 @@ notfound:
}
pdf_vmtx
-pdf_getvmtx(pdf_fontdesc *font, int cid)
+pdf_get_vmtx(pdf_font_desc *font, int cid)
{
pdf_hmtx h;
pdf_vmtx v;
int l = 0;
- int r = font->nvmtx - 1;
+ int r = font->vmtx_len - 1;
int m;
if (!font->vmtx)
@@ -131,7 +131,7 @@ pdf_getvmtx(pdf_fontdesc *font, int cid)
}
notfound:
- h = pdf_gethmtx(font, cid);
+ h = pdf_get_hmtx(font, cid);
v = font->dvmtx;
v.x = h.w / 2;
return v;
diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c
index 3fdd6ac7..392b5c19 100644
--- a/pdf/pdf_function.c
+++ b/pdf/pdf_function.c
@@ -3,8 +3,8 @@
enum
{
- MAXN = FZ_MAXCOLORS,
- MAXM = FZ_MAXCOLORS,
+ MAXN = FZ_MAX_COLORS,
+ MAXM = FZ_MAX_COLORS,
};
typedef struct psobj_s psobj;
@@ -25,7 +25,7 @@ struct pdf_function_s
int n; /* number of output values */
float domain[MAXM][2]; /* even index : min value, odd index : max value */
float range[MAXN][2]; /* even index : min value, odd index : max value */
- int hasrange;
+ int has_range;
union
{
@@ -72,20 +72,20 @@ static inline float LERP(float x, float xmin, float xmax, float ymin, float ymax
* PostScript calculator
*/
-enum { PSBOOL, PSINT, PSREAL, PSOPERATOR, PSBLOCK };
+enum { PS_BOOL, PS_INT, PS_REAL, PS_OPERATOR, PS_BLOCK };
enum
{
- PSOABS, PSOADD, PSOAND, PSOATAN, PSOBITSHIFT, PSOCEILING,
- PSOCOPY, PSOCOS, PSOCVI, PSOCVR, PSODIV, PSODUP, PSOEQ,
- PSOEXCH, PSOEXP, PSOFALSE, PSOFLOOR, PSOGE, PSOGT, PSOIDIV,
- PSOINDEX, PSOLE, PSOLN, PSOLOG, PSOLT, PSOMOD, PSOMUL,
- PSONE, PSONEG, PSONOT, PSOOR, PSOPOP, PSOROLL, PSOROUND,
- PSOSIN, PSOSQRT, PSOSUB, PSOTRUE, PSOTRUNCATE, PSOXOR,
- PSOIF, PSOIFELSE, PSORETURN
+ PS_OP_ABS, PS_OP_ADD, PS_OP_AND, PS_OP_ATAN, PS_OP_BITSHIFT, PS_OP_CEILING,
+ PS_OP_COPY, PS_OP_COS, PS_OP_CVI, PS_OP_CVR, PS_OP_DIV, PS_OP_DUP, PS_OP_EQ,
+ PS_OP_EXCH, PS_OP_EXP, PS_OP_FALSE, PS_OP_FLOOR, PS_OP_GE, PS_OP_GT, PS_OP_IDIV,
+ PS_OP_INDEX, PS_OP_LE, PS_OP_LN, PS_OP_LOG, PS_OP_LT, PS_OP_MOD, PS_OP_MUL,
+ PS_OP_NE, PS_OP_NEG, PS_OP_NOT, PS_OP_OR, PS_OP_POP, PS_OP_ROLL, PS_OP_ROUND,
+ PS_OP_SIN, PS_OP_SQRT, PS_OP_SUB, PS_OP_TRUE, PS_OP_TRUNCATE, PS_OP_XOR,
+ PS_OP_IF, PS_OP_IFELSE, PS_OP_RETURN
};
-static char *psopnames[] =
+static char *ps_op_names[] =
{
"abs", "add", "and", "atan", "bitshift", "ceiling", "copy",
"cos", "cvi", "cvr", "div", "dup", "eq", "exch", "exp",
@@ -108,16 +108,16 @@ struct psobj_s
} u;
};
-typedef struct psstack_s psstack;
+typedef struct ps_stack_s ps_stack;
-struct psstack_s
+struct ps_stack_s
{
psobj stack[100];
int sp;
};
void
-pdf_debugpsstack(psstack *st)
+pdf_debug_ps_stack(ps_stack *st)
{
int i;
@@ -127,18 +127,18 @@ pdf_debugpsstack(psstack *st)
{
switch (st->stack[i].type)
{
- case PSBOOL:
+ case PS_BOOL:
if (st->stack[i].u.b)
printf("true ");
else
printf("false ");
break;
- case PSINT:
+ case PS_INT:
printf("%d ", st->stack[i].u.i);
break;
- case PSREAL:
+ case PS_REAL:
printf("%g ", st->stack[i].u.f);
break;
}
@@ -148,110 +148,110 @@ pdf_debugpsstack(psstack *st)
}
static void
-psinitstack(psstack *st)
+ps_init_stack(ps_stack *st)
{
memset(st->stack, 0, sizeof(st->stack));
st->sp = 0;
}
static inline int
-psoverflow(psstack *st, int n)
+ps_overflow(ps_stack *st, int n)
{
return n < 0 || st->sp + n >= nelem(st->stack);
}
static inline int
-psunderflow(psstack *st, int n)
+ps_underflow(ps_stack *st, int n)
{
return n < 0 || st->sp - n < 0;
}
static inline int
-psistype(psstack *st, int t)
+ps_is_type(ps_stack *st, int t)
{
- return !psunderflow(st, 1) && st->stack[st->sp - 1].type == t;
+ return !ps_underflow(st, 1) && st->stack[st->sp - 1].type == t;
}
static inline int
-psistype2(psstack *st, int t)
+ps_is_type2(ps_stack *st, int t)
{
- return !psunderflow(st, 2) && st->stack[st->sp - 1].type == t && st->stack[st->sp - 2].type == t;
+ return !ps_underflow(st, 2) && st->stack[st->sp - 1].type == t && st->stack[st->sp - 2].type == t;
}
static void
-pspushbool(psstack *st, int b)
+ps_push_bool(ps_stack *st, int b)
{
- if (!psoverflow(st, 1))
+ if (!ps_overflow(st, 1))
{
- st->stack[st->sp].type = PSBOOL;
+ st->stack[st->sp].type = PS_BOOL;
st->stack[st->sp].u.b = b;
st->sp++;
}
}
static void
-pspushint(psstack *st, int n)
+ps_push_int(ps_stack *st, int n)
{
- if (!psoverflow(st, 1))
+ if (!ps_overflow(st, 1))
{
- st->stack[st->sp].type = PSINT;
+ st->stack[st->sp].type = PS_INT;
st->stack[st->sp].u.i = n;
st->sp++;
}
}
static void
-pspushreal(psstack *st, float n)
+ps_push_real(ps_stack *st, float n)
{
- if (!psoverflow(st, 1))
+ if (!ps_overflow(st, 1))
{
- st->stack[st->sp].type = PSREAL;
+ st->stack[st->sp].type = PS_REAL;
st->stack[st->sp].u.f = n;
st->sp++;
}
}
static int
-pspopbool(psstack *st)
+ps_pop_bool(ps_stack *st)
{
- if (!psunderflow(st, 1))
+ if (!ps_underflow(st, 1))
{
- if (psistype(st, PSBOOL))
+ if (ps_is_type(st, PS_BOOL))
return st->stack[--st->sp].u.b;
}
return 0;
}
static int
-pspopint(psstack *st)
+ps_pop_int(ps_stack *st)
{
- if (!psunderflow(st, 1))
+ if (!ps_underflow(st, 1))
{
- if (psistype(st, PSINT))
+ if (ps_is_type(st, PS_INT))
return st->stack[--st->sp].u.i;
- if (psistype(st, PSREAL))
+ if (ps_is_type(st, PS_REAL))
return st->stack[--st->sp].u.f;
}
return 0;
}
static float
-pspopreal(psstack *st)
+ps_pop_real(ps_stack *st)
{
- if (!psunderflow(st, 1))
+ if (!ps_underflow(st, 1))
{
- if (psistype(st, PSINT))
+ if (ps_is_type(st, PS_INT))
return st->stack[--st->sp].u.i;
- if (psistype(st, PSREAL))
+ if (ps_is_type(st, PS_REAL))
return st->stack[--st->sp].u.f;
}
return 0;
}
static void
-pscopy(psstack *st, int n)
+ps_copy(ps_stack *st, int n)
{
- if (!psunderflow(st, n) && !psoverflow(st, n))
+ if (!ps_underflow(st, n) && !ps_overflow(st, n))
{
memcpy(st->stack + st->sp, st->stack + st->sp - n, n * sizeof(psobj));
st->sp += n;
@@ -259,12 +259,12 @@ pscopy(psstack *st, int n)
}
static void
-psroll(psstack *st, int n, int j)
+ps_roll(ps_stack *st, int n, int j)
{
psobj tmp;
int i;
- if (psunderflow(st, n) || j == 0 || n == 0)
+ if (ps_underflow(st, n) || j == 0 || n == 0)
return;
if (j >= 0)
@@ -287,9 +287,9 @@ psroll(psstack *st, int n, int j)
}
static void
-psindex(psstack *st, int n)
+ps_index(ps_stack *st, int n)
{
- if (!psoverflow(st, 1) && !psunderflow(st, n))
+ if (!ps_overflow(st, 1) && !ps_underflow(st, n))
{
st->stack[st->sp] = st->stack[st->sp - n - 1];
st->sp++;
@@ -297,7 +297,7 @@ psindex(psstack *st, int n)
}
static void
-psrun(psobj *code, psstack *st, int pc)
+ps_run(psobj *code, ps_stack *st, int pc)
{
int i1, i2;
float r1, r2;
@@ -307,357 +307,357 @@ psrun(psobj *code, psstack *st, int pc)
{
switch (code[pc].type)
{
- case PSINT:
- pspushint(st, code[pc++].u.i);
+ case PS_INT:
+ ps_push_int(st, code[pc++].u.i);
break;
- case PSREAL:
- pspushreal(st, code[pc++].u.f);
+ case PS_REAL:
+ ps_push_real(st, code[pc++].u.f);
break;
- case PSOPERATOR:
+ case PS_OPERATOR:
switch (code[pc++].u.op)
{
- case PSOABS:
- if (psistype(st, PSINT))
- pspushint(st, abs(pspopint(st)));
+ case PS_OP_ABS:
+ if (ps_is_type(st, PS_INT))
+ ps_push_int(st, abs(ps_pop_int(st)));
else
- pspushreal(st, fabsf(pspopreal(st)));
+ ps_push_real(st, fabsf(ps_pop_real(st)));
break;
- case PSOADD:
- if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushint(st, i1 + i2);
+ case PS_OP_ADD:
+ if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_int(st, i1 + i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushreal(st, r1 + r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_real(st, r1 + r2);
}
break;
- case PSOAND:
- if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushint(st, i1 & i2);
+ case PS_OP_AND:
+ if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_int(st, i1 & i2);
}
else {
- b2 = pspopbool(st);
- b1 = pspopbool(st);
- pspushbool(st, b1 && b2);
+ b2 = ps_pop_bool(st);
+ b1 = ps_pop_bool(st);
+ ps_push_bool(st, b1 && b2);
}
break;
- case PSOATAN:
- r2 = pspopreal(st);
- r1 = pspopreal(st);
+ case PS_OP_ATAN:
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
r1 = atan2f(r1, r2) * RADIAN;
if (r1 < 0)
r1 += 360;
- pspushreal(st, r1);
+ ps_push_real(st, r1);
break;
- case PSOBITSHIFT:
- i2 = pspopint(st);
- i1 = pspopint(st);
+ case PS_OP_BITSHIFT:
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
if (i2 > 0)
- pspushint(st, i1 << i2);
+ ps_push_int(st, i1 << i2);
else if (i2 < 0)
- pspushint(st, (int)((unsigned int)i1 >> i2));
+ ps_push_int(st, (int)((unsigned int)i1 >> i2));
else
- pspushint(st, i1);
+ ps_push_int(st, i1);
break;
- case PSOCEILING:
- r1 = pspopreal(st);
- pspushreal(st, ceilf(r1));
+ case PS_OP_CEILING:
+ r1 = ps_pop_real(st);
+ ps_push_real(st, ceilf(r1));
break;
- case PSOCOPY:
- pscopy(st, pspopint(st));
+ case PS_OP_COPY:
+ ps_copy(st, ps_pop_int(st));
break;
- case PSOCOS:
- r1 = pspopreal(st);
- pspushreal(st, cosf(r1/RADIAN));
+ case PS_OP_COS:
+ r1 = ps_pop_real(st);
+ ps_push_real(st, cosf(r1/RADIAN));
break;
- case PSOCVI:
- pspushint(st, pspopint(st));
+ case PS_OP_CVI:
+ ps_push_int(st, ps_pop_int(st));
break;
- case PSOCVR:
- pspushreal(st, pspopreal(st));
+ case PS_OP_CVR:
+ ps_push_real(st, ps_pop_real(st));
break;
- case PSODIV:
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushreal(st, r1 / r2);
+ case PS_OP_DIV:
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_real(st, r1 / r2);
break;
- case PSODUP:
- pscopy(st, 1);
+ case PS_OP_DUP:
+ ps_copy(st, 1);
break;
- case PSOEQ:
- if (psistype2(st, PSBOOL)) {
- b2 = pspopbool(st);
- b1 = pspopbool(st);
- pspushbool(st, b1 == b2);
+ case PS_OP_EQ:
+ if (ps_is_type2(st, PS_BOOL)) {
+ b2 = ps_pop_bool(st);
+ b1 = ps_pop_bool(st);
+ ps_push_bool(st, b1 == b2);
}
- else if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushbool(st, i1 == i2);
+ else if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_bool(st, i1 == i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushbool(st, r1 == r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_bool(st, r1 == r2);
}
break;
- case PSOEXCH:
- psroll(st, 2, 1);
+ case PS_OP_EXCH:
+ ps_roll(st, 2, 1);
break;
- case PSOEXP:
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushreal(st, powf(r1, r2));
+ case PS_OP_EXP:
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_real(st, powf(r1, r2));
break;
- case PSOFALSE:
- pspushbool(st, 0);
+ case PS_OP_FALSE:
+ ps_push_bool(st, 0);
break;
- case PSOFLOOR:
- r1 = pspopreal(st);
- pspushreal(st, floorf(r1));
+ case PS_OP_FLOOR:
+ r1 = ps_pop_real(st);
+ ps_push_real(st, floorf(r1));
break;
- case PSOGE:
- if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushbool(st, i1 >= i2);
+ case PS_OP_GE:
+ if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_bool(st, i1 >= i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushbool(st, r1 >= r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_bool(st, r1 >= r2);
}
break;
- case PSOGT:
- if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushbool(st, i1 > i2);
+ case PS_OP_GT:
+ if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_bool(st, i1 > i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushbool(st, r1 > r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_bool(st, r1 > r2);
}
break;
- case PSOIDIV:
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushint(st, i1 / i2);
+ case PS_OP_IDIV:
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_int(st, i1 / i2);
break;
- case PSOINDEX:
- psindex(st, pspopint(st));
+ case PS_OP_INDEX:
+ ps_index(st, ps_pop_int(st));
break;
- case PSOLE:
- if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushbool(st, i1 <= i2);
+ case PS_OP_LE:
+ if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_bool(st, i1 <= i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushbool(st, r1 <= r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_bool(st, r1 <= r2);
}
break;
- case PSOLN:
- r1 = pspopreal(st);
- pspushreal(st, logf(r1));
+ case PS_OP_LN:
+ r1 = ps_pop_real(st);
+ ps_push_real(st, logf(r1));
break;
- case PSOLOG:
- r1 = pspopreal(st);
- pspushreal(st, log10f(r1));
+ case PS_OP_LOG:
+ r1 = ps_pop_real(st);
+ ps_push_real(st, log10f(r1));
break;
- case PSOLT:
- if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushbool(st, i1 < i2);
+ case PS_OP_LT:
+ if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_bool(st, i1 < i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushbool(st, r1 < r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_bool(st, r1 < r2);
}
break;
- case PSOMOD:
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushint(st, i1 % i2);
+ case PS_OP_MOD:
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_int(st, i1 % i2);
break;
- case PSOMUL:
- if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushint(st, i1 * i2);
+ case PS_OP_MUL:
+ if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_int(st, i1 * i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushreal(st, r1 * r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_real(st, r1 * r2);
}
break;
- case PSONE:
- if (psistype2(st, PSBOOL)) {
- b2 = pspopbool(st);
- b1 = pspopbool(st);
- pspushbool(st, b1 != b2);
+ case PS_OP_NE:
+ if (ps_is_type2(st, PS_BOOL)) {
+ b2 = ps_pop_bool(st);
+ b1 = ps_pop_bool(st);
+ ps_push_bool(st, b1 != b2);
}
- else if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushbool(st, i1 != i2);
+ else if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_bool(st, i1 != i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushbool(st, r1 != r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_bool(st, r1 != r2);
}
break;
- case PSONEG:
- if (psistype(st, PSINT))
- pspushint(st, -pspopint(st));
+ case PS_OP_NEG:
+ if (ps_is_type(st, PS_INT))
+ ps_push_int(st, -ps_pop_int(st));
else
- pspushreal(st, -pspopreal(st));
+ ps_push_real(st, -ps_pop_real(st));
break;
- case PSONOT:
- if (psistype(st, PSBOOL))
- pspushbool(st, !pspopbool(st));
+ case PS_OP_NOT:
+ if (ps_is_type(st, PS_BOOL))
+ ps_push_bool(st, !ps_pop_bool(st));
else
- pspushint(st, ~pspopint(st));
+ ps_push_int(st, ~ps_pop_int(st));
break;
- case PSOOR:
- if (psistype2(st, PSBOOL)) {
- b2 = pspopbool(st);
- b1 = pspopbool(st);
- pspushbool(st, b1 || b2);
+ case PS_OP_OR:
+ if (ps_is_type2(st, PS_BOOL)) {
+ b2 = ps_pop_bool(st);
+ b1 = ps_pop_bool(st);
+ ps_push_bool(st, b1 || b2);
}
else {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushint(st, i1 | i2);
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_int(st, i1 | i2);
}
break;
- case PSOPOP:
- if (!psunderflow(st, 1))
+ case PS_OP_POP:
+ if (!ps_underflow(st, 1))
st->sp--;
break;
- case PSOROLL:
- i2 = pspopint(st);
- i1 = pspopint(st);
- psroll(st, i1, i2);
+ case PS_OP_ROLL:
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_roll(st, i1, i2);
break;
- case PSOROUND:
- if (!psistype(st, PSINT)) {
- r1 = pspopreal(st);
- pspushreal(st, (r1 >= 0) ? floorf(r1 + 0.5f) : ceilf(r1 - 0.5f));
+ case PS_OP_ROUND:
+ if (!ps_is_type(st, PS_INT)) {
+ r1 = ps_pop_real(st);
+ ps_push_real(st, (r1 >= 0) ? floorf(r1 + 0.5f) : ceilf(r1 - 0.5f));
}
break;
- case PSOSIN:
- r1 = pspopreal(st);
- pspushreal(st, sinf(r1/RADIAN));
+ case PS_OP_SIN:
+ r1 = ps_pop_real(st);
+ ps_push_real(st, sinf(r1/RADIAN));
break;
- case PSOSQRT:
- r1 = pspopreal(st);
- pspushreal(st, sqrtf(r1));
+ case PS_OP_SQRT:
+ r1 = ps_pop_real(st);
+ ps_push_real(st, sqrtf(r1));
break;
- case PSOSUB:
- if (psistype2(st, PSINT)) {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushint(st, i1 - i2);
+ case PS_OP_SUB:
+ if (ps_is_type2(st, PS_INT)) {
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_int(st, i1 - i2);
}
else {
- r2 = pspopreal(st);
- r1 = pspopreal(st);
- pspushreal(st, r1 - r2);
+ r2 = ps_pop_real(st);
+ r1 = ps_pop_real(st);
+ ps_push_real(st, r1 - r2);
}
break;
- case PSOTRUE:
- pspushbool(st, 1);
+ case PS_OP_TRUE:
+ ps_push_bool(st, 1);
break;
- case PSOTRUNCATE:
- if (!psistype(st, PSINT)) {
- r1 = pspopreal(st);
- pspushreal(st, (r1 >= 0) ? floorf(r1) : ceilf(r1));
+ case PS_OP_TRUNCATE:
+ if (!ps_is_type(st, PS_INT)) {
+ r1 = ps_pop_real(st);
+ ps_push_real(st, (r1 >= 0) ? floorf(r1) : ceilf(r1));
}
break;
- case PSOXOR:
- if (psistype2(st, PSBOOL)) {
- b2 = pspopbool(st);
- b1 = pspopbool(st);
- pspushbool(st, b1 ^ b2);
+ case PS_OP_XOR:
+ if (ps_is_type2(st, PS_BOOL)) {
+ b2 = ps_pop_bool(st);
+ b1 = ps_pop_bool(st);
+ ps_push_bool(st, b1 ^ b2);
}
else {
- i2 = pspopint(st);
- i1 = pspopint(st);
- pspushint(st, i1 ^ i2);
+ i2 = ps_pop_int(st);
+ i1 = ps_pop_int(st);
+ ps_push_int(st, i1 ^ i2);
}
break;
- case PSOIF:
- b1 = pspopbool(st);
+ case PS_OP_IF:
+ b1 = ps_pop_bool(st);
if (b1)
- psrun(code, st, code[pc + 1].u.block);
+ ps_run(code, st, code[pc + 1].u.block);
pc = code[pc + 2].u.block;
break;
- case PSOIFELSE:
- b1 = pspopbool(st);
+ case PS_OP_IFELSE:
+ b1 = ps_pop_bool(st);
if (b1)
- psrun(code, st, code[pc + 1].u.block);
+ ps_run(code, st, code[pc + 1].u.block);
else
- psrun(code, st, code[pc + 0].u.block);
+ ps_run(code, st, code[pc + 0].u.block);
pc = code[pc + 2].u.block;
break;
- case PSORETURN:
+ case PS_OP_RETURN:
return;
default:
@@ -674,7 +674,7 @@ psrun(psobj *code, psstack *st, int pc)
}
static void
-resizecode(pdf_function *func, int newsize)
+resize_code(pdf_function *func, int newsize)
{
if (newsize >= func->u.p.cap)
{
@@ -684,7 +684,7 @@ resizecode(pdf_function *func, int newsize)
}
static fz_error
-parsecode(pdf_function *func, fz_stream *stream, int *codeptr)
+parse_code(pdf_function *func, fz_stream *stream, int *codeptr)
{
fz_error error;
char buf[64];
@@ -703,31 +703,31 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr)
switch(tok)
{
- case PDF_TEOF:
+ case PDF_TOK_EOF:
return fz_throw("truncated calculator function");
- case PDF_TINT:
- resizecode(func, *codeptr);
- func->u.p.code[*codeptr].type = PSINT;
+ case PDF_TOK_INT:
+ resize_code(func, *codeptr);
+ func->u.p.code[*codeptr].type = PS_INT;
func->u.p.code[*codeptr].u.i = atoi(buf);
++*codeptr;
break;
- case PDF_TREAL:
- resizecode(func, *codeptr);
- func->u.p.code[*codeptr].type = PSREAL;
+ case PDF_TOK_REAL:
+ resize_code(func, *codeptr);
+ func->u.p.code[*codeptr].type = PS_REAL;
func->u.p.code[*codeptr].u.f = atof(buf);
++*codeptr;
break;
- case PDF_TOBRACE:
+ case PDF_TOK_OPEN_BRACE:
opptr = *codeptr;
*codeptr += 4;
- resizecode(func, *codeptr);
+ resize_code(func, *codeptr);
ifptr = *codeptr;
- error = parsecode(func, stream, codeptr);
+ error = parse_code(func, stream, codeptr);
if (error)
return fz_rethrow(error, "error in 'if' branch");
@@ -735,10 +735,10 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr)
if (error)
return fz_rethrow(error, "calculator function syntax error");
- if (tok == PDF_TOBRACE)
+ if (tok == PDF_TOK_OPEN_BRACE)
{
elseptr = *codeptr;
- error = parsecode(func, stream, codeptr);
+ error = parse_code(func, stream, codeptr);
if (error)
return fz_rethrow(error, "error in 'else' branch");
@@ -751,30 +751,30 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr)
elseptr = -1;
}
- if (tok == PDF_TKEYWORD)
+ if (tok == PDF_TOK_KEYWORD)
{
if (!strcmp(buf, "if"))
{
if (elseptr >= 0)
return fz_throw("too many branches for 'if'");
- func->u.p.code[opptr].type = PSOPERATOR;
- func->u.p.code[opptr].u.op = PSOIF;
- func->u.p.code[opptr+2].type = PSBLOCK;
+ func->u.p.code[opptr].type = PS_OPERATOR;
+ func->u.p.code[opptr].u.op = PS_OP_IF;
+ func->u.p.code[opptr+2].type = PS_BLOCK;
func->u.p.code[opptr+2].u.block = ifptr;
- func->u.p.code[opptr+3].type = PSBLOCK;
+ func->u.p.code[opptr+3].type = PS_BLOCK;
func->u.p.code[opptr+3].u.block = *codeptr;
}
else if (!strcmp(buf, "ifelse"))
{
if (elseptr < 0)
return fz_throw("not enough branches for 'ifelse'");
- func->u.p.code[opptr].type = PSOPERATOR;
- func->u.p.code[opptr].u.op = PSOIFELSE;
- func->u.p.code[opptr+1].type = PSBLOCK;
+ func->u.p.code[opptr].type = PS_OPERATOR;
+ func->u.p.code[opptr].u.op = PS_OP_IFELSE;
+ func->u.p.code[opptr+1].type = PS_BLOCK;
func->u.p.code[opptr+1].u.block = elseptr;
- func->u.p.code[opptr+2].type = PSBLOCK;
+ func->u.p.code[opptr+2].type = PS_BLOCK;
func->u.p.code[opptr+2].u.block = ifptr;
- func->u.p.code[opptr+3].type = PSBLOCK;
+ func->u.p.code[opptr+3].type = PS_BLOCK;
func->u.p.code[opptr+3].u.block = *codeptr;
}
else
@@ -788,21 +788,21 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr)
}
break;
- case PDF_TCBRACE:
- resizecode(func, *codeptr);
- func->u.p.code[*codeptr].type = PSOPERATOR;
- func->u.p.code[*codeptr].u.op = PSORETURN;
+ case PDF_TOK_CLOSE_BRACE:
+ resize_code(func, *codeptr);
+ func->u.p.code[*codeptr].type = PS_OPERATOR;
+ func->u.p.code[*codeptr].u.op = PS_OP_RETURN;
++*codeptr;
return fz_okay;
- case PDF_TKEYWORD:
+ case PDF_TOK_KEYWORD:
cmp = -1;
a = -1;
- b = nelem(psopnames);
+ b = nelem(ps_op_names);
while (b - a > 1)
{
mid = (a + b) / 2;
- cmp = strcmp(buf, psopnames[mid]);
+ cmp = strcmp(buf, ps_op_names[mid]);
if (cmp > 0)
a = mid;
else if (cmp < 0)
@@ -813,8 +813,8 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr)
if (cmp != 0)
return fz_throw("unknown operator: '%s'", buf);
- resizecode(func, *codeptr);
- func->u.p.code[*codeptr].type = PSOPERATOR;
+ resize_code(func, *codeptr);
+ func->u.p.code[*codeptr].type = PS_OPERATOR;
func->u.p.code[*codeptr].u.op = a;
++*codeptr;
break;
@@ -826,7 +826,7 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr)
}
static fz_error
-loadpostscriptfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen)
+load_postscript_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen)
{
fz_error error;
fz_stream *stream;
@@ -835,9 +835,9 @@ loadpostscriptfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, in
int tok;
int len;
- pdf_logrsrc("load postscript function (%d %d R)\n", num, gen);
+ pdf_log_rsrc("load postscript function (%d %d R)\n", num, gen);
- error = pdf_openstream(&stream, xref, num, gen);
+ error = pdf_open_stream(&stream, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot open calculator function stream");
@@ -848,17 +848,17 @@ loadpostscriptfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, in
return fz_rethrow(error, "stream is not a calculator function");
}
- if (tok != PDF_TOBRACE)
+ if (tok != PDF_TOK_OPEN_BRACE)
{
fz_close(stream);
return fz_throw("stream is not a calculator function");
}
- func->u.p.code = nil;
+ func->u.p.code = NULL;
func->u.p.cap = 0;
codeptr = 0;
- error = parsecode(func, stream, &codeptr);
+ error = parse_code(func, stream, &codeptr);
if (error)
{
fz_close(stream);
@@ -870,25 +870,25 @@ loadpostscriptfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, in
}
static void
-evalpostscriptfunc(pdf_function *func, float *in, float *out)
+eval_postscript_func(pdf_function *func, float *in, float *out)
{
- psstack st;
+ ps_stack st;
float x;
int i;
- psinitstack(&st);
+ ps_init_stack(&st);
for (i = 0; i < func->m; i++)
{
x = CLAMP(in[i], func->domain[i][0], func->domain[i][1]);
- pspushreal(&st, x);
+ ps_push_real(&st, x);
}
- psrun(func->u.p.code, &st, 0);
+ ps_run(func->u.p.code, &st, 0);
for (i = func->n - 1; i >= 0; i--)
{
- x = pspopreal(&st);
+ x = ps_pop_real(&st);
out[i] = CLAMP(x, func->range[i][0], func->range[i][1]);
}
}
@@ -898,7 +898,7 @@ evalpostscriptfunc(pdf_function *func, float *in, float *out)
*/
static fz_error
-loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen)
+load_sample_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen)
{
fz_error error;
fz_stream *stream;
@@ -907,32 +907,32 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge
int bps;
int i;
- pdf_logrsrc("sampled function {\n");
+ pdf_log_rsrc("sampled function {\n");
- func->u.sa.samples = nil;
+ func->u.sa.samples = NULL;
- obj = fz_dictgets(dict, "Size");
- if (!fz_isarray(obj) || fz_arraylen(obj) != func->m)
+ obj = fz_dict_gets(dict, "Size");
+ if (!fz_is_array(obj) || fz_array_len(obj) != func->m)
return fz_throw("malformed /Size");
for (i = 0; i < func->m; i++)
- func->u.sa.size[i] = fz_toint(fz_arrayget(obj, i));
+ func->u.sa.size[i] = fz_to_int(fz_array_get(obj, i));
- obj = fz_dictgets(dict, "BitsPerSample");
- if (!fz_isint(obj))
+ obj = fz_dict_gets(dict, "BitsPerSample");
+ if (!fz_is_int(obj))
return fz_throw("malformed /BitsPerSample");
- func->u.sa.bps = bps = fz_toint(obj);
+ func->u.sa.bps = bps = fz_to_int(obj);
- pdf_logrsrc("bps %d\n", bps);
+ pdf_log_rsrc("bps %d\n", bps);
- obj = fz_dictgets(dict, "Encode");
- if (fz_isarray(obj))
+ obj = fz_dict_gets(dict, "Encode");
+ if (fz_is_array(obj))
{
- if (fz_arraylen(obj) != func->m * 2)
+ if (fz_array_len(obj) != func->m * 2)
return fz_throw("malformed /Encode");
for (i = 0; i < func->m; i++)
{
- func->u.sa.encode[i][0] = fz_toreal(fz_arrayget(obj, i*2+0));
- func->u.sa.encode[i][1] = fz_toreal(fz_arrayget(obj, i*2+1));
+ func->u.sa.encode[i][0] = fz_to_real(fz_array_get(obj, i*2+0));
+ func->u.sa.encode[i][1] = fz_to_real(fz_array_get(obj, i*2+1));
}
}
else
@@ -944,15 +944,15 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge
}
}
- obj = fz_dictgets(dict, "Decode");
- if (fz_isarray(obj))
+ obj = fz_dict_gets(dict, "Decode");
+ if (fz_is_array(obj))
{
- if (fz_arraylen(obj) != func->n * 2)
+ if (fz_array_len(obj) != func->n * 2)
return fz_throw("malformed /Decode");
for (i = 0; i < func->n; i++)
{
- func->u.sa.decode[i][0] = fz_toreal(fz_arrayget(obj, i*2+0));
- func->u.sa.decode[i][1] = fz_toreal(fz_arrayget(obj, i*2+1));
+ func->u.sa.decode[i][0] = fz_to_real(fz_array_get(obj, i*2+0));
+ func->u.sa.decode[i][1] = fz_to_real(fz_array_get(obj, i*2+1));
}
}
else
@@ -967,11 +967,11 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge
for (i = 0, samplecount = func->n; i < func->m; i++)
samplecount *= func->u.sa.size[i];
- pdf_logrsrc("samplecount %d\n", samplecount);
+ pdf_log_rsrc("samplecount %d\n", samplecount);
func->u.sa.samples = fz_calloc(samplecount, sizeof(float));
- error = pdf_openstream(&stream, xref, num, gen);
+ error = pdf_open_stream(&stream, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot open samples stream (%d %d R)", num, gen);
@@ -981,7 +981,7 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge
unsigned int x;
float s;
- if (fz_iseofbits(stream))
+ if (fz_is_eof_bits(stream))
{
fz_close(stream);
return fz_throw("truncated sample stream");
@@ -989,27 +989,27 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge
switch (bps)
{
- case 1: s = fz_readbits(stream, 1); break;
- case 2: s = fz_readbits(stream, 2) / 3.0f; break;
- case 4: s = fz_readbits(stream, 4) / 15.0f; break;
- case 8: s = fz_readbyte(stream) / 255.0f; break;
- case 12: s = fz_readbits(stream, 12) / 4095.0f; break;
+ case 1: s = fz_read_bits(stream, 1); break;
+ case 2: s = fz_read_bits(stream, 2) / 3.0f; break;
+ case 4: s = fz_read_bits(stream, 4) / 15.0f; break;
+ case 8: s = fz_read_byte(stream) / 255.0f; break;
+ case 12: s = fz_read_bits(stream, 12) / 4095.0f; break;
case 16:
- x = fz_readbyte(stream) << 8;
- x |= fz_readbyte(stream);
+ x = fz_read_byte(stream) << 8;
+ x |= fz_read_byte(stream);
s = x / 65535.0f;
break;
case 24:
- x = fz_readbyte(stream) << 16;
- x |= fz_readbyte(stream) << 8;
- x |= fz_readbyte(stream);
+ x = fz_read_byte(stream) << 16;
+ x |= fz_read_byte(stream) << 8;
+ x |= fz_read_byte(stream);
s = x / 16777215.0f;
break;
case 32:
- x = fz_readbyte(stream) << 24;
- x |= fz_readbyte(stream) << 16;
- x |= fz_readbyte(stream) << 8;
- x |= fz_readbyte(stream);
+ x = fz_read_byte(stream) << 24;
+ x |= fz_read_byte(stream) << 16;
+ x |= fz_read_byte(stream) << 8;
+ x |= fz_read_byte(stream);
s = x / 4294967295.0f;
break;
default:
@@ -1022,13 +1022,13 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge
fz_close(stream);
- pdf_logrsrc("}\n");
+ pdf_log_rsrc("}\n");
return fz_okay;
}
static float
-interpolatesample(pdf_function *func, int *scale, int *e0, int *e1, float *efrac, int dim, int idx)
+interpolate_sample(pdf_function *func, int *scale, int *e0, int *e1, float *efrac, int dim, int idx)
{
float a, b;
int idx0, idx1;
@@ -1043,15 +1043,15 @@ interpolatesample(pdf_function *func, int *scale, int *e0, int *e1, float *efrac
}
else
{
- a = interpolatesample(func, scale, e0, e1, efrac, dim - 1, idx0);
- b = interpolatesample(func, scale, e0, e1, efrac, dim - 1, idx1);
+ a = interpolate_sample(func, scale, e0, e1, efrac, dim - 1, idx0);
+ b = interpolate_sample(func, scale, e0, e1, efrac, dim - 1, idx1);
}
return a + (b - a) * efrac[dim];
}
static void
-evalsamplefunc(pdf_function *func, float *in, float *out)
+eval_sample_func(pdf_function *func, float *in, float *out)
{
int e0[MAXM], e1[MAXM], scale[MAXM];
float efrac[MAXM];
@@ -1107,7 +1107,7 @@ evalsamplefunc(pdf_function *func, float *in, float *out)
else
{
- float x = interpolatesample(func, scale, e0, e1, efrac, func->m - 1, i);
+ float x = interpolate_sample(func, scale, e0, e1, efrac, func->m - 1, i);
out[i] = LERP(x, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]);
out[i] = CLAMP(out[i], func->range[i][0], func->range[i][1]);
}
@@ -1119,31 +1119,31 @@ evalsamplefunc(pdf_function *func, float *in, float *out)
*/
static fz_error
-loadexponentialfunc(pdf_function *func, fz_obj *dict)
+load_exponential_func(pdf_function *func, fz_obj *dict)
{
fz_obj *obj;
int i;
- pdf_logrsrc("exponential function {\n");
+ pdf_log_rsrc("exponential function {\n");
if (func->m != 1)
return fz_throw("/Domain must be one dimension (%d)", func->m);
- obj = fz_dictgets(dict, "N");
- if (!fz_isint(obj) && !fz_isreal(obj))
+ obj = fz_dict_gets(dict, "N");
+ if (!fz_is_int(obj) && !fz_is_real(obj))
return fz_throw("malformed /N");
- func->u.e.n = fz_toreal(obj);
- pdf_logrsrc("n %g\n", func->u.e.n);
+ func->u.e.n = fz_to_real(obj);
+ pdf_log_rsrc("n %g\n", func->u.e.n);
- obj = fz_dictgets(dict, "C0");
- if (fz_isarray(obj))
+ obj = fz_dict_gets(dict, "C0");
+ if (fz_is_array(obj))
{
- func->n = fz_arraylen(obj);
+ func->n = fz_array_len(obj);
if (func->n >= MAXN)
return fz_throw("exponential function result array out of range");
for (i = 0; i < func->n; i++)
- func->u.e.c0[i] = fz_toreal(fz_arrayget(obj, i));
- pdf_logrsrc("c0 %d\n", func->n);
+ func->u.e.c0[i] = fz_to_real(fz_array_get(obj, i));
+ pdf_log_rsrc("c0 %d\n", func->n);
}
else
{
@@ -1151,14 +1151,14 @@ loadexponentialfunc(pdf_function *func, fz_obj *dict)
func->u.e.c0[0] = 0;
}
- obj = fz_dictgets(dict, "C1");
- if (fz_isarray(obj))
+ obj = fz_dict_gets(dict, "C1");
+ if (fz_is_array(obj))
{
- if (fz_arraylen(obj) != func->n)
+ if (fz_array_len(obj) != func->n)
return fz_throw("/C1 must match /C0 length");
for (i = 0; i < func->n; i++)
- func->u.e.c1[i] = fz_toreal(fz_arrayget(obj, i));
- pdf_logrsrc("c1 %d\n", func->n);
+ func->u.e.c1[i] = fz_to_real(fz_array_get(obj, i));
+ pdf_log_rsrc("c1 %d\n", func->n);
}
else
{
@@ -1167,13 +1167,13 @@ loadexponentialfunc(pdf_function *func, fz_obj *dict)
func->u.e.c1[0] = 1;
}
- pdf_logrsrc("}\n");
+ pdf_log_rsrc("}\n");
return fz_okay;
}
static void
-evalexponentialfunc(pdf_function *func, float in, float *out)
+eval_exponential_func(pdf_function *func, float in, float *out)
{
float x = in;
float tmp;
@@ -1192,7 +1192,7 @@ evalexponentialfunc(pdf_function *func, float in, float *out)
for (i = 0; i < func->n; i++)
{
out[i] = func->u.e.c0[i] + tmp * (func->u.e.c1[i] - func->u.e.c0[i]);
- if (func->hasrange)
+ if (func->has_range)
out[i] = CLAMP(out[i], func->range[i][0], func->range[i][1]);
}
}
@@ -1202,7 +1202,7 @@ evalexponentialfunc(pdf_function *func, float in, float *out)
*/
static fz_error
-loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict)
+load_stitching_func(pdf_function *func, pdf_xref *xref, fz_obj *dict)
{
pdf_function **funcs;
fz_error error;
@@ -1212,20 +1212,20 @@ loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict)
int k;
int i;
- pdf_logrsrc("stitching {\n");
+ pdf_log_rsrc("stitching {\n");
func->u.st.k = 0;
if (func->m != 1)
return fz_throw("/Domain must be one dimension (%d)", func->m);
- obj = fz_dictgets(dict, "Functions");
- if (!fz_isarray(obj))
+ obj = fz_dict_gets(dict, "Functions");
+ if (!fz_is_array(obj))
return fz_throw("stitching function has no input functions");
{
- k = fz_arraylen(obj);
+ k = fz_array_len(obj);
- pdf_logrsrc("k %d\n", k);
+ pdf_log_rsrc("k %d\n", k);
func->u.st.funcs = fz_calloc(k, sizeof(pdf_function*));
func->u.st.bounds = fz_calloc(k - 1, sizeof(float));
@@ -1234,10 +1234,10 @@ loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict)
for (i = 0; i < k; i++)
{
- sub = fz_arrayget(obj, i);
- error = pdf_loadfunction(&funcs[i], xref, sub);
+ sub = fz_array_get(obj, i);
+ error = pdf_load_function(&funcs[i], xref, sub);
if (error)
- return fz_rethrow(error, "cannot load sub function %d (%d %d R)", i, fz_tonum(sub), fz_togen(sub));
+ return fz_rethrow(error, "cannot load sub function %d (%d %d R)", i, fz_to_num(sub), fz_to_gen(sub));
if (funcs[i]->m != 1 || funcs[i]->n != funcs[0]->n)
return fz_throw("sub function %d /Domain or /Range mismatch", i);
func->u.st.k ++;
@@ -1249,19 +1249,19 @@ loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict)
return fz_throw("sub function /Domain or /Range mismatch");
}
- obj = fz_dictgets(dict, "Bounds");
- if (!fz_isarray(obj))
+ obj = fz_dict_gets(dict, "Bounds");
+ if (!fz_is_array(obj))
return fz_throw("stitching function has no bounds");
{
- if (!fz_isarray(obj) || fz_arraylen(obj) != k - 1)
+ if (!fz_is_array(obj) || fz_array_len(obj) != k - 1)
return fz_throw("malformed /Bounds (not array or wrong length)");
for (i = 0; i < k-1; i++)
{
- num = fz_arrayget(obj, i);
- if (!fz_isint(num) && !fz_isreal(num))
+ num = fz_array_get(obj, i);
+ if (!fz_is_int(num) && !fz_is_real(num))
return fz_throw("malformed /Bounds (item not real)");
- func->u.st.bounds[i] = fz_toreal(num);
+ func->u.st.bounds[i] = fz_to_real(num);
if (i && func->u.st.bounds[i-1] > func->u.st.bounds[i])
return fz_throw("malformed /Bounds (item not monotonic)");
}
@@ -1271,26 +1271,26 @@ loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict)
fz_warn("malformed shading function bounds (domain mismatch), proceeding anyway.");
}
- obj = fz_dictgets(dict, "Encode");
- if (!fz_isarray(obj))
+ obj = fz_dict_gets(dict, "Encode");
+ if (!fz_is_array(obj))
return fz_throw("stitching function is missing encoding");
{
- if (!fz_isarray(obj) || fz_arraylen(obj) != k * 2)
+ if (!fz_is_array(obj) || fz_array_len(obj) != k * 2)
return fz_throw("malformed /Encode");
for (i = 0; i < k; i++)
{
- func->u.st.encode[i*2+0] = fz_toreal(fz_arrayget(obj, i*2+0));
- func->u.st.encode[i*2+1] = fz_toreal(fz_arrayget(obj, i*2+1));
+ func->u.st.encode[i*2+0] = fz_to_real(fz_array_get(obj, i*2+0));
+ func->u.st.encode[i*2+1] = fz_to_real(fz_array_get(obj, i*2+1));
}
}
- pdf_logrsrc("}\n");
+ pdf_log_rsrc("}\n");
return fz_okay;
}
static void
-evalstitchingfunc(pdf_function *func, float in, float *out)
+eval_stitching_func(pdf_function *func, float in, float *out)
{
float low, high;
int k = func->u.st.k;
@@ -1328,7 +1328,7 @@ evalstitchingfunc(pdf_function *func, float in, float *out)
in = LERP(in, low, high, func->u.st.encode[i*2+0], func->u.st.encode[i*2+1]);
- pdf_evalfunction(func->u.st.funcs[i], &in, 1, out, func->n);
+ pdf_eval_function(func->u.st.funcs[i], &in, 1, out, func->n);
}
/*
@@ -1336,14 +1336,14 @@ evalstitchingfunc(pdf_function *func, float in, float *out)
*/
pdf_function *
-pdf_keepfunction(pdf_function *func)
+pdf_keep_function(pdf_function *func)
{
func->refs ++;
return func;
}
void
-pdf_dropfunction(pdf_function *func)
+pdf_drop_function(pdf_function *func)
{
int i;
if (--func->refs == 0)
@@ -1357,7 +1357,7 @@ pdf_dropfunction(pdf_function *func)
break;
case STITCHING:
for (i = 0; i < func->u.st.k; i++)
- pdf_dropfunction(func->u.st.funcs[i]);
+ pdf_drop_function(func->u.st.funcs[i]);
fz_free(func->u.st.funcs);
fz_free(func->u.st.bounds);
fz_free(func->u.st.encode);
@@ -1371,56 +1371,56 @@ pdf_dropfunction(pdf_function *func)
}
fz_error
-pdf_loadfunction(pdf_function **funcp, pdf_xref *xref, fz_obj *dict)
+pdf_load_function(pdf_function **funcp, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
pdf_function *func;
fz_obj *obj;
int i;
- if ((*funcp = pdf_finditem(xref->store, pdf_dropfunction, dict)))
+ if ((*funcp = pdf_find_item(xref->store, pdf_drop_function, dict)))
{
- pdf_keepfunction(*funcp);
+ pdf_keep_function(*funcp);
return fz_okay;
}
- pdf_logrsrc("load function (%d %d R) {\n", fz_tonum(dict), fz_togen(dict));
+ pdf_log_rsrc("load function (%d %d R) {\n", fz_to_num(dict), fz_to_gen(dict));
func = fz_malloc(sizeof(pdf_function));
memset(func, 0, sizeof(pdf_function));
func->refs = 1;
- obj = fz_dictgets(dict, "FunctionType");
- func->type = fz_toint(obj);
+ obj = fz_dict_gets(dict, "FunctionType");
+ func->type = fz_to_int(obj);
- pdf_logrsrc("type %d\n", func->type);
+ pdf_log_rsrc("type %d\n", func->type);
/* required for all */
- obj = fz_dictgets(dict, "Domain");
- func->m = fz_arraylen(obj) / 2;
+ obj = fz_dict_gets(dict, "Domain");
+ func->m = fz_array_len(obj) / 2;
for (i = 0; i < func->m; i++)
{
- func->domain[i][0] = fz_toreal(fz_arrayget(obj, i * 2 + 0));
- func->domain[i][1] = fz_toreal(fz_arrayget(obj, i * 2 + 1));
+ func->domain[i][0] = fz_to_real(fz_array_get(obj, i * 2 + 0));
+ func->domain[i][1] = fz_to_real(fz_array_get(obj, i * 2 + 1));
}
- pdf_logrsrc("domain %d\n", func->m);
+ pdf_log_rsrc("domain %d\n", func->m);
/* required for type0 and type4, optional otherwise */
- obj = fz_dictgets(dict, "Range");
- if (fz_isarray(obj))
+ obj = fz_dict_gets(dict, "Range");
+ if (fz_is_array(obj))
{
- func->hasrange = 1;
- func->n = fz_arraylen(obj) / 2;
+ func->has_range = 1;
+ func->n = fz_array_len(obj) / 2;
for (i = 0; i < func->n; i++)
{
- func->range[i][0] = fz_toreal(fz_arrayget(obj, i * 2 + 0));
- func->range[i][1] = fz_toreal(fz_arrayget(obj, i * 2 + 1));
+ func->range[i][0] = fz_to_real(fz_array_get(obj, i * 2 + 0));
+ func->range[i][1] = fz_to_real(fz_array_get(obj, i * 2 + 1));
}
- pdf_logrsrc("range %d\n", func->n);
+ pdf_log_rsrc("range %d\n", func->n);
}
else
{
- func->hasrange = 0;
+ func->has_range = 0;
func->n = 0;
}
@@ -1433,56 +1433,56 @@ pdf_loadfunction(pdf_function **funcp, pdf_xref *xref, fz_obj *dict)
switch(func->type)
{
case SAMPLE:
- error = loadsamplefunc(func, xref, dict, fz_tonum(dict), fz_togen(dict));
+ error = load_sample_func(func, xref, dict, fz_to_num(dict), fz_to_gen(dict));
if (error)
{
- pdf_dropfunction(func);
- return fz_rethrow(error, "cannot load sampled function (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ pdf_drop_function(func);
+ return fz_rethrow(error, "cannot load sampled function (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
break;
case EXPONENTIAL:
- error = loadexponentialfunc(func, dict);
+ error = load_exponential_func(func, dict);
if (error)
{
- pdf_dropfunction(func);
- return fz_rethrow(error, "cannot load exponential function (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ pdf_drop_function(func);
+ return fz_rethrow(error, "cannot load exponential function (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
break;
case STITCHING:
- error = loadstitchingfunc(func, xref, dict);
+ error = load_stitching_func(func, xref, dict);
if (error)
{
- pdf_dropfunction(func);
- return fz_rethrow(error, "cannot load stitching function (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ pdf_drop_function(func);
+ return fz_rethrow(error, "cannot load stitching function (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
break;
case POSTSCRIPT:
- error = loadpostscriptfunc(func, xref, dict, fz_tonum(dict), fz_togen(dict));
+ error = load_postscript_func(func, xref, dict, fz_to_num(dict), fz_to_gen(dict));
if (error)
{
- pdf_dropfunction(func);
- return fz_rethrow(error, "cannot load calculator function (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ pdf_drop_function(func);
+ return fz_rethrow(error, "cannot load calculator function (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
break;
default:
fz_free(func);
- return fz_throw("unknown function type (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ return fz_throw("unknown function type (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
- pdf_logrsrc("}\n");
+ pdf_log_rsrc("}\n");
- pdf_storeitem(xref->store, pdf_keepfunction, pdf_dropfunction, dict, func);
+ pdf_store_item(xref->store, pdf_keep_function, pdf_drop_function, dict, func);
*funcp = func;
return fz_okay;
}
void
-pdf_evalfunction(pdf_function *func, float *in, int inlen, float *out, int outlen)
+pdf_eval_function(pdf_function *func, float *in, int inlen, float *out, int outlen)
{
memset(out, 0, sizeof(float) * outlen);
@@ -1499,10 +1499,10 @@ pdf_evalfunction(pdf_function *func, float *in, int inlen, float *out, int outle
switch(func->type)
{
- case SAMPLE: evalsamplefunc(func, in, out); break;
- case EXPONENTIAL: evalexponentialfunc(func, *in, out); break;
- case STITCHING: evalstitchingfunc(func, *in, out); break;
- case POSTSCRIPT: evalpostscriptfunc(func, in, out); break;
+ case SAMPLE: eval_sample_func(func, in, out); break;
+ case EXPONENTIAL: eval_exponential_func(func, *in, out); break;
+ case STITCHING: eval_stitching_func(func, *in, out); break;
+ case POSTSCRIPT: eval_postscript_func(func, in, out); break;
}
}
@@ -1511,7 +1511,7 @@ pdf_evalfunction(pdf_function *func, float *in, int inlen, float *out, int outle
*/
static void
-pdf_debugindent(char *prefix, int level, char *suffix)
+pdf_debug_indent(char *prefix, int level, char *suffix)
{
int i;
@@ -1524,20 +1524,20 @@ pdf_debugindent(char *prefix, int level, char *suffix)
}
static void
-pdf_debugpsfunccode(psobj *funccode, psobj *code, int level)
+pdf_debug_ps_func_code(psobj *funccode, psobj *code, int level)
{
int eof, wasop;
- pdf_debugindent("", level, "{");
+ pdf_debug_indent("", level, "{");
/* Print empty blocks as { }, instead of separating braces on different lines. */
- if (code->type == PSOPERATOR && code->u.op == PSORETURN)
+ if (code->type == PS_OPERATOR && code->u.op == PS_OP_RETURN)
{
printf(" } ");
return;
}
- pdf_debugindent("\n", ++level, "");
+ pdf_debug_indent("\n", ++level, "");
eof = 0;
wasop = 0;
@@ -1545,60 +1545,60 @@ pdf_debugpsfunccode(psobj *funccode, psobj *code, int level)
{
switch (code->type)
{
- case PSINT:
+ case PS_INT:
if (wasop)
- pdf_debugindent("\n", level, "");
+ pdf_debug_indent("\n", level, "");
printf("%d ", code->u.i);
wasop = 0;
code++;
break;
- case PSREAL:
+ case PS_REAL:
if (wasop)
- pdf_debugindent("\n", level, "");
+ pdf_debug_indent("\n", level, "");
printf("%g ", code->u.f);
wasop = 0;
code++;
break;
- case PSOPERATOR:
- if (code->u.op == PSORETURN)
+ case PS_OPERATOR:
+ if (code->u.op == PS_OP_RETURN)
{
printf("\n");
eof = 1;
}
- else if (code->u.op == PSOIF)
+ else if (code->u.op == PS_OP_IF)
{
printf("\n");
- pdf_debugpsfunccode(funccode, &funccode[(code + 2)->u.block], level);
+ pdf_debug_ps_func_code(funccode, &funccode[(code + 2)->u.block], level);
- printf("%s", psopnames[code->u.op]);
+ printf("%s", ps_op_names[code->u.op]);
code = &funccode[(code + 3)->u.block];
- if (code->type != PSOPERATOR || code->u.op != PSORETURN)
- pdf_debugindent("\n", level, "");
+ if (code->type != PS_OPERATOR || code->u.op != PS_OP_RETURN)
+ pdf_debug_indent("\n", level, "");
wasop = 0;
}
- else if (code->u.op == PSOIFELSE)
+ else if (code->u.op == PS_OP_IFELSE)
{
printf("\n");
- pdf_debugpsfunccode(funccode, &funccode[(code + 2)->u.block], level);
+ pdf_debug_ps_func_code(funccode, &funccode[(code + 2)->u.block], level);
printf("\n");
- pdf_debugpsfunccode(funccode, &funccode[(code + 1)->u.block], level);
+ pdf_debug_ps_func_code(funccode, &funccode[(code + 1)->u.block], level);
- printf("%s", psopnames[code->u.op]);
+ printf("%s", ps_op_names[code->u.op]);
code = &funccode[(code + 3)->u.block];
- if (code->type != PSOPERATOR || code->u.op != PSORETURN)
- pdf_debugindent("\n", level, "");
+ if (code->type != PS_OPERATOR || code->u.op != PS_OP_RETURN)
+ pdf_debug_indent("\n", level, "");
wasop = 0;
}
else
{
- printf("%s ", psopnames[code->u.op]);
+ printf("%s ", ps_op_names[code->u.op]);
code++;
wasop = 1;
}
@@ -1606,17 +1606,17 @@ pdf_debugpsfunccode(psobj *funccode, psobj *code, int level)
}
}
- pdf_debugindent("", --level, "} ");
+ pdf_debug_indent("", --level, "} ");
}
static void
-pdf_debugfunctionimp(pdf_function *func, int level)
+pdf_debug_function_imp(pdf_function *func, int level)
{
int i;
- pdf_debugindent("", level, "function {\n");
+ pdf_debug_indent("", level, "function {\n");
- pdf_debugindent("", ++level, "");
+ pdf_debug_indent("", ++level, "");
switch (func->type)
{
case SAMPLE:
@@ -1633,17 +1633,17 @@ pdf_debugfunctionimp(pdf_function *func, int level)
break;
}
- pdf_debugindent("\n", level, "");
+ pdf_debug_indent("\n", level, "");
printf("%d input -> %d output\n", func->m, func->n);
- pdf_debugindent("", level, "domain ");
+ pdf_debug_indent("", level, "domain ");
for (i = 0; i < func->m; i++)
printf("%g %g ", func->domain[i][0], func->domain[i][1]);
printf("\n");
- if (func->hasrange)
+ if (func->has_range)
{
- pdf_debugindent("", level, "range ");
+ pdf_debug_indent("", level, "range ");
for (i = 0; i < func->n; i++)
printf("%g %g ", func->range[i][0], func->range[i][1]);
printf("\n");
@@ -1652,22 +1652,22 @@ pdf_debugfunctionimp(pdf_function *func, int level)
switch (func->type)
{
case SAMPLE:
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("bps: %d\n", func->u.sa.bps);
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("size: [ ");
for (i = 0; i < func->m; i++)
printf("%d ", func->u.sa.size[i]);
printf("]\n");
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("encode: [ ");
for (i = 0; i < func->m; i++)
printf("%g %g ", func->u.sa.encode[i][0], func->u.sa.encode[i][1]);
printf("]\n");
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("decode: [ ");
for (i = 0; i < func->m; i++)
printf("%g %g ", func->u.sa.decode[i][0], func->u.sa.decode[i][1]);
@@ -1675,16 +1675,16 @@ pdf_debugfunctionimp(pdf_function *func, int level)
break;
case EXPONENTIAL:
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("n: %g\n", func->u.e.n);
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("c0: [ ");
for (i = 0; i < func->n; i++)
printf("%g ", func->u.e.c0[i]);
printf("]\n");
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("c1: [ ");
for (i = 0; i < func->n; i++)
printf("%g ", func->u.e.c1[i]);
@@ -1692,36 +1692,36 @@ pdf_debugfunctionimp(pdf_function *func, int level)
break;
case STITCHING:
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("%d functions\n", func->u.st.k);
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("bounds: [ ");
for (i = 0; i < func->u.st.k - 1; i++)
printf("%g ", func->u.st.bounds[i]);
printf("]\n");
- pdf_debugindent("", level, "");
+ pdf_debug_indent("", level, "");
printf("encode: [ ");
for (i = 0; i < func->u.st.k * 2; i++)
printf("%g ", func->u.st.encode[i]);
printf("]\n");
for (i = 0; i < func->u.st.k; i++)
- pdf_debugfunctionimp(func->u.st.funcs[i], level);
+ pdf_debug_function_imp(func->u.st.funcs[i], level);
break;
case POSTSCRIPT:
- pdf_debugpsfunccode(func->u.p.code, func->u.p.code, level);
+ pdf_debug_ps_func_code(func->u.p.code, func->u.p.code, level);
printf("\n");
break;
}
- pdf_debugindent("", --level, "}\n");
+ pdf_debug_indent("", --level, "}\n");
}
void
-pdf_debugfunction(pdf_function *func)
+pdf_debug_function(pdf_function *func)
{
- pdf_debugfunctionimp(func, 0);
+ pdf_debug_function_imp(func, 0);
}
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c
index b37c7257..dc12c232 100644
--- a/pdf/pdf_image.c
+++ b/pdf/pdf_image.c
@@ -4,10 +4,10 @@
/* TODO: store JPEG compressed samples */
/* TODO: store flate compressed samples */
-static fz_error pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict);
+static fz_error pdf_load_jpx_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict);
static void
-pdf_maskcolorkey(fz_pixmap *pix, int n, int *colorkey)
+pdf_mask_color_key(fz_pixmap *pix, int n, int *colorkey)
{
unsigned char *p = pix->samples;
int len = pix->w * pix->h;
@@ -26,7 +26,7 @@ pdf_maskcolorkey(fz_pixmap *pix, int n, int *colorkey)
}
static fz_error
-pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, int forcemask)
+pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, int forcemask)
{
fz_stream *stm;
fz_pixmap *tile;
@@ -40,8 +40,8 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
fz_colorspace *colorspace;
fz_pixmap *mask; /* explicit mask/softmask image */
int usecolorkey;
- int colorkey[FZ_MAXCOLORS * 2];
- float decode[FZ_MAXCOLORS * 2];
+ int colorkey[FZ_MAX_COLORS * 2];
+ float decode[FZ_MAX_COLORS * 2];
int scale;
int stride;
@@ -49,21 +49,21 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
int i, len;
/* special case for JPEG2000 images */
- if (pdf_isjpximage(dict))
+ if (pdf_is_jpx_image(dict))
{
- tile = nil;
- error = pdf_loadjpximage(&tile, xref, dict);
+ tile = NULL;
+ error = pdf_load_jpx_image(&tile, xref, dict);
if (error)
return fz_rethrow(error, "cannot load jpx image");
if (forcemask)
{
if (tile->n != 2)
{
- fz_droppixmap(tile);
+ fz_drop_pixmap(tile);
return fz_throw("softmask must be grayscale");
}
- mask = fz_alphafromgray(tile, 1);
- fz_droppixmap(tile);
+ mask = fz_alpha_from_gray(tile, 1);
+ fz_drop_pixmap(tile);
*imgp = mask;
return fz_okay;
}
@@ -71,16 +71,16 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
return fz_okay;
}
- w = fz_toint(fz_dictgetsa(dict, "Width", "W"));
- h = fz_toint(fz_dictgetsa(dict, "Height", "H"));
- bpc = fz_toint(fz_dictgetsa(dict, "BitsPerComponent", "BPC"));
- imagemask = fz_tobool(fz_dictgetsa(dict, "ImageMask", "IM"));
- interpolate = fz_tobool(fz_dictgetsa(dict, "Interpolate", "I"));
+ w = fz_to_int(fz_dict_getsa(dict, "Width", "W"));
+ h = fz_to_int(fz_dict_getsa(dict, "Height", "H"));
+ bpc = fz_to_int(fz_dict_getsa(dict, "BitsPerComponent", "BPC"));
+ imagemask = fz_to_bool(fz_dict_getsa(dict, "ImageMask", "IM"));
+ interpolate = fz_to_bool(fz_dict_getsa(dict, "Interpolate", "I"));
indexed = 0;
usecolorkey = 0;
- colorspace = nil;
- mask = nil;
+ colorspace = NULL;
+ mask = NULL;
if (imagemask)
bpc = 1;
@@ -96,18 +96,18 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
if (h > (1 << 16))
return fz_throw("image is too high");
- obj = fz_dictgetsa(dict, "ColorSpace", "CS");
+ obj = fz_dict_getsa(dict, "ColorSpace", "CS");
if (obj && !imagemask && !forcemask)
{
/* colorspace resource lookup is only done for inline images */
- if (fz_isname(obj))
+ if (fz_is_name(obj))
{
- res = fz_dictget(fz_dictgets(rdb, "ColorSpace"), obj);
+ res = fz_dict_get(fz_dict_gets(rdb, "ColorSpace"), obj);
if (res)
obj = res;
}
- error = pdf_loadcolorspace(&colorspace, xref, obj);
+ error = pdf_load_colorspace(&colorspace, xref, obj);
if (error)
return fz_rethrow(error, "cannot load image colorspace");
@@ -121,11 +121,11 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
n = 1;
}
- obj = fz_dictgetsa(dict, "Decode", "D");
+ obj = fz_dict_getsa(dict, "Decode", "D");
if (obj)
{
for (i = 0; i < n * 2; i++)
- decode[i] = fz_toreal(fz_arrayget(obj, i));
+ decode[i] = fz_to_real(fz_array_get(obj, i));
}
else
{
@@ -134,44 +134,44 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
decode[i] = i & 1 ? maxval : 0;
}
- obj = fz_dictgetsa(dict, "SMask", "Mask");
- if (fz_isdict(obj))
+ obj = fz_dict_getsa(dict, "SMask", "Mask");
+ if (fz_is_dict(obj))
{
/* Not allowed for inline images */
if (!cstm)
{
- error = pdf_loadimageimp(&mask, xref, rdb, obj, nil, 1);
+ error = pdf_load_image_imp(&mask, xref, rdb, obj, NULL, 1);
if (error)
{
if (colorspace)
- fz_dropcolorspace(colorspace);
+ fz_drop_colorspace(colorspace);
return fz_rethrow(error, "cannot load image mask/softmask");
}
}
}
- else if (fz_isarray(obj))
+ else if (fz_is_array(obj))
{
usecolorkey = 1;
for (i = 0; i < n * 2; i++)
- colorkey[i] = fz_toint(fz_arrayget(obj, i));
+ colorkey[i] = fz_to_int(fz_array_get(obj, i));
}
stride = (w * n * bpc + 7) / 8;
if (cstm)
{
- stm = pdf_openinlinestream(cstm, xref, dict, stride * h);
+ stm = pdf_open_inline_stream(cstm, xref, dict, stride * h);
}
else
{
- error = pdf_openstream(&stm, xref, fz_tonum(dict), fz_togen(dict));
+ error = pdf_open_stream(&stm, xref, fz_to_num(dict), fz_to_gen(dict));
if (error)
{
if (colorspace)
- fz_dropcolorspace(colorspace);
+ fz_drop_colorspace(colorspace);
if (mask)
- fz_droppixmap(mask);
- return fz_rethrow(error, "cannot open image data stream (%d 0 R)", fz_tonum(dict));
+ fz_drop_pixmap(mask);
+ return fz_rethrow(error, "cannot open image data stream (%d 0 R)", fz_to_num(dict));
}
}
@@ -182,9 +182,9 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
{
fz_close(stm);
if (colorspace)
- fz_dropcolorspace(colorspace);
+ fz_drop_colorspace(colorspace);
if (mask)
- fz_droppixmap(mask);
+ fz_drop_pixmap(mask);
fz_free(samples);
return fz_rethrow(len, "cannot read image data");
}
@@ -205,7 +205,7 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
/* Pad truncated images */
if (len < stride * h)
{
- fz_warn("padding truncated image (%d 0 R)", fz_tonum(dict));
+ fz_warn("padding truncated image (%d 0 R)", fz_to_num(dict));
memset(samples + len, 0, stride * h - len);
}
@@ -219,11 +219,11 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
p[i] = ~p[i];
}
- pdf_logimage("size %dx%d n=%d bpc=%d imagemask=%d indexed=%d\n", w, h, n, bpc, imagemask, indexed);
+ pdf_log_image("size %dx%d n=%d bpc=%d imagemask=%d indexed=%d\n", w, h, n, bpc, imagemask, indexed);
/* Unpack samples into pixmap */
- tile = fz_newpixmap(colorspace, 0, 0, w, h);
+ tile = fz_new_pixmap(colorspace, 0, 0, w, h);
scale = 1;
if (!indexed)
@@ -236,28 +236,28 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
}
}
- fz_unpacktile(tile, samples, n, bpc, stride, scale);
+ fz_unpack_tile(tile, samples, n, bpc, stride, scale);
if (usecolorkey)
- pdf_maskcolorkey(tile, n, colorkey);
+ pdf_mask_color_key(tile, n, colorkey);
if (indexed)
{
fz_pixmap *conv;
- fz_decodeindexedtile(tile, decode, (1 << bpc) - 1);
+ fz_decode_indexed_tile(tile, decode, (1 << bpc) - 1);
- conv = pdf_expandindexedpixmap(tile);
- fz_droppixmap(tile);
+ conv = pdf_expand_indexed_pixmap(tile);
+ fz_drop_pixmap(tile);
tile = conv;
}
else
{
- fz_decodetile(tile, decode);
+ fz_decode_tile(tile, decode);
}
if (colorspace)
- fz_dropcolorspace(colorspace);
+ fz_drop_colorspace(colorspace);
tile->mask = mask;
tile->interpolate = interpolate;
@@ -269,97 +269,97 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
}
fz_error
-pdf_loadinlineimage(fz_pixmap **pixp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file)
+pdf_load_inline_image(fz_pixmap **pixp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file)
{
fz_error error;
- pdf_logimage("load inline image {\n");
+ pdf_log_image("load inline image {\n");
- error = pdf_loadimageimp(pixp, xref, rdb, dict, file, 0);
+ error = pdf_load_image_imp(pixp, xref, rdb, dict, file, 0);
if (error)
return fz_rethrow(error, "cannot load inline image");
- pdf_logimage("}\n");
+ pdf_log_image("}\n");
return fz_okay;
}
int
-pdf_isjpximage(fz_obj *dict)
+pdf_is_jpx_image(fz_obj *dict)
{
fz_obj *filter;
int i;
- filter = fz_dictgets(dict, "Filter");
- if (!strcmp(fz_toname(filter), "JPXDecode"))
+ filter = fz_dict_gets(dict, "Filter");
+ if (!strcmp(fz_to_name(filter), "JPXDecode"))
return 1;
- for (i = 0; i < fz_arraylen(filter); i++)
- if (!strcmp(fz_toname(fz_arrayget(filter, i)), "JPXDecode"))
+ for (i = 0; i < fz_array_len(filter); i++)
+ if (!strcmp(fz_to_name(fz_array_get(filter, i)), "JPXDecode"))
return 1;
return 0;
}
static fz_error
-pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict)
+pdf_load_jpx_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
fz_buffer *buf;
fz_pixmap *img;
fz_obj *obj;
- pdf_logimage("jpeg2000\n");
+ pdf_log_image("jpeg2000\n");
- error = pdf_loadstream(&buf, xref, fz_tonum(dict), fz_togen(dict));
+ error = pdf_load_stream(&buf, xref, fz_to_num(dict), fz_to_gen(dict));
if (error)
return fz_rethrow(error, "cannot load jpx image data");
- error = fz_loadjpximage(&img, buf->data, buf->len);
+ error = fz_load_jpx_image(&img, buf->data, buf->len);
if (error)
{
- fz_dropbuffer(buf);
+ fz_drop_buffer(buf);
return fz_rethrow(error, "cannot load jpx image");
}
- fz_dropbuffer(buf);
+ fz_drop_buffer(buf);
- obj = fz_dictgetsa(dict, "SMask", "Mask");
- if (fz_isdict(obj))
+ obj = fz_dict_getsa(dict, "SMask", "Mask");
+ if (fz_is_dict(obj))
{
- error = pdf_loadimageimp(&img->mask, xref, nil, obj, nil, 1);
+ error = pdf_load_image_imp(&img->mask, xref, NULL, obj, NULL, 1);
if (error)
{
- fz_droppixmap(img);
+ fz_drop_pixmap(img);
return fz_rethrow(error, "cannot load image mask/softmask");
}
}
- obj = fz_dictgets(dict, "ColorSpace");
+ obj = fz_dict_gets(dict, "ColorSpace");
if (obj)
{
fz_colorspace *original = img->colorspace;
- img->colorspace = nil;
+ img->colorspace = NULL;
- error = pdf_loadcolorspace(&img->colorspace, xref, obj);
+ error = pdf_load_colorspace(&img->colorspace, xref, obj);
if (error)
{
- fz_dropcolorspace(original);
+ fz_drop_colorspace(original);
return fz_rethrow(error, "cannot load image colorspace");
}
if (original->n != img->colorspace->n)
{
fz_warn("jpeg-2000 colorspace (%s) does not match promised colorspace (%s)", original->name, img->colorspace->name);
- fz_dropcolorspace(img->colorspace);
+ fz_drop_colorspace(img->colorspace);
img->colorspace = original;
}
else
- fz_dropcolorspace(original);
+ fz_drop_colorspace(original);
if (!strcmp(img->colorspace->name, "Indexed"))
{
fz_pixmap *conv;
- conv = pdf_expandindexedpixmap(img);
- fz_droppixmap(img);
+ conv = pdf_expand_indexed_pixmap(img);
+ fz_drop_pixmap(img);
img = conv;
}
}
@@ -369,25 +369,25 @@ pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict)
}
fz_error
-pdf_loadimage(fz_pixmap **pixp, pdf_xref *xref, fz_obj *dict)
+pdf_load_image(fz_pixmap **pixp, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
- if ((*pixp = pdf_finditem(xref->store, fz_droppixmap, dict)))
+ if ((*pixp = pdf_find_item(xref->store, fz_drop_pixmap, dict)))
{
- fz_keeppixmap(*pixp);
+ fz_keep_pixmap(*pixp);
return fz_okay;
}
- pdf_logimage("load image (%d 0 R) {\n", fz_tonum(dict));
+ pdf_log_image("load image (%d 0 R) {\n", fz_to_num(dict));
- error = pdf_loadimageimp(pixp, xref, nil, dict, nil, 0);
+ error = pdf_load_image_imp(pixp, xref, NULL, dict, NULL, 0);
if (error)
- return fz_rethrow(error, "cannot load image (%d 0 R)", fz_tonum(dict));
+ return fz_rethrow(error, "cannot load image (%d 0 R)", fz_to_num(dict));
- pdf_storeitem(xref->store, fz_keeppixmap, fz_droppixmap, dict, *pixp);
+ pdf_store_item(xref->store, fz_keep_pixmap, fz_drop_pixmap, dict, *pixp);
- pdf_logimage("}\n");
+ pdf_log_image("}\n");
return fz_okay;
}
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c
index dbeeb997..81848709 100644
--- a/pdf/pdf_interpret.c
+++ b/pdf/pdf_interpret.c
@@ -2,7 +2,7 @@
#include "mupdf.h"
static pdf_csi *
-pdf_newcsi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *target)
+pdf_new_csi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *target)
{
pdf_csi *csi;
@@ -12,43 +12,43 @@ pdf_newcsi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *target)
csi->target = target;
csi->top = 0;
- csi->obj = nil;
+ csi->obj = NULL;
csi->name[0] = 0;
- csi->stringlen = 0;
+ csi->string_len = 0;
memset(csi->stack, 0, sizeof csi->stack);
csi->xbalance = 0;
- csi->intext = 0;
- csi->inarray = 0;
+ csi->in_text = 0;
+ csi->in_array = 0;
- csi->path = fz_newpath();
+ csi->path = fz_new_path();
csi->clip = 0;
- csi->clipevenodd = 0;
+ csi->clip_even_odd = 0;
- csi->text = nil;
+ csi->text = NULL;
csi->tlm = fz_identity;
csi->tm = fz_identity;
- csi->textmode = 0;
+ csi->text_mode = 0;
csi->accumulate = 1;
- csi->topctm = ctm;
- pdf_initgstate(&csi->gstate[0], ctm);
+ csi->top_ctm = ctm;
+ pdf_init_gstate(&csi->gstate[0], ctm);
csi->gtop = 0;
return csi;
}
static void
-pdf_clearstack(pdf_csi *csi)
+pdf_clear_stack(pdf_csi *csi)
{
int i;
if (csi->obj)
- fz_dropobj(csi->obj);
- csi->obj = nil;
+ fz_drop_obj(csi->obj);
+ csi->obj = NULL;
csi->name[0] = 0;
- csi->stringlen = 0;
+ csi->string_len = 0;
for (i = 0; i < csi->top; i++)
csi->stack[i] = 0;
@@ -56,26 +56,26 @@ pdf_clearstack(pdf_csi *csi)
}
pdf_material *
-pdf_keepmaterial(pdf_material *mat)
+pdf_keep_material(pdf_material *mat)
{
if (mat->colorspace)
- fz_keepcolorspace(mat->colorspace);
+ fz_keep_colorspace(mat->colorspace);
if (mat->pattern)
- pdf_keeppattern(mat->pattern);
+ pdf_keep_pattern(mat->pattern);
if (mat->shade)
- fz_keepshade(mat->shade);
+ fz_keep_shade(mat->shade);
return mat;
}
pdf_material *
-pdf_dropmaterial(pdf_material *mat)
+pdf_drop_material(pdf_material *mat)
{
if (mat->colorspace)
- fz_dropcolorspace(mat->colorspace);
+ fz_drop_colorspace(mat->colorspace);
if (mat->pattern)
- pdf_droppattern(mat->pattern);
+ pdf_drop_pattern(mat->pattern);
if (mat->shade)
- fz_dropshade(mat->shade);
+ fz_drop_shade(mat->shade);
return mat;
}
@@ -94,19 +94,19 @@ pdf_gsave(pdf_csi *csi)
csi->gtop ++;
- pdf_keepmaterial(&gs->stroke);
- pdf_keepmaterial(&gs->fill);
+ pdf_keep_material(&gs->stroke);
+ pdf_keep_material(&gs->fill);
if (gs->font)
- pdf_keepfont(gs->font);
+ pdf_keep_font(gs->font);
if (gs->softmask)
- pdf_keepxobject(gs->softmask);
+ pdf_keep_xobject(gs->softmask);
}
void
pdf_grestore(pdf_csi *csi)
{
pdf_gstate *gs = csi->gstate + csi->gtop;
- int clipdepth = gs->clipdepth;
+ int clip_depth = gs->clip_depth;
if (csi->gtop == 0)
{
@@ -114,49 +114,49 @@ pdf_grestore(pdf_csi *csi)
return;
}
- pdf_dropmaterial(&gs->stroke);
- pdf_dropmaterial(&gs->fill);
+ pdf_drop_material(&gs->stroke);
+ pdf_drop_material(&gs->fill);
if (gs->font)
- pdf_dropfont(gs->font);
+ pdf_drop_font(gs->font);
if (gs->softmask)
- pdf_dropxobject(gs->softmask);
+ pdf_drop_xobject(gs->softmask);
csi->gtop --;
gs = csi->gstate + csi->gtop;
- while (clipdepth > gs->clipdepth)
+ while (clip_depth > gs->clip_depth)
{
- csi->dev->popclip(csi->dev->user);
- clipdepth--;
+ csi->dev->pop_clip(csi->dev->user);
+ clip_depth--;
}
}
static void
-pdf_freecsi(pdf_csi *csi)
+pdf_free_csi(pdf_csi *csi)
{
while (csi->gtop)
pdf_grestore(csi);
- pdf_dropmaterial(&csi->gstate[0].fill);
- pdf_dropmaterial(&csi->gstate[0].stroke);
+ pdf_drop_material(&csi->gstate[0].fill);
+ pdf_drop_material(&csi->gstate[0].stroke);
if (csi->gstate[0].font)
- pdf_dropfont(csi->gstate[0].font);
+ pdf_drop_font(csi->gstate[0].font);
if (csi->gstate[0].softmask)
- pdf_dropxobject(csi->gstate[0].softmask);
+ pdf_drop_xobject(csi->gstate[0].softmask);
- while (csi->gstate[0].clipdepth--)
- csi->dev->popclip(csi->dev->user);
+ while (csi->gstate[0].clip_depth--)
+ csi->dev->pop_clip(csi->dev->user);
- if (csi->path) fz_freepath(csi->path);
- if (csi->text) fz_freetext(csi->text);
+ if (csi->path) fz_free_path(csi->path);
+ if (csi->text) fz_free_text(csi->text);
- pdf_clearstack(csi);
+ pdf_clear_stack(csi);
fz_free(csi);
}
static int
-pdf_ishiddenocg(pdf_csi *csi, fz_obj *xobj)
+pdf_is_hidden_ocg(pdf_csi *csi, fz_obj *xobj)
{
char target_state[16];
fz_obj *obj;
@@ -164,18 +164,18 @@ pdf_ishiddenocg(pdf_csi *csi, fz_obj *xobj)
fz_strlcpy(target_state, csi->target, sizeof target_state);
fz_strlcat(target_state, "State", sizeof target_state);
- obj = fz_dictgets(xobj, "OC");
- obj = fz_dictgets(obj, "OCGs");
- if (fz_isarray(obj))
- obj = fz_arrayget(obj, 0);
- obj = fz_dictgets(obj, "Usage");
- obj = fz_dictgets(obj, csi->target);
- obj = fz_dictgets(obj, target_state);
- return !strcmp(fz_toname(obj), "OFF");
+ obj = fz_dict_gets(xobj, "OC");
+ obj = fz_dict_gets(obj, "OCGs");
+ if (fz_is_array(obj))
+ obj = fz_array_get(obj, 0);
+ obj = fz_dict_gets(obj, "Usage");
+ obj = fz_dict_gets(obj, csi->target);
+ obj = fz_dict_gets(obj, target_state);
+ return !strcmp(fz_to_name(obj), "OFF");
}
fz_error
-pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform)
+pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform)
{
fz_error error;
pdf_gstate *gstate;
@@ -199,26 +199,26 @@ pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tra
if (gstate->softmask)
{
pdf_xobject *softmask = gstate->softmask;
- fz_rect bbox = fz_transformrect(gstate->ctm, xobj->bbox);
+ fz_rect bbox = fz_transform_rect(gstate->ctm, xobj->bbox);
- gstate->softmask = nil;
+ gstate->softmask = NULL;
popmask = 1;
- csi->dev->beginmask(csi->dev->user, bbox, gstate->luminosity,
- softmask->colorspace, gstate->softmaskbc);
- error = pdf_runxobject(csi, resources, softmask, fz_identity);
+ csi->dev->begin_mask(csi->dev->user, bbox, gstate->luminosity,
+ softmask->colorspace, gstate->softmask_bc);
+ error = pdf_run_xobject(csi, resources, softmask, fz_identity);
if (error)
return fz_rethrow(error, "cannot run softmask");
- csi->dev->endmask(csi->dev->user);
+ csi->dev->end_mask(csi->dev->user);
- pdf_dropxobject(softmask);
+ pdf_drop_xobject(softmask);
}
- csi->dev->begingroup(csi->dev->user,
- fz_transformrect(gstate->ctm, xobj->bbox),
+ csi->dev->begin_group(csi->dev->user,
+ fz_transform_rect(gstate->ctm, xobj->bbox),
xobj->isolated, xobj->knockout, gstate->blendmode, gstate->fill.alpha);
- gstate->blendmode = FZ_BNORMAL;
+ gstate->blendmode = FZ_BLEND_NORMAL;
gstate->stroke.alpha = 1;
gstate->fill.alpha = 1;
}
@@ -231,21 +231,21 @@ pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tra
fz_lineto(csi->path, xobj->bbox.x0, xobj->bbox.y1);
fz_closepath(csi->path);
csi->clip = 1;
- pdf_showpath(csi, 0, 0, 0, 0);
+ pdf_show_path(csi, 0, 0, 0, 0);
/* run contents */
- oldtopctm = csi->topctm;
- csi->topctm = gstate->ctm;
+ oldtopctm = csi->top_ctm;
+ csi->top_ctm = gstate->ctm;
if (xobj->resources)
resources = xobj->resources;
- error = pdf_runcsibuffer(csi, resources, xobj->contents);
+ error = pdf_run_csi_buffer(csi, resources, xobj->contents);
if (error)
return fz_rethrow(error, "cannot interpret XObject stream");
- csi->topctm = oldtopctm;
+ csi->top_ctm = oldtopctm;
while (oldtop < csi->gtop)
pdf_grestore(csi);
@@ -256,124 +256,124 @@ pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tra
if (xobj->transparency)
{
- csi->dev->endgroup(csi->dev->user);
+ csi->dev->end_group(csi->dev->user);
if (popmask)
- csi->dev->popclip(csi->dev->user);
+ csi->dev->pop_clip(csi->dev->user);
}
return fz_okay;
}
static fz_error
-pdf_runinlineimage(pdf_csi *csi, fz_obj *rdb, fz_stream *file, fz_obj *dict)
+pdf_run_inline_image(pdf_csi *csi, fz_obj *rdb, fz_stream *file, fz_obj *dict)
{
fz_error error;
fz_pixmap *img;
int ch;
- error = pdf_loadinlineimage(&img, csi->xref, rdb, dict, file);
+ error = pdf_load_inline_image(&img, csi->xref, rdb, dict, file);
if (error)
return fz_rethrow(error, "cannot load inline image");
/* find EI */
- ch = fz_readbyte(file);
+ ch = fz_read_byte(file);
while (ch != 'E' && ch != EOF)
- ch = fz_readbyte(file);
- ch = fz_readbyte(file);
+ ch = fz_read_byte(file);
+ ch = fz_read_byte(file);
if (ch != 'I')
{
- fz_droppixmap(img);
+ fz_drop_pixmap(img);
return fz_rethrow(error, "syntax error after inline image");
}
- pdf_showimage(csi, img);
+ pdf_show_image(csi, img);
- fz_droppixmap(img);
+ fz_drop_pixmap(img);
return fz_okay;
}
static fz_error
-pdf_runextgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
+pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_colorspace *colorspace;
int i, k;
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
- for (i = 0; i < fz_dictlen(extgstate); i++)
+ for (i = 0; i < fz_dict_len(extgstate); i++)
{
- fz_obj *key = fz_dictgetkey(extgstate, i);
- fz_obj *val = fz_dictgetval(extgstate, i);
- char *s = fz_toname(key);
+ fz_obj *key = fz_dict_get_key(extgstate, i);
+ fz_obj *val = fz_dict_get_val(extgstate, i);
+ char *s = fz_to_name(key);
if (!strcmp(s, "Font"))
{
- if (fz_isarray(val) && fz_arraylen(val) == 2)
+ if (fz_is_array(val) && fz_array_len(val) == 2)
{
fz_error error;
- fz_obj *font = fz_arrayget(val, 0);
+ fz_obj *font = fz_array_get(val, 0);
if (gstate->font)
{
- pdf_dropfont(gstate->font);
- gstate->font = nil;
+ pdf_drop_font(gstate->font);
+ gstate->font = NULL;
}
- error = pdf_loadfont(&gstate->font, csi->xref, rdb, font);
+ error = pdf_load_font(&gstate->font, csi->xref, rdb, font);
if (error)
- return fz_rethrow(error, "cannot load font (%d %d R)", fz_tonum(font), fz_togen(font));
+ return fz_rethrow(error, "cannot load font (%d %d R)", fz_to_num(font), fz_to_gen(font));
if (!gstate->font)
return fz_throw("cannot find font in store");
- gstate->size = fz_toreal(fz_arrayget(val, 1));
+ gstate->size = fz_to_real(fz_array_get(val, 1));
}
else
return fz_throw("malformed /Font dictionary");
}
else if (!strcmp(s, "LW"))
- gstate->strokestate.linewidth = fz_toreal(val);
+ gstate->stroke_state.linewidth = fz_to_real(val);
else if (!strcmp(s, "LC"))
- gstate->strokestate.linecap = fz_toint(val);
+ gstate->stroke_state.linecap = fz_to_int(val);
else if (!strcmp(s, "LJ"))
- gstate->strokestate.linejoin = fz_toint(val);
+ gstate->stroke_state.linejoin = fz_to_int(val);
else if (!strcmp(s, "ML"))
- gstate->strokestate.miterlimit = fz_toreal(val);
+ gstate->stroke_state.miterlimit = fz_to_real(val);
else if (!strcmp(s, "D"))
{
- if (fz_isarray(val) && fz_arraylen(val) == 2)
+ if (fz_is_array(val) && fz_array_len(val) == 2)
{
- fz_obj *dashes = fz_arrayget(val, 0);
- gstate->strokestate.dashlen = MAX(fz_arraylen(dashes), 32);
- for (k = 0; k < gstate->strokestate.dashlen; k++)
- gstate->strokestate.dashlist[k] = fz_toreal(fz_arrayget(dashes, k));
- gstate->strokestate.dashphase = fz_toreal(fz_arrayget(val, 1));
+ fz_obj *dashes = fz_array_get(val, 0);
+ gstate->stroke_state.dash_len = MAX(fz_array_len(dashes), 32);
+ for (k = 0; k < gstate->stroke_state.dash_len; k++)
+ gstate->stroke_state.dash_list[k] = fz_to_real(fz_array_get(dashes, k));
+ gstate->stroke_state.dash_phase = fz_to_real(fz_array_get(val, 1));
}
else
return fz_throw("malformed /D");
}
else if (!strcmp(s, "CA"))
- gstate->stroke.alpha = fz_toreal(val);
+ gstate->stroke.alpha = fz_to_real(val);
else if (!strcmp(s, "ca"))
- gstate->fill.alpha = fz_toreal(val);
+ gstate->fill.alpha = fz_to_real(val);
else if (!strcmp(s, "BM"))
{
- if (fz_isarray(val))
- val = fz_arrayget(val, 0);
+ if (fz_is_array(val))
+ val = fz_array_get(val, 0);
- gstate->blendmode = FZ_BNORMAL;
- for (k = 0; fz_blendnames[k]; k++)
- if (!strcmp(fz_blendnames[k], fz_toname(val)))
+ gstate->blendmode = FZ_BLEND_NORMAL;
+ for (k = 0; fz_blendmode_names[k]; k++)
+ if (!strcmp(fz_blendmode_names[k], fz_to_name(val)))
gstate->blendmode = k;
}
else if (!strcmp(s, "SMask"))
{
- if (fz_isdict(val))
+ if (fz_is_dict(val))
{
fz_error error;
pdf_xobject *xobj;
@@ -381,52 +381,52 @@ pdf_runextgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
if (gstate->softmask)
{
- pdf_dropxobject(gstate->softmask);
- gstate->softmask = nil;
+ pdf_drop_xobject(gstate->softmask);
+ gstate->softmask = NULL;
}
- group = fz_dictgets(val, "G");
+ group = fz_dict_gets(val, "G");
if (!group)
- return fz_throw("cannot load softmask xobject (%d %d R)", fz_tonum(val), fz_togen(val));
- error = pdf_loadxobject(&xobj, csi->xref, group);
+ return fz_throw("cannot load softmask xobject (%d %d R)", fz_to_num(val), fz_to_gen(val));
+ error = pdf_load_xobject(&xobj, csi->xref, group);
if (error)
- return fz_rethrow(error, "cannot load xobject (%d %d R)", fz_tonum(val), fz_togen(val));
+ return fz_rethrow(error, "cannot load xobject (%d %d R)", fz_to_num(val), fz_to_gen(val));
colorspace = xobj->colorspace;
if (!colorspace)
- colorspace = fz_devicegray;
+ colorspace = fz_device_gray;
- gstate->softmaskctm = fz_concat(xobj->matrix, gstate->ctm);
+ gstate->softmask_ctm = fz_concat(xobj->matrix, gstate->ctm);
gstate->softmask = xobj;
for (k = 0; k < colorspace->n; k++)
- gstate->softmaskbc[k] = 0;
+ gstate->softmask_bc[k] = 0;
- bc = fz_dictgets(val, "BC");
- if (fz_isarray(bc))
+ bc = fz_dict_gets(val, "BC");
+ if (fz_is_array(bc))
{
for (k = 0; k < colorspace->n; k++)
- gstate->softmaskbc[k] = fz_toreal(fz_arrayget(bc, k));
+ gstate->softmask_bc[k] = fz_to_real(fz_array_get(bc, k));
}
- luminosity = fz_dictgets(val, "S");
- if (fz_isname(luminosity) && !strcmp(fz_toname(luminosity), "Luminosity"))
+ luminosity = fz_dict_gets(val, "S");
+ if (fz_is_name(luminosity) && !strcmp(fz_to_name(luminosity), "Luminosity"))
gstate->luminosity = 1;
else
gstate->luminosity = 0;
}
- else if (fz_isname(val) && !strcmp(fz_toname(val), "None"))
+ else if (fz_is_name(val) && !strcmp(fz_to_name(val), "None"))
{
if (gstate->softmask)
{
- pdf_dropxobject(gstate->softmask);
- gstate->softmask = nil;
+ pdf_drop_xobject(gstate->softmask);
+ gstate->softmask = NULL;
}
}
}
else if (!strcmp(s, "TR"))
{
- if (fz_isname(val) && strcmp(fz_toname(val), "Identity"))
+ if (fz_is_name(val) && strcmp(fz_to_name(val), "Identity"))
fz_warn("ignoring transfer function");
}
}
@@ -446,18 +446,18 @@ static fz_error pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file)
int buflen = sizeof(csi->xref->scratch);
fz_obj *obj;
- error = pdf_parsedict(&obj, csi->xref, file, buf, buflen);
+ error = pdf_parse_dict(&obj, csi->xref, file, buf, buflen);
if (error)
return fz_rethrow(error, "cannot parse inline image dictionary");
/* read whitespace after ID keyword */
- ch = fz_readbyte(file);
+ ch = fz_read_byte(file);
if (ch == '\r')
- if (fz_peekbyte(file) == '\n')
- fz_readbyte(file);
+ if (fz_peek_byte(file) == '\n')
+ fz_read_byte(file);
- error = pdf_runinlineimage(csi, rdb, file, obj);
- fz_dropobj(obj);
+ error = pdf_run_inline_image(csi, rdb, file, obj);
+ fz_drop_obj(obj);
if (error)
return fz_rethrow(error, "cannot parse inline image");
@@ -466,7 +466,7 @@ static fz_error pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file)
static void pdf_run_B(pdf_csi *csi)
{
- pdf_showpath(csi, 0, 1, 1, 0);
+ pdf_show_path(csi, 0, 1, 1, 0);
}
static void pdf_run_BMC(pdf_csi *csi)
@@ -475,7 +475,7 @@ static void pdf_run_BMC(pdf_csi *csi)
static void pdf_run_BT(pdf_csi *csi)
{
- csi->intext = 1;
+ csi->in_text = 1;
csi->tm = fz_identity;
csi->tlm = fz_identity;
}
@@ -487,7 +487,7 @@ static void pdf_run_BX(pdf_csi *csi)
static void pdf_run_Bstar(pdf_csi *csi)
{
- pdf_showpath(csi, 0, 1, 1, 1);
+ pdf_show_path(csi, 0, 1, 1, 1);
}
static fz_error pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
@@ -498,32 +498,32 @@ static fz_error pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
if (!strcmp(csi->name, "Pattern"))
{
- pdf_setpattern(csi, what, nil, nil);
+ pdf_set_pattern(csi, what, NULL, NULL);
}
else
{
if (!strcmp(csi->name, "DeviceGray"))
- colorspace = fz_keepcolorspace(fz_devicegray);
+ colorspace = fz_keep_colorspace(fz_device_gray);
else if (!strcmp(csi->name, "DeviceRGB"))
- colorspace = fz_keepcolorspace(fz_devicergb);
+ colorspace = fz_keep_colorspace(fz_device_rgb);
else if (!strcmp(csi->name, "DeviceCMYK"))
- colorspace = fz_keepcolorspace(fz_devicecmyk);
+ colorspace = fz_keep_colorspace(fz_device_cmyk);
else
{
- dict = fz_dictgets(rdb, "ColorSpace");
+ dict = fz_dict_gets(rdb, "ColorSpace");
if (!dict)
return fz_throw("cannot find ColorSpace dictionary");
- obj = fz_dictgets(dict, csi->name);
+ obj = fz_dict_gets(dict, csi->name);
if (!obj)
return fz_throw("cannot find colorspace resource '%s'", csi->name);
- error = pdf_loadcolorspace(&colorspace, csi->xref, obj);
+ error = pdf_load_colorspace(&colorspace, csi->xref, obj);
if (error)
- return fz_rethrow(error, "cannot load colorspace (%d 0 R)", fz_tonum(obj));
+ return fz_rethrow(error, "cannot load colorspace (%d 0 R)", fz_to_num(obj));
}
- pdf_setcolorspace(csi, what, colorspace);
+ pdf_set_colorspace(csi, what, colorspace);
- fz_dropcolorspace(colorspace);
+ fz_drop_colorspace(colorspace);
}
return fz_okay;
}
@@ -531,7 +531,7 @@ static fz_error pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
static void pdf_run_CS(pdf_csi *csi, fz_obj *rdb)
{
fz_error error;
- error = pdf_run_cs_imp(csi, rdb, PDF_MSTROKE);
+ error = pdf_run_cs_imp(csi, rdb, PDF_STROKE);
if (error)
fz_catch(error, "cannot set colorspace");
}
@@ -539,7 +539,7 @@ static void pdf_run_CS(pdf_csi *csi, fz_obj *rdb)
static void pdf_run_cs(pdf_csi *csi, fz_obj *rdb)
{
fz_error error;
- error = pdf_run_cs_imp(csi, rdb, PDF_MFILL);
+ error = pdf_run_cs_imp(csi, rdb, PDF_FILL);
if (error)
fz_catch(error, "cannot set colorspace");
}
@@ -555,64 +555,64 @@ static fz_error pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
fz_obj *subtype;
fz_error error;
- dict = fz_dictgets(rdb, "XObject");
+ dict = fz_dict_gets(rdb, "XObject");
if (!dict)
return fz_throw("cannot find XObject dictionary when looking for: '%s'", csi->name);
- obj = fz_dictgets(dict, csi->name);
+ obj = fz_dict_gets(dict, csi->name);
if (!obj)
return fz_throw("cannot find xobject resource: '%s'", csi->name);
- subtype = fz_dictgets(obj, "Subtype");
- if (!fz_isname(subtype))
+ subtype = fz_dict_gets(obj, "Subtype");
+ if (!fz_is_name(subtype))
return fz_throw("no XObject subtype specified");
- if (pdf_ishiddenocg(csi, obj))
+ if (pdf_is_hidden_ocg(csi, obj))
return fz_okay;
- if (!strcmp(fz_toname(subtype), "Form") && fz_dictgets(obj, "Subtype2"))
- subtype = fz_dictgets(obj, "Subtype2");
+ if (!strcmp(fz_to_name(subtype), "Form") && fz_dict_gets(obj, "Subtype2"))
+ subtype = fz_dict_gets(obj, "Subtype2");
- if (!strcmp(fz_toname(subtype), "Form"))
+ if (!strcmp(fz_to_name(subtype), "Form"))
{
pdf_xobject *xobj;
- error = pdf_loadxobject(&xobj, csi->xref, obj);
+ error = pdf_load_xobject(&xobj, csi->xref, obj);
if (error)
- return fz_rethrow(error, "cannot load xobject (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ return fz_rethrow(error, "cannot load xobject (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
/* Inherit parent resources, in case this one was empty XXX check where it's loaded */
if (!xobj->resources)
- xobj->resources = fz_keepobj(rdb);
+ xobj->resources = fz_keep_obj(rdb);
- error = pdf_runxobject(csi, xobj->resources, xobj, fz_identity);
+ error = pdf_run_xobject(csi, xobj->resources, xobj, fz_identity);
if (error)
- return fz_rethrow(error, "cannot draw xobject (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ return fz_rethrow(error, "cannot draw xobject (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
- pdf_dropxobject(xobj);
+ pdf_drop_xobject(xobj);
}
- else if (!strcmp(fz_toname(subtype), "Image"))
+ else if (!strcmp(fz_to_name(subtype), "Image"))
{
- if ((csi->dev->hints & FZ_IGNOREIMAGE) == 0)
+ if ((csi->dev->hints & FZ_IGNORE_IMAGE) == 0)
{
fz_pixmap *img;
- error = pdf_loadimage(&img, csi->xref, obj);
+ error = pdf_load_image(&img, csi->xref, obj);
if (error)
- return fz_rethrow(error, "cannot load image (%d %d R)", fz_tonum(obj), fz_togen(obj));
- pdf_showimage(csi, img);
- fz_droppixmap(img);
+ return fz_rethrow(error, "cannot load image (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ pdf_show_image(csi, img);
+ fz_drop_pixmap(img);
}
}
- else if (!strcmp(fz_toname(subtype), "PS"))
+ else if (!strcmp(fz_to_name(subtype), "PS"))
{
fz_warn("ignoring XObject with subtype PS");
}
else
{
- return fz_throw("unknown XObject subtype: '%s'", fz_toname(subtype));
+ return fz_throw("unknown XObject subtype: '%s'", fz_to_name(subtype));
}
return fz_okay;
@@ -624,9 +624,9 @@ static void pdf_run_EMC(pdf_csi *csi)
static void pdf_run_ET(pdf_csi *csi)
{
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
csi->accumulate = 1;
- csi->intext = 0;
+ csi->in_text = 0;
}
static void pdf_run_EX(pdf_csi *csi)
@@ -636,31 +636,31 @@ static void pdf_run_EX(pdf_csi *csi)
static void pdf_run_F(pdf_csi *csi)
{
- pdf_showpath(csi, 0, 1, 0, 0);
+ pdf_show_path(csi, 0, 1, 0, 0);
}
static void pdf_run_G(pdf_csi *csi)
{
- pdf_setcolorspace(csi, PDF_MSTROKE, fz_devicegray);
- pdf_setcolor(csi, PDF_MSTROKE, csi->stack);
+ pdf_set_colorspace(csi, PDF_STROKE, fz_device_gray);
+ pdf_set_color(csi, PDF_STROKE, csi->stack);
}
static void pdf_run_J(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- gstate->strokestate.linecap = csi->stack[0];
+ gstate->stroke_state.linecap = csi->stack[0];
}
static void pdf_run_K(pdf_csi *csi)
{
- pdf_setcolorspace(csi, PDF_MSTROKE, fz_devicecmyk);
- pdf_setcolor(csi, PDF_MSTROKE, csi->stack);
+ pdf_set_colorspace(csi, PDF_STROKE, fz_device_cmyk);
+ pdf_set_color(csi, PDF_STROKE, csi->stack);
}
static void pdf_run_M(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- gstate->strokestate.miterlimit = csi->stack[0];
+ gstate->stroke_state.miterlimit = csi->stack[0];
}
static void pdf_run_MP(pdf_csi *csi)
@@ -674,13 +674,13 @@ static void pdf_run_Q(pdf_csi *csi)
static void pdf_run_RG(pdf_csi *csi)
{
- pdf_setcolorspace(csi, PDF_MSTROKE, fz_devicergb);
- pdf_setcolor(csi, PDF_MSTROKE, csi->stack);
+ pdf_set_colorspace(csi, PDF_STROKE, fz_device_rgb);
+ pdf_set_color(csi, PDF_STROKE, csi->stack);
}
static void pdf_run_S(pdf_csi *csi)
{
- pdf_showpath(csi, 0, 0, 1, 0);
+ pdf_show_path(csi, 0, 0, 1, 0);
}
static fz_error pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *mat)
@@ -693,53 +693,53 @@ static fz_error pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material
kind = mat->kind;
if (csi->name[0])
- kind = PDF_MPATTERN;
+ kind = PDF_MAT_PATTERN;
switch (kind)
{
- case PDF_MNONE:
+ case PDF_MAT_NONE:
return fz_throw("cannot set color in mask objects");
- case PDF_MCOLOR:
- pdf_setcolor(csi, what, csi->stack);
+ case PDF_MAT_COLOR:
+ pdf_set_color(csi, what, csi->stack);
break;
- case PDF_MPATTERN:
- dict = fz_dictgets(rdb, "Pattern");
+ case PDF_MAT_PATTERN:
+ dict = fz_dict_gets(rdb, "Pattern");
if (!dict)
return fz_throw("cannot find Pattern dictionary");
- obj = fz_dictgets(dict, csi->name);
+ obj = fz_dict_gets(dict, csi->name);
if (!obj)
return fz_throw("cannot find pattern resource '%s'", csi->name);
- patterntype = fz_dictgets(obj, "PatternType");
+ patterntype = fz_dict_gets(obj, "PatternType");
- if (fz_toint(patterntype) == 1)
+ if (fz_to_int(patterntype) == 1)
{
pdf_pattern *pat;
- error = pdf_loadpattern(&pat, csi->xref, obj);
+ error = pdf_load_pattern(&pat, csi->xref, obj);
if (error)
- return fz_rethrow(error, "cannot load pattern (%d 0 R)", fz_tonum(obj));
- pdf_setpattern(csi, what, pat, csi->top > 0 ? csi->stack : nil);
- pdf_droppattern(pat);
+ return fz_rethrow(error, "cannot load pattern (%d 0 R)", fz_to_num(obj));
+ pdf_set_pattern(csi, what, pat, csi->top > 0 ? csi->stack : NULL);
+ pdf_drop_pattern(pat);
}
- else if (fz_toint(patterntype) == 2)
+ else if (fz_to_int(patterntype) == 2)
{
fz_shade *shd;
- error = pdf_loadshading(&shd, csi->xref, obj);
+ error = pdf_load_shading(&shd, csi->xref, obj);
if (error)
- return fz_rethrow(error, "cannot load shading (%d 0 R)", fz_tonum(obj));
- pdf_setshade(csi, what, shd);
- fz_dropshade(shd);
+ return fz_rethrow(error, "cannot load shading (%d 0 R)", fz_to_num(obj));
+ pdf_set_shade(csi, what, shd);
+ fz_drop_shade(shd);
}
else
{
- return fz_throw("unknown pattern type: %d", fz_toint(patterntype));
+ return fz_throw("unknown pattern type: %d", fz_to_int(patterntype));
}
break;
- case PDF_MSHADE:
+ case PDF_MAT_SHADE:
return fz_throw("cannot set color in shade objects");
}
@@ -750,7 +750,7 @@ static void pdf_run_SC(pdf_csi *csi, fz_obj *rdb)
{
fz_error error;
pdf_gstate *gstate = csi->gstate + csi->gtop;
- error = pdf_run_SC_imp(csi, rdb, PDF_MSTROKE, &gstate->stroke);
+ error = pdf_run_SC_imp(csi, rdb, PDF_STROKE, &gstate->stroke);
if (error)
fz_catch(error, "cannot set color and colorspace");
}
@@ -759,7 +759,7 @@ static void pdf_run_sc(pdf_csi *csi, fz_obj *rdb)
{
fz_error error;
pdf_gstate *gstate = csi->gstate + csi->gtop;
- error = pdf_run_SC_imp(csi, rdb, PDF_MFILL, &gstate->fill);
+ error = pdf_run_SC_imp(csi, rdb, PDF_FILL, &gstate->fill);
if (error)
fz_catch(error, "cannot set color and colorspace");
}
@@ -767,20 +767,20 @@ static void pdf_run_sc(pdf_csi *csi, fz_obj *rdb)
static void pdf_run_Tc(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- gstate->charspace = csi->stack[0];
+ gstate->char_space = csi->stack[0];
}
static void pdf_run_Tw(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- gstate->wordspace = csi->stack[0];
+ gstate->word_space = csi->stack[0];
}
static void pdf_run_Tz(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
float a = csi->stack[0] / 100;
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
gstate->scale = a;
}
@@ -799,20 +799,20 @@ static fz_error pdf_run_Tf(pdf_csi *csi, fz_obj *rdb)
gstate->size = csi->stack[0];
if (gstate->font)
- pdf_dropfont(gstate->font);
- gstate->font = nil;
+ pdf_drop_font(gstate->font);
+ gstate->font = NULL;
- dict = fz_dictgets(rdb, "Font");
+ dict = fz_dict_gets(rdb, "Font");
if (!dict)
return fz_throw("cannot find Font dictionary");
- obj = fz_dictgets(dict, csi->name);
+ obj = fz_dict_gets(dict, csi->name);
if (!obj)
return fz_throw("cannot find font resource: '%s'", csi->name);
- error = pdf_loadfont(&gstate->font, csi->xref, rdb, obj);
+ error = pdf_load_font(&gstate->font, csi->xref, rdb, obj);
if (error)
- return fz_rethrow(error, "cannot load font (%d 0 R)", fz_tonum(obj));
+ return fz_rethrow(error, "cannot load font (%d 0 R)", fz_to_num(obj));
return fz_okay;
}
@@ -849,7 +849,7 @@ static void pdf_run_TD(pdf_csi *csi)
static void pdf_run_Tm(pdf_csi *csi)
{
- pdf_flushtext(csi);
+ pdf_flush_text(csi);
csi->tm.a = csi->stack[0];
csi->tm.b = csi->stack[1];
csi->tm.c = csi->stack[2];
@@ -869,40 +869,40 @@ static void pdf_run_Tstar(pdf_csi *csi)
static void pdf_run_Tj(pdf_csi *csi)
{
- if (csi->stringlen)
- pdf_showstring(csi, csi->string, csi->stringlen);
+ if (csi->string_len)
+ pdf_show_string(csi, csi->string, csi->string_len);
else
- pdf_showtext(csi, csi->obj);
+ pdf_show_text(csi, csi->obj);
}
static void pdf_run_TJ(pdf_csi *csi)
{
- if (csi->stringlen)
- pdf_showstring(csi, csi->string, csi->stringlen);
+ if (csi->string_len)
+ pdf_show_string(csi, csi->string, csi->string_len);
else
- pdf_showtext(csi, csi->obj);
+ pdf_show_text(csi, csi->obj);
}
static void pdf_run_W(pdf_csi *csi)
{
csi->clip = 1;
- csi->clipevenodd = 0;
+ csi->clip_even_odd = 0;
}
static void pdf_run_Wstar(pdf_csi *csi)
{
csi->clip = 1;
- csi->clipevenodd = 1;
+ csi->clip_even_odd = 1;
}
static void pdf_run_b(pdf_csi *csi)
{
- pdf_showpath(csi, 1, 1, 1, 0);
+ pdf_show_path(csi, 1, 1, 1, 0);
}
static void pdf_run_bstar(pdf_csi *csi)
{
- pdf_showpath(csi, 1, 1, 1, 1);
+ pdf_show_path(csi, 1, 1, 1, 1);
}
static void pdf_run_c(pdf_csi *csi)
@@ -939,10 +939,10 @@ static void pdf_run_d(pdf_csi *csi)
int i;
array = csi->obj;
- gstate->strokestate.dashlen = MIN(fz_arraylen(array), nelem(gstate->strokestate.dashlist));
- for (i = 0; i < gstate->strokestate.dashlen; i++)
- gstate->strokestate.dashlist[i] = fz_toreal(fz_arrayget(array, i));
- gstate->strokestate.dashphase = csi->stack[0];
+ gstate->stroke_state.dash_len = MIN(fz_array_len(array), nelem(gstate->stroke_state.dash_list));
+ for (i = 0; i < gstate->stroke_state.dash_len; i++)
+ gstate->stroke_state.dash_list[i] = fz_to_real(fz_array_get(array, i));
+ gstate->stroke_state.dash_phase = csi->stack[0];
}
static void pdf_run_d0(pdf_csi *csi)
@@ -955,18 +955,18 @@ static void pdf_run_d1(pdf_csi *csi)
static void pdf_run_f(pdf_csi *csi)
{
- pdf_showpath(csi, 0, 1, 0, 0);
+ pdf_show_path(csi, 0, 1, 0, 0);
}
static void pdf_run_fstar(pdf_csi *csi)
{
- pdf_showpath(csi, 0, 1, 0, 1);
+ pdf_show_path(csi, 0, 1, 0, 1);
}
static void pdf_run_g(pdf_csi *csi)
{
- pdf_setcolorspace(csi, PDF_MFILL, fz_devicegray);
- pdf_setcolor(csi, PDF_MFILL, csi->stack);
+ pdf_set_colorspace(csi, PDF_FILL, fz_device_gray);
+ pdf_set_color(csi, PDF_FILL, csi->stack);
}
static fz_error pdf_run_gs(pdf_csi *csi, fz_obj *rdb)
@@ -975,17 +975,17 @@ static fz_error pdf_run_gs(pdf_csi *csi, fz_obj *rdb)
fz_obj *dict;
fz_obj *obj;
- dict = fz_dictgets(rdb, "ExtGState");
+ dict = fz_dict_gets(rdb, "ExtGState");
if (!dict)
return fz_throw("cannot find ExtGState dictionary");
- obj = fz_dictgets(dict, csi->name);
+ obj = fz_dict_gets(dict, csi->name);
if (!obj)
return fz_throw("cannot find extgstate resource '%s'", csi->name);
- error = pdf_runextgstate(csi, rdb, obj);
+ error = pdf_run_extgstate(csi, rdb, obj);
if (error)
- return fz_rethrow(error, "cannot set ExtGState (%d 0 R)", fz_tonum(obj));
+ return fz_rethrow(error, "cannot set ExtGState (%d 0 R)", fz_to_num(obj));
return fz_okay;
}
@@ -1001,13 +1001,13 @@ static void pdf_run_i(pdf_csi *csi)
static void pdf_run_j(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- gstate->strokestate.linejoin = csi->stack[0];
+ gstate->stroke_state.linejoin = csi->stack[0];
}
static void pdf_run_k(pdf_csi *csi)
{
- pdf_setcolorspace(csi, PDF_MFILL, fz_devicecmyk);
- pdf_setcolor(csi, PDF_MFILL, csi->stack);
+ pdf_set_colorspace(csi, PDF_FILL, fz_device_cmyk);
+ pdf_set_color(csi, PDF_FILL, csi->stack);
}
static void pdf_run_l(pdf_csi *csi)
@@ -1028,7 +1028,7 @@ static void pdf_run_m(pdf_csi *csi)
static void pdf_run_n(pdf_csi *csi)
{
- pdf_showpath(csi, 0, 0, 0, csi->clipevenodd);
+ pdf_show_path(csi, 0, 0, 0, csi->clip_even_odd);
}
static void pdf_run_q(pdf_csi *csi)
@@ -1054,17 +1054,17 @@ static void pdf_run_re(pdf_csi *csi)
static void pdf_run_rg(pdf_csi *csi)
{
- pdf_setcolorspace(csi, PDF_MFILL, fz_devicergb);
- pdf_setcolor(csi, PDF_MFILL, csi->stack);
+ pdf_set_colorspace(csi, PDF_FILL, fz_device_rgb);
+ pdf_set_color(csi, PDF_FILL, csi->stack);
}
static void pdf_run_ri(pdf_csi *csi)
{
}
-static void pdf_run_s(pdf_csi *csi)
+static void pdf_run(pdf_csi *csi)
{
- pdf_showpath(csi, 1, 0, 1, 0);
+ pdf_show_path(csi, 1, 0, 1, 0);
}
static fz_error pdf_run_sh(pdf_csi *csi, fz_obj *rdb)
@@ -1074,21 +1074,21 @@ static fz_error pdf_run_sh(pdf_csi *csi, fz_obj *rdb)
fz_shade *shd;
fz_error error;
- dict = fz_dictgets(rdb, "Shading");
+ dict = fz_dict_gets(rdb, "Shading");
if (!dict)
return fz_throw("cannot find shading dictionary");
- obj = fz_dictgets(dict, csi->name);
+ obj = fz_dict_gets(dict, csi->name);
if (!obj)
return fz_throw("cannot find shading resource: '%s'", csi->name);
- if ((csi->dev->hints & FZ_IGNORESHADE) == 0)
+ if ((csi->dev->hints & FZ_IGNORE_SHADE) == 0)
{
- error = pdf_loadshading(&shd, csi->xref, obj);
+ error = pdf_load_shading(&shd, csi->xref, obj);
if (error)
- return fz_rethrow(error, "cannot load shading (%d %d R)", fz_tonum(obj), fz_togen(obj));
- pdf_showshade(csi, shd);
- fz_dropshade(shd);
+ return fz_rethrow(error, "cannot load shading (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ pdf_show_shade(csi, shd);
+ fz_drop_shade(shd);
}
return fz_okay;
}
@@ -1106,7 +1106,7 @@ static void pdf_run_v(pdf_csi *csi)
static void pdf_run_w(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- gstate->strokestate.linewidth = csi->stack[0];
+ gstate->stroke_state.linewidth = csi->stack[0];
}
static void pdf_run_y(pdf_csi *csi)
@@ -1128,10 +1128,10 @@ static void pdf_run_squote(pdf_csi *csi)
csi->tlm = fz_concat(m, csi->tlm);
csi->tm = csi->tlm;
- if (csi->stringlen)
- pdf_showstring(csi, csi->string, csi->stringlen);
+ if (csi->string_len)
+ pdf_show_string(csi, csi->string, csi->string_len);
else
- pdf_showtext(csi, csi->obj);
+ pdf_show_text(csi, csi->obj);
}
static void pdf_run_dquote(pdf_csi *csi)
@@ -1139,17 +1139,17 @@ static void pdf_run_dquote(pdf_csi *csi)
fz_matrix m;
pdf_gstate *gstate = csi->gstate + csi->gtop;
- gstate->wordspace = csi->stack[0];
- gstate->charspace = csi->stack[1];
+ gstate->word_space = csi->stack[0];
+ gstate->char_space = csi->stack[1];
m = fz_translate(0, -gstate->leading);
csi->tlm = fz_concat(m, csi->tlm);
csi->tm = csi->tlm;
- if (csi->stringlen)
- pdf_showstring(csi, csi->string, csi->stringlen);
+ if (csi->string_len)
+ pdf_show_string(csi, csi->string, csi->string_len);
else
- pdf_showtext(csi, csi->obj);
+ pdf_show_text(csi, csi->obj);
}
#define A(a) (a)
@@ -1157,7 +1157,7 @@ static void pdf_run_dquote(pdf_csi *csi)
#define C(a,b,c) (a | b << 8 | c << 16)
static fz_error
-pdf_runkeyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
+pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
{
fz_error error;
int key;
@@ -1256,7 +1256,7 @@ pdf_runkeyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
case B('r','e'): pdf_run_re(csi); break;
case B('r','g'): pdf_run_rg(csi); break;
case B('r','i'): pdf_run_ri(csi); break;
- case A('s'): pdf_run_s(csi); break;
+ case A('s'): pdf_run(csi); break;
case B('s','c'): pdf_run_sc(csi, rdb); break;
case C('s','c','n'): pdf_run_sc(csi, rdb); break;
case B('s','h'):
@@ -1277,13 +1277,13 @@ pdf_runkeyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
}
static fz_error
-pdf_runcsifile(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen)
+pdf_run_csi_file(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen)
{
fz_error error;
int tok;
int len;
- pdf_clearstack(csi);
+ pdf_clear_stack(csi);
while (1)
{
@@ -1294,29 +1294,29 @@ pdf_runcsifile(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen
if (error)
return fz_rethrow(error, "lexical error in content stream");
- if (csi->inarray)
+ if (csi->in_array)
{
- if (tok == PDF_TCARRAY)
+ if (tok == PDF_TOK_CLOSE_ARRAY)
{
- csi->inarray = 0;
+ csi->in_array = 0;
}
- else if (tok == PDF_TINT || tok == PDF_TREAL)
+ else if (tok == PDF_TOK_INT || tok == PDF_TOK_REAL)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- pdf_showspace(csi, -atof(buf) * gstate->size * 0.001f);
+ pdf_show_space(csi, -atof(buf) * gstate->size * 0.001f);
}
- else if (tok == PDF_TSTRING)
+ else if (tok == PDF_TOK_STRING)
{
- pdf_showstring(csi, (unsigned char *)buf, len);
+ pdf_show_string(csi, (unsigned char *)buf, len);
}
- else if (tok == PDF_TKEYWORD)
+ else if (tok == PDF_TOK_KEYWORD)
{
if (!strcmp(buf, "Tw") || !strcmp(buf, "Tc"))
fz_warn("ignoring keyword '%s' inside array", buf);
else
return fz_throw("syntax error in array");
}
- else if (tok == PDF_TEOF)
+ else if (tok == PDF_TOK_EOF)
return fz_okay;
else
return fz_throw("syntax error in array");
@@ -1324,60 +1324,60 @@ pdf_runcsifile(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen
else switch (tok)
{
- case PDF_TENDSTREAM:
- case PDF_TEOF:
+ case PDF_TOK_ENDSTREAM:
+ case PDF_TOK_EOF:
return fz_okay;
- case PDF_TOARRAY:
- if (!csi->intext)
+ case PDF_TOK_OPEN_ARRAY:
+ if (!csi->in_text)
{
- error = pdf_parsearray(&csi->obj, csi->xref, file, buf, buflen);
+ error = pdf_parse_array(&csi->obj, csi->xref, file, buf, buflen);
if (error)
return fz_rethrow(error, "cannot parse array");
}
else
{
- csi->inarray = 1;
+ csi->in_array = 1;
}
break;
- case PDF_TODICT:
- error = pdf_parsedict(&csi->obj, csi->xref, file, buf, buflen);
+ case PDF_TOK_OPEN_DICT:
+ error = pdf_parse_dict(&csi->obj, csi->xref, file, buf, buflen);
if (error)
return fz_rethrow(error, "cannot parse dictionary");
break;
- case PDF_TNAME:
+ case PDF_TOK_NAME:
fz_strlcpy(csi->name, buf, sizeof(csi->name));
break;
- case PDF_TINT:
+ case PDF_TOK_INT:
csi->stack[csi->top] = atoi(buf);
csi->top ++;
break;
- case PDF_TREAL:
+ case PDF_TOK_REAL:
csi->stack[csi->top] = atof(buf);
csi->top ++;
break;
- case PDF_TSTRING:
+ case PDF_TOK_STRING:
if (len <= sizeof(csi->string))
{
memcpy(csi->string, buf, len);
- csi->stringlen = len;
+ csi->string_len = len;
}
else
{
- csi->obj = fz_newstring(buf, len);
+ csi->obj = fz_new_string(buf, len);
}
break;
- case PDF_TKEYWORD:
- error = pdf_runkeyword(csi, rdb, file, buf);
+ case PDF_TOK_KEYWORD:
+ error = pdf_run_keyword(csi, rdb, file, buf);
if (error)
return fz_rethrow(error, "cannot run keyword");
- pdf_clearstack(csi);
+ pdf_clear_stack(csi);
break;
default:
@@ -1387,12 +1387,12 @@ pdf_runcsifile(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen
}
fz_error
-pdf_runcsibuffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents)
+pdf_run_csi_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents)
{
fz_stream *file;
fz_error error;
- file = fz_openbuffer(contents);
- error = pdf_runcsifile(csi, rdb, file, csi->xref->scratch, sizeof csi->xref->scratch);
+ file = fz_open_buffer(contents);
+ error = pdf_run_csi_file(csi, rdb, file, csi->xref->scratch, sizeof csi->xref->scratch);
fz_close(file);
if (error)
return fz_rethrow(error, "cannot parse content stream");
@@ -1400,7 +1400,7 @@ pdf_runcsibuffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents)
}
fz_error
-pdf_runpagewithtarget(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *target)
+pdf_run_page_with_usage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *target)
{
pdf_csi *csi;
fz_error error;
@@ -1408,19 +1408,19 @@ pdf_runpagewithtarget(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix
int flags;
if (page->transparency)
- dev->begingroup(dev->user,
- fz_transformrect(ctm, page->mediabox),
- 0, 0, FZ_BNORMAL, 1);
+ dev->begin_group(dev->user,
+ fz_transform_rect(ctm, page->mediabox),
+ 0, 0, FZ_BLEND_NORMAL, 1);
- csi = pdf_newcsi(xref, dev, ctm, target);
- error = pdf_runcsibuffer(csi, page->resources, page->contents);
- pdf_freecsi(csi);
+ csi = pdf_new_csi(xref, dev, ctm, target);
+ error = pdf_run_csi_buffer(csi, page->resources, page->contents);
+ pdf_free_csi(csi);
if (error)
return fz_rethrow(error, "cannot parse page content stream");
for (annot = page->annots; annot; annot = annot->next)
{
- flags = fz_toint(fz_dictgets(annot->obj, "F"));
+ flags = fz_to_int(fz_dict_gets(annot->obj, "F"));
/* TODO: NoZoom and NoRotate */
if (flags & (1 << 0)) /* Invisible */
@@ -1430,34 +1430,34 @@ pdf_runpagewithtarget(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix
if (flags & (1 << 5)) /* NoView */
continue;
- if (pdf_ishiddenocg(csi, annot->obj))
+ if (pdf_is_hidden_ocg(csi, annot->obj))
continue;
- csi = pdf_newcsi(xref, dev, ctm, target);
- error = pdf_runxobject(csi, page->resources, annot->ap, annot->matrix);
- pdf_freecsi(csi);
+ csi = pdf_new_csi(xref, dev, ctm, target);
+ error = pdf_run_xobject(csi, page->resources, annot->ap, annot->matrix);
+ pdf_free_csi(csi);
if (error)
return fz_rethrow(error, "cannot parse annotation appearance stream");
}
if (page->transparency)
- dev->endgroup(dev->user);
+ dev->end_group(dev->user);
return fz_okay;
}
fz_error
-pdf_runpage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm)
+pdf_run_page(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm)
{
- return pdf_runpagewithtarget(xref, page, dev, ctm, "View");
+ return pdf_run_page_with_usage(xref, page, dev, ctm, "View");
}
fz_error
-pdf_runglyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm)
+pdf_run_glyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm)
{
- pdf_csi *csi = pdf_newcsi(xref, dev, ctm, "View");
- fz_error error = pdf_runcsibuffer(csi, resources, contents);
- pdf_freecsi(csi);
+ pdf_csi *csi = pdf_new_csi(xref, dev, ctm, "View");
+ fz_error error = pdf_run_csi_buffer(csi, resources, contents);
+ pdf_free_csi(csi);
if (error)
return fz_rethrow(error, "cannot parse glyph content stream");
return fz_okay;
diff --git a/pdf/pdf_lex.c b/pdf/pdf_lex.c
index 6b2f26e4..bb0e6e32 100644
--- a/pdf/pdf_lex.c
+++ b/pdf/pdf_lex.c
@@ -1,17 +1,17 @@
#include "fitz.h"
#include "mupdf.h"
-#define ISNUMBER \
+#define IS_NUMBER \
'+':case'-':case'.':case'0':case'1':case'2':case'3':\
case'4':case'5':case'6':case'7':case'8':case'9'
-#define ISWHITE \
+#define IS_WHITE \
'\000':case'\011':case'\012':case'\014':case'\015':case'\040'
-#define ISHEX \
+#define IS_HEX \
'0':case'1':case'2':case'3':case'4':case'5':case'6':\
case'7':case'8':case'9':case'A':case'B':case'C':\
case'D':case'E':case'F':case'a':case'b':case'c':\
case'd':case'e':case'f'
-#define ISDELIM \
+#define IS_DELIM \
'(':case')':case'<':case'>':case'[':case']':case'{':\
case'}':case'/':case'%'
@@ -36,7 +36,7 @@ iswhite(int ch)
}
static inline int
-fromhex(int ch)
+from_hex(int ch)
{
if (ch >= '0' && ch <= '9')
return ch - '0';
@@ -48,43 +48,43 @@ fromhex(int ch)
}
static inline void
-lexwhite(fz_stream *f)
+lex_white(fz_stream *f)
{
int c;
do
{
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
}
while ((c <= 32) && (iswhite(c)));
if (c != EOF)
- fz_unreadbyte(f);
+ fz_unread_byte(f);
}
static inline void
-lexcomment(fz_stream *f)
+lex_comment(fz_stream *f)
{
int c;
do
{
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
}
while ((c != '\012') && (c != '\015') && (c != EOF));
}
static int
-lexnumber(fz_stream *f, char *s, int n, int *tok)
+lex_number(fz_stream *f, char *s, int n, int *tok)
{
char *buf = s;
- *tok = PDF_TINT;
+ *tok = PDF_TOK_INT;
/* Initially we might have +, -, . or a digit */
if (n > 1)
{
- int c = fz_readbyte(f);
+ int c = fz_read_byte(f);
switch (c)
{
case '.':
- *tok = PDF_TREAL;
+ *tok = PDF_TOK_REAL;
*s++ = c;
n--;
goto loop_after_dot;
@@ -95,7 +95,7 @@ lexnumber(fz_stream *f, char *s, int n, int *tok)
n--;
goto loop_after_sign;
default:
- fz_unreadbyte(f);
+ fz_unread_byte(f);
goto end;
case EOF:
goto end;
@@ -106,11 +106,11 @@ lexnumber(fz_stream *f, char *s, int n, int *tok)
loop_after_sign:
while (n > 1)
{
- int c = fz_readbyte(f);
+ int c = fz_read_byte(f);
switch (c)
{
case '.':
- *tok = PDF_TREAL;
+ *tok = PDF_TOK_REAL;
*s++ = c;
n--;
goto loop_after_dot;
@@ -118,7 +118,7 @@ loop_after_sign:
*s++ = c;
break;
default:
- fz_unreadbyte(f);
+ fz_unread_byte(f);
goto end;
case EOF:
goto end;
@@ -130,14 +130,14 @@ loop_after_sign:
loop_after_dot:
while (n > 1)
{
- int c = fz_readbyte(f);
+ int c = fz_read_byte(f);
switch (c)
{
case RANGE_0_9:
*s++ = c;
break;
default:
- fz_unreadbyte(f);
+ fz_unread_byte(f);
goto end;
case EOF:
goto end;
@@ -151,23 +151,23 @@ end:
}
static void
-lexname(fz_stream *f, char *s, int n)
+lex_name(fz_stream *f, char *s, int n)
{
while (n > 1)
{
- int c = fz_readbyte(f);
+ int c = fz_read_byte(f);
switch (c)
{
- case ISWHITE:
- case ISDELIM:
- fz_unreadbyte(f);
+ case IS_WHITE:
+ case IS_DELIM:
+ fz_unread_byte(f);
goto end;
case EOF:
goto end;
case '#':
{
int d;
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
switch (c)
{
case RANGE_0_9:
@@ -180,12 +180,12 @@ lexname(fz_stream *f, char *s, int n)
d = (c - 'A' + 10) << 4;
break;
default:
- fz_unreadbyte(f);
+ fz_unread_byte(f);
/* fallthrough */
case EOF:
goto end;
}
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
switch (c)
{
case RANGE_0_9:
@@ -198,7 +198,7 @@ lexname(fz_stream *f, char *s, int n)
c -= 'A' - 10;
break;
default:
- fz_unreadbyte(f);
+ fz_unread_byte(f);
/* fallthrough */
case EOF:
*s++ = d;
@@ -220,7 +220,7 @@ end:
}
static int
-lexstring(fz_stream *f, char *buf, int n)
+lex_string(fz_stream *f, char *buf, int n)
{
char *s = buf;
char *e = buf + n;
@@ -230,7 +230,7 @@ lexstring(fz_stream *f, char *buf, int n)
while (s < e)
{
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
switch (c)
{
case EOF:
@@ -246,7 +246,7 @@ lexstring(fz_stream *f, char *buf, int n)
*s++ = c;
break;
case '\\':
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
switch (c)
{
case EOF:
@@ -277,26 +277,26 @@ lexstring(fz_stream *f, char *buf, int n)
break;
case RANGE_0_9:
oct = c - '0';
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
if (c >= '0' && c <= '9')
{
oct = oct * 8 + (c - '0');
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
if (c >= '0' && c <= '9')
oct = oct * 8 + (c - '0');
else if (c != EOF)
- fz_unreadbyte(f);
+ fz_unread_byte(f);
}
else if (c != EOF)
- fz_unreadbyte(f);
+ fz_unread_byte(f);
*s++ = oct;
break;
case '\n':
break;
case '\r':
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
if ((c != '\n') && (c != EOF))
- fz_unreadbyte(f);
+ fz_unread_byte(f);
break;
default:
*s++ = c;
@@ -312,7 +312,7 @@ end:
}
static int
-lexhexstring(fz_stream *f, char *buf, int n)
+lex_hex_string(fz_stream *f, char *buf, int n)
{
char *s = buf;
char *e = buf + n;
@@ -321,20 +321,20 @@ lexhexstring(fz_stream *f, char *buf, int n)
while (s < e)
{
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
switch (c)
{
- case ISWHITE:
+ case IS_WHITE:
break;
- case ISHEX:
+ case IS_HEX:
if (x)
{
- *s++ = a * 16 + fromhex(c);
+ *s++ = a * 16 + from_hex(c);
x = !x;
}
else
{
- a = fromhex(c);
+ a = from_hex(c);
x = !x;
}
break;
@@ -348,42 +348,42 @@ end:
}
static int
-pdf_tokenfromkeyword(char *key)
+pdf_token_from_keyword(char *key)
{
switch (*key)
{
case 'R':
- if (!strcmp(key, "R")) return PDF_TR;
+ if (!strcmp(key, "R")) return PDF_TOK_R;
break;
case 't':
- if (!strcmp(key, "true")) return PDF_TTRUE;
- if (!strcmp(key, "trailer")) return PDF_TTRAILER;
+ if (!strcmp(key, "true")) return PDF_TOK_TRUE;
+ if (!strcmp(key, "trailer")) return PDF_TOK_TRAILER;
break;
case 'f':
- if (!strcmp(key, "false")) return PDF_TFALSE;
+ if (!strcmp(key, "false")) return PDF_TOK_FALSE;
break;
case 'n':
- if (!strcmp(key, "null")) return PDF_TNULL;
+ if (!strcmp(key, "null")) return PDF_TOK_NULL;
break;
case 'o':
- if (!strcmp(key, "obj")) return PDF_TOBJ;
+ if (!strcmp(key, "obj")) return PDF_TOK_OBJ;
break;
case 'e':
- if (!strcmp(key, "endobj")) return PDF_TENDOBJ;
- if (!strcmp(key, "endstream")) return PDF_TENDSTREAM;
+ if (!strcmp(key, "endobj")) return PDF_TOK_ENDOBJ;
+ if (!strcmp(key, "endstream")) return PDF_TOK_ENDSTREAM;
break;
case 's':
- if (!strcmp(key, "stream")) return PDF_TSTREAM;
- if (!strcmp(key, "startxref")) return PDF_TSTARTXREF;
+ if (!strcmp(key, "stream")) return PDF_TOK_STREAM;
+ if (!strcmp(key, "startxref")) return PDF_TOK_STARTXREF;
break;
case 'x':
- if (!strcmp(key, "xref")) return PDF_TXREF;
+ if (!strcmp(key, "xref")) return PDF_TOK_XREF;
break;
default:
break;
}
- return PDF_TKEYWORD;
+ return PDF_TOK_KEYWORD;
}
fz_error
@@ -391,78 +391,78 @@ pdf_lex(int *tok, fz_stream *f, char *buf, int n, int *sl)
{
while (1)
{
- int c = fz_readbyte(f);
+ int c = fz_read_byte(f);
switch (c)
{
case EOF:
- *tok = PDF_TEOF;
+ *tok = PDF_TOK_EOF;
return fz_okay;
- case ISWHITE:
- lexwhite(f);
+ case IS_WHITE:
+ lex_white(f);
break;
case '%':
- lexcomment(f);
+ lex_comment(f);
break;
case '/':
- lexname(f, buf, n);
+ lex_name(f, buf, n);
*sl = strlen(buf);
- *tok = PDF_TNAME;
+ *tok = PDF_TOK_NAME;
return fz_okay;
case '(':
- *sl = lexstring(f, buf, n);
- *tok = PDF_TSTRING;
+ *sl = lex_string(f, buf, n);
+ *tok = PDF_TOK_STRING;
return fz_okay;
case ')':
- *tok = PDF_TERROR;
+ *tok = PDF_TOK_ERROR;
goto cleanuperror;
case '<':
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
if (c == '<')
{
- *tok = PDF_TODICT;
+ *tok = PDF_TOK_OPEN_DICT;
}
else
{
- fz_unreadbyte(f);
- *sl = lexhexstring(f, buf, n);
- *tok = PDF_TSTRING;
+ fz_unread_byte(f);
+ *sl = lex_hex_string(f, buf, n);
+ *tok = PDF_TOK_STRING;
}
return fz_okay;
case '>':
- c = fz_readbyte(f);
+ c = fz_read_byte(f);
if (c == '>')
{
- *tok = PDF_TCDICT;
+ *tok = PDF_TOK_CLOSE_DICT;
return fz_okay;
}
- *tok = PDF_TERROR;
+ *tok = PDF_TOK_ERROR;
goto cleanuperror;
case '[':
- *tok = PDF_TOARRAY;
+ *tok = PDF_TOK_OPEN_ARRAY;
return fz_okay;
case ']':
- *tok = PDF_TCARRAY;
+ *tok = PDF_TOK_CLOSE_ARRAY;
return fz_okay;
case '{':
- *tok = PDF_TOBRACE;
+ *tok = PDF_TOK_OPEN_BRACE;
return fz_okay;
case '}':
- *tok = PDF_TCBRACE;
+ *tok = PDF_TOK_CLOSE_BRACE;
return fz_okay;
- case ISNUMBER:
- fz_unreadbyte(f);
- *sl = lexnumber(f, buf, n, tok);
+ case IS_NUMBER:
+ fz_unread_byte(f);
+ *sl = lex_number(f, buf, n, tok);
return fz_okay;
default: /* isregular: !isdelim && !iswhite && c != EOF */
- fz_unreadbyte(f);
- lexname(f, buf, n);
+ fz_unread_byte(f);
+ lex_name(f, buf, n);
*sl = strlen(buf);
- *tok = pdf_tokenfromkeyword(buf);
+ *tok = pdf_token_from_keyword(buf);
return fz_okay;
}
}
cleanuperror:
- *tok = PDF_TERROR;
+ *tok = PDF_TOK_ERROR;
return fz_throw("lexical error");
}
diff --git a/pdf/pdf_nametree.c b/pdf/pdf_nametree.c
index 6b2314cd..e2b3e160 100644
--- a/pdf/pdf_nametree.c
+++ b/pdf/pdf_nametree.c
@@ -2,44 +2,44 @@
#include "mupdf.h"
static fz_obj *
-pdf_lookupnameimp(fz_obj *node, fz_obj *needle)
+pdf_lookup_name_imp(fz_obj *node, fz_obj *needle)
{
- fz_obj *kids = fz_dictgets(node, "Kids");
- fz_obj *names = fz_dictgets(node, "Names");
+ fz_obj *kids = fz_dict_gets(node, "Kids");
+ fz_obj *names = fz_dict_gets(node, "Names");
- if (fz_isarray(kids))
+ if (fz_is_array(kids))
{
int l = 0;
- int r = fz_arraylen(kids) - 1;
+ int r = fz_array_len(kids) - 1;
while (l <= r)
{
int m = (l + r) >> 1;
- fz_obj *kid = fz_arrayget(kids, m);
- fz_obj *limits = fz_dictgets(kid, "Limits");
- fz_obj *first = fz_arrayget(limits, 0);
- fz_obj *last = fz_arrayget(limits, 1);
+ fz_obj *kid = fz_array_get(kids, m);
+ fz_obj *limits = fz_dict_gets(kid, "Limits");
+ fz_obj *first = fz_array_get(limits, 0);
+ fz_obj *last = fz_array_get(limits, 1);
if (fz_objcmp(needle, first) < 0)
r = m - 1;
else if (fz_objcmp(needle, last) > 0)
l = m + 1;
else
- return pdf_lookupnameimp(kid, needle);
+ return pdf_lookup_name_imp(kid, needle);
}
}
- if (fz_isarray(names))
+ if (fz_is_array(names))
{
int l = 0;
- int r = (fz_arraylen(names) / 2) - 1;
+ int r = (fz_array_len(names) / 2) - 1;
while (l <= r)
{
int m = (l + r) >> 1;
int c;
- fz_obj *key = fz_arrayget(names, m * 2);
- fz_obj *val = fz_arrayget(names, m * 2 + 1);
+ fz_obj *key = fz_array_get(names, m * 2);
+ fz_obj *val = fz_array_get(names, m * 2 + 1);
c = fz_objcmp(needle, key);
if (c < 0)
@@ -51,89 +51,89 @@ pdf_lookupnameimp(fz_obj *node, fz_obj *needle)
}
}
- return nil;
+ return NULL;
}
fz_obj *
-pdf_lookupname(pdf_xref *xref, char *which, fz_obj *needle)
+pdf_lookup_name(pdf_xref *xref, char *which, fz_obj *needle)
{
- fz_obj *root = fz_dictgets(xref->trailer, "Root");
- fz_obj *names = fz_dictgets(root, "Names");
- fz_obj *tree = fz_dictgets(names, which);
- return pdf_lookupnameimp(tree, needle);
+ fz_obj *root = fz_dict_gets(xref->trailer, "Root");
+ fz_obj *names = fz_dict_gets(root, "Names");
+ fz_obj *tree = fz_dict_gets(names, which);
+ return pdf_lookup_name_imp(tree, needle);
}
fz_obj *
-pdf_lookupdest(pdf_xref *xref, fz_obj *needle)
+pdf_lookup_dest(pdf_xref *xref, fz_obj *needle)
{
- fz_obj *root = fz_dictgets(xref->trailer, "Root");
- fz_obj *dests = fz_dictgets(root, "Dests");
- fz_obj *names = fz_dictgets(root, "Names");
- fz_obj *dest = nil;
+ fz_obj *root = fz_dict_gets(xref->trailer, "Root");
+ fz_obj *dests = fz_dict_gets(root, "Dests");
+ fz_obj *names = fz_dict_gets(root, "Names");
+ fz_obj *dest = NULL;
/* PDF 1.1 has destinations in a dictionary */
if (dests)
{
- if (fz_isname(needle))
- return fz_dictget(dests, needle);
+ if (fz_is_name(needle))
+ return fz_dict_get(dests, needle);
else
- return fz_dictgets(dests, fz_tostrbuf(needle));
+ return fz_dict_gets(dests, fz_to_str_buf(needle));
}
/* PDF 1.2 has destinations in a name tree */
if (names && !dest)
{
- fz_obj *tree = fz_dictgets(names, "Dests");
- return pdf_lookupnameimp(tree, needle);
+ fz_obj *tree = fz_dict_gets(names, "Dests");
+ return pdf_lookup_name_imp(tree, needle);
}
- return nil;
+ return NULL;
}
static void
-pdf_loadnametreeimp(fz_obj *dict, pdf_xref *xref, fz_obj *node)
+pdf_load_name_tree_imp(fz_obj *dict, pdf_xref *xref, fz_obj *node)
{
- fz_obj *kids = fz_dictgets(node, "Kids");
- fz_obj *names = fz_dictgets(node, "Names");
+ fz_obj *kids = fz_dict_gets(node, "Kids");
+ fz_obj *names = fz_dict_gets(node, "Names");
int i;
if (kids)
{
- for (i = 0; i < fz_arraylen(kids); i++)
- pdf_loadnametreeimp(dict, xref, fz_arrayget(kids, i));
+ for (i = 0; i < fz_array_len(kids); i++)
+ pdf_load_name_tree_imp(dict, xref, fz_array_get(kids, i));
}
if (names)
{
- for (i = 0; i + 1 < fz_arraylen(names); i += 2)
+ for (i = 0; i + 1 < fz_array_len(names); i += 2)
{
- fz_obj *key = fz_arrayget(names, i);
- fz_obj *val = fz_arrayget(names, i + 1);
- if (fz_isstring(key))
+ fz_obj *key = fz_array_get(names, i);
+ fz_obj *val = fz_array_get(names, i + 1);
+ if (fz_is_string(key))
{
- key = pdf_toutf8name(key);
- fz_dictput(dict, key, val);
- fz_dropobj(key);
+ key = pdf_to_utf8_name(key);
+ fz_dict_put(dict, key, val);
+ fz_drop_obj(key);
}
- else if (fz_isname(key))
+ else if (fz_is_name(key))
{
- fz_dictput(dict, key, val);
+ fz_dict_put(dict, key, val);
}
}
}
}
fz_obj *
-pdf_loadnametree(pdf_xref *xref, char *which)
+pdf_load_name_tree(pdf_xref *xref, char *which)
{
- fz_obj *root = fz_dictgets(xref->trailer, "Root");
- fz_obj *names = fz_dictgets(root, "Names");
- fz_obj *tree = fz_dictgets(names, which);
- if (fz_isdict(tree))
+ fz_obj *root = fz_dict_gets(xref->trailer, "Root");
+ fz_obj *names = fz_dict_gets(root, "Names");
+ fz_obj *tree = fz_dict_gets(names, which);
+ if (fz_is_dict(tree))
{
- fz_obj *dict = fz_newdict(100);
- pdf_loadnametreeimp(dict, xref, tree);
+ fz_obj *dict = fz_new_dict(100);
+ pdf_load_name_tree_imp(dict, xref, tree);
return dict;
}
- return nil;
+ return NULL;
}
diff --git a/pdf/pdf_outline.c b/pdf/pdf_outline.c
index b211060f..829bfa8b 100644
--- a/pdf/pdf_outline.c
+++ b/pdf/pdf_outline.c
@@ -2,97 +2,97 @@
#include "mupdf.h"
static pdf_outline *
-pdf_loadoutlineimp(pdf_xref *xref, fz_obj *dict)
+pdf_load_outline_imp(pdf_xref *xref, fz_obj *dict)
{
pdf_outline *node;
fz_obj *obj;
- if (fz_isnull(dict))
- return nil;
+ if (fz_is_null(dict))
+ return NULL;
node = fz_malloc(sizeof(pdf_outline));
- node->title = nil;
- node->link = nil;
- node->child = nil;
- node->next = nil;
+ node->title = NULL;
+ node->link = NULL;
+ node->child = NULL;
+ node->next = NULL;
node->count = 0;
- pdf_logpage("load outline {\n");
+ pdf_log_page("load outline {\n");
- obj = fz_dictgets(dict, "Title");
+ obj = fz_dict_gets(dict, "Title");
if (obj)
{
- node->title = pdf_toutf8(obj);
- pdf_logpage("title %s\n", node->title);
+ node->title = pdf_to_utf8(obj);
+ pdf_log_page("title %s\n", node->title);
}
- obj = fz_dictgets(dict, "Count");
+ obj = fz_dict_gets(dict, "Count");
if (obj)
{
- node->count = fz_toint(obj);
+ node->count = fz_to_int(obj);
}
- if (fz_dictgets(dict, "Dest") || fz_dictgets(dict, "A"))
+ if (fz_dict_gets(dict, "Dest") || fz_dict_gets(dict, "A"))
{
- node->link = pdf_loadlink(xref, dict);
+ node->link = pdf_load_link(xref, dict);
}
- obj = fz_dictgets(dict, "First");
+ obj = fz_dict_gets(dict, "First");
if (obj)
{
- node->child = pdf_loadoutlineimp(xref, obj);
+ node->child = pdf_load_outline_imp(xref, obj);
}
- pdf_logpage("}\n");
+ pdf_log_page("}\n");
- obj = fz_dictgets(dict, "Next");
+ obj = fz_dict_gets(dict, "Next");
if (obj)
{
- node->next = pdf_loadoutlineimp(xref, obj);
+ node->next = pdf_load_outline_imp(xref, obj);
}
return node;
}
pdf_outline *
-pdf_loadoutline(pdf_xref *xref)
+pdf_load_outline(pdf_xref *xref)
{
pdf_outline *node;
fz_obj *root, *obj, *first;
- pdf_logpage("load outlines {\n");
+ pdf_log_page("load outlines {\n");
- node = nil;
+ node = NULL;
- root = fz_dictgets(xref->trailer, "Root");
- obj = fz_dictgets(root, "Outlines");
+ root = fz_dict_gets(xref->trailer, "Root");
+ obj = fz_dict_gets(root, "Outlines");
if (obj)
{
- first = fz_dictgets(obj, "First");
+ first = fz_dict_gets(obj, "First");
if (first)
- node = pdf_loadoutlineimp(xref, first);
+ node = pdf_load_outline_imp(xref, first);
}
- pdf_logpage("}\n");
+ pdf_log_page("}\n");
return node;
}
void
-pdf_freeoutline(pdf_outline *outline)
+pdf_free_outline(pdf_outline *outline)
{
if (outline->child)
- pdf_freeoutline(outline->child);
+ pdf_free_outline(outline->child);
if (outline->next)
- pdf_freeoutline(outline->next);
+ pdf_free_outline(outline->next);
if (outline->link)
- pdf_freelink(outline->link);
+ pdf_free_link(outline->link);
fz_free(outline->title);
fz_free(outline);
}
void
-pdf_debugoutline(pdf_outline *outline, int level)
+pdf_debug_outline(pdf_outline *outline, int level)
{
int i;
while (outline)
@@ -103,15 +103,15 @@ pdf_debugoutline(pdf_outline *outline, int level)
if (outline->title)
printf("%s ", outline->title);
else
- printf("<nil> ");
+ printf("<NULL> ");
if (outline->link)
- fz_debugobj(outline->link->dest);
+ fz_debug_obj(outline->link->dest);
else
- printf("<nil>\n");
+ printf("<NULL>\n");
if (outline->child)
- pdf_debugoutline(outline->child, level + 2);
+ pdf_debug_outline(outline->child, level + 2);
outline = outline->next;
}
diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c
index 869f7a5c..685ec3ae 100644
--- a/pdf/pdf_page.c
+++ b/pdf/pdf_page.c
@@ -4,36 +4,36 @@
/* we need to combine all sub-streams into one for the content stream interpreter */
static fz_error
-pdf_loadpagecontentsarray(fz_buffer **bigbufp, pdf_xref *xref, fz_obj *list)
+pdf_load_page_contents_array(fz_buffer **bigbufp, pdf_xref *xref, fz_obj *list)
{
fz_error error;
fz_buffer *big;
fz_buffer *one;
int i;
- pdf_logpage("multiple content streams: %d\n", fz_arraylen(list));
+ pdf_log_page("multiple content streams: %d\n", fz_array_len(list));
/* TODO: openstream, read, close into big buffer at once */
- big = fz_newbuffer(32 * 1024);
+ big = fz_new_buffer(32 * 1024);
- for (i = 0; i < fz_arraylen(list); i++)
+ for (i = 0; i < fz_array_len(list); i++)
{
- fz_obj *stm = fz_arrayget(list, i);
- error = pdf_loadstream(&one, xref, fz_tonum(stm), fz_togen(stm));
+ fz_obj *stm = fz_array_get(list, i);
+ error = pdf_load_stream(&one, xref, fz_to_num(stm), fz_to_gen(stm));
if (error)
{
- fz_dropbuffer(big);
- return fz_rethrow(error, "cannot load content stream part %d/%d (%d %d R)", i + 1, fz_arraylen(list), fz_tonum(stm), fz_togen(stm));
+ fz_drop_buffer(big);
+ return fz_rethrow(error, "cannot load content stream part %d/%d (%d %d R)", i + 1, fz_array_len(list), fz_to_num(stm), fz_to_gen(stm));
}
if (big->len + one->len + 1 > big->cap)
- fz_resizebuffer(big, big->len + one->len + 1);
+ fz_resize_buffer(big, big->len + one->len + 1);
memcpy(big->data + big->len, one->data, one->len);
big->data[big->len + one->len] = ' ';
big->len += one->len + 1;
- fz_dropbuffer(one);
+ fz_drop_buffer(one);
}
*bigbufp = big;
@@ -41,26 +41,26 @@ pdf_loadpagecontentsarray(fz_buffer **bigbufp, pdf_xref *xref, fz_obj *list)
}
static fz_error
-pdf_loadpagecontents(fz_buffer **bufp, pdf_xref *xref, fz_obj *obj)
+pdf_load_page_contents(fz_buffer **bufp, pdf_xref *xref, fz_obj *obj)
{
fz_error error;
- if (fz_isarray(obj))
+ if (fz_is_array(obj))
{
- error = pdf_loadpagecontentsarray(bufp, xref, obj);
+ error = pdf_load_page_contents_array(bufp, xref, obj);
if (error)
- return fz_rethrow(error, "cannot load content stream array (%d 0 R)", fz_tonum(obj));
+ return fz_rethrow(error, "cannot load content stream array (%d 0 R)", fz_to_num(obj));
}
- else if (pdf_isstream(xref, fz_tonum(obj), fz_togen(obj)))
+ else if (pdf_is_stream(xref, fz_to_num(obj), fz_to_gen(obj)))
{
- error = pdf_loadstream(bufp, xref, fz_tonum(obj), fz_togen(obj));
+ error = pdf_load_stream(bufp, xref, fz_to_num(obj), fz_to_gen(obj));
if (error)
- return fz_rethrow(error, "cannot load content stream (%d 0 R)", fz_tonum(obj));
+ return fz_rethrow(error, "cannot load content stream (%d 0 R)", fz_to_num(obj));
}
else
{
fz_warn("page contents missing, leaving page blank");
- *bufp = fz_newbuffer(0);
+ *bufp = fz_new_buffer(0);
}
return fz_okay;
@@ -68,112 +68,112 @@ pdf_loadpagecontents(fz_buffer **bufp, pdf_xref *xref, fz_obj *obj)
/* We need to know whether to install a page-level transparency group */
-static int pdf_resourcesuseblending(fz_obj *rdb);
+static int pdf_resources_use_blending(fz_obj *rdb);
static int
-pdf_extgstateusesblending(fz_obj *dict)
+pdf_extgstate_uses_blending(fz_obj *dict)
{
fz_obj *obj;
- obj = fz_dictgets(dict, "BM");
- if (fz_isname(obj) && strcmp(fz_toname(obj), "Normal"))
+ obj = fz_dict_gets(dict, "BM");
+ if (fz_is_name(obj) && strcmp(fz_to_name(obj), "Normal"))
return 1;
return 0;
}
static int
-pdf_patternusesblending(fz_obj *dict)
+pdf_pattern_uses_blending(fz_obj *dict)
{
fz_obj *obj;
- obj = fz_dictgets(dict, "Resources");
- if (fz_isdict(obj) && pdf_resourcesuseblending(obj))
+ obj = fz_dict_gets(dict, "Resources");
+ if (fz_is_dict(obj) && pdf_resources_use_blending(obj))
return 1;
- obj = fz_dictgets(dict, "ExtGState");
- if (fz_isdict(obj) && pdf_extgstateusesblending(obj))
+ obj = fz_dict_gets(dict, "ExtGState");
+ if (fz_is_dict(obj) && pdf_extgstate_uses_blending(obj))
return 1;
return 0;
}
static int
-pdf_xobjectusesblending(fz_obj *dict)
+pdf_xobject_uses_blending(fz_obj *dict)
{
fz_obj *obj;
- obj = fz_dictgets(dict, "Resources");
- if (fz_isdict(obj) && pdf_resourcesuseblending(obj))
+ obj = fz_dict_gets(dict, "Resources");
+ if (fz_is_dict(obj) && pdf_resources_use_blending(obj))
return 1;
return 0;
}
static int
-pdf_resourcesuseblending(fz_obj *rdb)
+pdf_resources_use_blending(fz_obj *rdb)
{
fz_obj *dict;
fz_obj *tmp;
int i;
/* stop on cyclic resource dependencies */
- if (fz_dictgets(rdb, ".useBM"))
- return fz_tobool(fz_dictgets(rdb, ".useBM"));
+ if (fz_dict_gets(rdb, ".useBM"))
+ return fz_to_bool(fz_dict_gets(rdb, ".useBM"));
- tmp = fz_newbool(0);
- fz_dictputs(rdb, ".useBM", tmp);
- fz_dropobj(tmp);
+ tmp = fz_new_bool(0);
+ fz_dict_puts(rdb, ".useBM", tmp);
+ fz_drop_obj(tmp);
- dict = fz_dictgets(rdb, "ExtGState");
- for (i = 0; i < fz_dictlen(dict); i++)
- if (pdf_extgstateusesblending(fz_dictgetval(dict, i)))
+ dict = fz_dict_gets(rdb, "ExtGState");
+ for (i = 0; i < fz_dict_len(dict); i++)
+ if (pdf_extgstate_uses_blending(fz_dict_get_val(dict, i)))
goto found;
- dict = fz_dictgets(rdb, "Pattern");
- for (i = 0; i < fz_dictlen(dict); i++)
- if (pdf_patternusesblending(fz_dictgetval(dict, i)))
+ dict = fz_dict_gets(rdb, "Pattern");
+ for (i = 0; i < fz_dict_len(dict); i++)
+ if (pdf_pattern_uses_blending(fz_dict_get_val(dict, i)))
goto found;
- dict = fz_dictgets(rdb, "XObject");
- for (i = 0; i < fz_dictlen(dict); i++)
- if (pdf_xobjectusesblending(fz_dictgetval(dict, i)))
+ dict = fz_dict_gets(rdb, "XObject");
+ for (i = 0; i < fz_dict_len(dict); i++)
+ if (pdf_xobject_uses_blending(fz_dict_get_val(dict, i)))
goto found;
return 0;
found:
- tmp = fz_newbool(1);
- fz_dictputs(rdb, ".useBM", tmp);
- fz_dropobj(tmp);
+ tmp = fz_new_bool(1);
+ fz_dict_puts(rdb, ".useBM", tmp);
+ fz_drop_obj(tmp);
return 1;
}
fz_error
-pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict)
+pdf_load_page(pdf_page **pagep, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
pdf_page *page;
fz_obj *obj;
fz_bbox bbox;
- pdf_logpage("load page {\n");
+ pdf_log_page("load page {\n");
// TODO: move this to a more appropriate place
/* Ensure that we have a store for resource objects */
if (!xref->store)
- xref->store = pdf_newstore();
+ xref->store = pdf_new_store();
page = fz_malloc(sizeof(pdf_page));
- page->resources = nil;
- page->contents = nil;
+ page->resources = NULL;
+ page->contents = NULL;
page->transparency = 0;
- page->links = nil;
- page->annots = nil;
+ page->links = NULL;
+ page->annots = NULL;
- obj = fz_dictgets(dict, "MediaBox");
- bbox = fz_roundrect(pdf_torect(obj));
- if (fz_isemptyrect(pdf_torect(obj)))
+ obj = fz_dict_gets(dict, "MediaBox");
+ bbox = fz_round_rect(pdf_to_rect(obj));
+ if (fz_is_empty_rect(pdf_to_rect(obj)))
{
fz_warn("cannot find page bounds, guessing page bounds.");
bbox.x0 = 0;
@@ -182,11 +182,11 @@ pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict)
bbox.y1 = 792;
}
- obj = fz_dictgets(dict, "CropBox");
- if (fz_isarray(obj))
+ obj = fz_dict_gets(dict, "CropBox");
+ if (fz_is_array(obj))
{
- fz_bbox cropbox = fz_roundrect(pdf_torect(obj));
- bbox = fz_intersectbbox(bbox, cropbox);
+ fz_bbox cropbox = fz_round_rect(pdf_to_rect(obj));
+ bbox = fz_intersect_bbox(bbox, cropbox);
}
page->mediabox.x0 = MIN(bbox.x0, bbox.x1);
@@ -197,50 +197,50 @@ pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict)
if (page->mediabox.x1 - page->mediabox.x0 < 1 || page->mediabox.y1 - page->mediabox.y0 < 1)
return fz_throw("invalid page size");
- page->rotate = fz_toint(fz_dictgets(dict, "Rotate"));
+ page->rotate = fz_to_int(fz_dict_gets(dict, "Rotate"));
- pdf_logpage("bbox [%d %d %d %d]\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1);
- pdf_logpage("rotate %d\n", page->rotate);
+ pdf_log_page("bbox [%d %d %d %d]\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1);
+ pdf_log_page("rotate %d\n", page->rotate);
- obj = fz_dictgets(dict, "Annots");
+ obj = fz_dict_gets(dict, "Annots");
if (obj)
{
- pdf_loadlinks(&page->links, xref, obj);
- pdf_loadannots(&page->annots, xref, obj);
+ pdf_load_links(&page->links, xref, obj);
+ pdf_load_annots(&page->annots, xref, obj);
}
- page->resources = fz_dictgets(dict, "Resources");
+ page->resources = fz_dict_gets(dict, "Resources");
if (page->resources)
- fz_keepobj(page->resources);
+ fz_keep_obj(page->resources);
- obj = fz_dictgets(dict, "Contents");
- error = pdf_loadpagecontents(&page->contents, xref, obj);
+ obj = fz_dict_gets(dict, "Contents");
+ error = pdf_load_page_contents(&page->contents, xref, obj);
if (error)
{
- pdf_freepage(page);
- return fz_rethrow(error, "cannot load page contents (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ pdf_free_page(page);
+ return fz_rethrow(error, "cannot load page contents (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
}
- if (page->resources && pdf_resourcesuseblending(page->resources))
+ if (page->resources && pdf_resources_use_blending(page->resources))
page->transparency = 1;
- pdf_logpage("} %p\n", page);
+ pdf_log_page("} %p\n", page);
*pagep = page;
return fz_okay;
}
void
-pdf_freepage(pdf_page *page)
+pdf_free_page(pdf_page *page)
{
- pdf_logpage("drop page %p\n", page);
+ pdf_log_page("drop page %p\n", page);
if (page->resources)
- fz_dropobj(page->resources);
+ fz_drop_obj(page->resources);
if (page->contents)
- fz_dropbuffer(page->contents);
+ fz_drop_buffer(page->contents);
if (page->links)
- pdf_freelink(page->links);
+ pdf_free_link(page->links);
if (page->annots)
- pdf_freeannot(page->annots);
+ pdf_free_annot(page->annots);
fz_free(page);
}
diff --git a/pdf/pdf_pagetree.c b/pdf/pdf_pagetree.c
index df3c8b8a..9320bb9c 100644
--- a/pdf/pdf_pagetree.c
+++ b/pdf/pdf_pagetree.c
@@ -10,132 +10,132 @@ struct info
};
int
-pdf_getpagecount(pdf_xref *xref)
+pdf_get_page_count(pdf_xref *xref)
{
- return xref->pagelen;
+ return xref->page_len;
}
fz_obj *
-pdf_getpageobject(pdf_xref *xref, int number)
+pdf_get_page_object(pdf_xref *xref, int number)
{
- if (number > 0 && number <= xref->pagelen)
- return xref->pageobjs[number - 1];
- return nil;
+ if (number > 0 && number <= xref->page_len)
+ return xref->page_objs[number - 1];
+ return NULL;
}
fz_obj *
-pdf_getpageref(pdf_xref *xref, int number)
+pdf_get_page_ref(pdf_xref *xref, int number)
{
- if (number > 0 && number <= xref->pagelen)
- return xref->pagerefs[number - 1];
- return nil;
+ if (number > 0 && number <= xref->page_len)
+ return xref->page_refs[number - 1];
+ return NULL;
}
int
-pdf_findpageobject(pdf_xref *xref, fz_obj *page)
+pdf_find_page_object(pdf_xref *xref, fz_obj *page)
{
- int num = fz_tonum(page);
- int gen = fz_togen(page);
+ int num = fz_to_num(page);
+ int gen = fz_to_gen(page);
int i;
- for (i = 0; i < xref->pagelen; i++)
- if (num == fz_tonum(xref->pagerefs[i]) && gen == fz_togen(xref->pagerefs[i]))
+ for (i = 0; i < xref->page_len; i++)
+ if (num == fz_to_num(xref->page_refs[i]) && gen == fz_to_gen(xref->page_refs[i]))
return i + 1;
return 0;
}
static void
-pdf_loadpagetreenode(pdf_xref *xref, fz_obj *node, struct info info)
+pdf_load_page_tree_node(pdf_xref *xref, fz_obj *node, struct info info)
{
fz_obj *dict, *kids, *count;
fz_obj *obj, *tmp;
int i, n;
/* prevent infinite recursion */
- if (fz_dictgets(node, ".seen"))
+ if (fz_dict_gets(node, ".seen"))
return;
- kids = fz_dictgets(node, "Kids");
- count = fz_dictgets(node, "Count");
+ kids = fz_dict_gets(node, "Kids");
+ count = fz_dict_gets(node, "Count");
- if (fz_isarray(kids) && fz_isint(count))
+ if (fz_is_array(kids) && fz_is_int(count))
{
- obj = fz_dictgets(node, "Resources");
+ obj = fz_dict_gets(node, "Resources");
if (obj)
info.resources = obj;
- obj = fz_dictgets(node, "MediaBox");
+ obj = fz_dict_gets(node, "MediaBox");
if (obj)
info.mediabox = obj;
- obj = fz_dictgets(node, "CropBox");
+ obj = fz_dict_gets(node, "CropBox");
if (obj)
info.cropbox = obj;
- obj = fz_dictgets(node, "Rotate");
+ obj = fz_dict_gets(node, "Rotate");
if (obj)
info.rotate = obj;
- tmp = fz_newnull();
- fz_dictputs(node, ".seen", tmp);
- fz_dropobj(tmp);
+ tmp = fz_new_null();
+ fz_dict_puts(node, ".seen", tmp);
+ fz_drop_obj(tmp);
- n = fz_arraylen(kids);
+ n = fz_array_len(kids);
for (i = 0; i < n; i++)
{
- obj = fz_arrayget(kids, i);
- pdf_loadpagetreenode(xref, obj, info);
+ obj = fz_array_get(kids, i);
+ pdf_load_page_tree_node(xref, obj, info);
}
- fz_dictdels(node, ".seen");
+ fz_dict_dels(node, ".seen");
}
else
{
- dict = fz_resolveindirect(node);
-
- if (info.resources && !fz_dictgets(dict, "Resources"))
- fz_dictputs(dict, "Resources", info.resources);
- if (info.mediabox && !fz_dictgets(dict, "MediaBox"))
- fz_dictputs(dict, "MediaBox", info.mediabox);
- if (info.cropbox && !fz_dictgets(dict, "CropBox"))
- fz_dictputs(dict, "CropBox", info.cropbox);
- if (info.rotate && !fz_dictgets(dict, "Rotate"))
- fz_dictputs(dict, "Rotate", info.rotate);
-
- if (xref->pagelen == xref->pagecap)
+ dict = fz_resolve_indirect(node);
+
+ if (info.resources && !fz_dict_gets(dict, "Resources"))
+ fz_dict_puts(dict, "Resources", info.resources);
+ if (info.mediabox && !fz_dict_gets(dict, "MediaBox"))
+ fz_dict_puts(dict, "MediaBox", info.mediabox);
+ if (info.cropbox && !fz_dict_gets(dict, "CropBox"))
+ fz_dict_puts(dict, "CropBox", info.cropbox);
+ if (info.rotate && !fz_dict_gets(dict, "Rotate"))
+ fz_dict_puts(dict, "Rotate", info.rotate);
+
+ if (xref->page_len == xref->page_cap)
{
fz_warn("found more pages than expected");
- xref->pagecap ++;
- xref->pagerefs = fz_realloc(xref->pagerefs, xref->pagecap, sizeof(fz_obj*));
- xref->pageobjs = fz_realloc(xref->pageobjs, xref->pagecap, sizeof(fz_obj*));
+ xref->page_cap ++;
+ xref->page_refs = fz_realloc(xref->page_refs, xref->page_cap, sizeof(fz_obj*));
+ xref->page_objs = fz_realloc(xref->page_objs, xref->page_cap, sizeof(fz_obj*));
}
- xref->pagerefs[xref->pagelen] = fz_keepobj(node);
- xref->pageobjs[xref->pagelen] = fz_keepobj(dict);
- xref->pagelen ++;
+ xref->page_refs[xref->page_len] = fz_keep_obj(node);
+ xref->page_objs[xref->page_len] = fz_keep_obj(dict);
+ xref->page_len ++;
}
}
fz_error
-pdf_loadpagetree(pdf_xref *xref)
+pdf_load_page_tree(pdf_xref *xref)
{
struct info info;
- fz_obj *catalog = fz_dictgets(xref->trailer, "Root");
- fz_obj *pages = fz_dictgets(catalog, "Pages");
- fz_obj *count = fz_dictgets(pages, "Count");
+ fz_obj *catalog = fz_dict_gets(xref->trailer, "Root");
+ fz_obj *pages = fz_dict_gets(catalog, "Pages");
+ fz_obj *count = fz_dict_gets(pages, "Count");
- if (!fz_isdict(pages))
+ if (!fz_is_dict(pages))
return fz_throw("missing page tree");
- if (!fz_isint(count))
+ if (!fz_is_int(count))
return fz_throw("missing page count");
- xref->pagecap = fz_toint(count);
- xref->pagelen = 0;
- xref->pagerefs = fz_calloc(xref->pagecap, sizeof(fz_obj*));
- xref->pageobjs = fz_calloc(xref->pagecap, sizeof(fz_obj*));
+ xref->page_cap = fz_to_int(count);
+ xref->page_len = 0;
+ xref->page_refs = fz_calloc(xref->page_cap, sizeof(fz_obj*));
+ xref->page_objs = fz_calloc(xref->page_cap, sizeof(fz_obj*));
- info.resources = nil;
- info.mediabox = nil;
- info.cropbox = nil;
- info.rotate = nil;
+ info.resources = NULL;
+ info.mediabox = NULL;
+ info.cropbox = NULL;
+ info.rotate = NULL;
- pdf_loadpagetreenode(xref, pages, info);
+ pdf_load_page_tree_node(xref, pages, info);
return fz_okay;
}
diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c
index b32f4d01..9f9d33b1 100644
--- a/pdf/pdf_parse.c
+++ b/pdf/pdf_parse.c
@@ -1,13 +1,13 @@
#include "fitz.h"
#include "mupdf.h"
-fz_rect pdf_torect(fz_obj *array)
+fz_rect pdf_to_rect(fz_obj *array)
{
fz_rect r;
- float a = fz_toreal(fz_arrayget(array, 0));
- float b = fz_toreal(fz_arrayget(array, 1));
- float c = fz_toreal(fz_arrayget(array, 2));
- float d = fz_toreal(fz_arrayget(array, 3));
+ float a = fz_to_real(fz_array_get(array, 0));
+ float b = fz_to_real(fz_array_get(array, 1));
+ float c = fz_to_real(fz_array_get(array, 2));
+ float d = fz_to_real(fz_array_get(array, 3));
r.x0 = MIN(a, c);
r.y0 = MIN(b, d);
r.x1 = MAX(a, c);
@@ -15,24 +15,24 @@ fz_rect pdf_torect(fz_obj *array)
return r;
}
-fz_matrix pdf_tomatrix(fz_obj *array)
+fz_matrix pdf_to_matrix(fz_obj *array)
{
fz_matrix m;
- m.a = fz_toreal(fz_arrayget(array, 0));
- m.b = fz_toreal(fz_arrayget(array, 1));
- m.c = fz_toreal(fz_arrayget(array, 2));
- m.d = fz_toreal(fz_arrayget(array, 3));
- m.e = fz_toreal(fz_arrayget(array, 4));
- m.f = fz_toreal(fz_arrayget(array, 5));
+ m.a = fz_to_real(fz_array_get(array, 0));
+ m.b = fz_to_real(fz_array_get(array, 1));
+ m.c = fz_to_real(fz_array_get(array, 2));
+ m.d = fz_to_real(fz_array_get(array, 3));
+ m.e = fz_to_real(fz_array_get(array, 4));
+ m.f = fz_to_real(fz_array_get(array, 5));
return m;
}
char *
-pdf_toutf8(fz_obj *src)
+pdf_to_utf8(fz_obj *src)
{
- unsigned char *srcptr = (unsigned char *) fz_tostrbuf(src);
+ unsigned char *srcptr = (unsigned char *) fz_to_str_buf(src);
char *dstptr, *dst;
- int srclen = fz_tostrlen(src);
+ int srclen = fz_to_str_len(src);
int dstlen = 0;
int ucs;
int i;
@@ -57,13 +57,13 @@ pdf_toutf8(fz_obj *src)
else
{
for (i = 0; i < srclen; i++)
- dstlen += runelen(pdf_docencoding[srcptr[i]]);
+ dstlen += runelen(pdf_doc_encoding[srcptr[i]]);
dstptr = dst = fz_malloc(dstlen + 1);
for (i = 0; i < srclen; i++)
{
- ucs = pdf_docencoding[srcptr[i]];
+ ucs = pdf_doc_encoding[srcptr[i]];
dstptr += runetochar(dstptr, &ucs);
}
}
@@ -73,11 +73,11 @@ pdf_toutf8(fz_obj *src)
}
unsigned short *
-pdf_toucs2(fz_obj *src)
+pdf_to_ucs2(fz_obj *src)
{
- unsigned char *srcptr = (unsigned char *) fz_tostrbuf(src);
+ unsigned char *srcptr = (unsigned char *) fz_to_str_buf(src);
unsigned short *dstptr, *dst;
- int srclen = fz_tostrlen(src);
+ int srclen = fz_to_str_len(src);
int i;
if (srclen > 2 && srcptr[0] == 254 && srcptr[1] == 255)
@@ -91,7 +91,7 @@ pdf_toucs2(fz_obj *src)
{
dstptr = dst = fz_calloc(srclen + 1, sizeof(short));
for (i = 0; i < srclen; i++)
- *dstptr++ = pdf_docencoding[srcptr[i]];
+ *dstptr++ = pdf_doc_encoding[srcptr[i]];
}
*dstptr = '\0';
@@ -99,68 +99,68 @@ pdf_toucs2(fz_obj *src)
}
fz_obj *
-pdf_toutf8name(fz_obj *src)
+pdf_to_utf8_name(fz_obj *src)
{
- char *buf = pdf_toutf8(src);
- fz_obj *dst = fz_newname(buf);
+ char *buf = pdf_to_utf8(src);
+ fz_obj *dst = fz_new_name(buf);
fz_free(buf);
return dst;
}
fz_error
-pdf_parsearray(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap)
+pdf_parse_array(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap)
{
fz_error error = fz_okay;
- fz_obj *ary = nil;
- fz_obj *obj = nil;
+ fz_obj *ary = NULL;
+ fz_obj *obj = NULL;
int a = 0, b = 0, n = 0;
int tok;
int len;
- ary = fz_newarray(4);
+ ary = fz_new_array(4);
while (1)
{
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
{
- fz_dropobj(ary);
+ fz_drop_obj(ary);
return fz_rethrow(error, "cannot parse array");
}
- if (tok != PDF_TINT && tok != PDF_TR)
+ if (tok != PDF_TOK_INT && tok != PDF_TOK_R)
{
if (n > 0)
{
- obj = fz_newint(a);
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ obj = fz_new_int(a);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
}
if (n > 1)
{
- obj = fz_newint(b);
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ obj = fz_new_int(b);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
}
n = 0;
}
- if (tok == PDF_TINT && n == 2)
+ if (tok == PDF_TOK_INT && n == 2)
{
- obj = fz_newint(a);
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ obj = fz_new_int(a);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
a = b;
n --;
}
switch (tok)
{
- case PDF_TCARRAY:
+ case PDF_TOK_CLOSE_ARRAY:
*op = ary;
return fz_okay;
- case PDF_TINT:
+ case PDF_TOK_INT:
if (n == 0)
a = atoi(buf);
if (n == 1)
@@ -168,212 +168,212 @@ pdf_parsearray(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap)
n ++;
break;
- case PDF_TR:
+ case PDF_TOK_R:
if (n != 2)
{
- fz_dropobj(ary);
+ fz_drop_obj(ary);
return fz_throw("cannot parse indirect reference in array");
}
- obj = fz_newindirect(a, b, xref);
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ obj = fz_new_indirect(a, b, xref);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
n = 0;
break;
- case PDF_TOARRAY:
- error = pdf_parsearray(&obj, xref, file, buf, cap);
+ case PDF_TOK_OPEN_ARRAY:
+ error = pdf_parse_array(&obj, xref, file, buf, cap);
if (error)
{
- fz_dropobj(ary);
+ fz_drop_obj(ary);
return fz_rethrow(error, "cannot parse array");
}
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
break;
- case PDF_TODICT:
- error = pdf_parsedict(&obj, xref, file, buf, cap);
+ case PDF_TOK_OPEN_DICT:
+ error = pdf_parse_dict(&obj, xref, file, buf, cap);
if (error)
{
- fz_dropobj(ary);
+ fz_drop_obj(ary);
return fz_rethrow(error, "cannot parse array");
}
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
break;
- case PDF_TNAME:
- obj = fz_newname(buf);
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ case PDF_TOK_NAME:
+ obj = fz_new_name(buf);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
break;
- case PDF_TREAL:
- obj = fz_newreal(atof(buf));
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ case PDF_TOK_REAL:
+ obj = fz_new_real(atof(buf));
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
break;
- case PDF_TSTRING:
- obj = fz_newstring(buf, len);
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ case PDF_TOK_STRING:
+ obj = fz_new_string(buf, len);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
break;
- case PDF_TTRUE:
- obj = fz_newbool(1);
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ case PDF_TOK_TRUE:
+ obj = fz_new_bool(1);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
break;
- case PDF_TFALSE:
- obj = fz_newbool(0);
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ case PDF_TOK_FALSE:
+ obj = fz_new_bool(0);
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
break;
- case PDF_TNULL:
- obj = fz_newnull();
- fz_arraypush(ary, obj);
- fz_dropobj(obj);
+ case PDF_TOK_NULL:
+ obj = fz_new_null();
+ fz_array_push(ary, obj);
+ fz_drop_obj(obj);
break;
default:
- fz_dropobj(ary);
+ fz_drop_obj(ary);
return fz_throw("cannot parse token in array");
}
}
}
fz_error
-pdf_parsedict(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap)
+pdf_parse_dict(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap)
{
fz_error error = fz_okay;
- fz_obj *dict = nil;
- fz_obj *key = nil;
- fz_obj *val = nil;
+ fz_obj *dict = NULL;
+ fz_obj *key = NULL;
+ fz_obj *val = NULL;
int tok;
int len;
int a, b;
- dict = fz_newdict(8);
+ dict = fz_new_dict(8);
while (1)
{
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
{
- fz_dropobj(dict);
+ fz_drop_obj(dict);
return fz_rethrow(error, "cannot parse dict");
}
skip:
- if (tok == PDF_TCDICT)
+ if (tok == PDF_TOK_CLOSE_DICT)
{
*op = dict;
return fz_okay;
}
/* for BI .. ID .. EI in content streams */
- if (tok == PDF_TKEYWORD && !strcmp(buf, "ID"))
+ if (tok == PDF_TOK_KEYWORD && !strcmp(buf, "ID"))
{
*op = dict;
return fz_okay;
}
- if (tok != PDF_TNAME)
+ if (tok != PDF_TOK_NAME)
{
- fz_dropobj(dict);
+ fz_drop_obj(dict);
return fz_throw("invalid key in dict");
}
- key = fz_newname(buf);
+ key = fz_new_name(buf);
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
{
- fz_dropobj(key);
- fz_dropobj(dict);
+ fz_drop_obj(key);
+ fz_drop_obj(dict);
return fz_rethrow(error, "cannot parse dict");
}
switch (tok)
{
- case PDF_TOARRAY:
- error = pdf_parsearray(&val, xref, file, buf, cap);
+ case PDF_TOK_OPEN_ARRAY:
+ error = pdf_parse_array(&val, xref, file, buf, cap);
if (error)
{
- fz_dropobj(key);
- fz_dropobj(dict);
+ fz_drop_obj(key);
+ fz_drop_obj(dict);
return fz_rethrow(error, "cannot parse dict");
}
break;
- case PDF_TODICT:
- error = pdf_parsedict(&val, xref, file, buf, cap);
+ case PDF_TOK_OPEN_DICT:
+ error = pdf_parse_dict(&val, xref, file, buf, cap);
if (error)
{
- fz_dropobj(key);
- fz_dropobj(dict);
+ fz_drop_obj(key);
+ fz_drop_obj(dict);
return fz_rethrow(error, "cannot parse dict");
}
break;
- case PDF_TNAME: val = fz_newname(buf); break;
- case PDF_TREAL: val = fz_newreal(atof(buf)); break;
- case PDF_TSTRING: val = fz_newstring(buf, len); break;
- case PDF_TTRUE: val = fz_newbool(1); break;
- case PDF_TFALSE: val = fz_newbool(0); break;
- case PDF_TNULL: val = fz_newnull(); break;
+ case PDF_TOK_NAME: val = fz_new_name(buf); break;
+ case PDF_TOK_REAL: val = fz_new_real(atof(buf)); break;
+ case PDF_TOK_STRING: val = fz_new_string(buf, len); break;
+ case PDF_TOK_TRUE: val = fz_new_bool(1); break;
+ case PDF_TOK_FALSE: val = fz_new_bool(0); break;
+ case PDF_TOK_NULL: val = fz_new_null(); break;
- case PDF_TINT:
+ case PDF_TOK_INT:
/* 64-bit to allow for numbers > INT_MAX and overflow */
a = (int) strtoll(buf, 0, 10);
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
{
- fz_dropobj(key);
- fz_dropobj(dict);
+ fz_drop_obj(key);
+ fz_drop_obj(dict);
return fz_rethrow(error, "cannot parse dict");
}
- if (tok == PDF_TCDICT || tok == PDF_TNAME ||
- (tok == PDF_TKEYWORD && !strcmp(buf, "ID")))
+ if (tok == PDF_TOK_CLOSE_DICT || tok == PDF_TOK_NAME ||
+ (tok == PDF_TOK_KEYWORD && !strcmp(buf, "ID")))
{
- val = fz_newint(a);
- fz_dictput(dict, key, val);
- fz_dropobj(val);
- fz_dropobj(key);
+ val = fz_new_int(a);
+ fz_dict_put(dict, key, val);
+ fz_drop_obj(val);
+ fz_drop_obj(key);
goto skip;
}
- if (tok == PDF_TINT)
+ if (tok == PDF_TOK_INT)
{
b = atoi(buf);
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
{
- fz_dropobj(key);
- fz_dropobj(dict);
+ fz_drop_obj(key);
+ fz_drop_obj(dict);
return fz_rethrow(error, "cannot parse dict");
}
- if (tok == PDF_TR)
+ if (tok == PDF_TOK_R)
{
- val = fz_newindirect(a, b, xref);
+ val = fz_new_indirect(a, b, xref);
break;
}
}
- fz_dropobj(key);
- fz_dropobj(dict);
+ fz_drop_obj(key);
+ fz_drop_obj(dict);
return fz_throw("invalid indirect reference in dict");
default:
- fz_dropobj(key);
- fz_dropobj(dict);
+ fz_drop_obj(key);
+ fz_drop_obj(dict);
return fz_throw("unknown token in dict");
}
- fz_dictput(dict, key, val);
- fz_dropobj(val);
- fz_dropobj(key);
+ fz_dict_put(dict, key, val);
+ fz_drop_obj(val);
+ fz_drop_obj(key);
}
}
fz_error
-pdf_parsestmobj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap)
+pdf_parse_stm_obj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap)
{
fz_error error;
int tok;
@@ -385,23 +385,23 @@ pdf_parsestmobj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap
switch (tok)
{
- case PDF_TOARRAY:
- error = pdf_parsearray(op, xref, file, buf, cap);
+ case PDF_TOK_OPEN_ARRAY:
+ error = pdf_parse_array(op, xref, file, buf, cap);
if (error)
return fz_rethrow(error, "cannot parse object stream");
break;
- case PDF_TODICT:
- error = pdf_parsedict(op, xref, file, buf, cap);
+ case PDF_TOK_OPEN_DICT:
+ error = pdf_parse_dict(op, xref, file, buf, cap);
if (error)
return fz_rethrow(error, "cannot parse object stream");
break;
- case PDF_TNAME: *op = fz_newname(buf); break;
- case PDF_TREAL: *op = fz_newreal(atof(buf)); break;
- case PDF_TSTRING: *op = fz_newstring(buf, len); break;
- case PDF_TTRUE: *op = fz_newbool(1); break;
- case PDF_TFALSE: *op = fz_newbool(0); break;
- case PDF_TNULL: *op = fz_newnull(); break;
- case PDF_TINT: *op = fz_newint(atoi(buf)); break;
+ case PDF_TOK_NAME: *op = fz_new_name(buf); break;
+ case PDF_TOK_REAL: *op = fz_new_real(atof(buf)); break;
+ case PDF_TOK_STRING: *op = fz_new_string(buf, len); break;
+ case PDF_TOK_TRUE: *op = fz_new_bool(1); break;
+ case PDF_TOK_FALSE: *op = fz_new_bool(0); break;
+ case PDF_TOK_NULL: *op = fz_new_null(); break;
+ case PDF_TOK_INT: *op = fz_new_int(atoi(buf)); break;
default: return fz_throw("unknown token in object stream");
}
@@ -409,13 +409,13 @@ pdf_parsestmobj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap
}
fz_error
-pdf_parseindobj(fz_obj **op, pdf_xref *xref,
+pdf_parse_ind_obj(fz_obj **op, pdf_xref *xref,
fz_stream *file, char *buf, int cap,
int *onum, int *ogen, int *ostmofs)
{
fz_error error = fz_okay;
- fz_obj *obj = nil;
- int num = 0, gen = 0, stmofs;
+ fz_obj *obj = NULL;
+ int num = 0, gen = 0, stm_ofs;
int tok;
int len;
int a, b;
@@ -423,21 +423,21 @@ pdf_parseindobj(fz_obj **op, pdf_xref *xref,
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen);
- if (tok != PDF_TINT)
+ if (tok != PDF_TOK_INT)
return fz_throw("expected object number (%d %d R)", num, gen);
num = atoi(buf);
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen);
- if (tok != PDF_TINT)
+ if (tok != PDF_TOK_INT)
return fz_throw("expected generation number (%d %d R)", num, gen);
gen = atoi(buf);
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen);
- if (tok != PDF_TOBJ)
+ if (tok != PDF_TOK_OBJ)
return fz_throw("expected 'obj' keyword (%d %d R)", num, gen);
error = pdf_lex(&tok, file, buf, cap, &len);
@@ -446,51 +446,51 @@ pdf_parseindobj(fz_obj **op, pdf_xref *xref,
switch (tok)
{
- case PDF_TOARRAY:
- error = pdf_parsearray(&obj, xref, file, buf, cap);
+ case PDF_TOK_OPEN_ARRAY:
+ error = pdf_parse_array(&obj, xref, file, buf, cap);
if (error)
return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen);
break;
- case PDF_TODICT:
- error = pdf_parsedict(&obj, xref, file, buf, cap);
+ case PDF_TOK_OPEN_DICT:
+ error = pdf_parse_dict(&obj, xref, file, buf, cap);
if (error)
return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen);
break;
- case PDF_TNAME: obj = fz_newname(buf); break;
- case PDF_TREAL: obj = fz_newreal(atof(buf)); break;
- case PDF_TSTRING: obj = fz_newstring(buf, len); break;
- case PDF_TTRUE: obj = fz_newbool(1); break;
- case PDF_TFALSE: obj = fz_newbool(0); break;
- case PDF_TNULL: obj = fz_newnull(); break;
+ case PDF_TOK_NAME: obj = fz_new_name(buf); break;
+ case PDF_TOK_REAL: obj = fz_new_real(atof(buf)); break;
+ case PDF_TOK_STRING: obj = fz_new_string(buf, len); break;
+ case PDF_TOK_TRUE: obj = fz_new_bool(1); break;
+ case PDF_TOK_FALSE: obj = fz_new_bool(0); break;
+ case PDF_TOK_NULL: obj = fz_new_null(); break;
- case PDF_TINT:
+ case PDF_TOK_INT:
a = atoi(buf);
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen);
- if (tok == PDF_TSTREAM || tok == PDF_TENDOBJ)
+ if (tok == PDF_TOK_STREAM || tok == PDF_TOK_ENDOBJ)
{
- obj = fz_newint(a);
+ obj = fz_new_int(a);
goto skip;
}
- if (tok == PDF_TINT)
+ if (tok == PDF_TOK_INT)
{
b = atoi(buf);
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen);
- if (tok == PDF_TR)
+ if (tok == PDF_TOK_R)
{
- obj = fz_newindirect(a, b, xref);
+ obj = fz_new_indirect(a, b, xref);
break;
}
}
return fz_throw("expected 'R' keyword (%d %d R)", num, gen);
- case PDF_TENDOBJ:
- obj = fz_newnull();
+ case PDF_TOK_ENDOBJ:
+ obj = fz_new_null();
goto skip;
default:
@@ -500,39 +500,39 @@ pdf_parseindobj(fz_obj **op, pdf_xref *xref,
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
{
- fz_dropobj(obj);
+ fz_drop_obj(obj);
return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen);
}
skip:
- if (tok == PDF_TSTREAM)
+ if (tok == PDF_TOK_STREAM)
{
- int c = fz_readbyte(file);
+ int c = fz_read_byte(file);
while (c == ' ')
- c = fz_readbyte(file);
+ c = fz_read_byte(file);
if (c == '\r')
{
- c = fz_peekbyte(file);
+ c = fz_peek_byte(file);
if (c != '\n')
fz_warn("line feed missing after stream begin marker (%d %d R)", num, gen);
else
- fz_readbyte(file);
+ fz_read_byte(file);
}
- stmofs = fz_tell(file);
+ stm_ofs = fz_tell(file);
}
- else if (tok == PDF_TENDOBJ)
+ else if (tok == PDF_TOK_ENDOBJ)
{
- stmofs = 0;
+ stm_ofs = 0;
}
else
{
fz_warn("expected 'endobj' or 'stream' keyword (%d %d R)", num, gen);
- stmofs = 0;
+ stm_ofs = 0;
}
if (onum) *onum = num;
if (ogen) *ogen = gen;
- if (ostmofs) *ostmofs = stmofs;
+ if (ostmofs) *ostmofs = stm_ofs;
*op = obj;
return fz_okay;
}
diff --git a/pdf/pdf_pattern.c b/pdf/pdf_pattern.c
index 7d3a38d1..ab464cfd 100644
--- a/pdf/pdf_pattern.c
+++ b/pdf/pdf_pattern.c
@@ -2,88 +2,88 @@
#include "mupdf.h"
fz_error
-pdf_loadpattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *dict)
+pdf_load_pattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
pdf_pattern *pat;
fz_obj *obj;
- if ((*patp = pdf_finditem(xref->store, pdf_droppattern, dict)))
+ if ((*patp = pdf_find_item(xref->store, pdf_drop_pattern, dict)))
{
- pdf_keeppattern(*patp);
+ pdf_keep_pattern(*patp);
return fz_okay;
}
- pdf_logrsrc("load pattern (%d %d R) {\n", fz_tonum(dict), fz_togen(dict));
+ pdf_log_rsrc("load pattern (%d %d R) {\n", fz_to_num(dict), fz_to_gen(dict));
pat = fz_malloc(sizeof(pdf_pattern));
pat->refs = 1;
- pat->resources = nil;
- pat->contents = nil;
+ pat->resources = NULL;
+ pat->contents = NULL;
/* Store pattern now, to avoid possible recursion if objects refer back to this one */
- pdf_storeitem(xref->store, pdf_keeppattern, pdf_droppattern, dict, pat);
+ pdf_store_item(xref->store, pdf_keep_pattern, pdf_drop_pattern, dict, pat);
- pat->ismask = fz_toint(fz_dictgets(dict, "PaintType")) == 2;
- pat->xstep = fz_toreal(fz_dictgets(dict, "XStep"));
- pat->ystep = fz_toreal(fz_dictgets(dict, "YStep"));
+ pat->ismask = fz_to_int(fz_dict_gets(dict, "PaintType")) == 2;
+ pat->xstep = fz_to_real(fz_dict_gets(dict, "XStep"));
+ pat->ystep = fz_to_real(fz_dict_gets(dict, "YStep"));
- pdf_logrsrc("mask %d\n", pat->ismask);
- pdf_logrsrc("xstep %g\n", pat->xstep);
- pdf_logrsrc("ystep %g\n", pat->ystep);
+ pdf_log_rsrc("mask %d\n", pat->ismask);
+ pdf_log_rsrc("xstep %g\n", pat->xstep);
+ pdf_log_rsrc("ystep %g\n", pat->ystep);
- obj = fz_dictgets(dict, "BBox");
- pat->bbox = pdf_torect(obj);
+ obj = fz_dict_gets(dict, "BBox");
+ pat->bbox = pdf_to_rect(obj);
- pdf_logrsrc("bbox [%g %g %g %g]\n",
+ pdf_log_rsrc("bbox [%g %g %g %g]\n",
pat->bbox.x0, pat->bbox.y0,
pat->bbox.x1, pat->bbox.y1);
- obj = fz_dictgets(dict, "Matrix");
+ obj = fz_dict_gets(dict, "Matrix");
if (obj)
- pat->matrix = pdf_tomatrix(obj);
+ pat->matrix = pdf_to_matrix(obj);
else
pat->matrix = fz_identity;
- pdf_logrsrc("matrix [%g %g %g %g %g %g]\n",
+ pdf_log_rsrc("matrix [%g %g %g %g %g %g]\n",
pat->matrix.a, pat->matrix.b,
pat->matrix.c, pat->matrix.d,
pat->matrix.e, pat->matrix.f);
- pat->resources = fz_dictgets(dict, "Resources");
+ pat->resources = fz_dict_gets(dict, "Resources");
if (pat->resources)
- fz_keepobj(pat->resources);
+ fz_keep_obj(pat->resources);
- error = pdf_loadstream(&pat->contents, xref, fz_tonum(dict), fz_togen(dict));
+ error = pdf_load_stream(&pat->contents, xref, fz_to_num(dict), fz_to_gen(dict));
if (error)
{
- pdf_removeitem(xref->store, pdf_droppattern, dict);
- pdf_droppattern(pat);
- return fz_rethrow(error, "cannot load pattern stream (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ pdf_remove_item(xref->store, pdf_drop_pattern, dict);
+ pdf_drop_pattern(pat);
+ return fz_rethrow(error, "cannot load pattern stream (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
- pdf_logrsrc("}\n");
+ pdf_log_rsrc("}\n");
*patp = pat;
return fz_okay;
}
pdf_pattern *
-pdf_keeppattern(pdf_pattern *pat)
+pdf_keep_pattern(pdf_pattern *pat)
{
pat->refs ++;
return pat;
}
void
-pdf_droppattern(pdf_pattern *pat)
+pdf_drop_pattern(pdf_pattern *pat)
{
if (pat && --pat->refs == 0)
{
if (pat->resources)
- fz_dropobj(pat->resources);
+ fz_drop_obj(pat->resources);
if (pat->contents)
- fz_dropbuffer(pat->contents);
+ fz_drop_buffer(pat->contents);
fz_free(pat);
}
}
diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c
index 436f7303..45310fc6 100644
--- a/pdf/pdf_repair.c
+++ b/pdf/pdf_repair.c
@@ -8,93 +8,93 @@ struct entry
int num;
int gen;
int ofs;
- int stmofs;
- int stmlen;
+ int stm_ofs;
+ int stm_len;
};
static fz_error
-fz_repairobj(fz_stream *file, char *buf, int cap, int *stmofsp, int *stmlenp, fz_obj **encrypt, fz_obj **id)
+pdf_repair_obj(fz_stream *file, char *buf, int cap, int *stmofsp, int *stmlenp, fz_obj **encrypt, fz_obj **id)
{
fz_error error;
int tok;
- int stmlen;
+ int stm_len;
int len;
int n;
*stmofsp = 0;
*stmlenp = -1;
- stmlen = 0;
+ stm_len = 0;
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
return fz_rethrow(error, "cannot parse object");
- if (tok == PDF_TODICT)
+ if (tok == PDF_TOK_OPEN_DICT)
{
fz_obj *dict, *obj;
- /* Send nil xref so we don't try to resolve references */
- error = pdf_parsedict(&dict, nil, file, buf, cap);
+ /* Send NULL xref so we don't try to resolve references */
+ error = pdf_parse_dict(&dict, NULL, file, buf, cap);
if (error)
return fz_rethrow(error, "cannot parse object");
- obj = fz_dictgets(dict, "Type");
- if (fz_isname(obj) && !strcmp(fz_toname(obj), "XRef"))
+ obj = fz_dict_gets(dict, "Type");
+ if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "XRef"))
{
- obj = fz_dictgets(dict, "Encrypt");
+ obj = fz_dict_gets(dict, "Encrypt");
if (obj)
{
if (*encrypt)
- fz_dropobj(*encrypt);
- *encrypt = fz_keepobj(obj);
+ fz_drop_obj(*encrypt);
+ *encrypt = fz_keep_obj(obj);
}
- obj = fz_dictgets(dict, "ID");
+ obj = fz_dict_gets(dict, "ID");
if (obj)
{
if (*id)
- fz_dropobj(*id);
- *id = fz_keepobj(obj);
+ fz_drop_obj(*id);
+ *id = fz_keep_obj(obj);
}
}
- obj = fz_dictgets(dict, "Length");
- if (fz_isint(obj))
- stmlen = fz_toint(obj);
+ obj = fz_dict_gets(dict, "Length");
+ if (fz_is_int(obj))
+ stm_len = fz_to_int(obj);
- fz_dropobj(dict);
+ fz_drop_obj(dict);
}
- while ( tok != PDF_TSTREAM &&
- tok != PDF_TENDOBJ &&
- tok != PDF_TERROR &&
- tok != PDF_TEOF )
+ while ( tok != PDF_TOK_STREAM &&
+ tok != PDF_TOK_ENDOBJ &&
+ tok != PDF_TOK_ERROR &&
+ tok != PDF_TOK_EOF )
{
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
return fz_rethrow(error, "cannot scan for endobj or stream token");
}
- if (tok == PDF_TSTREAM)
+ if (tok == PDF_TOK_STREAM)
{
- int c = fz_readbyte(file);
+ int c = fz_read_byte(file);
if (c == '\r') {
- c = fz_peekbyte(file);
+ c = fz_peek_byte(file);
if (c == '\n')
- fz_readbyte(file);
+ fz_read_byte(file);
}
*stmofsp = fz_tell(file);
if (*stmofsp < 0)
return fz_throw("cannot seek in file");
- if (stmlen > 0)
+ if (stm_len > 0)
{
- fz_seek(file, *stmofsp + stmlen, 0);
+ fz_seek(file, *stmofsp + stm_len, 0);
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
fz_catch(error, "cannot find endstream token, falling back to scanning");
- if (tok == PDF_TENDSTREAM)
+ if (tok == PDF_TOK_ENDSTREAM)
goto atobjend;
fz_seek(file, *stmofsp, 0);
}
@@ -105,7 +105,7 @@ fz_repairobj(fz_stream *file, char *buf, int cap, int *stmofsp, int *stmlenp, fz
while (memcmp(buf, "endstream", 9) != 0)
{
- c = fz_readbyte(file);
+ c = fz_read_byte(file);
if (c == EOF)
break;
memmove(buf, buf + 1, 8);
@@ -118,7 +118,7 @@ atobjend:
error = pdf_lex(&tok, file, buf, cap, &len);
if (error)
return fz_rethrow(error, "cannot scan for endobj token");
- if (tok != PDF_TENDOBJ)
+ if (tok != PDF_TOK_ENDOBJ)
fz_warn("object missing 'endobj' token");
}
@@ -126,7 +126,7 @@ atobjend:
}
static fz_error
-pdf_repairobjstm(pdf_xref *xref, int num, int gen)
+pdf_repair_obj_stm(pdf_xref *xref, int num, int gen)
{
fz_error error;
fz_obj *obj;
@@ -135,22 +135,22 @@ pdf_repairobjstm(pdf_xref *xref, int num, int gen)
int i, n, count;
char buf[256];
- error = pdf_loadobject(&obj, xref, num, gen);
+ error = pdf_load_object(&obj, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot load object stream object (%d %d R)", num, gen);
- count = fz_toint(fz_dictgets(obj, "N"));
+ count = fz_to_int(fz_dict_gets(obj, "N"));
- fz_dropobj(obj);
+ fz_drop_obj(obj);
- error = pdf_openstream(&stm, xref, num, gen);
+ error = pdf_open_stream(&stm, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot open object stream object (%d %d R)", num, gen);
for (i = 0; i < count; i++)
{
error = pdf_lex(&tok, stm, buf, sizeof buf, &n);
- if (error || tok != PDF_TINT)
+ if (error || tok != PDF_TOK_INT)
{
fz_close(stm);
return fz_rethrow(error, "corrupt object stream (%d %d R)", num, gen);
@@ -158,16 +158,16 @@ pdf_repairobjstm(pdf_xref *xref, int num, int gen)
n = atoi(buf);
if (n >= xref->len)
- pdf_resizexref(xref, n + 1);
+ pdf_resize_xref(xref, n + 1);
xref->table[n].ofs = num;
xref->table[n].gen = i;
- xref->table[n].stmofs = 0;
- xref->table[n].obj = nil;
+ xref->table[n].stm_ofs = 0;
+ xref->table[n].obj = NULL;
xref->table[n].type = 'o';
error = pdf_lex(&tok, stm, buf, sizeof buf, &n);
- if (error || tok != PDF_TINT)
+ if (error || tok != PDF_TOK_INT)
{
fz_close(stm);
return fz_rethrow(error, "corrupt object stream (%d %d R)", num, gen);
@@ -179,18 +179,18 @@ pdf_repairobjstm(pdf_xref *xref, int num, int gen)
}
fz_error
-pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
+pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize)
{
fz_error error;
fz_obj *dict, *obj;
fz_obj *length;
- fz_obj *encrypt = nil;
- fz_obj *id = nil;
- fz_obj *root = nil;
- fz_obj *info = nil;
+ fz_obj *encrypt = NULL;
+ fz_obj *id = NULL;
+ fz_obj *root = NULL;
+ fz_obj *info = NULL;
- struct entry *list = nil;
+ struct entry *list = NULL;
int listlen;
int listcap;
int maxnum = 0;
@@ -198,12 +198,12 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
int num = 0;
int gen = 0;
int tmpofs, numofs = 0, genofs = 0;
- int stmlen, stmofs = 0;
+ int stm_len, stm_ofs = 0;
int tok;
int next;
int i, n;
- pdf_logxref("repairxref %p\n", xref);
+ pdf_log_xref("repairxref %p\n", xref);
fz_seek(xref->file, 0, 0);
@@ -245,7 +245,7 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
break;
}
- if (tok == PDF_TINT)
+ if (tok == PDF_TOK_INT)
{
numofs = genofs;
num = gen;
@@ -253,16 +253,16 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
gen = atoi(buf);
}
- if (tok == PDF_TOBJ)
+ if (tok == PDF_TOK_OBJ)
{
- error = fz_repairobj(xref->file, buf, bufsize, &stmofs, &stmlen, &encrypt, &id);
+ error = pdf_repair_obj(xref->file, buf, bufsize, &stm_ofs, &stm_len, &encrypt, &id);
if (error)
{
error = fz_rethrow(error, "cannot parse object (%d %d R)", num, gen);
goto cleanup;
}
- pdf_logxref("found object: (%d %d R)\n", num, gen);
+ pdf_log_xref("found object: (%d %d R)\n", num, gen);
if (listlen + 1 == listcap)
{
@@ -273,8 +273,8 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
list[listlen].num = num;
list[listlen].gen = gen;
list[listlen].ofs = numofs;
- list[listlen].stmofs = stmofs;
- list[listlen].stmlen = stmlen;
+ list[listlen].stm_ofs = stm_ofs;
+ list[listlen].stm_len = stm_len;
listlen ++;
if (num > maxnum)
@@ -282,60 +282,60 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
}
/* trailer dictionary */
- if (tok == PDF_TODICT)
+ if (tok == PDF_TOK_OPEN_DICT)
{
- error = pdf_parsedict(&dict, xref, xref->file, buf, bufsize);
+ error = pdf_parse_dict(&dict, xref, xref->file, buf, bufsize);
if (error)
{
error = fz_rethrow(error, "cannot parse object");
goto cleanup;
}
- obj = fz_dictgets(dict, "Encrypt");
+ obj = fz_dict_gets(dict, "Encrypt");
if (obj)
{
if (encrypt)
- fz_dropobj(encrypt);
- encrypt = fz_keepobj(obj);
+ fz_drop_obj(encrypt);
+ encrypt = fz_keep_obj(obj);
}
- obj = fz_dictgets(dict, "ID");
+ obj = fz_dict_gets(dict, "ID");
if (obj)
{
if (id)
- fz_dropobj(id);
- id = fz_keepobj(obj);
+ fz_drop_obj(id);
+ id = fz_keep_obj(obj);
}
- obj = fz_dictgets(dict, "Root");
+ obj = fz_dict_gets(dict, "Root");
if (obj)
{
if (root)
- fz_dropobj(root);
- root = fz_keepobj(obj);
+ fz_drop_obj(root);
+ root = fz_keep_obj(obj);
}
- obj = fz_dictgets(dict, "Info");
+ obj = fz_dict_gets(dict, "Info");
if (obj)
{
if (info)
- fz_dropobj(info);
- info = fz_keepobj(obj);
+ fz_drop_obj(info);
+ info = fz_keep_obj(obj);
}
- fz_dropobj(dict);
+ fz_drop_obj(dict);
}
- if (tok == PDF_TERROR)
- fz_readbyte(xref->file);
+ if (tok == PDF_TOK_ERROR)
+ fz_read_byte(xref->file);
- if (tok == PDF_TEOF)
+ if (tok == PDF_TOK_EOF)
break;
}
/* make xref reasonable */
- pdf_resizexref(xref, maxnum + 1);
+ pdf_resize_xref(xref, maxnum + 1);
for (i = 0; i < listlen; i++)
{
@@ -343,26 +343,26 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
xref->table[list[i].num].ofs = list[i].ofs;
xref->table[list[i].num].gen = list[i].gen;
- xref->table[list[i].num].stmofs = list[i].stmofs;
+ xref->table[list[i].num].stm_ofs = list[i].stm_ofs;
/* corrected stream length */
- if (list[i].stmlen >= 0)
+ if (list[i].stm_len >= 0)
{
- pdf_logxref("correct stream length %d %d = %d\n",
- list[i].num, list[i].gen, list[i].stmlen);
+ pdf_log_xref("correct stream length %d %d = %d\n",
+ list[i].num, list[i].gen, list[i].stm_len);
- error = pdf_loadobject(&dict, xref, list[i].num, list[i].gen);
+ error = pdf_load_object(&dict, xref, list[i].num, list[i].gen);
if (error)
{
error = fz_rethrow(error, "cannot load stream object (%d %d R)", list[i].num, list[i].gen);
goto cleanup;
}
- length = fz_newint(list[i].stmlen);
- fz_dictputs(dict, "Length", length);
- fz_dropobj(length);
+ length = fz_new_int(list[i].stm_len);
+ fz_dict_puts(dict, "Length", length);
+ fz_drop_obj(length);
- fz_dropobj(dict);
+ fz_drop_obj(dict);
}
}
@@ -370,8 +370,8 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
xref->table[0].type = 'f';
xref->table[0].ofs = 0;
xref->table[0].gen = 65535;
- xref->table[0].stmofs = 0;
- xref->table[0].obj = nil;
+ xref->table[0].stm_ofs = 0;
+ xref->table[0].obj = NULL;
next = 0;
for (i = xref->len - 1; i >= 0; i--)
@@ -387,75 +387,75 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
/* create a repaired trailer, Root will be added later */
- xref->trailer = fz_newdict(5);
+ xref->trailer = fz_new_dict(5);
- obj = fz_newint(maxnum + 1);
- fz_dictputs(xref->trailer, "Size", obj);
- fz_dropobj(obj);
+ obj = fz_new_int(maxnum + 1);
+ fz_dict_puts(xref->trailer, "Size", obj);
+ fz_drop_obj(obj);
if (root)
{
- fz_dictputs(xref->trailer, "Root", root);
- fz_dropobj(root);
+ fz_dict_puts(xref->trailer, "Root", root);
+ fz_drop_obj(root);
}
if (info)
{
- fz_dictputs(xref->trailer, "Info", info);
- fz_dropobj(info);
+ fz_dict_puts(xref->trailer, "Info", info);
+ fz_drop_obj(info);
}
if (encrypt)
{
- if (fz_isindirect(encrypt))
+ if (fz_is_indirect(encrypt))
{
- /* create new reference with non-nil xref pointer */
- obj = fz_newindirect(fz_tonum(encrypt), fz_togen(encrypt), xref);
- fz_dropobj(encrypt);
+ /* create new reference with non-NULL xref pointer */
+ obj = fz_new_indirect(fz_to_num(encrypt), fz_to_gen(encrypt), xref);
+ fz_drop_obj(encrypt);
encrypt = obj;
}
- fz_dictputs(xref->trailer, "Encrypt", encrypt);
- fz_dropobj(encrypt);
+ fz_dict_puts(xref->trailer, "Encrypt", encrypt);
+ fz_drop_obj(encrypt);
}
if (id)
{
- if (fz_isindirect(id))
+ if (fz_is_indirect(id))
{
- /* create new reference with non-nil xref pointer */
- obj = fz_newindirect(fz_tonum(id), fz_togen(id), xref);
- fz_dropobj(id);
+ /* create new reference with non-NULL xref pointer */
+ obj = fz_new_indirect(fz_to_num(id), fz_to_gen(id), xref);
+ fz_drop_obj(id);
id = obj;
}
- fz_dictputs(xref->trailer, "ID", id);
- fz_dropobj(id);
+ fz_dict_puts(xref->trailer, "ID", id);
+ fz_drop_obj(id);
}
fz_free(list);
return fz_okay;
cleanup:
- if (encrypt) fz_dropobj(encrypt);
- if (id) fz_dropobj(id);
- if (root) fz_dropobj(root);
- if (info) fz_dropobj(info);
+ if (encrypt) fz_drop_obj(encrypt);
+ if (id) fz_drop_obj(id);
+ if (root) fz_drop_obj(root);
+ if (info) fz_drop_obj(info);
fz_free(list);
return error; /* already rethrown */
}
fz_error
-pdf_repairobjstms(pdf_xref *xref)
+pdf_repair_obj_stms(pdf_xref *xref)
{
fz_obj *dict;
int i;
for (i = 0; i < xref->len; i++)
{
- if (xref->table[i].stmofs)
+ if (xref->table[i].stm_ofs)
{
- pdf_loadobject(&dict, xref, i, 0);
- if (!strcmp(fz_toname(fz_dictgets(dict, "Type")), "ObjStm"))
- pdf_repairobjstm(xref, i, 0);
- fz_dropobj(dict);
+ pdf_load_object(&dict, xref, i, 0);
+ if (!strcmp(fz_to_name(fz_dict_gets(dict, "Type")), "ObjStm"))
+ pdf_repair_obj_stm(xref, i, 0);
+ fz_drop_obj(dict);
}
}
diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c
index 1b301724..46392059 100644
--- a/pdf/pdf_shade.c
+++ b/pdf/pdf_shade.c
@@ -9,70 +9,70 @@
struct vertex
{
float x, y;
- float c[FZ_MAXCOLORS];
+ float c[FZ_MAX_COLORS];
};
static void
-pdf_growmesh(fz_shade *shade, int amount)
+pdf_grow_mesh(fz_shade *shade, int amount)
{
- if (shade->meshlen + amount < shade->meshcap)
+ if (shade->mesh_len + amount < shade->mesh_cap)
return;
- if (shade->meshcap == 0)
- shade->meshcap = 1024;
+ if (shade->mesh_cap == 0)
+ shade->mesh_cap = 1024;
- while (shade->meshlen + amount > shade->meshcap)
- shade->meshcap = (shade->meshcap * 3) / 2;
+ while (shade->mesh_len + amount > shade->mesh_cap)
+ shade->mesh_cap = (shade->mesh_cap * 3) / 2;
- shade->mesh = fz_realloc(shade->mesh, shade->meshcap, sizeof(float));
+ shade->mesh = fz_realloc(shade->mesh, shade->mesh_cap, sizeof(float));
}
static void
-pdf_addvertex(fz_shade *shade, struct vertex *v)
+pdf_add_vertex(fz_shade *shade, struct vertex *v)
{
- int ncomp = shade->usefunction ? 1 : shade->colorspace->n;
+ int ncomp = shade->use_function ? 1 : shade->colorspace->n;
int i;
- pdf_growmesh(shade, 2 + ncomp);
- shade->mesh[shade->meshlen++] = v->x;
- shade->mesh[shade->meshlen++] = v->y;
+ pdf_grow_mesh(shade, 2 + ncomp);
+ shade->mesh[shade->mesh_len++] = v->x;
+ shade->mesh[shade->mesh_len++] = v->y;
for (i = 0; i < ncomp; i++)
- shade->mesh[shade->meshlen++] = v->c[i];
+ shade->mesh[shade->mesh_len++] = v->c[i];
}
static void
-pdf_addtriangle(fz_shade *shade,
+pdf_add_triangle(fz_shade *shade,
struct vertex *v0,
struct vertex *v1,
struct vertex *v2)
{
- pdf_addvertex(shade, v0);
- pdf_addvertex(shade, v1);
- pdf_addvertex(shade, v2);
+ pdf_add_vertex(shade, v0);
+ pdf_add_vertex(shade, v1);
+ pdf_add_vertex(shade, v2);
}
static void
-pdf_addquad(fz_shade *shade,
+pdf_add_quad(fz_shade *shade,
struct vertex *v0,
struct vertex *v1,
struct vertex *v2,
struct vertex *v3)
{
- pdf_addtriangle(shade, v0, v1, v3);
- pdf_addtriangle(shade, v1, v3, v2);
+ pdf_add_triangle(shade, v0, v1, v3);
+ pdf_add_triangle(shade, v1, v3, v2);
}
/* Subdivide and tesselate tensor-patches */
-typedef struct pdf_tensorpatch_s pdf_tensorpatch;
+typedef struct pdf_tensor_patch_s pdf_tensor_patch;
-struct pdf_tensorpatch_s
+struct pdf_tensor_patch_s
{
fz_point pole[4][4];
- float color[4][FZ_MAXCOLORS];
+ float color[4][FZ_MAX_COLORS];
};
static void
-triangulatepatch(pdf_tensorpatch p, fz_shade *shade)
+triangulate_patch(pdf_tensor_patch p, fz_shade *shade)
{
struct vertex v0, v1, v2, v3;
@@ -92,19 +92,19 @@ triangulatepatch(pdf_tensorpatch p, fz_shade *shade)
v3.y = p.pole[3][0].y;
memcpy(v3.c, p.color[3], sizeof(v3.c));
- pdf_addquad(shade, &v0, &v1, &v2, &v3);
+ pdf_add_quad(shade, &v0, &v1, &v2, &v3);
}
static inline void
midcolor(float *c, float *c1, float *c2)
{
int i;
- for (i = 0; i < FZ_MAXCOLORS; i++)
+ for (i = 0; i < FZ_MAX_COLORS; i++)
c[i] = (c1[i] + c2[i]) * 0.5f;
}
static inline void
-splitcurve(fz_point *pole, fz_point *q0, fz_point *q1, int polestep)
+split_curve(fz_point *pole, fz_point *q0, fz_point *q1, int polestep)
{
/*
split bezier curve given by control points pole[0]..pole[3]
@@ -140,16 +140,16 @@ splitcurve(fz_point *pole, fz_point *q0, fz_point *q1, int polestep)
}
static inline void
-splitstripe(pdf_tensorpatch *p, pdf_tensorpatch *s0, pdf_tensorpatch *s1)
+split_stripe(pdf_tensor_patch *p, pdf_tensor_patch *s0, pdf_tensor_patch *s1)
{
/*
split all horizontal bezier curves in patch,
creating two new patches with half the width.
*/
- splitcurve(&p->pole[0][0], &s0->pole[0][0], &s1->pole[0][0], 4);
- splitcurve(&p->pole[0][1], &s0->pole[0][1], &s1->pole[0][1], 4);
- splitcurve(&p->pole[0][2], &s0->pole[0][2], &s1->pole[0][2], 4);
- splitcurve(&p->pole[0][3], &s0->pole[0][3], &s1->pole[0][3], 4);
+ split_curve(&p->pole[0][0], &s0->pole[0][0], &s1->pole[0][0], 4);
+ split_curve(&p->pole[0][1], &s0->pole[0][1], &s1->pole[0][1], 4);
+ split_curve(&p->pole[0][2], &s0->pole[0][2], &s1->pole[0][2], 4);
+ split_curve(&p->pole[0][3], &s0->pole[0][3], &s1->pole[0][3], 4);
/* interpolate the colors for the two new patches. */
memcpy(s0->color[0], p->color[0], sizeof(s0->color[0]));
@@ -164,39 +164,39 @@ splitstripe(pdf_tensorpatch *p, pdf_tensorpatch *s0, pdf_tensorpatch *s1)
}
static void
-drawstripe(pdf_tensorpatch *p, fz_shade *shade, int depth)
+draw_stripe(pdf_tensor_patch *p, fz_shade *shade, int depth)
{
- pdf_tensorpatch s0, s1;
+ pdf_tensor_patch s0, s1;
/* split patch into two half-height patches */
- splitstripe(p, &s0, &s1);
+ split_stripe(p, &s0, &s1);
depth--;
if (depth == 0)
{
/* if no more subdividing, draw two new patches... */
- triangulatepatch(s0, shade);
- triangulatepatch(s1, shade);
+ triangulate_patch(s0, shade);
+ triangulate_patch(s1, shade);
}
else
{
/* ...otherwise, continue subdividing. */
- drawstripe(&s0, shade, depth);
- drawstripe(&s1, shade, depth);
+ draw_stripe(&s0, shade, depth);
+ draw_stripe(&s1, shade, depth);
}
}
static inline void
-splitpatch(pdf_tensorpatch *p, pdf_tensorpatch *s0, pdf_tensorpatch *s1)
+split_patch(pdf_tensor_patch *p, pdf_tensor_patch *s0, pdf_tensor_patch *s1)
{
/*
split all vertical bezier curves in patch,
creating two new patches with half the height.
*/
- splitcurve(p->pole[0], s0->pole[0], s1->pole[0], 1);
- splitcurve(p->pole[1], s0->pole[1], s1->pole[1], 1);
- splitcurve(p->pole[2], s0->pole[2], s1->pole[2], 1);
- splitcurve(p->pole[3], s0->pole[3], s1->pole[3], 1);
+ split_curve(p->pole[0], s0->pole[0], s1->pole[0], 1);
+ split_curve(p->pole[1], s0->pole[1], s1->pole[1], 1);
+ split_curve(p->pole[2], s0->pole[2], s1->pole[2], 1);
+ split_curve(p->pole[3], s0->pole[3], s1->pole[3], 1);
/* interpolate the colors for the two new patches. */
memcpy(s0->color[0], p->color[0], sizeof(s0->color[0]));
@@ -211,30 +211,30 @@ splitpatch(pdf_tensorpatch *p, pdf_tensorpatch *s0, pdf_tensorpatch *s1)
}
static void
-drawpatch(fz_shade *shade, pdf_tensorpatch *p, int depth, int origdepth)
+draw_patch(fz_shade *shade, pdf_tensor_patch *p, int depth, int origdepth)
{
- pdf_tensorpatch s0, s1;
+ pdf_tensor_patch s0, s1;
/* split patch into two half-width patches */
- splitpatch(p, &s0, &s1);
+ split_patch(p, &s0, &s1);
depth--;
if (depth == 0)
{
/* if no more subdividing, draw two new patches... */
- drawstripe(&s0, shade, origdepth);
- drawstripe(&s1, shade, origdepth);
+ draw_stripe(&s0, shade, origdepth);
+ draw_stripe(&s1, shade, origdepth);
}
else
{
/* ...otherwise, continue subdividing. */
- drawpatch(shade, &s0, depth, origdepth);
- drawpatch(shade, &s1, depth, origdepth);
+ draw_patch(shade, &s0, depth, origdepth);
+ draw_patch(shade, &s1, depth, origdepth);
}
}
static inline fz_point
-pdf_computetensorinterior(
+pdf_compute_tensor_interior(
fz_point a, fz_point b, fz_point c, fz_point d,
fz_point e, fz_point f, fz_point g, fz_point h)
{
@@ -260,7 +260,7 @@ pdf_computetensorinterior(
}
static inline void
-pdf_maketensorpatch(pdf_tensorpatch *p, int type, fz_point *pt)
+pdf_make_tensor_patch(pdf_tensor_patch *p, int type, fz_point *pt)
{
if (type == 6)
{
@@ -281,19 +281,19 @@ pdf_maketensorpatch(pdf_tensorpatch *p, int type, fz_point *pt)
/* see equations at page 330 in pdf 1.7 */
- p->pole[1][1] = pdf_computetensorinterior(
+ p->pole[1][1] = pdf_compute_tensor_interior(
p->pole[0][0], p->pole[0][1], p->pole[1][0], p->pole[0][3],
p->pole[3][0], p->pole[3][1], p->pole[1][3], p->pole[3][3]);
- p->pole[1][2] = pdf_computetensorinterior(
+ p->pole[1][2] = pdf_compute_tensor_interior(
p->pole[0][3], p->pole[0][2], p->pole[1][3], p->pole[0][0],
p->pole[3][3], p->pole[3][2], p->pole[1][0], p->pole[3][0]);
- p->pole[2][1] = pdf_computetensorinterior(
+ p->pole[2][1] = pdf_compute_tensor_interior(
p->pole[3][0], p->pole[3][1], p->pole[2][0], p->pole[3][3],
p->pole[0][0], p->pole[0][1], p->pole[2][3], p->pole[0][3]);
- p->pole[2][2] = pdf_computetensorinterior(
+ p->pole[2][2] = pdf_compute_tensor_interior(
p->pole[3][3], p->pole[3][2], p->pole[2][3], p->pole[3][0],
p->pole[0][3], p->pole[0][2], p->pole[2][0], p->pole[0][0]);
}
@@ -323,7 +323,7 @@ pdf_maketensorpatch(pdf_tensorpatch *p, int type, fz_point *pt)
/* Sample various functions into lookup tables */
static void
-pdf_samplecompositeshadefunction(fz_shade *shade, pdf_function *func, float t0, float t1)
+pdf_sample_composite_shade_function(fz_shade *shade, pdf_function *func, float t0, float t1)
{
int i;
float t;
@@ -331,13 +331,13 @@ pdf_samplecompositeshadefunction(fz_shade *shade, pdf_function *func, float t0,
for (i = 0; i < 256; i++)
{
t = t0 + (i / 255.0f) * (t1 - t0);
- pdf_evalfunction(func, &t, 1, shade->function[i], shade->colorspace->n);
+ pdf_eval_function(func, &t, 1, shade->function[i], shade->colorspace->n);
shade->function[i][shade->colorspace->n] = 1;
}
}
static void
-pdf_samplecomponentshadefunction(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
+pdf_sample_component_shade_function(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
{
int i, k;
float t;
@@ -346,25 +346,25 @@ pdf_samplecomponentshadefunction(fz_shade *shade, int funcs, pdf_function **func
{
t = t0 + (i / 255.0f) * (t1 - t0);
for (k = 0; k < funcs; k++)
- pdf_evalfunction(func[k], &t, 1, &shade->function[i][k], 1);
+ pdf_eval_function(func[k], &t, 1, &shade->function[i][k], 1);
shade->function[i][k] = 1;
}
}
static void
-pdf_sampleshadefunction(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
+pdf_sample_shade_function(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
{
- shade->usefunction = 1;
+ shade->use_function = 1;
if (funcs == 1)
- pdf_samplecompositeshadefunction(shade, func[0], t0, t1);
+ pdf_sample_composite_shade_function(shade, func[0], t0, t1);
else
- pdf_samplecomponentshadefunction(shade, funcs, func, t0, t1);
+ pdf_sample_component_shade_function(shade, funcs, func, t0, t1);
}
/* Type 1-3 -- Function-based, axial and radial shadings */
static void
-pdf_loadfunctionbasedshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_function *func)
+pdf_load_function_based_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_function *func)
{
fz_obj *obj;
float x0, y0, x1, y1;
@@ -375,23 +375,23 @@ pdf_loadfunctionbasedshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_
float xn, yn;
int i;
- pdf_logshade("load type1 (function-based) shading\n");
+ pdf_log_shade("load type1 (function-based) shading\n");
x0 = y0 = 0;
x1 = y1 = 1;
- obj = fz_dictgets(dict, "Domain");
- if (fz_arraylen(obj) == 4)
+ obj = fz_dict_gets(dict, "Domain");
+ if (fz_array_len(obj) == 4)
{
- x0 = fz_toreal(fz_arrayget(obj, 0));
- x1 = fz_toreal(fz_arrayget(obj, 1));
- y0 = fz_toreal(fz_arrayget(obj, 2));
- y1 = fz_toreal(fz_arrayget(obj, 3));
+ x0 = fz_to_real(fz_array_get(obj, 0));
+ x1 = fz_to_real(fz_array_get(obj, 1));
+ y0 = fz_to_real(fz_array_get(obj, 2));
+ y1 = fz_to_real(fz_array_get(obj, 3));
}
matrix = fz_identity;
- obj = fz_dictgets(dict, "Matrix");
- if (fz_arraylen(obj) == 6)
- matrix = pdf_tomatrix(obj);
+ obj = fz_dict_gets(dict, "Matrix");
+ if (fz_array_len(obj) == 6)
+ matrix = pdf_to_matrix(obj);
for (yy = 0; yy < FUNSEGS; yy++)
{
@@ -415,22 +415,22 @@ pdf_loadfunctionbasedshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_
fv[0] = v[i].x;
fv[1] = v[i].y;
- pdf_evalfunction(func, fv, 2, v[i].c, shade->colorspace->n);
+ pdf_eval_function(func, fv, 2, v[i].c, shade->colorspace->n);
pt.x = v[i].x;
pt.y = v[i].y;
- pt = fz_transformpoint(matrix, pt);
+ pt = fz_transform_point(matrix, pt);
v[i].x = pt.x;
v[i].y = pt.y;
}
- pdf_addquad(shade, &v[0], &v[1], &v[2], &v[3]);
+ pdf_add_quad(shade, &v[0], &v[1], &v[2], &v[3]);
}
}
}
static void
-pdf_loadaxialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func)
+pdf_load_axial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func)
{
fz_obj *obj;
float d0, d1;
@@ -438,32 +438,32 @@ pdf_loadaxialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, p
float x0, y0, x1, y1;
struct vertex p1, p2;
- pdf_logshade("load type2 (axial) shading\n");
+ pdf_log_shade("load type2 (axial) shading\n");
- obj = fz_dictgets(dict, "Coords");
- x0 = fz_toreal(fz_arrayget(obj, 0));
- y0 = fz_toreal(fz_arrayget(obj, 1));
- x1 = fz_toreal(fz_arrayget(obj, 2));
- y1 = fz_toreal(fz_arrayget(obj, 3));
+ obj = fz_dict_gets(dict, "Coords");
+ x0 = fz_to_real(fz_array_get(obj, 0));
+ y0 = fz_to_real(fz_array_get(obj, 1));
+ x1 = fz_to_real(fz_array_get(obj, 2));
+ y1 = fz_to_real(fz_array_get(obj, 3));
d0 = 0;
d1 = 1;
- obj = fz_dictgets(dict, "Domain");
- if (fz_arraylen(obj) == 2)
+ obj = fz_dict_gets(dict, "Domain");
+ if (fz_array_len(obj) == 2)
{
- d0 = fz_toreal(fz_arrayget(obj, 0));
- d1 = fz_toreal(fz_arrayget(obj, 1));
+ d0 = fz_to_real(fz_array_get(obj, 0));
+ d1 = fz_to_real(fz_array_get(obj, 1));
}
e0 = e1 = 0;
- obj = fz_dictgets(dict, "Extend");
- if (fz_arraylen(obj) == 2)
+ obj = fz_dict_gets(dict, "Extend");
+ if (fz_array_len(obj) == 2)
{
- e0 = fz_tobool(fz_arrayget(obj, 0));
- e1 = fz_tobool(fz_arrayget(obj, 1));
+ e0 = fz_to_bool(fz_array_get(obj, 0));
+ e1 = fz_to_bool(fz_array_get(obj, 1));
}
- pdf_sampleshadefunction(shade, funcs, func, d0, d1);
+ pdf_sample_shade_function(shade, funcs, func, d0, d1);
shade->type = FZ_LINEAR;
@@ -473,16 +473,16 @@ pdf_loadaxialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, p
p1.x = x0;
p1.y = y0;
p1.c[0] = 0;
- pdf_addvertex(shade, &p1);
+ pdf_add_vertex(shade, &p1);
p2.x = x1;
p2.y = y1;
p2.c[0] = 0;
- pdf_addvertex(shade, &p2);
+ pdf_add_vertex(shade, &p2);
}
static void
-pdf_loadradialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func)
+pdf_load_radial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func)
{
fz_obj *obj;
float d0, d1;
@@ -490,34 +490,34 @@ pdf_loadradialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs,
float x0, y0, r0, x1, y1, r1;
struct vertex p1, p2;
- pdf_logshade("load type3 (radial) shading\n");
+ pdf_log_shade("load type3 (radial) shading\n");
- obj = fz_dictgets(dict, "Coords");
- x0 = fz_toreal(fz_arrayget(obj, 0));
- y0 = fz_toreal(fz_arrayget(obj, 1));
- r0 = fz_toreal(fz_arrayget(obj, 2));
- x1 = fz_toreal(fz_arrayget(obj, 3));
- y1 = fz_toreal(fz_arrayget(obj, 4));
- r1 = fz_toreal(fz_arrayget(obj, 5));
+ obj = fz_dict_gets(dict, "Coords");
+ x0 = fz_to_real(fz_array_get(obj, 0));
+ y0 = fz_to_real(fz_array_get(obj, 1));
+ r0 = fz_to_real(fz_array_get(obj, 2));
+ x1 = fz_to_real(fz_array_get(obj, 3));
+ y1 = fz_to_real(fz_array_get(obj, 4));
+ r1 = fz_to_real(fz_array_get(obj, 5));
d0 = 0;
d1 = 1;
- obj = fz_dictgets(dict, "Domain");
- if (fz_arraylen(obj) == 2)
+ obj = fz_dict_gets(dict, "Domain");
+ if (fz_array_len(obj) == 2)
{
- d0 = fz_toreal(fz_arrayget(obj, 0));
- d1 = fz_toreal(fz_arrayget(obj, 1));
+ d0 = fz_to_real(fz_array_get(obj, 0));
+ d1 = fz_to_real(fz_array_get(obj, 1));
}
e0 = e1 = 0;
- obj = fz_dictgets(dict, "Extend");
- if (fz_arraylen(obj) == 2)
+ obj = fz_dict_gets(dict, "Extend");
+ if (fz_array_len(obj) == 2)
{
- e0 = fz_tobool(fz_arrayget(obj, 0));
- e1 = fz_tobool(fz_arrayget(obj, 1));
+ e0 = fz_to_bool(fz_array_get(obj, 0));
+ e1 = fz_to_bool(fz_array_get(obj, 1));
}
- pdf_sampleshadefunction(shade, funcs, func, d0, d1);
+ pdf_sample_shade_function(shade, funcs, func, d0, d1);
shade->type = FZ_RADIAL;
@@ -527,25 +527,25 @@ pdf_loadradialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs,
p1.x = x0;
p1.y = y0;
p1.c[0] = r0;
- pdf_addvertex(shade, &p1);
+ pdf_add_vertex(shade, &p1);
p2.x = x1;
p2.y = y1;
p2.c[0] = r1;
- pdf_addvertex(shade, &p2);
+ pdf_add_vertex(shade, &p2);
}
/* Type 4-7 -- Triangle and patch mesh shadings */
static inline float
-readsample(fz_stream *stream, int bits, float min, float max)
+read_sample(fz_stream *stream, int bits, float min, float max)
{
/* we use pow(2,x) because (1<<x) would overflow the math on 32-bit samples */
float bitscale = 1 / (powf(2, bits) - 1);
- return min + fz_readbits(stream, bits) * (max - min) * bitscale;
+ return min + fz_read_bits(stream, bits) * (max - min) * bitscale;
}
-struct meshparams
+struct mesh_params
{
int vprow;
int bpflag;
@@ -553,41 +553,41 @@ struct meshparams
int bpcomp;
float x0, x1;
float y0, y1;
- float c0[FZ_MAXCOLORS];
- float c1[FZ_MAXCOLORS];
+ float c0[FZ_MAX_COLORS];
+ float c1[FZ_MAX_COLORS];
};
static void
-pdf_loadmeshparams(pdf_xref *xref, fz_obj *dict, struct meshparams *p)
+pdf_load_mesh_params(pdf_xref *xref, fz_obj *dict, struct mesh_params *p)
{
fz_obj *obj;
int i, n;
p->x0 = p->y0 = 0;
p->x1 = p->y1 = 1;
- for (i = 0; i < FZ_MAXCOLORS; i++)
+ for (i = 0; i < FZ_MAX_COLORS; i++)
{
p->c0[i] = 0;
p->c1[i] = 1;
}
- p->vprow = fz_toint(fz_dictgets(dict, "VerticesPerRow"));
- p->bpflag = fz_toint(fz_dictgets(dict, "BitsPerFlag"));
- p->bpcoord = fz_toint(fz_dictgets(dict, "BitsPerCoordinate"));
- p->bpcomp = fz_toint(fz_dictgets(dict, "BitsPerComponent"));
+ p->vprow = fz_to_int(fz_dict_gets(dict, "VerticesPerRow"));
+ p->bpflag = fz_to_int(fz_dict_gets(dict, "BitsPerFlag"));
+ p->bpcoord = fz_to_int(fz_dict_gets(dict, "BitsPerCoordinate"));
+ p->bpcomp = fz_to_int(fz_dict_gets(dict, "BitsPerComponent"));
- obj = fz_dictgets(dict, "Decode");
- if (fz_arraylen(obj) >= 6)
+ obj = fz_dict_gets(dict, "Decode");
+ if (fz_array_len(obj) >= 6)
{
- n = (fz_arraylen(obj) - 4) / 2;
- p->x0 = fz_toreal(fz_arrayget(obj, 0));
- p->x1 = fz_toreal(fz_arrayget(obj, 1));
- p->y0 = fz_toreal(fz_arrayget(obj, 2));
- p->y1 = fz_toreal(fz_arrayget(obj, 3));
+ n = (fz_array_len(obj) - 4) / 2;
+ p->x0 = fz_to_real(fz_array_get(obj, 0));
+ p->x1 = fz_to_real(fz_array_get(obj, 1));
+ p->y0 = fz_to_real(fz_array_get(obj, 2));
+ p->y1 = fz_to_real(fz_array_get(obj, 3));
for (i = 0; i < n; i++)
{
- p->c0[i] = fz_toreal(fz_arrayget(obj, 4 + i * 2));
- p->c1[i] = fz_toreal(fz_arrayget(obj, 5 + i * 2));
+ p->c0[i] = fz_to_real(fz_array_get(obj, 4 + i * 2));
+ p->c1[i] = fz_to_real(fz_array_get(obj, 5 + i * 2));
}
}
@@ -608,89 +608,89 @@ pdf_loadmeshparams(pdf_xref *xref, fz_obj *dict, struct meshparams *p)
}
static void
-pdf_loadtype4shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
+pdf_load_type4_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
int funcs, pdf_function **func, fz_stream *stream)
{
- struct meshparams p;
+ struct mesh_params p;
struct vertex va, vb, vc, vd;
int ncomp;
int flag;
int i;
- pdf_logshade("load type4 (free-form triangle mesh) shading\n");
+ pdf_log_shade("load type4 (free-form triangle mesh) shading\n");
- pdf_loadmeshparams(xref, dict, &p);
+ pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
- pdf_sampleshadefunction(shade, funcs, func, p.c0[0], p.c1[0]);
+ pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
- while (!fz_iseofbits(stream))
+ while (!fz_is_eof_bits(stream))
{
- flag = fz_readbits(stream, p.bpflag);
- vd.x = readsample(stream, p.bpcoord, p.x0, p.x1);
- vd.y = readsample(stream, p.bpcoord, p.y0, p.y1);
+ flag = fz_read_bits(stream, p.bpflag);
+ vd.x = read_sample(stream, p.bpcoord, p.x0, p.x1);
+ vd.y = read_sample(stream, p.bpcoord, p.y0, p.y1);
for (i = 0; i < ncomp; i++)
- vd.c[i] = readsample(stream, p.bpcomp, p.c0[i], p.c1[i]);
+ vd.c[i] = read_sample(stream, p.bpcomp, p.c0[i], p.c1[i]);
switch (flag)
{
case 0: /* start new triangle */
va = vd;
- fz_readbits(stream, p.bpflag);
- vb.x = readsample(stream, p.bpcoord, p.x0, p.x1);
- vb.y = readsample(stream, p.bpcoord, p.y0, p.y1);
+ fz_read_bits(stream, p.bpflag);
+ vb.x = read_sample(stream, p.bpcoord, p.x0, p.x1);
+ vb.y = read_sample(stream, p.bpcoord, p.y0, p.y1);
for (i = 0; i < ncomp; i++)
- vb.c[i] = readsample(stream, p.bpcomp, p.c0[i], p.c1[i]);
+ vb.c[i] = read_sample(stream, p.bpcomp, p.c0[i], p.c1[i]);
- fz_readbits(stream, p.bpflag);
- vc.x = readsample(stream, p.bpcoord, p.x0, p.x1);
- vc.y = readsample(stream, p.bpcoord, p.y0, p.y1);
+ fz_read_bits(stream, p.bpflag);
+ vc.x = read_sample(stream, p.bpcoord, p.x0, p.x1);
+ vc.y = read_sample(stream, p.bpcoord, p.y0, p.y1);
for (i = 0; i < ncomp; i++)
- vc.c[i] = readsample(stream, p.bpcomp, p.c0[i], p.c1[i]);
+ vc.c[i] = read_sample(stream, p.bpcomp, p.c0[i], p.c1[i]);
- pdf_addtriangle(shade, &va, &vb, &vc);
+ pdf_add_triangle(shade, &va, &vb, &vc);
break;
case 1: /* Vb, Vc, Vd */
va = vb;
vb = vc;
vc = vd;
- pdf_addtriangle(shade, &va, &vb, &vc);
+ pdf_add_triangle(shade, &va, &vb, &vc);
break;
case 2: /* Va, Vc, Vd */
vb = vc;
vc = vd;
- pdf_addtriangle(shade, &va, &vb, &vc);
+ pdf_add_triangle(shade, &va, &vb, &vc);
break;
}
}
}
static void
-pdf_loadtype5shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
+pdf_load_type5_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
int funcs, pdf_function **func, fz_stream *stream)
{
- struct meshparams p;
+ struct mesh_params p;
struct vertex *buf, *ref;
int first;
int ncomp;
int i, k;
- pdf_logshade("load type5 (lattice-form triangle mesh) shading\n");
+ pdf_log_shade("load type5 (lattice-form triangle mesh) shading\n");
- pdf_loadmeshparams(xref, dict, &p);
+ pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
- pdf_sampleshadefunction(shade, funcs, func, p.c0[0], p.c1[0]);
+ pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
@@ -699,19 +699,19 @@ pdf_loadtype5shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
buf = fz_calloc(p.vprow, sizeof(struct vertex));
first = 1;
- while (!fz_iseofbits(stream))
+ while (!fz_is_eof_bits(stream))
{
for (i = 0; i < p.vprow; i++)
{
- buf[i].x = readsample(stream, p.bpcoord, p.x0, p.x1);
- buf[i].y = readsample(stream, p.bpcoord, p.y0, p.y1);
+ buf[i].x = read_sample(stream, p.bpcoord, p.x0, p.x1);
+ buf[i].y = read_sample(stream, p.bpcoord, p.y0, p.y1);
for (k = 0; k < ncomp; k++)
- buf[i].c[k] = readsample(stream, p.bpcomp, p.c0[k], p.c1[k]);
+ buf[i].c[k] = read_sample(stream, p.bpcomp, p.c0[k], p.c1[k]);
}
if (!first)
for (i = 0; i < p.vprow - 1; i++)
- pdf_addquad(shade,
+ pdf_add_quad(shade,
&ref[i], &ref[i+1], &buf[i+1], &buf[i]);
memcpy(ref, buf, p.vprow * sizeof(struct vertex));
@@ -725,39 +725,39 @@ pdf_loadtype5shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
/* Type 6 & 7 -- Patch mesh shadings */
static void
-pdf_loadtype6shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
+pdf_load_type6_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
int funcs, pdf_function **func, fz_stream *stream)
{
- struct meshparams p;
+ struct mesh_params p;
int haspatch, hasprevpatch;
- float prevc[4][FZ_MAXCOLORS];
+ float prevc[4][FZ_MAX_COLORS];
fz_point prevp[12];
int ncomp;
int i, k;
- pdf_logshade("load type6 (coons patch mesh) shading\n");
+ pdf_log_shade("load type6 (coons patch mesh) shading\n");
- pdf_loadmeshparams(xref, dict, &p);
+ pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
- pdf_sampleshadefunction(shade, funcs, func, p.c0[0], p.c1[0]);
+ pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
hasprevpatch = 0;
- while (!fz_iseofbits(stream))
+ while (!fz_is_eof_bits(stream))
{
- float c[4][FZ_MAXCOLORS];
+ float c[4][FZ_MAX_COLORS];
fz_point v[12];
int startcolor;
int startpt;
int flag;
- flag = fz_readbits(stream, p.bpflag);
+ flag = fz_read_bits(stream, p.bpflag);
if (flag == 0)
{
@@ -772,14 +772,14 @@ pdf_loadtype6shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
for (i = startpt; i < 12; i++)
{
- v[i].x = readsample(stream, p.bpcoord, p.x0, p.x1);
- v[i].y = readsample(stream, p.bpcoord, p.y0, p.y1);
+ v[i].x = read_sample(stream, p.bpcoord, p.x0, p.x1);
+ v[i].y = read_sample(stream, p.bpcoord, p.y0, p.y1);
}
for (i = startcolor; i < 4; i++)
{
for (k = 0; k < ncomp; k++)
- c[i][k] = readsample(stream, p.bpcomp, p.c0[k], p.c1[k]);
+ c[i][k] = read_sample(stream, p.bpcomp, p.c0[k], p.c1[k]);
}
haspatch = 0;
@@ -824,14 +824,14 @@ pdf_loadtype6shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
if (haspatch)
{
- pdf_tensorpatch patch;
+ pdf_tensor_patch patch;
- pdf_maketensorpatch(&patch, 6, v);
+ pdf_make_tensor_patch(&patch, 6, v);
for (i = 0; i < 4; i++)
memcpy(patch.color[i], c[i], ncomp * sizeof(float));
- drawpatch(shade, &patch, SUBDIV, SUBDIV);
+ draw_patch(shade, &patch, SUBDIV, SUBDIV);
for (i = 0; i < 12; i++)
prevp[i] = v[i];
@@ -845,39 +845,39 @@ pdf_loadtype6shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
}
static void
-pdf_loadtype7shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
+pdf_load_type7_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
int funcs, pdf_function **func, fz_stream *stream)
{
- struct meshparams p;
+ struct mesh_params p;
int haspatch, hasprevpatch;
- float prevc[4][FZ_MAXCOLORS];
+ float prevc[4][FZ_MAX_COLORS];
fz_point prevp[16];
int ncomp;
int i, k;
- pdf_logshade("load type7 (tensor-product patch mesh) shading\n");
+ pdf_log_shade("load type7 (tensor-product patch mesh) shading\n");
- pdf_loadmeshparams(xref, dict, &p);
+ pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
- pdf_sampleshadefunction(shade, funcs, func, p.c0[0], p.c1[0]);
+ pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
hasprevpatch = 0;
- while (!fz_iseofbits(stream))
+ while (!fz_is_eof_bits(stream))
{
- float c[4][FZ_MAXCOLORS];
+ float c[4][FZ_MAX_COLORS];
fz_point v[16];
int startcolor;
int startpt;
int flag;
- flag = fz_readbits(stream, p.bpflag);
+ flag = fz_read_bits(stream, p.bpflag);
if (flag == 0)
{
@@ -892,14 +892,14 @@ pdf_loadtype7shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
for (i = startpt; i < 16; i++)
{
- v[i].x = readsample(stream, p.bpcoord, p.x0, p.x1);
- v[i].y = readsample(stream, p.bpcoord, p.y0, p.y1);
+ v[i].x = read_sample(stream, p.bpcoord, p.x0, p.x1);
+ v[i].y = read_sample(stream, p.bpcoord, p.y0, p.y1);
}
for (i = startcolor; i < 4; i++)
{
for (k = 0; k < ncomp; k++)
- c[i][k] = readsample(stream, p.bpcomp, p.c0[k], p.c1[k]);
+ c[i][k] = read_sample(stream, p.bpcomp, p.c0[k], p.c1[k]);
}
haspatch = 0;
@@ -944,20 +944,20 @@ pdf_loadtype7shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
if (haspatch)
{
- pdf_tensorpatch patch;
+ pdf_tensor_patch patch;
- pdf_maketensorpatch(&patch, 7, v);
+ pdf_make_tensor_patch(&patch, 7, v);
for (i = 0; i < 4; i++)
memcpy(patch.color[i], c[i], ncomp * sizeof(float));
- drawpatch(shade, &patch, SUBDIV, SUBDIV);
+ draw_patch(shade, &patch, SUBDIV, SUBDIV);
for (i = 0; i < 16; i++)
prevp[i] = v[i];
for (i = 0; i < 4; i++)
- memcpy(prevc[i], c[i], FZ_MAXCOLORS * sizeof(float));
+ memcpy(prevc[i], c[i], FZ_MAX_COLORS * sizeof(float));
hasprevpatch = 1;
}
@@ -967,84 +967,84 @@ pdf_loadtype7shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
/* Load all of the shading dictionary parameters, then switch on the shading type. */
static fz_error
-pdf_loadshadingdict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix transform)
+pdf_load_shading_dict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix transform)
{
fz_error error;
fz_shade *shade;
- pdf_function *func[FZ_MAXCOLORS] = { nil };
- fz_stream *stream = nil;
+ pdf_function *func[FZ_MAX_COLORS] = { NULL };
+ fz_stream *stream = NULL;
fz_obj *obj;
int funcs;
int type;
int i;
- pdf_logshade("load shading dict (%d %d R) {\n", fz_tonum(dict), fz_togen(dict));
+ pdf_log_shade("load shading dict (%d %d R) {\n", fz_to_num(dict), fz_to_gen(dict));
shade = fz_malloc(sizeof(fz_shade));
shade->refs = 1;
shade->type = FZ_MESH;
- shade->usebackground = 0;
- shade->usefunction = 0;
+ shade->use_background = 0;
+ shade->use_function = 0;
shade->matrix = transform;
- shade->bbox = fz_infiniterect;
+ shade->bbox = fz_infinite_rect;
shade->extend[0] = 0;
shade->extend[1] = 0;
- shade->meshlen = 0;
- shade->meshcap = 0;
- shade->mesh = nil;
+ shade->mesh_len = 0;
+ shade->mesh_cap = 0;
+ shade->mesh = NULL;
- shade->colorspace = nil;
+ shade->colorspace = NULL;
funcs = 0;
- obj = fz_dictgets(dict, "ShadingType");
- type = fz_toint(obj);
+ obj = fz_dict_gets(dict, "ShadingType");
+ type = fz_to_int(obj);
- obj = fz_dictgets(dict, "ColorSpace");
+ obj = fz_dict_gets(dict, "ColorSpace");
if (!obj)
{
- fz_dropshade(shade);
+ fz_drop_shade(shade);
return fz_throw("shading colorspace is missing");
}
- error = pdf_loadcolorspace(&shade->colorspace, xref, obj);
+ error = pdf_load_colorspace(&shade->colorspace, xref, obj);
if (error)
{
- fz_dropshade(shade);
- return fz_rethrow(error, "cannot load colorspace (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ fz_drop_shade(shade);
+ return fz_rethrow(error, "cannot load colorspace (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
}
- pdf_logshade("colorspace %s\n", shade->colorspace->name);
+ pdf_log_shade("colorspace %s\n", shade->colorspace->name);
- obj = fz_dictgets(dict, "Background");
+ obj = fz_dict_gets(dict, "Background");
if (obj)
{
- pdf_logshade("background\n");
- shade->usebackground = 1;
+ pdf_log_shade("background\n");
+ shade->use_background = 1;
for (i = 0; i < shade->colorspace->n; i++)
- shade->background[i] = fz_toreal(fz_arrayget(obj, i));
+ shade->background[i] = fz_to_real(fz_array_get(obj, i));
}
- obj = fz_dictgets(dict, "BBox");
- if (fz_isarray(obj))
+ obj = fz_dict_gets(dict, "BBox");
+ if (fz_is_array(obj))
{
- shade->bbox = pdf_torect(obj);
+ shade->bbox = pdf_to_rect(obj);
}
- obj = fz_dictgets(dict, "Function");
- if (fz_isdict(obj))
+ obj = fz_dict_gets(dict, "Function");
+ if (fz_is_dict(obj))
{
funcs = 1;
- error = pdf_loadfunction(&func[0], xref, obj);
+ error = pdf_load_function(&func[0], xref, obj);
if (error)
{
- error = fz_rethrow(error, "cannot load shading function (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ error = fz_rethrow(error, "cannot load shading function (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
goto cleanup;
}
}
- else if (fz_isarray(obj))
+ else if (fz_is_array(obj))
{
- funcs = fz_arraylen(obj);
+ funcs = fz_array_len(obj);
if (funcs != 1 && funcs != shade->colorspace->n)
{
error = fz_throw("incorrect number of shading functions");
@@ -1053,10 +1053,10 @@ pdf_loadshadingdict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix t
for (i = 0; i < funcs; i++)
{
- error = pdf_loadfunction(&func[i], xref, fz_arrayget(obj, i));
+ error = pdf_load_function(&func[i], xref, fz_array_get(obj, i));
if (error)
{
- error = fz_rethrow(error, "cannot load shading function (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ error = fz_rethrow(error, "cannot load shading function (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
goto cleanup;
}
}
@@ -1064,23 +1064,23 @@ pdf_loadshadingdict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix t
if (type >= 4 && type <= 7)
{
- error = pdf_openstream(&stream, xref, fz_tonum(dict), fz_togen(dict));
+ error = pdf_open_stream(&stream, xref, fz_to_num(dict), fz_to_gen(dict));
if (error)
{
- error = fz_rethrow(error, "cannot open shading stream (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ error = fz_rethrow(error, "cannot open shading stream (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
goto cleanup;
}
}
switch (type)
{
- case 1: pdf_loadfunctionbasedshading(shade, xref, dict, func[0]); break;
- case 2: pdf_loadaxialshading(shade, xref, dict, funcs, func); break;
- case 3: pdf_loadradialshading(shade, xref, dict, funcs, func); break;
- case 4: pdf_loadtype4shade(shade, xref, dict, funcs, func, stream); break;
- case 5: pdf_loadtype5shade(shade, xref, dict, funcs, func, stream); break;
- case 6: pdf_loadtype6shade(shade, xref, dict, funcs, func, stream); break;
- case 7: pdf_loadtype7shade(shade, xref, dict, funcs, func, stream); break;
+ case 1: pdf_load_function_based_shading(shade, xref, dict, func[0]); break;
+ case 2: pdf_load_axial_shading(shade, xref, dict, funcs, func); break;
+ case 3: pdf_load_radial_shading(shade, xref, dict, funcs, func); break;
+ case 4: pdf_load_type4_shade(shade, xref, dict, funcs, func, stream); break;
+ case 5: pdf_load_type5_shade(shade, xref, dict, funcs, func, stream); break;
+ case 6: pdf_load_type6_shade(shade, xref, dict, funcs, func, stream); break;
+ case 7: pdf_load_type7_shade(shade, xref, dict, funcs, func, stream); break;
default:
error = fz_throw("unknown shading type: %d", type);
goto cleanup;
@@ -1090,9 +1090,9 @@ pdf_loadshadingdict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix t
fz_close(stream);
for (i = 0; i < funcs; i++)
if (func[i])
- pdf_dropfunction(func[i]);
+ pdf_drop_function(func[i]);
- pdf_logshade("}\n");
+ pdf_log_shade("}\n");
*shadep = shade;
return fz_okay;
@@ -1102,35 +1102,35 @@ cleanup:
fz_close(stream);
for (i = 0; i < funcs; i++)
if (func[i])
- pdf_dropfunction(func[i]);
- fz_dropshade(shade);
+ pdf_drop_function(func[i]);
+ fz_drop_shade(shade);
- return fz_rethrow(error, "cannot load shading type %d (%d %d R)", type, fz_tonum(dict), fz_togen(dict));
+ return fz_rethrow(error, "cannot load shading type %d (%d %d R)", type, fz_to_num(dict), fz_to_gen(dict));
}
fz_error
-pdf_loadshading(fz_shade **shadep, pdf_xref *xref, fz_obj *dict)
+pdf_load_shading(fz_shade **shadep, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
fz_matrix mat;
fz_obj *obj;
- if ((*shadep = pdf_finditem(xref->store, fz_dropshade, dict)))
+ if ((*shadep = pdf_find_item(xref->store, fz_drop_shade, dict)))
{
- fz_keepshade(*shadep);
+ fz_keep_shade(*shadep);
return fz_okay;
}
/* Type 2 pattern dictionary */
- if (fz_dictgets(dict, "PatternType"))
+ if (fz_dict_gets(dict, "PatternType"))
{
- pdf_logshade("load shading pattern (%d %d R) {\n", fz_tonum(dict), fz_togen(dict));
+ pdf_log_shade("load shading pattern (%d %d R) {\n", fz_to_num(dict), fz_to_gen(dict));
- obj = fz_dictgets(dict, "Matrix");
+ obj = fz_dict_gets(dict, "Matrix");
if (obj)
{
- mat = pdf_tomatrix(obj);
- pdf_logshade("matrix [%g %g %g %g %g %g]\n",
+ mat = pdf_to_matrix(obj);
+ pdf_log_shade("matrix [%g %g %g %g %g %g]\n",
mat.a, mat.b, mat.c, mat.d, mat.e, mat.f);
}
else
@@ -1138,35 +1138,35 @@ pdf_loadshading(fz_shade **shadep, pdf_xref *xref, fz_obj *dict)
mat = fz_identity;
}
- obj = fz_dictgets(dict, "ExtGState");
+ obj = fz_dict_gets(dict, "ExtGState");
if (obj)
{
- if (fz_dictgets(obj, "CA") || fz_dictgets(obj, "ca"))
+ if (fz_dict_gets(obj, "CA") || fz_dict_gets(obj, "ca"))
{
fz_warn("shading with alpha not supported");
}
}
- obj = fz_dictgets(dict, "Shading");
+ obj = fz_dict_gets(dict, "Shading");
if (!obj)
return fz_throw("syntaxerror: missing shading dictionary");
- error = pdf_loadshadingdict(shadep, xref, obj, mat);
+ error = pdf_load_shading_dict(shadep, xref, obj, mat);
if (error)
- return fz_rethrow(error, "cannot load shading dictionary (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ return fz_rethrow(error, "cannot load shading dictionary (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
- pdf_logshade("}\n");
+ pdf_log_shade("}\n");
}
/* Naked shading dictionary */
else
{
- error = pdf_loadshadingdict(shadep, xref, dict, fz_identity);
+ error = pdf_load_shading_dict(shadep, xref, dict, fz_identity);
if (error)
- return fz_rethrow(error, "cannot load shading dictionary (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ return fz_rethrow(error, "cannot load shading dictionary (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
- pdf_storeitem(xref->store, fz_keepshade, fz_dropshade, dict, *shadep);
+ pdf_store_item(xref->store, fz_keep_shade, fz_drop_shade, dict, *shadep);
return fz_okay;
}
diff --git a/pdf/pdf_store.c b/pdf/pdf_store.c
index d6be2088..cccfc76c 100644
--- a/pdf/pdf_store.c
+++ b/pdf/pdf_store.c
@@ -5,7 +5,7 @@ typedef struct pdf_item_s pdf_item;
struct pdf_item_s
{
- void *dropfunc;
+ void *drop_func;
fz_obj *key;
void *val;
int age;
@@ -14,29 +14,29 @@ struct pdf_item_s
struct refkey
{
- void *dropfunc;
+ void *drop_func;
int num;
int gen;
};
struct pdf_store_s
{
- fz_hashtable *hash; /* hash for num/gen keys */
+ fz_hash_table *hash; /* hash for num/gen keys */
pdf_item *root; /* linked list for everything else */
};
pdf_store *
-pdf_newstore(void)
+pdf_new_store(void)
{
pdf_store *store;
store = fz_malloc(sizeof(pdf_store));
- store->hash = fz_newhash(4096, sizeof(struct refkey));
- store->root = nil;
+ store->hash = fz_new_hash_table(4096, sizeof(struct refkey));
+ store->root = NULL;
return store;
}
void
-pdf_storeitem(pdf_store *store, void *keepfunc, void *dropfunc, fz_obj *key, void *val)
+pdf_store_item(pdf_store *store, void *keepfunc, void *drop_func, fz_obj *key, void *val)
{
pdf_item *item;
@@ -44,47 +44,47 @@ pdf_storeitem(pdf_store *store, void *keepfunc, void *dropfunc, fz_obj *key, voi
return;
item = fz_malloc(sizeof(pdf_item));
- item->dropfunc = dropfunc;
- item->key = fz_keepobj(key);
+ item->drop_func = drop_func;
+ item->key = fz_keep_obj(key);
item->val = ((void*(*)(void*))keepfunc)(val);
item->age = 0;
- item->next = nil;
+ item->next = NULL;
- if (fz_isindirect(key))
+ if (fz_is_indirect(key))
{
struct refkey refkey;
- pdf_logrsrc("store item (%d %d R) ptr=%p\n", fz_tonum(key), fz_togen(key), val);
- refkey.dropfunc = dropfunc;
- refkey.num = fz_tonum(key);
- refkey.gen = fz_togen(key);
- fz_hashinsert(store->hash, &refkey, item);
+ pdf_log_rsrc("store item (%d %d R) ptr=%p\n", fz_to_num(key), fz_to_gen(key), val);
+ refkey.drop_func = drop_func;
+ refkey.num = fz_to_num(key);
+ refkey.gen = fz_to_gen(key);
+ fz_hash_insert(store->hash, &refkey, item);
}
else
{
- pdf_logrsrc("store item (...) = %p\n", val);
+ pdf_log_rsrc("store item (...) = %p\n", val);
item->next = store->root;
store->root = item;
}
}
void *
-pdf_finditem(pdf_store *store, void *dropfunc, fz_obj *key)
+pdf_find_item(pdf_store *store, void *drop_func, fz_obj *key)
{
struct refkey refkey;
pdf_item *item;
if (!store)
- return nil;
+ return NULL;
- if (key == nil)
- return nil;
+ if (key == NULL)
+ return NULL;
- if (fz_isindirect(key))
+ if (fz_is_indirect(key))
{
- refkey.dropfunc = dropfunc;
- refkey.num = fz_tonum(key);
- refkey.gen = fz_togen(key);
- item = fz_hashfind(store->hash, &refkey);
+ refkey.drop_func = drop_func;
+ refkey.num = fz_to_num(key);
+ refkey.gen = fz_to_gen(key);
+ item = fz_hash_find(store->hash, &refkey);
if (item)
{
item->age = 0;
@@ -95,7 +95,7 @@ pdf_finditem(pdf_store *store, void *dropfunc, fz_obj *key)
{
for (item = store->root; item; item = item->next)
{
- if (item->dropfunc == dropfunc && !fz_objcmp(item->key, key))
+ if (item->drop_func == drop_func && !fz_objcmp(item->key, key))
{
item->age = 0;
return item->val;
@@ -103,43 +103,43 @@ pdf_finditem(pdf_store *store, void *dropfunc, fz_obj *key)
}
}
- return nil;
+ return NULL;
}
void
-pdf_removeitem(pdf_store *store, void *dropfunc, fz_obj *key)
+pdf_remove_item(pdf_store *store, void *drop_func, fz_obj *key)
{
struct refkey refkey;
pdf_item *item, *prev, *next;
- if (fz_isindirect(key))
+ if (fz_is_indirect(key))
{
- refkey.dropfunc = dropfunc;
- refkey.num = fz_tonum(key);
- refkey.gen = fz_togen(key);
- item = fz_hashfind(store->hash, &refkey);
+ refkey.drop_func = drop_func;
+ refkey.num = fz_to_num(key);
+ refkey.gen = fz_to_gen(key);
+ item = fz_hash_find(store->hash, &refkey);
if (item)
{
- fz_hashremove(store->hash, &refkey);
- ((void(*)(void*))item->dropfunc)(item->val);
- fz_dropobj(item->key);
+ fz_hash_remove(store->hash, &refkey);
+ ((void(*)(void*))item->drop_func)(item->val);
+ fz_drop_obj(item->key);
fz_free(item);
}
}
else
{
- prev = nil;
+ prev = NULL;
for (item = store->root; item; item = next)
{
next = item->next;
- if (item->dropfunc == dropfunc && !fz_objcmp(item->key, key))
+ if (item->drop_func == drop_func && !fz_objcmp(item->key, key))
{
if (!prev)
store->root = next;
else
prev->next = next;
- ((void(*)(void*))item->dropfunc)(item->val);
- fz_dropobj(item->key);
+ ((void(*)(void*))item->drop_func)(item->val);
+ fz_drop_obj(item->key);
fz_free(item);
}
else
@@ -149,27 +149,27 @@ pdf_removeitem(pdf_store *store, void *dropfunc, fz_obj *key)
}
void
-pdf_agestore(pdf_store *store, int maxage)
+pdf_age_store(pdf_store *store, int maxage)
{
struct refkey *refkey;
pdf_item *item, *prev, *next;
int i;
- for (i = 0; i < fz_hashlen(store->hash); i++)
+ for (i = 0; i < fz_hash_len(store->hash); i++)
{
- refkey = fz_hashgetkey(store->hash, i);
- item = fz_hashgetval(store->hash, i);
+ refkey = fz_hash_get_key(store->hash, i);
+ item = fz_hash_get_val(store->hash, i);
if (item && ++item->age > maxage)
{
- fz_hashremove(store->hash, refkey);
- ((void(*)(void*))item->dropfunc)(item->val);
- fz_dropobj(item->key);
+ fz_hash_remove(store->hash, refkey);
+ ((void(*)(void*))item->drop_func)(item->val);
+ fz_drop_obj(item->key);
fz_free(item);
i--; /* items with same hash may move into place */
}
}
- prev = nil;
+ prev = NULL;
for (item = store->root; item; item = next)
{
next = item->next;
@@ -179,8 +179,8 @@ pdf_agestore(pdf_store *store, int maxage)
store->root = next;
else
prev->next = next;
- ((void(*)(void*))item->dropfunc)(item->val);
- fz_dropobj(item->key);
+ ((void(*)(void*))item->drop_func)(item->val);
+ fz_drop_obj(item->key);
fz_free(item);
}
else
@@ -189,15 +189,15 @@ pdf_agestore(pdf_store *store, int maxage)
}
void
-pdf_freestore(pdf_store *store)
+pdf_free_store(pdf_store *store)
{
- pdf_agestore(store, 0);
- fz_freehash(store->hash);
+ pdf_age_store(store, 0);
+ fz_free_hash(store->hash);
fz_free(store);
}
void
-pdf_debugstore(pdf_store *store)
+pdf_debug_store(pdf_store *store)
{
pdf_item *item;
pdf_item *next;
@@ -206,10 +206,10 @@ pdf_debugstore(pdf_store *store)
printf("-- resource store contents --\n");
- for (i = 0; i < fz_hashlen(store->hash); i++)
+ for (i = 0; i < fz_hash_len(store->hash); i++)
{
- refkey = fz_hashgetkey(store->hash, i);
- item = fz_hashgetval(store->hash, i);
+ refkey = fz_hash_get_key(store->hash, i);
+ item = fz_hash_get_val(store->hash, i);
if (item)
printf("store[%d] (%d %d R) = %p\n", i, refkey->num, refkey->gen, item->val);
}
@@ -218,7 +218,7 @@ pdf_debugstore(pdf_store *store)
{
next = item->next;
printf("store[*] ");
- fz_debugobj(item->key);
+ fz_debug_obj(item->key);
printf(" = %p\n", item->val);
}
}
diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c
index cae95a89..79b39d07 100644
--- a/pdf/pdf_stream.c
+++ b/pdf/pdf_stream.c
@@ -5,44 +5,44 @@
* Check if an object is a stream or not.
*/
int
-pdf_isstream(pdf_xref *xref, int num, int gen)
+pdf_is_stream(pdf_xref *xref, int num, int gen)
{
fz_error error;
if (num < 0 || num >= xref->len)
return 0;
- error = pdf_cacheobject(xref, num, gen);
+ error = pdf_cache_object(xref, num, gen);
if (error)
{
fz_catch(error, "cannot load object, ignoring error");
return 0;
}
- return xref->table[num].stmofs > 0;
+ return xref->table[num].stm_ofs > 0;
}
/*
* Scan stream dictionary for an explicit /Crypt filter
*/
static int
-pdf_streamhascrypt(fz_obj *stm)
+pdf_stream_has_crypt(fz_obj *stm)
{
fz_obj *filters;
fz_obj *obj;
int i;
- filters = fz_dictgetsa(stm, "Filter", "F");
+ filters = fz_dict_getsa(stm, "Filter", "F");
if (filters)
{
- if (!strcmp(fz_toname(filters), "Crypt"))
+ if (!strcmp(fz_to_name(filters), "Crypt"))
return 1;
- if (fz_isarray(filters))
+ if (fz_is_array(filters))
{
- for (i = 0; i < fz_arraylen(filters); i++)
+ for (i = 0; i < fz_array_len(filters); i++)
{
- obj = fz_arrayget(filters, i);
- if (!strcmp(fz_toname(obj), "Crypt"))
+ obj = fz_array_get(filters, i);
+ if (!strcmp(fz_to_name(obj), "Crypt"))
return 1;
}
}
@@ -54,58 +54,58 @@ pdf_streamhascrypt(fz_obj *stm)
* Create a filter given a name and param dictionary.
*/
static fz_stream *
-buildfilter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, int gen)
+build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, int gen)
{
fz_error error;
char *s;
- s = fz_toname(f);
+ s = fz_to_name(f);
if (!strcmp(s, "ASCIIHexDecode") || !strcmp(s, "AHx"))
- return fz_openahxd(chain);
+ return fz_open_ahxd(chain);
else if (!strcmp(s, "ASCII85Decode") || !strcmp(s, "A85"))
- return fz_opena85d(chain);
+ return fz_open_a85d(chain);
else if (!strcmp(s, "CCITTFaxDecode") || !strcmp(s, "CCF"))
- return fz_openfaxd(chain, p);
+ return fz_open_faxd(chain, p);
else if (!strcmp(s, "DCTDecode") || !strcmp(s, "DCT"))
- return fz_opendctd(chain, p);
+ return fz_open_dctd(chain, p);
else if (!strcmp(s, "RunLengthDecode") || !strcmp(s, "RL"))
- return fz_openrld(chain);
+ return fz_open_rld(chain);
else if (!strcmp(s, "FlateDecode") || !strcmp(s, "Fl"))
{
- fz_obj *obj = fz_dictgets(p, "Predictor");
- if (fz_toint(obj) > 1)
- return fz_openpredict(fz_openflated(chain), p);
- return fz_openflated(chain);
+ fz_obj *obj = fz_dict_gets(p, "Predictor");
+ if (fz_to_int(obj) > 1)
+ return fz_open_predict(fz_open_flated(chain), p);
+ return fz_open_flated(chain);
}
else if (!strcmp(s, "LZWDecode") || !strcmp(s, "LZW"))
{
- fz_obj *obj = fz_dictgets(p, "Predictor");
- if (fz_toint(obj) > 1)
- return fz_openpredict(fz_openlzwd(chain, p), p);
- return fz_openlzwd(chain, p);
+ fz_obj *obj = fz_dict_gets(p, "Predictor");
+ if (fz_to_int(obj) > 1)
+ return fz_open_predict(fz_open_lzwd(chain, p), p);
+ return fz_open_lzwd(chain, p);
}
else if (!strcmp(s, "JBIG2Decode"))
{
- fz_obj *obj = fz_dictgets(p, "JBIG2Globals");
+ fz_obj *obj = fz_dict_gets(p, "JBIG2Globals");
if (obj)
{
fz_buffer *globals;
- error = pdf_loadstream(&globals, xref, fz_tonum(obj), fz_togen(obj));
+ error = pdf_load_stream(&globals, xref, fz_to_num(obj), fz_to_gen(obj));
if (error)
fz_catch(error, "cannot load jbig2 global segments");
- chain = fz_openjbig2d(chain, globals);
- fz_dropbuffer(globals);
+ chain = fz_open_jbig2d(chain, globals);
+ fz_drop_buffer(globals);
return chain;
}
- return fz_openjbig2d(chain, nil);
+ return fz_open_jbig2d(chain, NULL);
}
else if (!strcmp(s, "JPXDecode"))
@@ -113,7 +113,7 @@ buildfilter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num,
else if (!strcmp(s, "Crypt"))
{
- pdf_cryptfilter cf;
+ pdf_crypt_filter cf;
fz_obj *name;
if (!xref->crypt)
@@ -122,17 +122,17 @@ buildfilter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num,
return chain;
}
- name = fz_dictgets(p, "Name");
- if (fz_isname(name) && strcmp(fz_toname(name), "Identity") != 0)
+ name = fz_dict_gets(p, "Name");
+ if (fz_is_name(name) && strcmp(fz_to_name(name), "Identity") != 0)
{
- fz_obj *obj = fz_dictget(xref->crypt->cf, name);
- if (fz_isdict(obj))
+ fz_obj *obj = fz_dict_get(xref->crypt->cf, name);
+ if (fz_is_dict(obj))
{
- error = pdf_parsecryptfilter(&cf, obj, xref->crypt->length);
+ error = pdf_parse_crypt_filter(&cf, obj, xref->crypt->length);
if (error)
- fz_catch(error, "cannot parse crypt filter (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ fz_catch(error, "cannot parse crypt filter (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
else
- return pdf_opencrypt(chain, xref->crypt, &cf, num, gen);
+ return pdf_open_crypt(chain, xref->crypt, &cf, num, gen);
}
}
@@ -149,17 +149,17 @@ buildfilter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num,
* Assume ownership of head.
*/
static fz_stream *
-buildfilterchain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int num, int gen)
+build_filter_chain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int num, int gen)
{
fz_obj *f;
fz_obj *p;
int i;
- for (i = 0; i < fz_arraylen(fs); i++)
+ for (i = 0; i < fz_array_len(fs); i++)
{
- f = fz_arrayget(fs, i);
- p = fz_arrayget(ps, i);
- chain = buildfilter(chain, xref, f, p, num, gen);
+ f = fz_array_get(fs, i);
+ p = fz_array_get(ps, i);
+ chain = build_filter(chain, xref, f, p, num, gen);
}
return chain;
@@ -171,20 +171,20 @@ buildfilterchain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int n
* stream length, followed by a decryption filter.
*/
static fz_stream *
-pdf_openrawfilter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen)
+pdf_open_raw_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen)
{
int hascrypt;
int len;
/* don't close chain when we close this filter */
- fz_keepstream(chain);
+ fz_keep_stream(chain);
- len = fz_toint(fz_dictgets(stmobj, "Length"));
- chain = fz_opennull(chain, len);
+ len = fz_to_int(fz_dict_gets(stmobj, "Length"));
+ chain = fz_open_null(chain, len);
- hascrypt = pdf_streamhascrypt(stmobj);
+ hascrypt = pdf_stream_has_crypt(stmobj);
if (xref->crypt && !hascrypt)
- chain = pdf_opencrypt(chain, xref->crypt, &xref->crypt->stmf, num, gen);
+ chain = pdf_open_crypt(chain, xref->crypt, &xref->crypt->stmf, num, gen);
return chain;
}
@@ -194,20 +194,20 @@ pdf_openrawfilter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int
* to stream length and decrypting.
*/
static fz_stream *
-pdf_openfilter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen)
+pdf_open_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen)
{
fz_obj *filters;
fz_obj *params;
- filters = fz_dictgetsa(stmobj, "Filter", "F");
- params = fz_dictgetsa(stmobj, "DecodeParms", "DP");
+ filters = fz_dict_getsa(stmobj, "Filter", "F");
+ params = fz_dict_getsa(stmobj, "DecodeParms", "DP");
- chain = pdf_openrawfilter(chain, xref, stmobj, num, gen);
+ chain = pdf_open_raw_filter(chain, xref, stmobj, num, gen);
- if (fz_isname(filters))
- return buildfilter(chain, xref, filters, params, num, gen);
- if (fz_arraylen(filters) > 0)
- return buildfilterchain(chain, xref, filters, params, num, gen);
+ if (fz_is_name(filters))
+ return build_filter(chain, xref, filters, params, num, gen);
+ if (fz_array_len(filters) > 0)
+ return build_filter_chain(chain, xref, filters, params, num, gen);
return chain;
}
@@ -217,23 +217,23 @@ pdf_openfilter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int ge
* constraining to stream length, and without decryption.
*/
fz_stream *
-pdf_openinlinestream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length)
+pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length)
{
fz_obj *filters;
fz_obj *params;
- filters = fz_dictgetsa(stmobj, "Filter", "F");
- params = fz_dictgetsa(stmobj, "DecodeParms", "DP");
+ filters = fz_dict_getsa(stmobj, "Filter", "F");
+ params = fz_dict_getsa(stmobj, "DecodeParms", "DP");
/* don't close chain when we close this filter */
- fz_keepstream(chain);
+ fz_keep_stream(chain);
- if (fz_isname(filters))
- return buildfilter(chain, xref, filters, params, 0, 0);
- if (fz_arraylen(filters) > 0)
- return buildfilterchain(chain, xref, filters, params, 0, 0);
+ if (fz_is_name(filters))
+ return build_filter(chain, xref, filters, params, 0, 0);
+ if (fz_array_len(filters) > 0)
+ return build_filter_chain(chain, xref, filters, params, 0, 0);
- return fz_opennull(chain, length);
+ return fz_open_null(chain, length);
}
/*
@@ -241,9 +241,9 @@ pdf_openinlinestream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int lengt
* Using xref->file while this is open is a bad idea.
*/
fz_error
-pdf_openrawstream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
+pdf_open_raw_stream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
{
- pdf_xrefentry *x;
+ pdf_xref_entry *x;
fz_error error;
if (num < 0 || num >= xref->len)
@@ -251,14 +251,14 @@ pdf_openrawstream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
x = xref->table + num;
- error = pdf_cacheobject(xref, num, gen);
+ error = pdf_cache_object(xref, num, gen);
if (error)
return fz_rethrow(error, "cannot load stream object (%d %d R)", num, gen);
- if (x->stmofs)
+ if (x->stm_ofs)
{
- *stmp = pdf_openrawfilter(xref->file, xref, x->obj, num, gen);
- fz_seek(xref->file, x->stmofs, 0);
+ *stmp = pdf_open_raw_filter(xref->file, xref, x->obj, num, gen);
+ fz_seek(xref->file, x->stm_ofs, 0);
return fz_okay;
}
@@ -271,9 +271,9 @@ pdf_openrawstream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
* Using xref->file while a stream is open is a Bad idea.
*/
fz_error
-pdf_openstream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
+pdf_open_stream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
{
- pdf_xrefentry *x;
+ pdf_xref_entry *x;
fz_error error;
if (num < 0 || num >= xref->len)
@@ -281,14 +281,14 @@ pdf_openstream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
x = xref->table + num;
- error = pdf_cacheobject(xref, num, gen);
+ error = pdf_cache_object(xref, num, gen);
if (error)
return fz_rethrow(error, "cannot load stream object (%d %d R)", num, gen);
- if (x->stmofs)
+ if (x->stm_ofs)
{
- *stmp = pdf_openfilter(xref->file, xref, x->obj, num, gen);
- fz_seek(xref->file, x->stmofs, 0);
+ *stmp = pdf_open_filter(xref->file, xref, x->obj, num, gen);
+ fz_seek(xref->file, x->stm_ofs, 0);
return fz_okay;
}
@@ -296,12 +296,12 @@ pdf_openstream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
}
fz_error
-pdf_openstreamat(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stmofs)
+pdf_open_stream_at(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stm_ofs)
{
- if (stmofs)
+ if (stm_ofs)
{
- *stmp = pdf_openfilter(xref->file, xref, dict, num, gen);
- fz_seek(xref->file, stmofs, 0);
+ *stmp = pdf_open_filter(xref->file, xref, dict, num, gen);
+ fz_seek(xref->file, stm_ofs, 0);
return fz_okay;
}
return fz_throw("object is not a stream");
@@ -311,26 +311,26 @@ pdf_openstreamat(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dic
* Load raw (compressed but decrypted) contents of a stream into buf.
*/
fz_error
-pdf_loadrawstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen)
+pdf_load_raw_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen)
{
fz_error error;
fz_stream *stm;
fz_obj *dict;
int len;
- error = pdf_loadobject(&dict, xref, num, gen);
+ error = pdf_load_object(&dict, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot load stream dictionary (%d %d R)", num, gen);
- len = fz_toint(fz_dictgets(dict, "Length"));
+ len = fz_to_int(fz_dict_gets(dict, "Length"));
- fz_dropobj(dict);
+ fz_drop_obj(dict);
- error = pdf_openrawstream(&stm, xref, num, gen);
+ error = pdf_open_raw_stream(&stm, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot open raw stream (%d %d R)", num, gen);
- error = fz_readall(bufp, stm, len);
+ error = fz_read_all(bufp, stm, len);
if (error)
{
fz_close(stm);
@@ -342,7 +342,7 @@ pdf_loadrawstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen)
}
static int
-pdf_guessfilterlength(int len, char *filter)
+pdf_guess_filter_length(int len, char *filter)
{
if (!strcmp(filter, "ASCIIHexDecode"))
return len / 2;
@@ -361,30 +361,30 @@ pdf_guessfilterlength(int len, char *filter)
* Load uncompressed contents of a stream into buf.
*/
fz_error
-pdf_loadstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen)
+pdf_load_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen)
{
fz_error error;
fz_stream *stm;
fz_obj *dict, *obj;
int i, len;
- error = pdf_openstream(&stm, xref, num, gen);
+ error = pdf_open_stream(&stm, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot open stream (%d %d R)", num, gen);
- error = pdf_loadobject(&dict, xref, num, gen);
+ error = pdf_load_object(&dict, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot load stream dictionary (%d %d R)", num, gen);
- len = fz_toint(fz_dictgets(dict, "Length"));
- obj = fz_dictgets(dict, "Filter");
- len = pdf_guessfilterlength(len, fz_toname(obj));
- for (i = 0; i < fz_arraylen(obj); i++)
- len = pdf_guessfilterlength(len, fz_toname(fz_arrayget(obj, i)));
+ len = fz_to_int(fz_dict_gets(dict, "Length"));
+ obj = fz_dict_gets(dict, "Filter");
+ len = pdf_guess_filter_length(len, fz_to_name(obj));
+ for (i = 0; i < fz_array_len(obj); i++)
+ len = pdf_guess_filter_length(len, fz_to_name(fz_array_get(obj, i)));
- fz_dropobj(dict);
+ fz_drop_obj(dict);
- error = fz_readall(bufp, stm, len);
+ error = fz_read_all(bufp, stm, len);
if (error)
{
fz_close(stm);
diff --git a/pdf/pdf_type3.c b/pdf/pdf_type3.c
index 9cc15596..4c22654b 100644
--- a/pdf/pdf_type3.c
+++ b/pdf/pdf_type3.c
@@ -2,12 +2,12 @@
#include "mupdf.h"
fz_error
-pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict)
+pdf_load_type3_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict)
{
fz_error error;
char buf[256];
char *estrings[256];
- pdf_fontdesc *fontdesc;
+ pdf_font_desc *fontdesc;
fz_obj *encoding;
fz_obj *widths;
fz_obj *charprocs;
@@ -17,91 +17,91 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj
fz_rect bbox;
fz_matrix matrix;
- obj = fz_dictgets(dict, "Name");
- if (fz_isname(obj))
- fz_strlcpy(buf, fz_toname(obj), sizeof buf);
+ obj = fz_dict_gets(dict, "Name");
+ if (fz_is_name(obj))
+ fz_strlcpy(buf, fz_to_name(obj), sizeof buf);
else
sprintf(buf, "Unnamed-T3");
- fontdesc = pdf_newfontdesc();
+ fontdesc = pdf_new_font_desc();
- pdf_logfont("load type3 font (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), fontdesc);
- pdf_logfont("name %s\n", buf);
+ pdf_log_font("load type3 font (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), fontdesc);
+ pdf_log_font("name %s\n", buf);
- obj = fz_dictgets(dict, "FontMatrix");
- matrix = pdf_tomatrix(obj);
+ obj = fz_dict_gets(dict, "FontMatrix");
+ matrix = pdf_to_matrix(obj);
- pdf_logfont("matrix [%g %g %g %g %g %g]\n",
+ pdf_log_font("matrix [%g %g %g %g %g %g]\n",
matrix.a, matrix.b,
matrix.c, matrix.d,
matrix.e, matrix.f);
- obj = fz_dictgets(dict, "FontBBox");
- bbox = pdf_torect(obj);
+ obj = fz_dict_gets(dict, "FontBBox");
+ bbox = pdf_to_rect(obj);
- pdf_logfont("bbox [%g %g %g %g]\n",
+ pdf_log_font("bbox [%g %g %g %g]\n",
bbox.x0, bbox.y0,
bbox.x1, bbox.y1);
- fontdesc->font = fz_newtype3font(buf, matrix);
+ fontdesc->font = fz_new_type3_font(buf, matrix);
- fz_setfontbbox(fontdesc->font, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
+ fz_set_font_bbox(fontdesc->font, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
/* Encoding */
for (i = 0; i < 256; i++)
- estrings[i] = nil;
+ estrings[i] = NULL;
- encoding = fz_dictgets(dict, "Encoding");
+ encoding = fz_dict_gets(dict, "Encoding");
if (!encoding)
{
error = fz_throw("syntaxerror: Type3 font missing Encoding");
goto cleanup;
}
- if (fz_isname(encoding))
- pdf_loadencoding(estrings, fz_toname(encoding));
+ if (fz_is_name(encoding))
+ pdf_load_encoding(estrings, fz_to_name(encoding));
- if (fz_isdict(encoding))
+ if (fz_is_dict(encoding))
{
fz_obj *base, *diff, *item;
- base = fz_dictgets(encoding, "BaseEncoding");
- if (fz_isname(base))
- pdf_loadencoding(estrings, fz_toname(base));
+ base = fz_dict_gets(encoding, "BaseEncoding");
+ if (fz_is_name(base))
+ pdf_load_encoding(estrings, fz_to_name(base));
- diff = fz_dictgets(encoding, "Differences");
- if (fz_isarray(diff))
+ diff = fz_dict_gets(encoding, "Differences");
+ if (fz_is_array(diff))
{
- n = fz_arraylen(diff);
+ n = fz_array_len(diff);
k = 0;
for (i = 0; i < n; i++)
{
- item = fz_arrayget(diff, i);
- if (fz_isint(item))
- k = fz_toint(item);
- if (fz_isname(item))
- estrings[k++] = fz_toname(item);
+ item = fz_array_get(diff, i);
+ if (fz_is_int(item))
+ k = fz_to_int(item);
+ if (fz_is_name(item))
+ estrings[k++] = fz_to_name(item);
if (k < 0) k = 0;
if (k > 255) k = 255;
}
}
}
- fontdesc->encoding = pdf_newidentitycmap(0, 1);
+ fontdesc->encoding = pdf_new_identity_cmap(0, 1);
- error = pdf_loadtounicode(fontdesc, xref, estrings, nil, fz_dictgets(dict, "ToUnicode"));
+ error = pdf_load_to_unicode(fontdesc, xref, estrings, NULL, fz_dict_gets(dict, "ToUnicode"));
if (error)
goto cleanup;
/* Widths */
- pdf_setdefaulthmtx(fontdesc, 0);
+ pdf_set_default_hmtx(fontdesc, 0);
- first = fz_toint(fz_dictgets(dict, "FirstChar"));
- last = fz_toint(fz_dictgets(dict, "LastChar"));
+ first = fz_to_int(fz_dict_gets(dict, "FirstChar"));
+ last = fz_to_int(fz_dict_gets(dict, "LastChar"));
- widths = fz_dictgets(dict, "Widths");
+ widths = fz_dict_gets(dict, "Widths");
if (!widths)
{
error = fz_throw("syntaxerror: Type3 font missing Widths");
@@ -110,30 +110,30 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj
for (i = first; i <= last; i++)
{
- float w = fz_toreal(fz_arrayget(widths, i - first));
+ float w = fz_to_real(fz_array_get(widths, i - first));
w = fontdesc->font->t3matrix.a * w * 1000;
fontdesc->font->t3widths[i] = w * 0.001f;
- pdf_addhmtx(fontdesc, i, i, w);
+ pdf_add_hmtx(fontdesc, i, i, w);
}
- pdf_endhmtx(fontdesc);
+ pdf_end_hmtx(fontdesc);
/* Resources -- inherit page resources if the font doesn't have its own */
- fontdesc->font->t3resources = fz_dictgets(dict, "Resources");
+ fontdesc->font->t3resources = fz_dict_gets(dict, "Resources");
if (!fontdesc->font->t3resources)
fontdesc->font->t3resources = rdb;
if (fontdesc->font->t3resources)
- fz_keepobj(fontdesc->font->t3resources);
+ fz_keep_obj(fontdesc->font->t3resources);
if (!fontdesc->font->t3resources)
fz_warn("no resource dictionary for type 3 font!");
fontdesc->font->t3xref = xref;
- fontdesc->font->t3run = pdf_runglyph;
+ fontdesc->font->t3run = pdf_run_glyph;
/* CharProcs */
- charprocs = fz_dictgets(dict, "CharProcs");
+ charprocs = fz_dict_gets(dict, "CharProcs");
if (!charprocs)
{
error = fz_throw("syntaxerror: Type3 font missing CharProcs");
@@ -144,23 +144,23 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj
{
if (estrings[i])
{
- obj = fz_dictgets(charprocs, estrings[i]);
- if (pdf_isstream(xref, fz_tonum(obj), fz_togen(obj)))
+ obj = fz_dict_gets(charprocs, estrings[i]);
+ if (pdf_is_stream(xref, fz_to_num(obj), fz_to_gen(obj)))
{
- error = pdf_loadstream(&fontdesc->font->t3procs[i], xref, fz_tonum(obj), fz_togen(obj));
+ error = pdf_load_stream(&fontdesc->font->t3procs[i], xref, fz_to_num(obj), fz_to_gen(obj));
if (error)
goto cleanup;
}
}
}
- pdf_logfont("}\n");
+ pdf_log_font("}\n");
*fontdescp = fontdesc;
return fz_okay;
cleanup:
- fz_dropfont(fontdesc->font);
+ fz_drop_font(fontdesc->font);
fz_free(fontdesc);
- return fz_rethrow(error, "cannot load type3 font (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ return fz_rethrow(error, "cannot load type3 font (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
diff --git a/pdf/pdf_unicode.c b/pdf/pdf_unicode.c
index 6c2d6372..01326b53 100644
--- a/pdf/pdf_unicode.c
+++ b/pdf/pdf_unicode.c
@@ -4,7 +4,7 @@
/* Load or synthesize ToUnicode map for fonts */
fz_error
-pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref,
+pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref,
char **strings, char *collection, fz_obj *cmapstm)
{
fz_error error = fz_okay;
@@ -14,76 +14,76 @@ pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref,
int ucslen;
int i;
- if (pdf_isstream(xref, fz_tonum(cmapstm), fz_togen(cmapstm)))
+ if (pdf_is_stream(xref, fz_to_num(cmapstm), fz_to_gen(cmapstm)))
{
- pdf_logfont("tounicode embedded cmap\n");
+ pdf_log_font("to_unicode embedded cmap\n");
- error = pdf_loadembeddedcmap(&cmap, xref, cmapstm);
+ error = pdf_load_embedded_cmap(&cmap, xref, cmapstm);
if (error)
- return fz_rethrow(error, "cannot load embedded cmap (%d %d R)", fz_tonum(cmapstm), fz_togen(cmapstm));
+ return fz_rethrow(error, "cannot load embedded cmap (%d %d R)", fz_to_num(cmapstm), fz_to_gen(cmapstm));
- font->tounicode = pdf_newcmap();
+ font->to_unicode = pdf_new_cmap();
for (i = 0; i < (strings ? 256 : 65536); i++)
{
- cid = pdf_lookupcmap(font->encoding, i);
+ cid = pdf_lookup_cmap(font->encoding, i);
if (cid >= 0)
{
- ucslen = pdf_lookupcmapfull(cmap, i, ucsbuf);
+ ucslen = pdf_lookup_cmap_full(cmap, i, ucsbuf);
if (ucslen == 1)
- pdf_maprangetorange(font->tounicode, cid, cid, ucsbuf[0]);
+ pdf_map_range_to_range(font->to_unicode, cid, cid, ucsbuf[0]);
if (ucslen > 1)
- pdf_maponetomany(font->tounicode, cid, ucsbuf, ucslen);
+ pdf_map_one_to_many(font->to_unicode, cid, ucsbuf, ucslen);
}
}
- pdf_sortcmap(font->tounicode);
+ pdf_sort_cmap(font->to_unicode);
- pdf_dropcmap(cmap);
+ pdf_drop_cmap(cmap);
}
else if (collection)
{
- pdf_logfont("tounicode cid collection (%s)\n", collection);
+ pdf_log_font("to_unicode cid collection (%s)\n", collection);
error = fz_okay;
if (!strcmp(collection, "Adobe-CNS1"))
- error = pdf_loadsystemcmap(&font->tounicode, "Adobe-CNS1-UCS2");
+ error = pdf_load_system_cmap(&font->to_unicode, "Adobe-CNS1-UCS2");
else if (!strcmp(collection, "Adobe-GB1"))
- error = pdf_loadsystemcmap(&font->tounicode, "Adobe-GB1-UCS2");
+ error = pdf_load_system_cmap(&font->to_unicode, "Adobe-GB1-UCS2");
else if (!strcmp(collection, "Adobe-Japan1"))
- error = pdf_loadsystemcmap(&font->tounicode, "Adobe-Japan1-UCS2");
+ error = pdf_load_system_cmap(&font->to_unicode, "Adobe-Japan1-UCS2");
else if (!strcmp(collection, "Adobe-Japan2"))
- error = pdf_loadsystemcmap(&font->tounicode, "Adobe-Japan2-UCS2"); /* where's this? */
+ error = pdf_load_system_cmap(&font->to_unicode, "Adobe-Japan2-UCS2"); /* where's this? */
else if (!strcmp(collection, "Adobe-Korea1"))
- error = pdf_loadsystemcmap(&font->tounicode, "Adobe-Korea1-UCS2");
+ error = pdf_load_system_cmap(&font->to_unicode, "Adobe-Korea1-UCS2");
if (error)
- return fz_rethrow(error, "cannot load tounicode system cmap %s-UCS2", collection);
+ return fz_rethrow(error, "cannot load to_unicode system cmap %s-UCS2", collection);
}
if (strings)
{
- pdf_logfont("tounicode strings\n");
+ pdf_log_font("to_unicode strings\n");
/* TODO one-to-many mappings */
- font->ncidtoucs = 256;
- font->cidtoucs = fz_calloc(256, sizeof(unsigned short));
+ font->cid_to_ucs_len = 256;
+ font->cid_to_ucs = fz_calloc(256, sizeof(unsigned short));
for (i = 0; i < 256; i++)
{
if (strings[i])
- font->cidtoucs[i] = pdf_lookupagl(strings[i]);
+ font->cid_to_ucs[i] = pdf_lookup_agl(strings[i]);
else
- font->cidtoucs[i] = '?';
+ font->cid_to_ucs[i] = '?';
}
}
- if (!font->tounicode && !font->cidtoucs)
+ if (!font->to_unicode && !font->cid_to_ucs)
{
- pdf_logfont("tounicode could not be loaded\n");
+ pdf_log_font("to_unicode could not be loaded\n");
/* TODO: synthesize a ToUnicode if it's a freetype font with
* cmap and/or post tables or if it has glyph names. */
}
diff --git a/pdf/pdf_xobject.c b/pdf/pdf_xobject.c
index 44389efc..86360d3a 100644
--- a/pdf/pdf_xobject.c
+++ b/pdf/pdf_xobject.c
@@ -2,43 +2,43 @@
#include "mupdf.h"
fz_error
-pdf_loadxobject(pdf_xobject **formp, pdf_xref *xref, fz_obj *dict)
+pdf_load_xobject(pdf_xobject **formp, pdf_xref *xref, fz_obj *dict)
{
fz_error error;
pdf_xobject *form;
fz_obj *obj;
- if ((*formp = pdf_finditem(xref->store, pdf_dropxobject, dict)))
+ if ((*formp = pdf_find_item(xref->store, pdf_drop_xobject, dict)))
{
- pdf_keepxobject(*formp);
+ pdf_keep_xobject(*formp);
return fz_okay;
}
form = fz_malloc(sizeof(pdf_xobject));
form->refs = 1;
- form->resources = nil;
- form->contents = nil;
- form->colorspace = nil;
+ form->resources = NULL;
+ form->contents = NULL;
+ form->colorspace = NULL;
- pdf_logrsrc("load xobject (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), form);
+ pdf_log_rsrc("load xobject (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), form);
/* Store item immediately, to avoid possible recursion if objects refer back to this one */
- pdf_storeitem(xref->store, pdf_keepxobject, pdf_dropxobject, dict, form);
+ pdf_store_item(xref->store, pdf_keep_xobject, pdf_drop_xobject, dict, form);
- obj = fz_dictgets(dict, "BBox");
- form->bbox = pdf_torect(obj);
+ obj = fz_dict_gets(dict, "BBox");
+ form->bbox = pdf_to_rect(obj);
- pdf_logrsrc("bbox [%g %g %g %g]\n",
+ pdf_log_rsrc("bbox [%g %g %g %g]\n",
form->bbox.x0, form->bbox.y0,
form->bbox.x1, form->bbox.y1);
- obj = fz_dictgets(dict, "Matrix");
+ obj = fz_dict_gets(dict, "Matrix");
if (obj)
- form->matrix = pdf_tomatrix(obj);
+ form->matrix = pdf_to_matrix(obj);
else
form->matrix = fz_identity;
- pdf_logrsrc("matrix [%g %g %g %g %g %g]\n",
+ pdf_log_rsrc("matrix [%g %g %g %g %g %g]\n",
form->matrix.a, form->matrix.b,
form->matrix.c, form->matrix.d,
form->matrix.e, form->matrix.f);
@@ -47,69 +47,69 @@ pdf_loadxobject(pdf_xobject **formp, pdf_xref *xref, fz_obj *dict)
form->knockout = 0;
form->transparency = 0;
- obj = fz_dictgets(dict, "Group");
+ obj = fz_dict_gets(dict, "Group");
if (obj)
{
fz_obj *attrs = obj;
- form->isolated = fz_tobool(fz_dictgets(attrs, "I"));
- form->knockout = fz_tobool(fz_dictgets(attrs, "K"));
+ form->isolated = fz_to_bool(fz_dict_gets(attrs, "I"));
+ form->knockout = fz_to_bool(fz_dict_gets(attrs, "K"));
- obj = fz_dictgets(attrs, "S");
- if (fz_isname(obj) && !strcmp(fz_toname(obj), "Transparency"))
+ obj = fz_dict_gets(attrs, "S");
+ if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Transparency"))
form->transparency = 1;
- obj = fz_dictgets(attrs, "CS");
+ obj = fz_dict_gets(attrs, "CS");
if (obj)
{
- error = pdf_loadcolorspace(&form->colorspace, xref, obj);
+ error = pdf_load_colorspace(&form->colorspace, xref, obj);
if (error)
fz_catch(error, "cannot load xobject colorspace");
- pdf_logrsrc("colorspace %s\n", form->colorspace->name);
+ pdf_log_rsrc("colorspace %s\n", form->colorspace->name);
}
}
- pdf_logrsrc("isolated %d\n", form->isolated);
- pdf_logrsrc("knockout %d\n", form->knockout);
- pdf_logrsrc("transparency %d\n", form->transparency);
+ pdf_log_rsrc("isolated %d\n", form->isolated);
+ pdf_log_rsrc("knockout %d\n", form->knockout);
+ pdf_log_rsrc("transparency %d\n", form->transparency);
- form->resources = fz_dictgets(dict, "Resources");
+ form->resources = fz_dict_gets(dict, "Resources");
if (form->resources)
- fz_keepobj(form->resources);
+ fz_keep_obj(form->resources);
- error = pdf_loadstream(&form->contents, xref, fz_tonum(dict), fz_togen(dict));
+ error = pdf_load_stream(&form->contents, xref, fz_to_num(dict), fz_to_gen(dict));
if (error)
{
- pdf_removeitem(xref->store, pdf_dropxobject, dict);
- pdf_dropxobject(form);
- return fz_rethrow(error, "cannot load xobject content stream (%d %d R)", fz_tonum(dict), fz_togen(dict));
+ pdf_remove_item(xref->store, pdf_drop_xobject, dict);
+ pdf_drop_xobject(form);
+ return fz_rethrow(error, "cannot load xobject content stream (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
}
- pdf_logrsrc("stream %d bytes\n", form->contents->len);
- pdf_logrsrc("}\n");
+ pdf_log_rsrc("stream %d bytes\n", form->contents->len);
+ pdf_log_rsrc("}\n");
*formp = form;
return fz_okay;
}
pdf_xobject *
-pdf_keepxobject(pdf_xobject *xobj)
+pdf_keep_xobject(pdf_xobject *xobj)
{
xobj->refs ++;
return xobj;
}
void
-pdf_dropxobject(pdf_xobject *xobj)
+pdf_drop_xobject(pdf_xobject *xobj)
{
if (xobj && --xobj->refs == 0)
{
if (xobj->colorspace)
- fz_dropcolorspace(xobj->colorspace);
+ fz_drop_colorspace(xobj->colorspace);
if (xobj->resources)
- fz_dropobj(xobj->resources);
+ fz_drop_obj(xobj->resources);
if (xobj->contents)
- fz_dropbuffer(xobj->contents);
+ fz_drop_buffer(xobj->contents);
fz_free(xobj);
}
}
diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c
index 2e98c97e..ce973d39 100644
--- a/pdf/pdf_xref.c
+++ b/pdf/pdf_xref.c
@@ -13,24 +13,24 @@ static inline int iswhite(int ch)
*/
static fz_error
-pdf_loadversion(pdf_xref *xref)
+pdf_load_version(pdf_xref *xref)
{
char buf[20];
fz_seek(xref->file, 0, 0);
- fz_readline(xref->file, buf, sizeof buf);
+ fz_read_line(xref->file, buf, sizeof buf);
if (memcmp(buf, "%PDF-", 5) != 0)
return fz_throw("cannot recognize version marker");
xref->version = atof(buf + 5) * 10;
- pdf_logxref("version %d.%d\n", xref->version / 10, xref->version % 10);
+ pdf_log_xref("version %d.%d\n", xref->version / 10, xref->version % 10);
return fz_okay;
}
static fz_error
-pdf_readstartxref(pdf_xref *xref)
+pdf_read_start_xref(pdf_xref *xref)
{
unsigned char buf[1024];
int t, n;
@@ -38,9 +38,9 @@ pdf_readstartxref(pdf_xref *xref)
fz_seek(xref->file, 0, 2);
- xref->filesize = fz_tell(xref->file);
+ xref->file_size = fz_tell(xref->file);
- t = MAX(0, xref->filesize - (int)sizeof buf);
+ t = MAX(0, xref->file_size - (int)sizeof buf);
fz_seek(xref->file, t, 0);
n = fz_read(xref->file, buf, sizeof buf);
@@ -55,7 +55,7 @@ pdf_readstartxref(pdf_xref *xref)
while (iswhite(buf[i]) && i < n)
i ++;
xref->startxref = atoi((char*)(buf + i));
- pdf_logxref("startxref %d\n", xref->startxref);
+ pdf_log_xref("startxref %d\n", xref->startxref);
return fz_okay;
}
}
@@ -68,7 +68,7 @@ pdf_readstartxref(pdf_xref *xref)
*/
static fz_error
-pdf_readoldtrailer(pdf_xref *xref, char *buf, int cap)
+pdf_read_old_trailer(pdf_xref *xref, char *buf, int cap)
{
fz_error error;
int len;
@@ -78,19 +78,19 @@ pdf_readoldtrailer(pdf_xref *xref, char *buf, int cap)
int tok;
int c;
- pdf_logxref("load old xref format trailer\n");
+ pdf_log_xref("load old xref format trailer\n");
- fz_readline(xref->file, buf, cap);
+ fz_read_line(xref->file, buf, cap);
if (strncmp(buf, "xref", 4) != 0)
return fz_throw("cannot find xref marker");
while (1)
{
- c = fz_peekbyte(xref->file);
+ c = fz_peek_byte(xref->file);
if (!(c >= '0' && c <= '9'))
break;
- fz_readline(xref->file, buf, cap);
+ fz_read_line(xref->file, buf, cap);
s = buf;
fz_strsep(&s, " "); /* ignore ofs */
if (!s)
@@ -111,55 +111,55 @@ pdf_readoldtrailer(pdf_xref *xref, char *buf, int cap)
error = pdf_lex(&tok, xref->file, buf, cap, &n);
if (error)
return fz_rethrow(error, "cannot parse trailer");
- if (tok != PDF_TTRAILER)
+ if (tok != PDF_TOK_TRAILER)
return fz_throw("expected trailer marker");
error = pdf_lex(&tok, xref->file, buf, cap, &n);
if (error)
return fz_rethrow(error, "cannot parse trailer");
- if (tok != PDF_TODICT)
+ if (tok != PDF_TOK_OPEN_DICT)
return fz_throw("expected trailer dictionary");
- error = pdf_parsedict(&xref->trailer, xref, xref->file, buf, cap);
+ error = pdf_parse_dict(&xref->trailer, xref, xref->file, buf, cap);
if (error)
return fz_rethrow(error, "cannot parse trailer");
return fz_okay;
}
static fz_error
-pdf_readnewtrailer(pdf_xref *xref, char *buf, int cap)
+pdf_read_new_trailer(pdf_xref *xref, char *buf, int cap)
{
fz_error error;
- pdf_logxref("load new xref format trailer\n");
+ pdf_log_xref("load new xref format trailer\n");
- error = pdf_parseindobj(&xref->trailer, xref, xref->file, buf, cap, nil, nil, nil);
+ error = pdf_parse_ind_obj(&xref->trailer, xref, xref->file, buf, cap, NULL, NULL, NULL);
if (error)
return fz_rethrow(error, "cannot parse trailer (compressed)");
return fz_okay;
}
static fz_error
-pdf_readtrailer(pdf_xref *xref, char *buf, int cap)
+pdf_read_trailer(pdf_xref *xref, char *buf, int cap)
{
fz_error error;
int c;
fz_seek(xref->file, xref->startxref, 0);
- while (iswhite(fz_peekbyte(xref->file)))
- fz_readbyte(xref->file);
+ while (iswhite(fz_peek_byte(xref->file)))
+ fz_read_byte(xref->file);
- c = fz_peekbyte(xref->file);
+ c = fz_peek_byte(xref->file);
if (c == 'x')
{
- error = pdf_readoldtrailer(xref, buf, cap);
+ error = pdf_read_old_trailer(xref, buf, cap);
if (error)
return fz_rethrow(error, "cannot read trailer");
}
else if (c >= '0' && c <= '9')
{
- error = pdf_readnewtrailer(xref, buf, cap);
+ error = pdf_read_new_trailer(xref, buf, cap);
if (error)
return fz_rethrow(error, "cannot read trailer");
}
@@ -176,24 +176,24 @@ pdf_readtrailer(pdf_xref *xref, char *buf, int cap)
*/
void
-pdf_resizexref(pdf_xref *xref, int newlen)
+pdf_resize_xref(pdf_xref *xref, int newlen)
{
int i;
- xref->table = fz_realloc(xref->table, newlen, sizeof(pdf_xrefentry));
+ xref->table = fz_realloc(xref->table, newlen, sizeof(pdf_xref_entry));
for (i = xref->len; i < newlen; i++)
{
xref->table[i].type = 0;
xref->table[i].ofs = 0;
xref->table[i].gen = 0;
- xref->table[i].stmofs = 0;
- xref->table[i].obj = nil;
+ xref->table[i].stm_ofs = 0;
+ xref->table[i].obj = NULL;
}
xref->len = newlen;
}
static fz_error
-pdf_readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
+pdf_read_old_xref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
{
fz_error error;
int ofs, len;
@@ -203,19 +203,19 @@ pdf_readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
int i;
int c;
- pdf_logxref("load old xref format\n");
+ pdf_log_xref("load old xref format\n");
- fz_readline(xref->file, buf, cap);
+ fz_read_line(xref->file, buf, cap);
if (strncmp(buf, "xref", 4) != 0)
return fz_throw("cannot find xref marker");
while (1)
{
- c = fz_peekbyte(xref->file);
+ c = fz_peek_byte(xref->file);
if (!(c >= '0' && c <= '9'))
break;
- fz_readline(xref->file, buf, cap);
+ fz_read_line(xref->file, buf, cap);
s = buf;
ofs = atoi(fz_strsep(&s, " "));
len = atoi(fz_strsep(&s, " "));
@@ -231,7 +231,7 @@ pdf_readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
if (ofs + len > xref->len)
{
fz_warn("broken xref section, proceeding anyway.");
- pdf_resizexref(xref, ofs + len);
+ pdf_resize_xref(xref, ofs + len);
}
for (i = ofs; i < ofs + len; i++)
@@ -259,23 +259,23 @@ pdf_readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
error = pdf_lex(&tok, xref->file, buf, cap, &n);
if (error)
return fz_rethrow(error, "cannot parse trailer");
- if (tok != PDF_TTRAILER)
+ if (tok != PDF_TOK_TRAILER)
return fz_throw("expected trailer marker");
error = pdf_lex(&tok, xref->file, buf, cap, &n);
if (error)
return fz_rethrow(error, "cannot parse trailer");
- if (tok != PDF_TODICT)
+ if (tok != PDF_TOK_OPEN_DICT)
return fz_throw("expected trailer dictionary");
- error = pdf_parsedict(trailerp, xref, xref->file, buf, cap);
+ error = pdf_parse_dict(trailerp, xref, xref->file, buf, cap);
if (error)
return fz_rethrow(error, "cannot parse trailer");
return fz_okay;
}
static fz_error
-pdf_readnewxrefsection(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, int w1, int w2)
+pdf_read_new_xref_section(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, int w1, int w2)
{
int i, n;
@@ -288,15 +288,15 @@ pdf_readnewxrefsection(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, i
int b = 0;
int c = 0;
- if (fz_iseof(stm))
+ if (fz_is_eof(stm))
return fz_throw("truncated xref stream");
for (n = 0; n < w0; n++)
- a = (a << 8) + fz_readbyte(stm);
+ a = (a << 8) + fz_read_byte(stm);
for (n = 0; n < w1; n++)
- b = (b << 8) + fz_readbyte(stm);
+ b = (b << 8) + fz_read_byte(stm);
for (n = 0; n < w2; n++)
- c = (c << 8) + fz_readbyte(stm);
+ c = (c << 8) + fz_read_byte(stm);
if (!xref->table[i].type)
{
@@ -311,83 +311,83 @@ pdf_readnewxrefsection(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, i
}
static fz_error
-pdf_readnewxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
+pdf_read_new_xref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
{
fz_error error;
fz_stream *stm;
fz_obj *trailer;
fz_obj *index;
fz_obj *obj;
- int num, gen, stmofs;
+ int num, gen, stm_ofs;
int size, w0, w1, w2;
int t;
- pdf_logxref("load new xref format\n");
+ pdf_log_xref("load new xref format\n");
- error = pdf_parseindobj(&trailer, xref, xref->file, buf, cap, &num, &gen, &stmofs);
+ error = pdf_parse_ind_obj(&trailer, xref, xref->file, buf, cap, &num, &gen, &stm_ofs);
if (error)
return fz_rethrow(error, "cannot parse compressed xref stream object");
- obj = fz_dictgets(trailer, "Size");
+ obj = fz_dict_gets(trailer, "Size");
if (!obj)
{
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_throw("xref stream missing Size entry (%d %d R)", num, gen);
}
- size = fz_toint(obj);
+ size = fz_to_int(obj);
if (size > xref->len)
{
- pdf_resizexref(xref, size);
+ pdf_resize_xref(xref, size);
}
if (num < 0 || num >= xref->len)
{
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_throw("object id (%d %d R) out of range (0..%d)", num, gen, xref->len - 1);
}
- pdf_logxref("\tnum=%d gen=%d size=%d\n", num, gen, size);
+ pdf_log_xref("\tnum=%d gen=%d size=%d\n", num, gen, size);
- obj = fz_dictgets(trailer, "W");
+ obj = fz_dict_gets(trailer, "W");
if (!obj) {
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_throw("xref stream missing W entry (%d %d R)", num, gen);
}
- w0 = fz_toint(fz_arrayget(obj, 0));
- w1 = fz_toint(fz_arrayget(obj, 1));
- w2 = fz_toint(fz_arrayget(obj, 2));
+ w0 = fz_to_int(fz_array_get(obj, 0));
+ w1 = fz_to_int(fz_array_get(obj, 1));
+ w2 = fz_to_int(fz_array_get(obj, 2));
- index = fz_dictgets(trailer, "Index");
+ index = fz_dict_gets(trailer, "Index");
- error = pdf_openstreamat(&stm, xref, num, gen, trailer, stmofs);
+ error = pdf_open_stream_at(&stm, xref, num, gen, trailer, stm_ofs);
if (error)
{
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_rethrow(error, "cannot open compressed xref stream (%d %d R)", num, gen);
}
if (!index)
{
- error = pdf_readnewxrefsection(xref, stm, 0, size, w0, w1, w2);
+ error = pdf_read_new_xref_section(xref, stm, 0, size, w0, w1, w2);
if (error)
{
fz_close(stm);
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_rethrow(error, "cannot read xref stream (%d %d R)", num, gen);
}
}
else
{
- for (t = 0; t < fz_arraylen(index); t += 2)
+ for (t = 0; t < fz_array_len(index); t += 2)
{
- int i0 = fz_toint(fz_arrayget(index, t + 0));
- int i1 = fz_toint(fz_arrayget(index, t + 1));
- error = pdf_readnewxrefsection(xref, stm, i0, i1, w0, w1, w2);
+ int i0 = fz_to_int(fz_array_get(index, t + 0));
+ int i1 = fz_to_int(fz_array_get(index, t + 1));
+ error = pdf_read_new_xref_section(xref, stm, i0, i1, w0, w1, w2);
if (error)
{
fz_close(stm);
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_rethrow(error, "cannot read xref stream section (%d %d R)", num, gen);
}
}
@@ -401,26 +401,26 @@ pdf_readnewxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
}
static fz_error
-pdf_readxref(fz_obj **trailerp, pdf_xref *xref, int ofs, char *buf, int cap)
+pdf_read_xref(fz_obj **trailerp, pdf_xref *xref, int ofs, char *buf, int cap)
{
fz_error error;
int c;
fz_seek(xref->file, ofs, 0);
- while (iswhite(fz_peekbyte(xref->file)))
- fz_readbyte(xref->file);
+ while (iswhite(fz_peek_byte(xref->file)))
+ fz_read_byte(xref->file);
- c = fz_peekbyte(xref->file);
+ c = fz_peek_byte(xref->file);
if (c == 'x')
{
- error = pdf_readoldxref(trailerp, xref, buf, cap);
+ error = pdf_read_old_xref(trailerp, xref, buf, cap);
if (error)
return fz_rethrow(error, "cannot read xref (ofs=%d)", ofs);
}
else if (c >= '0' && c <= '9')
{
- error = pdf_readnewxref(trailerp, xref, buf, cap);
+ error = pdf_read_new_xref(trailerp, xref, buf, cap);
if (error)
return fz_rethrow(error, "cannot read xref (ofs=%d)", ofs);
}
@@ -433,43 +433,43 @@ pdf_readxref(fz_obj **trailerp, pdf_xref *xref, int ofs, char *buf, int cap)
}
static fz_error
-pdf_readxrefsections(pdf_xref *xref, int ofs, char *buf, int cap)
+pdf_read_xref_sections(pdf_xref *xref, int ofs, char *buf, int cap)
{
fz_error error;
fz_obj *trailer;
fz_obj *prev;
fz_obj *xrefstm;
- error = pdf_readxref(&trailer, xref, ofs, buf, cap);
+ error = pdf_read_xref(&trailer, xref, ofs, buf, cap);
if (error)
return fz_rethrow(error, "cannot read xref section");
/* FIXME: do we overwrite free entries properly? */
- xrefstm = fz_dictgets(trailer, "XRefStm");
+ xrefstm = fz_dict_gets(trailer, "XRefStm");
if (xrefstm)
{
- pdf_logxref("load xrefstm\n");
- error = pdf_readxrefsections(xref, fz_toint(xrefstm), buf, cap);
+ pdf_log_xref("load xrefstm\n");
+ error = pdf_read_xref_sections(xref, fz_to_int(xrefstm), buf, cap);
if (error)
{
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_rethrow(error, "cannot read /XRefStm xref section");
}
}
- prev = fz_dictgets(trailer, "Prev");
+ prev = fz_dict_gets(trailer, "Prev");
if (prev)
{
- pdf_logxref("load prev at %#x\n", fz_toint(prev));
- error = pdf_readxrefsections(xref, fz_toint(prev), buf, cap);
+ pdf_log_xref("load prev at %#x\n", fz_to_int(prev));
+ error = pdf_read_xref_sections(xref, fz_to_int(prev), buf, cap);
if (error)
{
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_rethrow(error, "cannot read /Prev xref section");
}
}
- fz_dropobj(trailer);
+ fz_drop_obj(trailer);
return fz_okay;
}
@@ -478,33 +478,33 @@ pdf_readxrefsections(pdf_xref *xref, int ofs, char *buf, int cap)
*/
static fz_error
-pdf_loadxref(pdf_xref *xref, char *buf, int bufsize)
+pdf_load_xref(pdf_xref *xref, char *buf, int bufsize)
{
fz_error error;
fz_obj *size;
int i;
- error = pdf_loadversion(xref);
+ error = pdf_load_version(xref);
if (error)
return fz_rethrow(error, "cannot read version marker");
- error = pdf_readstartxref(xref);
+ error = pdf_read_start_xref(xref);
if (error)
return fz_rethrow(error, "cannot read startxref");
- error = pdf_readtrailer(xref, buf, bufsize);
+ error = pdf_read_trailer(xref, buf, bufsize);
if (error)
return fz_rethrow(error, "cannot read trailer");
- size = fz_dictgets(xref->trailer, "Size");
+ size = fz_dict_gets(xref->trailer, "Size");
if (!size)
return fz_throw("trailer missing Size entry");
- pdf_logxref("\tsize %d at %#x\n", fz_toint(size), xref->startxref);
+ pdf_log_xref("\tsize %d at %#x\n", fz_to_int(size), xref->startxref);
- pdf_resizexref(xref, fz_toint(size));
+ pdf_resize_xref(xref, fz_to_int(size));
- error = pdf_readxrefsections(xref, xref->startxref, buf, bufsize);
+ error = pdf_read_xref_sections(xref, xref->startxref, buf, bufsize);
if (error)
return fz_rethrow(error, "cannot read xref");
@@ -515,7 +515,7 @@ pdf_loadxref(pdf_xref *xref, char *buf, int bufsize)
/* broken pdfs where object offsets are out of range */
for (i = 0; i < xref->len; i++)
if (xref->table[i].type == 'n')
- if (xref->table[i].ofs <= 0 || xref->table[i].ofs >= xref->filesize)
+ if (xref->table[i].ofs <= 0 || xref->table[i].ofs >= xref->file_size)
return fz_throw("object offset out of range: %d (%d 0 R)", xref->table[i].ofs, i);
return fz_okay;
@@ -527,7 +527,7 @@ pdf_loadxref(pdf_xref *xref, char *buf, int bufsize)
*/
fz_error
-pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password)
+pdf_open_xref_with_stream(pdf_xref **xrefp, fz_stream *file, char *password)
{
pdf_xref *xref;
fz_error error;
@@ -536,61 +536,61 @@ pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password)
int i, repaired = 0;
/* install pdf specific callback */
- fz_resolveindirect = pdf_resolveindirect;
+ fz_resolve_indirect = pdf_resolve_indirect;
xref = fz_malloc(sizeof(pdf_xref));
memset(xref, 0, sizeof(pdf_xref));
- pdf_logxref("openxref %p\n", xref);
+ pdf_log_xref("openxref %p\n", xref);
- xref->file = fz_keepstream(file);
+ xref->file = fz_keep_stream(file);
- error = pdf_loadxref(xref, xref->scratch, sizeof xref->scratch);
+ error = pdf_load_xref(xref, xref->scratch, sizeof xref->scratch);
if (error)
{
fz_catch(error, "trying to repair");
if (xref->table)
{
fz_free(xref->table);
- xref->table = nil;
+ xref->table = NULL;
xref->len = 0;
}
if (xref->trailer)
{
- fz_dropobj(xref->trailer);
- xref->trailer = nil;
+ fz_drop_obj(xref->trailer);
+ xref->trailer = NULL;
}
- error = pdf_repairxref(xref, xref->scratch, sizeof xref->scratch);
+ error = pdf_repair_xref(xref, xref->scratch, sizeof xref->scratch);
if (error)
{
- pdf_freexref(xref);
+ pdf_free_xref(xref);
return fz_rethrow(error, "cannot repair document");
}
repaired = 1;
}
- encrypt = fz_dictgets(xref->trailer, "Encrypt");
- id = fz_dictgets(xref->trailer, "ID");
- if (fz_isdict(encrypt))
+ encrypt = fz_dict_gets(xref->trailer, "Encrypt");
+ id = fz_dict_gets(xref->trailer, "ID");
+ if (fz_is_dict(encrypt))
{
- error = pdf_newcrypt(&xref->crypt, encrypt, id);
+ error = pdf_new_crypt(&xref->crypt, encrypt, id);
if (error)
{
- pdf_freexref(xref);
+ pdf_free_xref(xref);
return fz_rethrow(error, "cannot decrypt document");
}
}
- if (pdf_needspassword(xref))
+ if (pdf_needs_password(xref))
{
/* Only care if we have a password */
if (password)
{
- int okay = pdf_authenticatepassword(xref, password);
+ int okay = pdf_authenticate_password(xref, password);
if (!okay)
{
- pdf_freexref(xref);
+ pdf_free_xref(xref);
return fz_throw("invalid password");
}
}
@@ -600,22 +600,22 @@ pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password)
{
int hasroot, hasinfo;
- error = pdf_repairobjstms(xref);
+ error = pdf_repair_obj_stms(xref);
if (error)
{
- pdf_freexref(xref);
+ pdf_free_xref(xref);
return fz_rethrow(error, "cannot repair document");
}
- hasroot = fz_dictgets(xref->trailer, "Root") != nil;
- hasinfo = fz_dictgets(xref->trailer, "Info") != nil;
+ hasroot = fz_dict_gets(xref->trailer, "Root") != NULL;
+ hasinfo = fz_dict_gets(xref->trailer, "Info") != NULL;
for (i = 1; i < xref->len; i++)
{
if (xref->table[i].type == 0 || xref->table[i].type == 'f')
continue;
- error = pdf_loadobject(&dict, xref, i, 0);
+ error = pdf_load_object(&dict, xref, i, 0);
if (error)
{
fz_catch(error, "ignoring broken object (%d 0 R)", i);
@@ -624,28 +624,28 @@ pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password)
if (!hasroot)
{
- obj = fz_dictgets(dict, "Type");
- if (fz_isname(obj) && !strcmp(fz_toname(obj), "Catalog"))
+ obj = fz_dict_gets(dict, "Type");
+ if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Catalog"))
{
- pdf_logxref("found catalog: (%d %d R)\n", i, 0);
- obj = fz_newindirect(i, 0, xref);
- fz_dictputs(xref->trailer, "Root", obj);
- fz_dropobj(obj);
+ pdf_log_xref("found catalog: (%d %d R)\n", i, 0);
+ obj = fz_new_indirect(i, 0, xref);
+ fz_dict_puts(xref->trailer, "Root", obj);
+ fz_drop_obj(obj);
}
}
if (!hasinfo)
{
- if (fz_dictgets(dict, "Creator") || fz_dictgets(dict, "Producer"))
+ if (fz_dict_gets(dict, "Creator") || fz_dict_gets(dict, "Producer"))
{
- pdf_logxref("found info: (%d %d R)\n", i, 0);
- obj = fz_newindirect(i, 0, xref);
- fz_dictputs(xref->trailer, "Info", obj);
- fz_dropobj(obj);
+ pdf_log_xref("found info: (%d %d R)\n", i, 0);
+ obj = fz_new_indirect(i, 0, xref);
+ fz_dict_puts(xref->trailer, "Info", obj);
+ fz_drop_obj(obj);
}
}
- fz_dropobj(dict);
+ fz_drop_obj(dict);
}
}
@@ -654,14 +654,14 @@ pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password)
}
void
-pdf_freexref(pdf_xref *xref)
+pdf_free_xref(pdf_xref *xref)
{
int i;
- pdf_logxref("freexref %p\n", xref);
+ pdf_log_xref("freexref %p\n", xref);
if (xref->store)
- pdf_freestore(xref->store);
+ pdf_free_store(xref->store);
if (xref->table)
{
@@ -669,50 +669,50 @@ pdf_freexref(pdf_xref *xref)
{
if (xref->table[i].obj)
{
- fz_dropobj(xref->table[i].obj);
- xref->table[i].obj = nil;
+ fz_drop_obj(xref->table[i].obj);
+ xref->table[i].obj = NULL;
}
}
fz_free(xref->table);
}
- if (xref->pageobjs)
+ if (xref->page_objs)
{
- for (i = 0; i < xref->pagelen; i++)
- fz_dropobj(xref->pageobjs[i]);
- fz_free(xref->pageobjs);
+ for (i = 0; i < xref->page_len; i++)
+ fz_drop_obj(xref->page_objs[i]);
+ fz_free(xref->page_objs);
}
- if (xref->pagerefs)
+ if (xref->page_refs)
{
- for (i = 0; i < xref->pagelen; i++)
- fz_dropobj(xref->pagerefs[i]);
- fz_free(xref->pagerefs);
+ for (i = 0; i < xref->page_len; i++)
+ fz_drop_obj(xref->page_refs[i]);
+ fz_free(xref->page_refs);
}
if (xref->file)
fz_close(xref->file);
if (xref->trailer)
- fz_dropobj(xref->trailer);
+ fz_drop_obj(xref->trailer);
if (xref->crypt)
- pdf_freecrypt(xref->crypt);
+ pdf_free_crypt(xref->crypt);
fz_free(xref);
}
void
-pdf_debugxref(pdf_xref *xref)
+pdf_debug_xref(pdf_xref *xref)
{
int i;
printf("xref\n0 %d\n", xref->len);
for (i = 0; i < xref->len; i++)
{
- printf("%05d: %010d %05d %c (refs=%d, stmofs=%d)\n", i,
+ printf("%05d: %010d %05d %c (refs=%d, stm_ofs=%d)\n", i,
xref->table[i].ofs,
xref->table[i].gen,
xref->table[i].type ? xref->table[i].type : '-',
xref->table[i].obj ? xref->table[i].obj->refs : 0,
- xref->table[i].stmofs);
+ xref->table[i].stm_ofs);
}
}
@@ -721,7 +721,7 @@ pdf_debugxref(pdf_xref *xref)
*/
static fz_error
-pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap)
+pdf_load_obj_stm(pdf_xref *xref, int num, int gen, char *buf, int cap)
{
fz_error error;
fz_stream *stm;
@@ -735,21 +735,21 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap)
int i, n;
int tok;
- pdf_logxref("loadobjstm (%d %d R)\n", num, gen);
+ pdf_log_xref("loadobjstm (%d %d R)\n", num, gen);
- error = pdf_loadobject(&objstm, xref, num, gen);
+ error = pdf_load_object(&objstm, xref, num, gen);
if (error)
return fz_rethrow(error, "cannot load object stream object (%d %d R)", num, gen);
- count = fz_toint(fz_dictgets(objstm, "N"));
- first = fz_toint(fz_dictgets(objstm, "First"));
+ count = fz_to_int(fz_dict_gets(objstm, "N"));
+ first = fz_to_int(fz_dict_gets(objstm, "First"));
- pdf_logxref("\tcount %d\n", count);
+ pdf_log_xref("\tcount %d\n", count);
numbuf = fz_calloc(count, sizeof(int));
ofsbuf = fz_calloc(count, sizeof(int));
- error = pdf_openstream(&stm, xref, num, gen);
+ error = pdf_open_stream(&stm, xref, num, gen);
if (error)
{
error = fz_rethrow(error, "cannot open object stream (%d %d R)", num, gen);
@@ -759,7 +759,7 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap)
for (i = 0; i < count; i++)
{
error = pdf_lex(&tok, stm, buf, cap, &n);
- if (error || tok != PDF_TINT)
+ if (error || tok != PDF_TOK_INT)
{
error = fz_rethrow(error, "corrupt object stream (%d %d R)", num, gen);
goto cleanupstm;
@@ -767,7 +767,7 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap)
numbuf[i] = atoi(buf);
error = pdf_lex(&tok, stm, buf, cap, &n);
- if (error || tok != PDF_TINT)
+ if (error || tok != PDF_TOK_INT)
{
error = fz_rethrow(error, "corrupt object stream (%d %d R)", num, gen);
goto cleanupstm;
@@ -781,7 +781,7 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap)
{
fz_seek(stm, first + ofsbuf[i], 0);
- error = pdf_parsestmobj(&obj, xref, stm, buf, cap);
+ error = pdf_parse_stm_obj(&obj, xref, stm, buf, cap);
if (error)
{
error = fz_rethrow(error, "cannot parse object %d in stream (%d %d R)", i, num, gen);
@@ -790,7 +790,7 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap)
if (numbuf[i] < 1 || numbuf[i] >= xref->len)
{
- fz_dropobj(obj);
+ fz_drop_obj(obj);
error = fz_throw("object id (%d 0 R) out of range (0..%d)", numbuf[i], xref->len - 1);
goto cleanupstm;
}
@@ -798,19 +798,19 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap)
if (xref->table[numbuf[i]].type == 'o' && xref->table[numbuf[i]].ofs == num)
{
if (xref->table[numbuf[i]].obj)
- fz_dropobj(xref->table[numbuf[i]].obj);
+ fz_drop_obj(xref->table[numbuf[i]].obj);
xref->table[numbuf[i]].obj = obj;
}
else
{
- fz_dropobj(obj);
+ fz_drop_obj(obj);
}
}
fz_close(stm);
fz_free(ofsbuf);
fz_free(numbuf);
- fz_dropobj(objstm);
+ fz_drop_obj(objstm);
return fz_okay;
cleanupstm:
@@ -818,7 +818,7 @@ cleanupstm:
cleanupbuf:
fz_free(ofsbuf);
fz_free(numbuf);
- fz_dropobj(objstm);
+ fz_drop_obj(objstm);
return error; /* already rethrown */
}
@@ -827,10 +827,10 @@ cleanupbuf:
*/
fz_error
-pdf_cacheobject(pdf_xref *xref, int num, int gen)
+pdf_cache_object(pdf_xref *xref, int num, int gen)
{
fz_error error;
- pdf_xrefentry *x;
+ pdf_xref_entry *x;
int rnum, rgen;
if (num < 0 || num >= xref->len)
@@ -843,15 +843,15 @@ pdf_cacheobject(pdf_xref *xref, int num, int gen)
if (x->type == 'f')
{
- x->obj = fz_newnull();
+ x->obj = fz_new_null();
return fz_okay;
}
else if (x->type == 'n')
{
fz_seek(xref->file, x->ofs, 0);
- error = pdf_parseindobj(&x->obj, xref, xref->file, xref->scratch, sizeof xref->scratch,
- &rnum, &rgen, &x->stmofs);
+ error = pdf_parse_ind_obj(&x->obj, xref, xref->file, xref->scratch, sizeof xref->scratch,
+ &rnum, &rgen, &x->stm_ofs);
if (error)
return fz_rethrow(error, "cannot parse object (%d %d R)", num, gen);
@@ -859,13 +859,13 @@ pdf_cacheobject(pdf_xref *xref, int num, int gen)
return fz_throw("found object (%d %d R) instead of (%d %d R)", rnum, rgen, num, gen);
if (xref->crypt)
- pdf_cryptobj(xref->crypt, x->obj, num, gen);
+ pdf_crypt_obj(xref->crypt, x->obj, num, gen);
}
else if (x->type == 'o')
{
if (!x->obj)
{
- error = pdf_loadobjstm(xref, x->ofs, 0, xref->scratch, sizeof xref->scratch);
+ error = pdf_load_obj_stm(xref, x->ofs, 0, xref->scratch, sizeof xref->scratch);
if (error)
return fz_rethrow(error, "cannot load object stream containing object (%d %d R)", num, gen);
if (!x->obj)
@@ -881,32 +881,32 @@ pdf_cacheobject(pdf_xref *xref, int num, int gen)
}
fz_error
-pdf_loadobject(fz_obj **objp, pdf_xref *xref, int num, int gen)
+pdf_load_object(fz_obj **objp, pdf_xref *xref, int num, int gen)
{
fz_error error;
- error = pdf_cacheobject(xref, num, gen);
+ error = pdf_cache_object(xref, num, gen);
if (error)
return fz_rethrow(error, "cannot load object (%d %d R) into cache", num, gen);
assert(xref->table[num].obj);
- *objp = fz_keepobj(xref->table[num].obj);
+ *objp = fz_keep_obj(xref->table[num].obj);
return fz_okay;
}
fz_obj *
-pdf_resolveindirect(fz_obj *ref)
+pdf_resolve_indirect(fz_obj *ref)
{
- if (fz_isindirect(ref))
+ if (fz_is_indirect(ref))
{
pdf_xref *xref = ref->u.r.xref;
- int num = fz_tonum(ref);
- int gen = fz_togen(ref);
+ int num = fz_to_num(ref);
+ int gen = fz_to_gen(ref);
if (xref)
{
- fz_error error = pdf_cacheobject(xref, num, gen);
+ fz_error error = pdf_cache_object(xref, num, gen);
if (error)
{
fz_catch(error, "cannot load object (%d %d R) into cache", num, gen);
@@ -921,9 +921,9 @@ pdf_resolveindirect(fz_obj *ref)
/* Replace numbered object -- for use by pdfclean and similar tools */
void
-pdf_updateobject(pdf_xref *xref, int num, int gen, fz_obj *newobj)
+pdf_update_object(pdf_xref *xref, int num, int gen, fz_obj *newobj)
{
- pdf_xrefentry *x;
+ pdf_xref_entry *x;
if (num < 0 || num >= xref->len)
{
@@ -934,29 +934,29 @@ pdf_updateobject(pdf_xref *xref, int num, int gen, fz_obj *newobj)
x = &xref->table[num];
if (x->obj)
- fz_dropobj(x->obj);
+ fz_drop_obj(x->obj);
- x->obj = fz_keepobj(newobj);
+ x->obj = fz_keep_obj(newobj);
x->type = 'n';
x->ofs = 0;
}
/*
- * Convenience function to open a file then call pdf_openxrefwithstream.
+ * Convenience function to open a file then call pdf_open_xref_with_stream.
*/
fz_error
-pdf_openxref(pdf_xref **xrefp, char *filename, char *password)
+pdf_open_xref(pdf_xref **xrefp, char *filename, char *password)
{
fz_error error;
pdf_xref *xref;
fz_stream *file;
- file = fz_openfile(filename);
+ file = fz_open_file(filename);
if (!file)
return fz_throw("cannot open file '%s': %s", filename, strerror(errno));
- error = pdf_openxrefwithstream(&xref, file, password);
+ error = pdf_open_xref_with_stream(&xref, file, password);
if (error)
return fz_rethrow(error, "cannot load document '%s'", filename);