From 3afdcd7307fd5e68f35c7bb91a4d856499f1df44 Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor.andersson@artifex.com>
Date: Tue, 15 Dec 2015 11:31:36 +0100
Subject: Rename fz_write_x to fz_save_pixmap_as_x or fz_save_bitmap_as_x.

Separate naming of functions that save complete files to disk
from functions that write data to streams.
---
 source/fitz/bitmap.c        |  2 +-
 source/fitz/document.c      |  6 ++--
 source/fitz/draw-device.c   |  2 +-
 source/fitz/output-pcl.c    |  4 +--
 source/fitz/output-pwg.c    |  4 +--
 source/fitz/pixmap.c        |  8 ++---
 source/gprf/gprf-skeleton.c |  2 +-
 source/pdf/pdf-clean-file.c |  4 +--
 source/pdf/pdf-write.c      | 80 ++++++++++++++++++++++-----------------------
 source/pdf/pdf-xref.c       |  2 +-
 source/tools/mudraw.c       | 18 +++++-----
 source/tools/pdfclean.c     |  2 +-
 source/tools/pdfextract.c   |  4 +--
 source/tools/pdfposter.c    |  4 +--
 14 files changed, 71 insertions(+), 71 deletions(-)

(limited to 'source')

diff --git a/source/fitz/bitmap.c b/source/fitz/bitmap.c
index 5d2af061..a9a53a98 100644
--- a/source/fitz/bitmap.c
+++ b/source/fitz/bitmap.c
@@ -67,7 +67,7 @@ fz_output_pbm(fz_context *ctx, fz_output *out, fz_bitmap *bitmap)
 }
 
 void
-fz_write_pbm(fz_context *ctx, fz_bitmap *bitmap, char *filename)
+fz_save_bitmap_as_pbm(fz_context *ctx, fz_bitmap *bitmap, char *filename)
 {
 	fz_output *out = fz_new_output_with_path(ctx, filename, 0);
 	fz_try(ctx)
diff --git a/source/fitz/document.c b/source/fitz/document.c
index 1fc4ff87..588ee71c 100644
--- a/source/fitz/document.c
+++ b/source/fitz/document.c
@@ -240,10 +240,10 @@ fz_lookup_metadata(fz_context *ctx, fz_document *doc, const char *key, char *buf
 }
 
 void
-fz_write_document(fz_context *ctx, fz_document *doc, char *filename, fz_write_options *opts)
+fz_save_document(fz_context *ctx, fz_document *doc, char *filename, fz_save_options *opts)
 {
-	if (doc && doc->write)
-		doc->write(ctx, doc, filename, opts);
+	if (doc && doc->save)
+		doc->save(ctx, doc, filename, opts);
 }
 
 fz_page *
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index 065daaa9..08ab129a 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -63,7 +63,7 @@ static void fz_dump_blend(fz_context *ctx, fz_pixmap *pix, const char *s)
 		printf("%s%02d", s, group_dump_count);
 	group_dump_count++;
 
-	fz_write_png(ctx, pix, name, (pix->n > 1));
+	fz_save_pixmap_as_png(ctx, pix, name, (pix->n > 1));
 }
 
 static void dump_spaces(int x, const char *s)
diff --git a/source/fitz/output-pcl.c b/source/fitz/output-pcl.c
index 9d21a6d3..a87a84a9 100644
--- a/source/fitz/output-pcl.c
+++ b/source/fitz/output-pcl.c
@@ -790,7 +790,7 @@ fz_output_pcl_bitmap(fz_context *ctx, fz_output *out, const fz_bitmap *bitmap, f
 }
 
 void
