From e8d620594f97876ebfda5ea393a8bf3d70db3201 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sat, 22 Mar 2008 12:09:34 +0100 Subject: Revert to using boolean to indicate good/bad password. --- apps/common/pdfapp.c | 9 ++++----- apps/mozilla/moz_main.c | 12 ++---------- apps/pdftool.c | 6 +++--- 3 files changed, 9 insertions(+), 18 deletions(-) (limited to 'apps') diff --git a/apps/common/pdfapp.c b/apps/common/pdfapp.c index 9174cbc1..9e0d4962 100644 --- a/apps/common/pdfapp.c +++ b/apps/common/pdfapp.c @@ -105,15 +105,14 @@ void pdfapp_open(pdfapp_t *app, char *filename) if (app->xref->crypt) { - error = pdf_setpassword(app->xref->crypt, password); - while (error) + int okay = pdf_setpassword(app->xref->crypt, password); + while (!okay) { - fz_droperror(error); password = winpassword(app, filename); if (!password) exit(1); - error = pdf_setpassword(app->xref->crypt, password); - if (error) + okay = pdf_setpassword(app->xref->crypt, password); + if (!okay) pdfapp_warn(app, "Invalid password."); } } diff --git a/apps/mozilla/moz_main.c b/apps/mozilla/moz_main.c index 4c38b78b..4e78596f 100644 --- a/apps/mozilla/moz_main.c +++ b/apps/mozilla/moz_main.c @@ -115,17 +115,9 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename) if (moz->xref->crypt) { - error = pdf_setpassword(moz->xref->crypt, password); - // while (error) - // { - // fz_droperror(error); - // password = winpassword(moz, filename); - // if (!password) - // exit(1); - // error = pdf_setpassword(moz->xref->crypt, password); - if (error) + int okay = pdf_setpassword(moz->xref->crypt, password); + if (!okay) pdfmoz_warn(moz, "Invalid password."); - // } } /* diff --git a/apps/pdftool.c b/apps/pdftool.c index 559eca03..3daeb777 100644 --- a/apps/pdftool.c +++ b/apps/pdftool.c @@ -83,9 +83,9 @@ void opensrc(char *filename, char *password, int loadpages) if (src->crypt) { - error = pdf_setpassword(src->crypt, password); - if (error) - die(fz_rethrow(error, "invalid password")); + int okay = pdf_setpassword(src->crypt, password); + if (!okay) + die(fz_throw("invalid password")); } if (loadpages) -- cgit v1.2.3