ipdf-svn/src/main.cc File Reference

#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

CPDFApppApp = NULL
pid_t AppID


Function Documentation

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 }

Here is the call graph for this function:

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 }

Here is the call graph for this function:

void OnTerminated ( int  sig  ) 

Definition at line 42 of file main.cc.

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 }

Here is the call graph for this function:

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 (  ) 

Definition at line 56 of file main.cc.

00057 {
00058     printf("\nUsage: ipdf <filename>\n");
00059 }


Variable Documentation

pid_t AppID

Definition at line 39 of file main.cc.

CPDFApp* pApp = NULL

Definition at line 38 of file main.cc.


Generated on Wed Feb 4 18:26:07 2009 by  doxygen 1.5.6