[gs-commits] mupdf 1.16.1.epub-prerelease-9 pdfapp: Provide app handle

[email protected] (Sebastian Rasmussen) Mon, 28 Oct 2019 11:21:50 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
commit e3680c43ac03c89fa7cb59c4aadb016616957d84
Author: Sebastian Rasmussen <[email protected]>
Date:   Wed Oct 23 12:50:03 2019 +0200

    pdfapp: Provide app handle to all API calls.

diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index e9a4c95..fa201c6 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -680,7 +680,7 @@ static int pdfapp_save(pdfapp_t *app)
 
 		if (strcmp(buf, app->docpath) != 0)
 		{
-			wincopyfile(app->docpath, buf);
+			wincopyfile(app, app->docpath, buf);
 			pdf_save_document(app->ctx, idoc, buf, &opts);
 			pdfapp_close(app);
 			pdfapp_open(app, buf, 1);
@@ -693,7 +693,7 @@ static int pdfapp_save(pdfapp_t *app)
 
 			fz_try(app->ctx)
 			{
-				wincopyfile(app->docpath, buf);
+				wincopyfile(app, app->docpath, buf);
 				pdf_save_document(app->ctx, idoc, buf, &opts);
 				written = 1;
 			}
@@ -706,7 +706,7 @@ static int pdfapp_save(pdfapp_t *app)
 				char buf2[PATH_MAX];
 				fz_strlcpy(buf2, app->docpath, PATH_MAX);
 				pdfapp_close(app);
-				winreplacefile(buf, buf2);
+				winreplacefile(app, buf, buf2);
 				pdfapp_open(app, buf2, 1);
 
 				return written;
diff --git a/platform/x11/pdfapp.h b/platform/x11/pdfapp.h
index 4f3fdb0..dc29ace 100644
--- a/platform/x11/pdfapp.h
+++ b/platform/x11/pdfapp.h
@@ -42,13 +42,13 @@ extern void winhelp(pdfapp_t*);
 extern void winfullscreen(pdfapp_t*, int state);
 extern int winsavequery(pdfapp_t*);
 extern int winquery(pdfapp_t*, const char*);
-extern int wingetcertpath(char *buf, int len);
+extern int wingetcertpath(pdfapp_t *, char *buf, int len);
 extern int wingetsavepath(pdfapp_t*, char *buf, int len);
 extern void winalert(pdfapp_t *, pdf_alert_event *alert);
 extern void winprint(pdfapp_t *);
 extern void winadvancetimer(pdfapp_t *, float duration);
-extern void winreplacefile(char *source, char *target);
-extern void wincopyfile(char *source, char *target);
+extern void winreplacefile(pdfapp_t *, char *source, char *target);
+extern void wincopyfile(pdfapp_t *, char *source, char *target);
 extern void winreloadpage(pdfapp_t *);
 
 struct pdfapp_s
diff --git a/platform/x11/win_main.c b/platform/x11/win_main.c
index 5ad4af3..5a56d02 100644
--- a/platform/x11/win_main.c
+++ b/platform/x11/win_main.c
@@ -213,7 +213,7 @@ int winfilename(wchar_t *buf, int len)
 	return GetOpenFileNameW(&ofn);
 }
 
-int wingetcertpath(char *buf, int len)
+int wingetcertpath(pdfapp_t *app, char *buf, int len)
 {
 	wchar_t twbuf[PATH_MAX] = {0};
 	OPENFILENAME ofn;
@@ -232,7 +232,7 @@ int wingetcertpath(char *buf, int len)
 		int code = WideCharToMultiByte(CP_UTF8, 0, twbuf, -1, buf, MIN(PATH_MAX, len), NULL, NULL);
 		if (code == 0)
 		{
-			winerror(&gapp, "cannot convert filename to utf-8");
+			pdfapp_error(app, "cannot convert filename to utf-8");
 			return 0;
 		}
 
@@ -278,7 +278,7 @@ int wingetsavepath(pdfapp_t *app, char *buf, int len)
 	}
 }
 
