00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdio.h>
00020 #include "goo/GooList.h"
00021 #include "poppler/GlobalParams.h"
00022 #include "poppler/Object.h"
00023 #include "poppler/Link.h"
00024 #include "goo/GooString.h"
00025 #include "poppler/PDFDoc.h"
00026 #include "splash/SplashBitmap.h"
00027 #include "poppler/SplashOutputDev.h"
00028 #include "splash/SplashTypes.h"
00029 #include <unistd.h>
00030 #include <sys/time.h>
00031 #include <time.h>
00032 #include "PDFApp.h"
00033 #include "PDFViewerLog.h"
00034 #include <gtk/gtk.h>
00035 #include <sys/time.h>
00036 #include <sys/resource.h>
00037
00038 CPDFApp * pApp = NULL;
00039 pid_t AppID;
00040
00041
00042 void OnTerminated(int sig)
00043 {
00044 PV_DUMP("On receive signal %d pid %d\n", sig, getpid());
00045 {
00046 AppID = 0;
00047 pApp->quit();
00048 delete pApp;
00049 pApp = NULL;
00050 }
00051 exit(0);
00052 }
00053
00054
00055
00056 void usage()
00057 {
00058 printf("\nUsage: ipdf <filename>\n");
00059 }
00060
00061 void installTermHandler()
00062 {
00063
00064 struct sigaction on_term;
00065 memset(&on_term, 0x00, sizeof(on_term));
00066 on_term.sa_handler = OnTerminated;
00067 sigaction(SIGTERM, &on_term, NULL);
00068
00069
00070 sigaction(SIGSEGV, &on_term, NULL);
00071 sigaction(SIGABRT, &on_term, NULL);
00072
00073
00074 AppID = getpid();
00075 }
00076
00077
00078 void setMemLimit()
00079 {
00080 struct rlimit limit;
00081 int ret = getrlimit(RLIMIT_AS, &limit);
00082 limit.rlim_cur = MAXIMUM_MEMORY_LIMIT;
00083 ret = setrlimit(RLIMIT_AS, &limit);
00084 }
00085
00086 int main(int argc, char * argv[])
00087 {
00088 if (argc != 2)
00089 {
00090 usage();
00091 return 0;
00092 }
00093
00094
00095 installTermHandler();
00096
00097
00098 setMemLimit();
00099
00100
00101 gtk_rc_parse(DATA_DIR "/ipdf.rc");
00102 gtk_init (&argc, &argv);
00103
00104
00105 GooString *name = new GooString(argv[1]);
00106
00107
00108 pApp = new CPDFApp(&argc, argv);
00109
00110
00111 if (pApp->open(name))
00112 {
00113 pApp->run();
00114 }
00115
00116 delete pApp;
00117 pApp = NULL;
00118 return 0;
00119 }
00120
00121
00122
00123 void *StandardSecurityHandler::getAuthData()
00124 {
00125 if (pApp)
00126 {
00127 GooString * password = (GooString *)pApp->getAuthData();
00128 if (password)
00129 {
00130 return new StandardAuthData(password, password->copy());
00131 }
00132 return NULL;
00133 }
00134 return NULL;
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151