-fz_write_pcl(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, fz_pcl_options *pcl)
+fz_save_pixmap_as_pcl(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, fz_pcl_options *pcl)
 {
 	fz_output *out = fz_new_output_with_path(ctx, filename, append);
 	fz_try(ctx)
@@ -802,7 +802,7 @@ fz_write_pcl(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, fz_
 }
 
 void
-fz_write_pcl_bitmap(fz_context *ctx, fz_bitmap *bitmap, char *filename, int append, fz_pcl_options *pcl)
+fz_save_bitmap_as_pcl(fz_context *ctx, fz_bitmap *bitmap, char *filename, int append, fz_pcl_options *pcl)
 {
 	fz_output *out = fz_new_output_with_path(ctx, filename, append);
 	fz_try(ctx)
diff --git a/source/fitz/output-pwg.c b/source/fitz/output-pwg.c
index d46dd04f..4810049a 100644
--- a/source/fitz/output-pwg.c
+++ b/source/fitz/output-pwg.c
@@ -258,7 +258,7 @@ fz_output_pwg(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz
 }
 
 void
-fz_write_pwg(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, const fz_pwg_options *pwg)
+fz_save_pixmap_as_pwg(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, const fz_pwg_options *pwg)
 {
 	fz_output *out = fz_new_output_with_path(ctx, filename, append);
 	fz_try(ctx)
@@ -274,7 +274,7 @@ fz_write_pwg(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, con
 }
 
 void
-fz_write_pwg_bitmap(fz_context *ctx, fz_bitmap *bitmap, char *filename, int append, const fz_pwg_options *pwg)
+fz_save_bitmap_as_pwg(fz_context *ctx, fz_bitmap *bitmap, char *filename, int append, const fz_pwg_options *pwg)
 {
 	fz_output *out = fz_new_output_with_path(ctx, filename, append);
 	fz_try(ctx)
diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c
index 9f1ec20e..255418bb 100644
--- a/source/fitz/pixmap.c
+++ b/source/fitz/pixmap.c
@@ -583,7 +583,7 @@ fz_output_pnm(fz_context *ctx, fz_output *out, fz_pixmap *pixmap)
 }
 
 void
-fz_write_pnm(fz_context *ctx, fz_pixmap *pixmap, char *filename)
+fz_save_pixmap_as_pnm(fz_context *ctx, fz_pixmap *pixmap, char *filename)
 {
 	fz_output *out = fz_new_output_with_path(ctx, filename, 0);
 	fz_output_pnm_header(ctx, out, pixmap->w, pixmap->h, pixmap->n);
@@ -652,7 +652,7 @@ fz_output_pam(fz_context *ctx, fz_output *out, fz_pixmap *pixmap, int savealpha)
 }
 
 void
-fz_write_pam(fz_context *ctx, fz_pixmap *pixmap, char *filename, int savealpha)
+fz_save_pixmap_as_pam(fz_context *ctx, fz_pixmap *pixmap, char *filename, int savealpha)
 {
 	fz_output *out = fz_new_output_with_path(ctx, filename, 0);
 	fz_output_pam_header(ctx, out, pixmap->w, pixmap->h, pixmap->n, savealpha);
@@ -687,7 +687,7 @@ static void putchunk(fz_context *ctx, fz_output *out, char *tag, unsigned char *
 }
 
 void
-fz_write_png(fz_context *ctx, fz_pixmap *pixmap, char *filename, int savealpha)
+fz_save_pixmap_as_png(fz_context *ctx, fz_pixmap *pixmap, const char *filename, int savealpha)
 {
 	fz_output *out = fz_new_output_with_path(ctx, filename, 0);
 	fz_png_output_context *poc = NULL;
@@ -978,7 +978,7 @@ static inline void tga_put_pixel(fz_context *ctx, fz_output *out, unsigned char
 }
 
 void
-fz_write_tga(fz_context *ctx, fz_pixmap *pixmap, const char *filename, int savealpha)
+fz_save_pixmap_as_tga(fz_context *ctx, fz_pixmap *pixmap, const char *filename, int savealpha)
 {
 	fz_output *out;
 	unsigned char head[18];
diff --git a/source/gprf/gprf-skeleton.c b/source/gprf/gprf-skeleton.c
index 6ed8a29d..ad0cb6a8 100644
--- a/source/gprf/gprf-skeleton.c
+++ b/source/gprf/gprf-skeleton.c
@@ -1,7 +1,7 @@
 #include "mupdf/fitz.h"
 
 void
-fz_write_gproof_file(fz_context *ctx, const char *pdf_file, fz_document *doc, const char *filename, int res,
+fz_save_gproof(fz_context *ctx, const char *pdf_file, fz_document *doc, const char *filename, int res,
 				const char *print_profile, const char *display_profile)
 {
 	int i;
diff --git a/source/pdf/pdf-clean-file.c b/source/pdf/pdf-clean-file.c
index f1302efb..69e796b3 100644
--- a/source/pdf/pdf-clean-file.c
+++ b/source/pdf/pdf-clean-file.c
@@ -190,7 +190,7 @@ static void retainpages(fz_context *ctx, globals *glo, int argc, char **argv)
 	}
 }
 
-void pdf_clean_file(fz_context *ctx, char *infile, char *outfile, char *password, fz_write_options *opts, char *argv[], int argc)
+void pdf_clean_file(fz_context *ctx, char *infile, char *outfile, char *password, fz_save_options *opts, char *argv[], int argc)
 {
 	globals glo = { 0 };
 
@@ -207,7 +207,7 @@ void pdf_clean_file(fz_context *ctx, char *infile, char *outfile, char *password
 		if (argc)
 			retainpages(ctx, &glo, argc, argv);
 
-		pdf_write_document(ctx, glo.doc, outfile, opts);
+		pdf_save_document(ctx, glo.doc, outfile, opts);
 	}
 	fz_always(ctx)
 	{
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 1c7a3739..b321edf7 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -6,7 +6,7 @@
 /* #define DEBUG_HEAP_SORT */
 /* #define DEBUG_WRITING */
 
-typedef struct pdf_write_options_s pdf_write_options;
+typedef struct pdf_save_options_s pdf_save_options;
 
 /*
 	As part of linearization, we need to keep a list of what objects are used
@@ -45,7 +45,7 @@ typedef struct {
 	page_objects *page[1];
 } page_objects_list;
 
-struct pdf_write_options_s
+struct pdf_save_options_s
 {
 	fz_output *out;
 	int do_incremental;
@@ -181,7 +181,7 @@ page_objects_insert(fz_context *ctx, page_objects **ppo, int i)
 }
 
 static void
-page_objects_list_insert(fz_context *ctx, pdf_write_options *opts, int page, int object)
+page_objects_list_insert(fz_context *ctx, pdf_save_options *opts, int page, int object)
 {
 	page_objects_list_ensure(ctx, &opts->page_object_lists, page+1);
 	if (opts->page_object_lists->len < page+1)
@@ -190,7 +190,7 @@ page_objects_list_insert(fz_context *ctx, pdf_write_options *opts, int page, int
 }
 
 static void
-page_objects_list_set_page_object(fz_context *ctx, pdf_write_options *opts, int page, int object)
+page_objects_list_set_page_object(fz_context *ctx, pdf_save_options *opts, int page, int object)
 {
 	page_objects_list_ensure(ctx, &opts->page_object_lists, page+1);
 	opts->page_object_lists->page[page]->page_object_number = object;
@@ -472,7 +472,7 @@ page_objects_list_sort_and_dedupe(fz_context *ctx, page_objects_list *pol)
 
 #ifdef DEBUG_LINEARIZATION
 static void
-page_objects_dump(pdf_write_options *opts)
+page_objects_dump(pdf_save_options *opts)
 {
 	page_objects_list *pol = opts->page_object_lists;
 	int i, j;
@@ -493,7 +493,7 @@ page_objects_dump(pdf_write_options *opts)
 }
 
 static void
-objects_dump(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+objects_dump(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	int i;
 
@@ -513,7 +513,7 @@ objects_dump(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
  * that we can continue our recursive marking. If it's a duff reference
  * return the fact so that we can remove the reference at source.
  */
-static pdf_obj *markref(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *obj, int *duff)
+static pdf_obj *markref(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *obj, int *duff)
 {
 	int num = pdf_to_num(ctx, obj);
 	int gen = pdf_to_gen(ctx, obj);
@@ -561,7 +561,7 @@ static pdf_obj *markref(fz_context *ctx, pdf_document *doc, pdf_write_options *o
 
 /* Recursively mark an object. If any references found are duff, then
  * replace them with nulls. */
-static int markobj(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *obj)
+static int markobj(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *obj)
 {
 	int i;
 
@@ -596,7 +596,7 @@ static int markobj(fz_context *ctx, pdf_document *doc, pdf_write_options *opts,
  * Scan for and remove duplicate objects (slow)
  */
 
-static void removeduplicateobjs(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+static void removeduplicateobjs(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	int num, other;
 	int xref_len = pdf_xref_len(ctx, doc);
@@ -696,7 +696,7 @@ static void removeduplicateobjs(fz_context *ctx, pdf_document *doc, pdf_write_op
  * This code assumes that any opts->renumber_map[n] <= n for all n.
  */
 
-static void compactxref(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+static void compactxref(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	int num, newnum;
 	int xref_len = pdf_xref_len(ctx, doc);
@@ -738,7 +738,7 @@ static void compactxref(fz_context *ctx, pdf_document *doc, pdf_write_options *o
  * removing duplicate objects and compacting the xref.
  */
 
-static void renumberobj(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *obj)
+static void renumberobj(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *obj)
 {
 	int i;
 	int xref_len = pdf_xref_len(ctx, doc);
@@ -791,7 +791,7 @@ static void renumberobj(fz_context *ctx, pdf_document *doc, pdf_write_options *o
 	}
 }
 
-static void renumberobjs(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+static void renumberobjs(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	pdf_xref_entry *newxref = NULL;
 	int newlen;
@@ -877,7 +877,7 @@ static void renumberobjs(fz_context *ctx, pdf_document *doc, pdf_write_options *
 	}
 }
 
-static void page_objects_list_renumber(pdf_write_options *opts)
+static void page_objects_list_renumber(pdf_save_options *opts)
 {
 	int i, j;
 
@@ -893,7 +893,7 @@ static void page_objects_list_renumber(pdf_write_options *opts)
 }
 
 static void
-mark_all(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *val, int flag, int page)
+mark_all(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *val, int flag, int page)
 {
 
 	if (pdf_mark_obj(ctx, val))
@@ -943,7 +943,7 @@ mark_all(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *v
 }
 
 static int
-mark_pages(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *val, int pagenum)
+mark_pages(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *val, int pagenum)
 {
 
 	if (pdf_mark_obj(ctx, val))
@@ -1011,7 +1011,7 @@ mark_pages(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj
 }
 
 static void
-mark_root(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *dict)
+mark_root(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *dict)
 {
 	int i, n = pdf_dict_len(ctx, dict);
 
@@ -1063,7 +1063,7 @@ mark_root(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *
 }
 
 static void
-mark_trailer(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *dict)
+mark_trailer(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *dict)
 {
 	int i, n = pdf_dict_len(ctx, dict);
 
@@ -1094,7 +1094,7 @@ mark_trailer(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_ob
 }
 
 static void
-add_linearization_objs(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+add_linearization_objs(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	pdf_obj *params_obj = NULL;
 	pdf_obj *params_ref = NULL;
@@ -1357,7 +1357,7 @@ pdf_localise_page_resources(fz_context *ctx, pdf_document *doc)
 }
 
 static void
-linearize(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+linearize(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	int i;
 	int n = pdf_xref_len(ctx, doc) + 2;
@@ -1433,7 +1433,7 @@ linearize(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
 }
 
 static void
-update_linearization_params(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+update_linearization_params(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	fz_off_t offset;
 	pdf_set_int(ctx, opts->linear_l, opts->file_len);
@@ -1587,7 +1587,7 @@ static fz_buffer *deflatebuf(fz_context *ctx, unsigned char *p, int n)
 	return buf;
 }
 
-static void copystream(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *obj_orig, int num, int gen)
+static void copystream(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *obj_orig, int num, int gen)
 {
 	fz_buffer *buf, *tmp;
 	pdf_obj *newlen;
@@ -1631,7 +1631,7 @@ static void copystream(fz_context *ctx, pdf_document *doc, pdf_write_options *op
 	pdf_drop_obj(ctx, obj);
 }
 
-static void expandstream(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *obj_orig, int num, int gen)
+static void expandstream(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *obj_orig, int num, int gen)
 {
 	fz_buffer *buf, *tmp;
 	pdf_obj *newlen;
@@ -1708,7 +1708,7 @@ static int filter_implies_image(fz_context *ctx, pdf_document *doc, pdf_obj *o)
 	return 0;
 }
 
-static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, int num, int gen, int skip_xrefs)
+static void writeobject(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, int num, int gen, int skip_xrefs)
 {
 	pdf_xref_entry *entry;
 	pdf_obj *obj;
@@ -1821,7 +1821,7 @@ static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_options *o
 	pdf_drop_obj(ctx, obj);
 }
 
-static void writexrefsubsect(fz_context *ctx, pdf_write_options *opts, int from, int to)
+static void writexrefsubsect(fz_context *ctx, pdf_save_options *opts, int from, int to)
 {
 	int num;
 
@@ -1835,7 +1835,7 @@ static void writexrefsubsect(fz_context *ctx, pdf_write_options *opts, int from,
 	}
 }
 
-static void writexref(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, int from, int to, int first, int main_xref_offset, int startxref)
+static void writexref(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, int from, int to, int first, int main_xref_offset, int startxref)
 {
 	pdf_obj *trailer = NULL;
 	pdf_obj *obj;
@@ -1935,7 +1935,7 @@ static void writexref(fz_context *ctx, pdf_document *doc, pdf_write_options *opt
 	doc->has_xref_streams = 0;
 }
 
-static void writexrefstreamsubsect(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, pdf_obj *index, fz_buffer *fzbuf, int from, int to)
+static void writexrefstreamsubsect(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, pdf_obj *index, fz_buffer *fzbuf, int from, int to)
 {
 	int num;
 
@@ -1952,7 +1952,7 @@ static void writexrefstreamsubsect(fz_context *ctx, pdf_document *doc, pdf_write
 	}
 }
 
-static void writexrefstream(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, int from, int to, int first, int main_xref_offset, int startxref)
+static void writexrefstream(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, int from, int to, int first, int main_xref_offset, int startxref)
 {
 	int num;
 	pdf_obj *dict = NULL;
@@ -2082,7 +2082,7 @@ padto(fz_context *ctx, fz_output *out, fz_off_t target)
 }
 
 static void
-dowriteobject(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, int num, int pass)
+dowriteobject(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, int num, int pass)
 {
 	pdf_xref_entry *entry = pdf_get_xref_entry(ctx, doc, num);
 	if (entry->type == 'f')
@@ -2118,7 +2118,7 @@ dowriteobject(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, int n
 }
 
 static void
-writeobjects(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, int pass)
+writeobjects(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, int pass)
 {
 	int num;
 	int xref_len = pdf_xref_len(ctx, doc);
@@ -2174,7 +2174,7 @@ my_log2(int x)
 }
 
 static void
-make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, fz_buffer *buf)
+make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, fz_buffer *buf)
 {
 	int i, j;
 	int min_objs_per_page, max_objs_per_page;
@@ -2444,7 +2444,7 @@ make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_write_options *op
 }
 
 static void
-make_hint_stream(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+make_hint_stream(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	fz_buffer *buf = fz_new_buffer(ctx, 100);
 
@@ -2463,7 +2463,7 @@ make_hint_stream(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
 }
 
 #ifdef DEBUG_WRITING
-static void dump_object_details(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
+static void dump_object_details(fz_context *ctx, pdf_document *doc, pdf_save_options *opts)
 {
 	int i;
 
@@ -2511,7 +2511,7 @@ static void presize_unsaved_signature_byteranges(fz_context *ctx, pdf_document *
 	}
 }
 
-static void complete_signatures(fz_context *ctx, pdf_document *doc, pdf_write_options *opts, char *filename)
+static void complete_signatures(fz_context *ctx, pdf_document *doc, pdf_save_options *opts, char *filename)
 {
 	pdf_unsaved_sig *usig;
 	char buf[5120];
@@ -2615,9 +2615,9 @@ static void sanitize(fz_context *ctx, pdf_document *doc, int ascii)
 	}
 }
 
-/* Initialise the pdf_write_options, used dynamically during the write, from the static
- * fz_write_options, passed into pdf_write_document */
-static void initialise_write_options(fz_context *ctx, pdf_document *doc, const fz_write_options *fz_opts, pdf_write_options *opts)
+/* Initialise the pdf_save_options, used dynamically during the write, from the static
+ * fz_save_options, passed into pdf_save_document */
+static void initialise_write_options(fz_context *ctx, pdf_document *doc, const fz_save_options *fz_opts, pdf_save_options *opts)
 {
 	int num;
 	int xref_len = pdf_xref_len(ctx, doc);
@@ -2655,7 +2655,7 @@ static void initialise_write_options(fz_context *ctx, pdf_document *doc, const f
 }
 
 /* Free the resources held by the dynamic write options */
-static void finalise_write_options(fz_context *ctx, pdf_write_options *opts)
+static void finalise_write_options(fz_context *ctx, pdf_save_options *opts)
 {
 	fz_free(ctx, opts->use_list);
 	fz_free(ctx, opts->ofs_list);
@@ -2676,10 +2676,10 @@ static void finalise_write_options(fz_context *ctx, pdf_write_options *opts)
 	fz_drop_output(ctx, opts->out);
 }
 
-void pdf_write_document(fz_context *ctx, pdf_document *doc, char *filename, fz_write_options *fz_opts)
+void pdf_save_document(fz_context *ctx, pdf_document *doc, char *filename, fz_save_options *fz_opts)
 {
-	fz_write_options opts_defaults = { 0 };
-	pdf_write_options opts = { 0 };
+	fz_save_options opts_defaults = { 0 };
+	pdf_save_options opts = { 0 };
 
 	int lastfree;
 	int num;
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index f65edefc..960c1c34 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -2336,7 +2336,7 @@ pdf_new_document(fz_context *ctx, fz_stream *file)
 	doc->super.count_pages = (fz_document_count_pages_fn *)pdf_count_pages;
 	doc->super.load_page = (fz_document_load_page_fn *)pdf_load_page;
 	doc->super.lookup_metadata = (fz_document_lookup_metadata_fn *)pdf_lookup_metadata;
-	doc->super.write = (fz_document_write_fn *)pdf_write_document;
+	doc->super.save = (fz_document_save_fn *)pdf_save_document;
 	doc->update_appearance = pdf_update_appearance;
 
 	pdf_lexbuf_init(ctx, &doc->lexbuf.base, PDF_LEXBUF_LARGE);
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index b486171a..f80c2c0e 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -615,11 +615,11 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
 						if (out_cs == CS_MONO)
 						{
 							fz_bitmap *bit = fz_halftone_pixmap(ctx, pix, NULL);
-							fz_write_pwg_bitmap(ctx, bit, filename_buf, append, NULL);
+							fz_save_bitmap_as_pwg(ctx, bit, filename_buf, append, NULL);
 							fz_drop_bitmap(ctx, bit);
 						}
 						else
-							fz_write_pwg(ctx, pix, filename_buf, append, NULL);
+							fz_save_pixmap_as_pwg(ctx, pix, filename_buf, append, NULL);
 						append = 1;
 					}
 					else if (output_format == OUT_PCL)
@@ -633,21 +633,21 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
 						if (out_cs == CS_MONO)
 						{
 							fz_bitmap *bit = fz_halftone_pixmap(ctx, pix, NULL);
-							fz_write_pcl_bitmap(ctx, bit, filename_buf, append, &options);
+							fz_save_bitmap_as_pcl(ctx, bit, filename_buf, append, &options);
 							fz_drop_bitmap(ctx, bit);
 						}
 						else
-							fz_write_pcl(ctx, pix, filename_buf, append, &options);
+							fz_save_pixmap_as_pcl(ctx, pix, filename_buf, append, &options);
 						append = 1;
 					}
 					else if (output_format == OUT_PBM) {
 						fz_bitmap *bit = fz_halftone_pixmap(ctx, pix, NULL);
-						fz_write_pbm(ctx, bit, filename_buf);
+						fz_save_bitmap_as_pbm(ctx, bit, filename_buf);
 						fz_drop_bitmap(ctx, bit);
 					}
 					else if (output_format == OUT_TGA)
 					{
-						fz_write_tga(ctx, pix, filename_buf, savealpha);
+						fz_save_pixmap_as_tga(ctx, pix, filename_buf, savealpha);
 					}
 				}
 				ctm.f -= drawheight;
@@ -1094,7 +1094,7 @@ int mudraw_main(int argc, char **argv)
 					fz_printf(ctx, out, "<document name=\"%s\">\n", filename);
 				if (output_format == OUT_GPROOF)
 				{
-					fz_write_gproof_file(ctx, filename, doc, output, resolution, "", "");
+					fz_save_gproof(ctx, filename, doc, output, resolution, "", "");
 				}
 				else
 				{
@@ -1130,9 +1130,9 @@ int mudraw_main(int argc, char **argv)
 
 	if (pdfout)
 	{
-		fz_write_options opts = { 0 };
+		fz_save_options opts = { 0 };
 
-		pdf_write_document(ctx, pdfout, output, &opts);
+		pdf_save_document(ctx, pdfout, output, &opts);
 		pdf_close_document(ctx, pdfout);
 	}
 
diff --git a/source/tools/pdfclean.c b/source/tools/pdfclean.c
index 7a7f68bc..93ec762d 100644
--- a/source/tools/pdfclean.c
+++ b/source/tools/pdfclean.c
@@ -37,7 +37,7 @@ int pdfclean_main(int argc, char **argv)
 	char *outfile = "out.pdf";
 	char *password = "";
 	int c;
-	fz_write_options opts;
+	fz_save_options opts;
 	int errors = 0;
 	fz_context *ctx;
 
diff --git a/source/tools/pdfextract.c b/source/tools/pdfextract.c
index 0c89931a..6f2ed1ca 100644
--- a/source/tools/pdfextract.c
+++ b/source/tools/pdfextract.c
@@ -48,13 +48,13 @@ static void writepixmap(fz_context *ctx, fz_pixmap *pix, char *file, int rgb)
 	{
 		snprintf(buf, sizeof(buf), "%s.png", file);
 		printf("extracting image %s\n", buf);
-		fz_write_png(ctx, pix, buf, 0);
+		fz_save_pixmap_as_png(ctx, pix, buf, 0);
 	}
 	else
 	{
 		snprintf(buf, sizeof(buf), "%s.pam", file);
 		printf("extracting image %s\n", buf);
-		fz_write_pam(ctx, pix, buf, 0);
+		fz_save_pixmap_as_pam(ctx, pix, buf, 0);
 	}
 
 	fz_drop_pixmap(ctx, converted);
diff --git a/source/tools/pdfposter.c b/source/tools/pdfposter.c
index 9a58909e..16bbc080 100644
--- a/source/tools/pdfposter.c
+++ b/source/tools/pdfposter.c
@@ -157,7 +157,7 @@ int pdfposter_main(int argc, char **argv)
 	char *outfile = "out.pdf";
 	char *password = "";
 	int c;
-	fz_write_options opts = { 0 };
+	fz_save_options opts = { 0 };
 	pdf_document *doc;
 	fz_context *ctx;
 
@@ -203,7 +203,7 @@ int pdfposter_main(int argc, char **argv)
 
 	decimatepages(ctx, doc);
 
-	pdf_write_document(ctx, doc, outfile, &opts);
+	pdf_save_document(ctx, doc, outfile, &opts);
 
 	pdf_close_document(ctx, doc);
 	fz_drop_context(ctx);
-- 
cgit v1.2.3