-void winreplacefile(char *source, char *target)
+void winreplacefile(pdfapp_t *app, char *source, char *target)
 {
 	wchar_t wsource[PATH_MAX];
 	wchar_t wtarget[PATH_MAX];
@@ -286,14 +286,14 @@ void winreplacefile(char *source, char *target)
 	int sz = MultiByteToWideChar(CP_UTF8, 0, source, -1, wsource, PATH_MAX);
 	if (sz == 0)
 	{
-		winerror(&gapp, "cannot convert filename to Unicode");
+		pdfapp_error(app, "cannot convert filename to Unicode");
 		return;
 	}
 
 	sz = MultiByteToWideChar(CP_UTF8, 0, target, -1, wtarget, PATH_MAX);
 	if (sz == 0)
 	{
-		winerror(&gapp, "cannot convert filename to Unicode");
+		pdfapp_error(app, "cannot convert filename to Unicode");
 		return;
 	}
 
@@ -305,7 +305,7 @@ void winreplacefile(char *source, char *target)
 #endif
 }
 
-void wincopyfile(char *source, char *target)
+void wincopyfile(pdfapp_t *app, char *source, char *target)
 {
 	wchar_t wsource[PATH_MAX];
 	wchar_t wtarget[PATH_MAX];
@@ -313,14 +313,14 @@ void wincopyfile(char *source, char *target)
 	int sz = MultiByteToWideChar(CP_UTF8, 0, source, -1, wsource, PATH_MAX);
 	if (sz == 0)
 	{
-		winerror(&gapp, "cannot convert filename to Unicode");
+		pdfapp_error(app, "cannot convert filename to Unicode");
 		return;
 	}
 
 	sz = MultiByteToWideChar(CP_UTF8, 0, target, -1, wtarget, PATH_MAX);
 	if (sz == 0)
 	{
-		winerror(&gapp, "cannot convert filename to Unicode");
+		pdfapp_error(app, "cannot convert filename to Unicode");
 		return;
 	}
 
diff --git a/platform/x11/x11_main.c b/platform/x11/x11_main.c
index a902bd5..f85a108 100644
--- a/platform/x11/x11_main.c
+++ b/platform/x11/x11_main.c
@@ -309,12 +309,12 @@ int wingetsavepath(pdfapp_t *app, char *buf, int len)
 	return 0;
 }
 
-void winreplacefile(char *source, char *target)
+void winreplacefile(pdfapp_t *app, char *source, char *target)
 {
 	rename(source, target);
 }
 
-void wincopyfile(char *source, char *target)
+void wincopyfile(pdfapp_t *app, char *source, char *target)
 {
 	FILE *in, *out;
 	char buf[32 << 10];
@@ -323,13 +323,13 @@ void wincopyfile(char *source, char *target)
 	in = fopen(source, "rb");
 	if (!in)
 	{
-		winerror(&gapp, "cannot open source file for copying");
+		pdfapp_error(app, "cannot open source file for copying");
 		return;
 	}
 	out = fopen(target, "wb");
 	if (!out)
 	{
-		winerror(&gapp, "cannot open target file for copying");
+		pdfapp_error(app, "cannot open target file for copying");
 		fclose(in);
 		return;
 	}
@@ -341,7 +341,7 @@ void wincopyfile(char *source, char *target)
 		if (n < sizeof buf)
 		{
 			if (ferror(in))
-				winerror(&gapp, "cannot read data from source file");
+				pdfapp_error(app, "cannot read data from source file");
 			break;
 		}
 	}
@@ -783,7 +783,7 @@ int winquery(pdfapp_t *app, const char *query)
 	return QUERY_NO;
 }
 
-int wingetcertpath(char *buf, int len)
+int wingetcertpath(pdfapp_t *app, char *buf, int len)
 {
 	return 0;
 }

http://git.ghostscript.com/?p=mupdf.git;a=commit;h=e3680c43ac03c89fa7cb59c4aadb016616957d84

--
MuPDF library
Artifex Software, Inc.