#include <stdio.h>
#include "goo/GooList.h"
#include "poppler/GlobalParams.h"
#include "poppler/Object.h"
#include "poppler/Link.h"
#include "goo/GooString.h"
#include "poppler/PDFDoc.h"
#include "splash/SplashBitmap.h"
#include "poppler/SplashOutputDev.h"
#include "splash/SplashTypes.h"
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include "PDFApp.h"
#include "PDFViewerLog.h"
#include <gtk/gtk.h>
#include <sys/resource.h>
Go to the source code of this file.
Functions | |
void | OnTerminated (int sig) |
void | usage () |
void | installTermHandler () |
void | setMemLimit () |
int | main (int argc, char *argv[]) |
Variables | |
CPDFApp * | pApp = NULL |
pid_t | AppID |
void installTermHandler | ( | ) |
Definition at line 61 of file main.cc.
00062 { 00063 // catch the SIGTERM signal 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 // Also install the SIGSEGV/SIGABRT 00070 sigaction(SIGSEGV, &on_term, NULL); 00071 sigaction(SIGABRT, &on_term, NULL); 00072 00073 // record the id 00074 AppID = getpid(); 00075 }
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 86 of file main.cc.
00087 { 00088 if (argc != 2) 00089 { 00090 usage(); 00091 return 0; 00092 } 00093 00094 // terminate handle 00095 installTermHandler(); 00096 00097 // set memory limit 00098 setMemLimit(); 00099 00100 // init gtk 00101 gtk_rc_parse(DATA_DIR "/ipdf.rc"); 00102 gtk_init (&argc, &argv); 00103 00104 // name will be removed by PDFDoc, so no need to delete in main 00105 GooString *name = new GooString(argv[1]); 00106 00107 // init application 00108 pApp = new CPDFApp(&argc, argv); 00109 00110 // open file and render 00111 if (pApp->open(name)) 00112 { 00113 pApp->run(); 00114 } 00115 00116 delete pApp; 00117 pApp = NULL; 00118 return 0; 00119 }
void OnTerminated | ( | int | sig | ) |
void setMemLimit | ( | ) |
Definition at line 78 of file main.cc.
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 }
void usage | ( | ) |