summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-05-14 01:49:22 +0200
committerTor Andersson <tor@ghostscript.com>2010-05-14 01:49:22 +0200
commit08e7bb2f11ff940998daf8dbadfaaef3eaec7496 (patch)
tree260154b98a32d7b94f4ffb93e1ece9db1fa92d18
parent92c591efc27373c0ae876ca55eb1f34da81ca9ec (diff)
downloadmupdf-08e7bb2f11ff940998daf8dbadfaaef3eaec7496.tar.xz
Change pdf_openxref to take a fz_stream instead of a filename so that windows can open files with unicode names.
-rw-r--r--apps/pdfapp.c8
-rw-r--r--apps/pdfapp.h3
-rw-r--r--apps/pdftool.c10
-rw-r--r--apps/win_main.c185
-rw-r--r--apps/x11_main.c7
-rw-r--r--fitz/fitz_stream.h8
-rw-r--r--fitz/stm_open.c27
-rw-r--r--mupdf/cmapdump.c9
-rw-r--r--mupdf/mupdf.h2
-rw-r--r--mupdf/pdf_image.c2
-rw-r--r--mupdf/pdf_interpret.c2
-rw-r--r--mupdf/pdf_open.c8
-rw-r--r--mupdf/pdf_stream.c4
-rw-r--r--win32/mupdf_viewer/mupdf_viewer.vcproj6
-rw-r--r--win32/pdfclean/pdfclean.vcproj2
-rw-r--r--win32/pdfdraw/pdfdraw.vcproj2
-rw-r--r--win32/pdfextract/pdfextract.vcproj2
-rw-r--r--win32/pdfinfo/pdfinfo.vcproj2
-rw-r--r--win32/pdfshow/pdfshow.vcproj2
19 files changed, 137 insertions, 154 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index ae465587..2f8a57fc 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -59,19 +59,19 @@ void pdfapp_init(pdfapp_t *app)
app->cache = fz_newglyphcache();
}
-void pdfapp_open(pdfapp_t *app, char *filename)
+void pdfapp_open(pdfapp_t *app, char *filename, int fd)
{
fz_obj *obj;
fz_obj *info;
char *password = "";
+ fz_stream *file;
/*
* Open PDF and load xref table
*/
- app->filename = filename;
-
- app->xref = pdf_openxref(filename);
+ file = fz_openfile(fd);
+ app->xref = pdf_openxref(file);
if (!app->xref)
pdfapp_error(app, -1);
diff --git a/apps/pdfapp.h b/apps/pdfapp.h
index 1c80ee4a..8c82f635 100644
--- a/apps/pdfapp.h
+++ b/apps/pdfapp.h
@@ -22,7 +22,6 @@ extern void windocopy(pdfapp_t*);
struct pdfapp_s
{
/* current document params */
- char *filename;
char *doctitle;
pdf_xref *xref;
pdf_outline *outline;
@@ -64,7 +63,7 @@ struct pdfapp_s
};
void pdfapp_init(pdfapp_t *app);
-void pdfapp_open(pdfapp_t *app, char *filename);
+void pdfapp_open(pdfapp_t *app, char *filename, int fd);
void pdfapp_close(pdfapp_t *app);
char *pdfapp_usage(pdfapp_t *app);
diff --git a/apps/pdftool.c b/apps/pdftool.c
index 44532f3d..e4034714 100644
--- a/apps/pdftool.c
+++ b/apps/pdftool.c
@@ -23,7 +23,9 @@ void setcleanup(void (*func)(void))
void openxref(char *filename, char *password, int dieonbadpass)
{
+ fz_stream *file;
int okay;
+ int fd;
basename = strrchr(filename, '/');
if (!basename)
@@ -31,9 +33,15 @@ void openxref(char *filename, char *password, int dieonbadpass)
else
basename++;
- xref = pdf_openxref(filename);
+ fd = open(filename, O_BINARY | O_RDONLY, 0666);
+ if (fd < 0)
+ die(fz_throw("cannot open file"));
+
+ file = fz_openfile(fd);
+ xref = pdf_openxref(file);
if (!xref)
die(-1);
+ fz_dropstream(file);
if (pdf_needspassword(xref))
{
diff --git a/apps/win_main.c b/apps/win_main.c
index 0fc32ecd..e1e22723 100644
--- a/apps/win_main.c
+++ b/apps/win_main.c
@@ -2,6 +2,8 @@
#include <mupdf.h>
#include "pdfapp.h"
+#undef UNICODE
+#undef _UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commdlg.h>
@@ -26,78 +28,8 @@ static int justcopied = 0;
static pdfapp_t gapp;
-/*
- * Associate PDFView with PDF files.
- */
-#if 0
-void associate(char *argv0)
-{
- char tmp[256];
- char *name = "Adobe PDF Document";
- HKEY key, kicon, kshell, kopen, kcmd;
- DWORD disp;
-
- /* HKEY_CLASSES_ROOT\.pdf */
-
- if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
- ".pdf", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &key, &disp))
- return;
-
- if (RegSetValueEx(key, "", 0, REG_SZ, "MuPDF", strlen("MuPDF")+1))
- return;
-
- RegCloseKey(key);
-
- /* HKEY_CLASSES_ROOT\MuPDF */
-
- if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
- "MuPDF", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &key, &disp))
- return;
-
- if (RegSetValueEx(key, "", 0, REG_SZ, name, strlen(name)+1))
- return;
-
- /* HKEY_CLASSES_ROOT\MuPDF\DefaultIcon */
-
- if (RegCreateKeyEx(key,
- "DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &kicon, &disp))
- return;
-
- sprintf(tmp, "%s,1", argv0);
- if (RegSetValueEx(kicon, "", 0, REG_SZ, tmp, strlen(tmp)+1))
- return;
-
- RegCloseKey(kicon);
-
- /* HKEY_CLASSES_ROOT\MuPDF\Shell\Open\Command */
-
- if (RegCreateKeyEx(key,
- "shell", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &kshell, &disp))
- return;
- if (RegCreateKeyEx(kshell,
- "open", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &kopen, &disp))
- return;
- if (RegCreateKeyEx(kopen,
- "command", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &kcmd, &disp))
- return;
-
- sprintf(tmp, "\"%s\" \"%%1\"", argv0);
- if (RegSetValueEx(kcmd, "", 0, REG_SZ, tmp, strlen(tmp)+1))
- return;
-
- RegCloseKey(kcmd);
- RegCloseKey(kopen);
- RegCloseKey(kshell);
-
- RegCloseKey(key);
-}
-#endif
+static wchar_t wbuf[1024];
+static char filename[1024];
/*
* Dialog boxes
@@ -115,20 +47,34 @@ void winerror(pdfapp_t *app, fz_error error)
exit(1);
}
-int winfilename(char *buf, int len)
+void win32error(char *msg)
+{
+ LPSTR buf;
+ int code = GetLastError();
+ FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ code,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ &buf, 0, NULL);
+ winerror(&gapp, fz_throw("%s: %s", msg, buf));
+}
+
+int winfilename(wchar_t *buf, int len)
{
OPENFILENAME ofn;
- strcpy(buf, "");
+ buf[0] = 0;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwndframe;
ofn.lpstrFile = buf;
ofn.nMaxFile = len;
ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = "MuPDF: Open PDF file";
- ofn.lpstrFilter = "PDF Files (*.pdf)\0*.pdf\0All Files\0*\0\0";
+ ofn.lpstrTitle = L"MuPDF: Open PDF file";
+ ofn.lpstrFilter = L"PDF Files (*.pdf)\0*.pdf\0All Files\0*\0\0";
ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
- return GetOpenFileName(&ofn);
+ return GetOpenFileNameW(&ofn);
}
static char pd_filename[256] = "The file is encrypted.";
@@ -141,14 +87,14 @@ dlogpassproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
switch(message)
{
case WM_INITDIALOG:
- SetDlgItemText(hwnd, 4, pd_filename);
+ SetDlgItemTextA(hwnd, 4, pd_filename);
return TRUE;
case WM_COMMAND:
switch(wParam)
{
case 1:
pd_okay = 1;
- GetDlgItemText(hwnd, 3, pd_password, sizeof pd_password);
+ GetDlgItemTextA(hwnd, 3, pd_password, sizeof pd_password);
EndDialog(hwnd, 0);
return TRUE;
case 2:
@@ -171,7 +117,7 @@ char *winpassword(pdfapp_t *app, char *filename)
if (strlen(s) > 32)
strcpy(s + 30, "...");
sprintf(pd_filename, "The file \"%s\" is encrypted.", s);
- DialogBox(NULL, "IDD_DLOGPASS", hwndframe, dlogpassproc);
+ DialogBoxA(NULL, "IDD_DLOGPASS", hwndframe, dlogpassproc);
if (pd_okay)
return pd_password;
return NULL;
@@ -188,7 +134,7 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
case WM_INITDIALOG:
- SetDlgItemTextA(hwnd, 0x10, gapp.filename);
+ SetDlgItemTextW(hwnd, 0x10, wbuf);
sprintf(buf, "PDF %d.%d", xref->version / 10, xref->version % 10);
SetDlgItemTextA(hwnd, 0x11, buf);
@@ -231,14 +177,22 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
fz_free(ucs); \
}
- if ((obj = fz_dictgets(info, "Title"))) SETUCS(0x20);
- if ((obj = fz_dictgets(info, "Author"))) SETUCS(0x21);
- if ((obj = fz_dictgets(info, "Subject"))) SETUCS(0x22);
- if ((obj = fz_dictgets(info, "Keywords"))) SETUCS(0x23);
- if ((obj = fz_dictgets(info, "Creator"))) SETUCS(0x24);
- if ((obj = fz_dictgets(info, "Producer"))) SETUCS(0x25);
- if ((obj = fz_dictgets(info, "CreationDate"))) SETUCS(0x26);
- if ((obj = fz_dictgets(info, "ModDate"))) SETUCS(0x27);
+ if ((obj = fz_dictgets(info, "Title")))
+ SETUCS(0x20);
+ if ((obj = fz_dictgets(info, "Author")))
+ SETUCS(0x21);
+ if ((obj = fz_dictgets(info, "Subject")))
+ SETUCS(0x22);
+ if ((obj = fz_dictgets(info, "Keywords")))
+ SETUCS(0x23);
+ if ((obj = fz_dictgets(info, "Creator")))
+ SETUCS(0x24);
+ if ((obj = fz_dictgets(info, "Producer")))
+ SETUCS(0x25);
+ if ((obj = fz_dictgets(info, "CreationDate")))
+ SETUCS(0x26);
+ if ((obj = fz_dictgets(info, "ModDate")))
+ SETUCS(0x27);
return TRUE;
case WM_COMMAND:
@@ -259,7 +213,6 @@ dlogaboutproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
switch(message)
{
case WM_INITDIALOG:
- SetDlgItemTextA(hwnd, 0x10, gapp.filename);
SetDlgItemTextA(hwnd, 2, "MuPDF is Copyright (C) 2006-2008 artofcode, LLC");
SetDlgItemTextA(hwnd, 3, pdfapp_usage(&gapp));
return TRUE;
@@ -284,8 +237,10 @@ void winopen()
WNDCLASS wc;
HMENU menu;
RECT r;
+ ATOM a;
/* Create and register window frame class */
+ memset(&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = frameproc;
wc.cbClsExtra = 0;
@@ -296,9 +251,12 @@ void winopen()
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "FrameWindow";
- assert(RegisterClass(&wc) && "Register window class");
+ a = RegisterClass(&wc);
+ if (!a)
+ win32error("cannot register frame window class");
/* Create and register window view class */
+ memset(&wc, 0, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = viewproc;
wc.cbClsExtra = 0;
@@ -309,7 +267,9 @@ void winopen()
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "ViewWindow";
- assert(RegisterClass(&wc) && "Register window class");
+ a = RegisterClass(&wc);
+ if (!a)
+ win32error("cannot register view window class");
/* Get screen size */
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
@@ -339,7 +299,7 @@ void winopen()
dibinf->bmiHeader.biClrUsed = 0;
/* Create window */
- hwndframe = CreateWindow("FrameWindow", // window class name
+ hwndframe = CreateWindowA("FrameWindow", // window class name
NULL, // window caption
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, // initial position
@@ -349,22 +309,26 @@ void winopen()
0, // window menu handle
0, // program instance handle
0); // creation parameters
+ if (!hwndframe)
+ win32error("cannot create frame: %s");
- hwndview = CreateWindow("ViewWindow", // window class name
+ hwndview = CreateWindowA("ViewWindow", // window class name
NULL,
WS_VISIBLE | WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
hwndframe, 0, 0, 0);
+ if (!hwndview)
+ win32error("cannot create view: %s");
hdc = NULL;
SetWindowTextA(hwndframe, "MuPDF");
menu = GetSystemMenu(hwndframe, 0);
- AppendMenu(menu, MF_SEPARATOR, 0, NULL);
- AppendMenu(menu, MF_STRING, ID_ABOUT, "About MuPDF...");
- AppendMenu(menu, MF_STRING, ID_DOCINFO, "Document Properties...");
+ AppendMenuA(menu, MF_SEPARATOR, 0, NULL);
+ AppendMenuA(menu, MF_STRING, ID_ABOUT, "About MuPDF...");
+ AppendMenuA(menu, MF_STRING, ID_DOCINFO, "Document Properties...");
SetCursor(arrowcurs);
}
@@ -381,7 +345,7 @@ void wincursor(pdfapp_t *app, int curs)
void wintitle(pdfapp_t *app, char *title)
{
- unsigned short wide[256], *dp;
+ wchar_t wide[256], *dp;
char *sp;
int rune;
@@ -774,11 +738,15 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hwnd, message, wParam, lParam);
}
-int main(int argc, char **argv)
+int WINAPI
+WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
+ int argc;
+ LPWSTR *argv;
MSG msg;
- char buf[1024];
- char *filename;
+ int fd;
+
+ argv = CommandLineToArgvW(GetCommandLineW(), &argc);
fz_cpudetect();
fz_accelerate();
@@ -789,15 +757,22 @@ int main(int argc, char **argv)
winopen();
if (argc == 2)
- filename = fz_strdup(argv[1]);
+ {
+ wcscpy(wbuf, argv[1]);
+ }
else
{
- if (!winfilename(buf, sizeof buf))
+ if (!winfilename(wbuf, nelem(wbuf)))
exit(0);
- filename = buf;
}
- pdfapp_open(&gapp, filename);
+ fd = _wopen(wbuf, O_BINARY | O_RDONLY, 0666);
+ if (fd < 0)
+ winerror(&gapp, fz_throw("cannot open file '%s'", filename));
+
+ WideCharToMultiByte(CP_ACP, 0, wbuf, -1, filename, sizeof filename, NULL, NULL);
+
+ pdfapp_open(&gapp, filename, fd);
while (GetMessage(&msg, NULL, 0, 0))
{
diff --git a/apps/x11_main.c b/apps/x11_main.c
index 49a7dd95..a0fde675 100644
--- a/apps/x11_main.c
+++ b/apps/x11_main.c
@@ -523,6 +523,7 @@ int main(int argc, char **argv)
int pageno = 1;
int wasshowingpage;
struct timeval tmo, tmo_at;
+ int fd;
while ((c = fz_getopt(argc, argv, "d:z:p:")) != -1)
{
@@ -556,7 +557,11 @@ int main(int argc, char **argv)
gapp.zoom = zoom / 100.0;
gapp.pageno = pageno;
- pdfapp_open(&gapp, filename);
+ fd = open(filename, O_BINARY | O_RDONLY, 0666);
+ if (fd < 0)
+ winerror(&gapp, fz_throw("cannot open file '%s'", filename));
+
+ pdfapp_open(&gapp, filename, fd);
winresettmo(&tmo, &tmo_at);
diff --git a/fitz/fitz_stream.h b/fitz/fitz_stream.h
index 1aa3f8f5..8689677e 100644
--- a/fitz/fitz_stream.h
+++ b/fitz/fitz_stream.h
@@ -338,10 +338,10 @@ struct fz_stream_s
* Various stream creation functions.
*/
-fz_error fz_openrfile(fz_stream **stmp, char *filename);
-fz_stream * fz_openrmemory(unsigned char *mem, int len);
-fz_stream * fz_openrbuffer(fz_buffer *buf);
-fz_stream * fz_openrfilter(fz_filter *flt, fz_stream *chain);
+fz_stream * fz_openfile(int file);
+fz_stream * fz_openmemory(unsigned char *mem, int len);
+fz_stream * fz_openbuffer(fz_buffer *buf);
+fz_stream * fz_openfilter(fz_filter *flt, fz_stream *chain);
/*
* Functions that are common to both input and output streams.
diff --git a/fitz/stm_open.c b/fitz/stm_open.c
index 02b4cd51..c15f803f 100644
--- a/fitz/stm_open.c
+++ b/fitz/stm_open.c
@@ -61,27 +61,20 @@ fz_dropstream(fz_stream *stm)
}
}
-fz_error fz_openrfile(fz_stream **stmp, char *path)
+fz_stream *
+fz_openfile(int fd)
{
fz_stream *stm;
stm = newstm(FZ_SFILE);
-
stm->buffer = fz_newbuffer(FZ_BUFSIZE);
+ stm->file = fd;
- stm->file = open(path, O_BINARY | O_RDONLY, 0666);
- if (stm->file < 0)
- {
- fz_dropbuffer(stm->buffer);
- fz_free(stm);
- return fz_throw("syserr: open '%s': %s", path, strerror(errno));
- }
-
- *stmp = stm;
- return fz_okay;
+ return stm;
}
-fz_stream * fz_openrfilter(fz_filter *flt, fz_stream *src)
+fz_stream *
+fz_openfilter(fz_filter *flt, fz_stream *src)
{
fz_stream *stm;
@@ -93,7 +86,8 @@ fz_stream * fz_openrfilter(fz_filter *flt, fz_stream *src)
return stm;
}
-fz_stream * fz_openrbuffer(fz_buffer *buf)
+fz_stream *
+fz_openbuffer(fz_buffer *buf)
{
fz_stream *stm;
@@ -104,13 +98,14 @@ fz_stream * fz_openrbuffer(fz_buffer *buf)
return stm;
}
-fz_stream * fz_openrmemory(unsigned char *mem, int len)
+fz_stream *
+fz_openmemory(unsigned char *mem, int len)
{
fz_buffer *buf;
fz_stream *stm;
buf = fz_newbufferwithmemory(mem, len);
- stm = fz_openrbuffer(buf);
+ stm = fz_openbuffer(buf);
fz_dropbuffer(buf);
return stm;
diff --git a/mupdf/cmapdump.c b/mupdf/cmapdump.c
index b0a6e01c..79933208 100644
--- a/mupdf/cmapdump.c
+++ b/mupdf/cmapdump.c
@@ -52,6 +52,7 @@ main(int argc, char **argv)
char name[256];
char *realname;
int i, k;
+ int fd;
if (argc < 3)
{
@@ -89,13 +90,15 @@ main(int argc, char **argv)
strcpy(name, realname);
clean(name);
- error = fz_openrfile(&fi, argv[i]);
- if (error)
+ fd = open(argv[i], O_BINARY | O_RDONLY, 0666);
+ if (fd < 0)
{
- fz_catch(error, "cmapdump: could not open input file '%s'\n", argv[i]);
+ fz_throw(-1, "cmapdump: could not open input file '%s'\n", argv[i]);
return 1;
}
+ fi = fz_openfile(fd);
+
error = pdf_parsecmap(&cmap, fi);
if (error)
{
diff --git a/mupdf/mupdf.h b/mupdf/mupdf.h
index 29742f22..b9dea160 100644
--- a/mupdf/mupdf.h
+++ b/mupdf/mupdf.h
@@ -144,7 +144,7 @@ struct pdf_xrefentry_s
int type; /* 0=unset (f)ree i(n)use (o)bjstm */
};
-pdf_xref * pdf_openxref(char *filename);
+pdf_xref * pdf_openxref(fz_stream *file);
void pdf_closexref(pdf_xref *);
void pdf_debugxref(pdf_xref *);
void pdf_flushxref(pdf_xref *, int force);
diff --git a/mupdf/pdf_image.c b/mupdf/pdf_image.c
index 0b1dca7e..013ffbc7 100644
--- a/mupdf/pdf_image.c
+++ b/mupdf/pdf_image.c
@@ -170,7 +170,7 @@ pdf_loadinlineimage(pdf_image **imgp, pdf_xref *xref,
filter = pdf_buildinlinefilter(xref, dict);
- tempfile = fz_openrfilter(filter, file);
+ tempfile = fz_openfilter(filter, file);
img->samples = fz_readall(tempfile, img->stride * img->h);
fz_dropstream(tempfile);
diff --git a/mupdf/pdf_interpret.c b/mupdf/pdf_interpret.c
index ffa3c0b4..0f483098 100644
--- a/mupdf/pdf_interpret.c
+++ b/mupdf/pdf_interpret.c
@@ -1361,7 +1361,7 @@ pdf_runcsibuffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents)
fz_error error;
contents->rp = contents->bp;
- file = fz_openrbuffer(contents);
+ file = fz_openbuffer(contents);
error = pdf_runcsifile(csi, rdb, file, csi->xref->scratch, sizeof csi->xref->scratch);
fz_dropstream(file);
contents->rp = contents->bp;
diff --git a/mupdf/pdf_open.c b/mupdf/pdf_open.c
index 384f7691..9a0c2163 100644
--- a/mupdf/pdf_open.c
+++ b/mupdf/pdf_open.c
@@ -620,7 +620,7 @@ pdf_loadxref(pdf_xref *xref, char *buf, int bufsize)
*/
pdf_xref *
-pdf_openxref(char *filename)
+pdf_openxref(fz_stream *file)
{
pdf_xref *xref;
fz_error error;
@@ -630,11 +630,9 @@ pdf_openxref(char *filename)
xref = fz_malloc(sizeof(pdf_xref));
memset(xref, 0, sizeof(pdf_xref));
- pdf_logxref("loadxref '%s' %p\n", filename, xref);
+ pdf_logxref("loadxref %p\n", xref);
- error = fz_openrfile(&xref->file, filename);
- if (error)
- goto cleanup;
+ xref->file = fz_keepstream(file);
error = pdf_loadxref(xref, xref->scratch, sizeof xref->scratch);
if (error)
diff --git a/mupdf/pdf_stream.c b/mupdf/pdf_stream.c
index 3b23b6c3..6c0b15f6 100644
--- a/mupdf/pdf_stream.c
+++ b/mupdf/pdf_stream.c
@@ -331,7 +331,7 @@ pdf_openrawstream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
if (error)
return fz_rethrow(error, "cannot seek to stream");
- *stmp = fz_openrfilter(filter, xref->file);
+ *stmp = fz_openfilter(filter, xref->file);
fz_dropfilter(filter);
return fz_okay;
}
@@ -368,7 +368,7 @@ pdf_openstream(fz_stream **stmp, pdf_xref *xref, int num, int gen)
if (error)
return fz_rethrow(error, "cannot seek to stream");
- *stmp = fz_openrfilter(filter, xref->file);
+ *stmp = fz_openfilter(filter, xref->file);
fz_dropfilter(filter);
return fz_okay;
}
diff --git a/win32/mupdf_viewer/mupdf_viewer.vcproj b/win32/mupdf_viewer/mupdf_viewer.vcproj
index 19282d8c..19be3d03 100644
--- a/win32/mupdf_viewer/mupdf_viewer.vcproj
+++ b/win32/mupdf_viewer/mupdf_viewer.vcproj
@@ -64,7 +64,7 @@
LinkIncremental="2"
IgnoreDefaultLibraryNames="libcmtd"
GenerateDebugInformation="true"
- SubSystem="1"
+ SubSystem="2"
TargetMachine="1"
/>
<Tool
@@ -137,9 +137,9 @@
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
- IgnoreDefaultLibraryNames="libcmtd"
+ IgnoreDefaultLibraryNames="libcmt"
GenerateDebugInformation="true"
- SubSystem="1"
+ SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
diff --git a/win32/pdfclean/pdfclean.vcproj b/win32/pdfclean/pdfclean.vcproj
index 33ea73cb..bba6ea68 100644
--- a/win32/pdfclean/pdfclean.vcproj
+++ b/win32/pdfclean/pdfclean.vcproj
@@ -138,7 +138,7 @@
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
- IgnoreDefaultLibraryNames="libcmtd"
+ IgnoreDefaultLibraryNames="libcmt"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
diff --git a/win32/pdfdraw/pdfdraw.vcproj b/win32/pdfdraw/pdfdraw.vcproj
index e268dee7..23b1de61 100644
--- a/win32/pdfdraw/pdfdraw.vcproj
+++ b/win32/pdfdraw/pdfdraw.vcproj
@@ -137,7 +137,7 @@
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
- IgnoreDefaultLibraryNames="libcmtd"
+ IgnoreDefaultLibraryNames="libcmt"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
diff --git a/win32/pdfextract/pdfextract.vcproj b/win32/pdfextract/pdfextract.vcproj
index 2c9d270c..43783d1d 100644
--- a/win32/pdfextract/pdfextract.vcproj
+++ b/win32/pdfextract/pdfextract.vcproj
@@ -137,7 +137,7 @@
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
- IgnoreDefaultLibraryNames="libcmtd"
+ IgnoreDefaultLibraryNames="libcmt"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
diff --git a/win32/pdfinfo/pdfinfo.vcproj b/win32/pdfinfo/pdfinfo.vcproj
index fc7b8575..d738c72d 100644
--- a/win32/pdfinfo/pdfinfo.vcproj
+++ b/win32/pdfinfo/pdfinfo.vcproj
@@ -137,7 +137,7 @@
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
- IgnoreDefaultLibraryNames="libcmtd"
+ IgnoreDefaultLibraryNames="libcmt"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
diff --git a/win32/pdfshow/pdfshow.vcproj b/win32/pdfshow/pdfshow.vcproj
index 87a6df48..0fec4bd0 100644
--- a/win32/pdfshow/pdfshow.vcproj
+++ b/win32/pdfshow/pdfshow.vcproj
@@ -137,7 +137,7 @@
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
- IgnoreDefaultLibraryNames="libcmtd"
+ IgnoreDefaultLibraryNames="libcmt"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"