PLInit.cpp File Reference

#include <unistd.h>
#include <execinfo.h>
#include <getopt.h>
#include "PLSessionManager.h"

Go to the source code of this file.

Functions

void usage (char *progname)
void show_stackframe ()
 Handles the SEGFAULT.
void segfaultHandler (int sig)
int main (int argc, char *argv[])

Variables

static char Usage []
static char Usage2 []

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 75 of file PLInit.cpp.

00076 {
00077     #ifdef RIO_DEBUG1
00078     RioErr << "### [PLInit - main] Start" << endl;
00079     #endif
00080 
00081     int hResult;
00082     PLSessionManager *m_PLSessionManager;
00083 
00084     char optch;
00085     int ind = -1;
00086     // Variavel usada pela nova opcao para permitir o arquivo de configuracao
00087     // em um diretorio diferente do que esta o RIOPL, e salvar os logs em 
00088     // um diretorio diferente de onde esta o RIOPL.
00089     char *prefix_directory = NULL;
00090     static char opts_short[] ="hp:v";
00091     static struct option opts_int[] =
00092     {
00093        {"help"            , 0, 0, 'h'},
00094        // Nova opcao para permitir arquivos de configuracao e os logd em um 
00095        // diretorio diferente do que esta o servidor. Os arquivos de
00096        // configuracao estarao em no subdiretorio etc e os arquivos de log
00097        // no subdiretorio var
00098        {"prefixdirectory" , 1, 0, 'p'},
00099        {"version"         , 0, 0, 'v'},
00100        {0, 0, 0, 0}
00101     };
00102 
00103     // parse main options
00104     while( (optch = getopt_long(argc, argv, opts_short, opts_int, &ind)) != -1)
00105     {
00106         switch( optch )
00107         {
00108             case 'h':
00109                 usage( argv[ 0 ] );
00110             // Nova opcao para permitir arquivos de configuracao em um 
00111             // diretorio diferente do que esta o servidor
00112             case 'p':
00113                 prefix_directory = optarg;
00114                 break;
00115             case 'v':
00116                 cout << " RIOPL version: " << VERSION << endl;
00117                 exit( 0 );
00118             default:
00119                 usage( argv[ 0 ] );
00120          }
00121     }
00122 
00123     RioErr << "Criando a classe PLSessionManager na PLInit." << endl;
00124 
00125     m_PLSessionManager = new PLSessionManager();
00126 
00127     hResult = m_PLSessionManager->Initialize(  prefix_directory );
00128 
00129     if( FAILED( hResult ) )
00130     {
00131         RioErr << "Start(): Failed to initialize Session Manager"
00132                << ". hresult=" << (int *)hResult << endl;
00133 
00134         delete m_PLSessionManager;
00135         m_PLSessionManager = 0;
00136 
00137         #ifdef RIO_DEBUG1
00138         RioErr << "### [PLInit - main] Finish" << endl;
00139         #endif
00140 
00141         return hResult;
00142     }
00143 
00144     signal( SIGSEGV, segfaultHandler );
00145     signal( SIGABRT, segfaultHandler );
00146 
00147     while( true )
00148     {
00149         sleep( 10 );
00150         RioErr << "Dormindo 10 segundos na PLInit." << endl;
00151     }
00152 }/* end of main */

void segfaultHandler ( int  sig  ) 

Definition at line 65 of file PLInit.cpp.

00066 {
00067     RioErr << "[PL] SEGMENTATION FAULT(" << sig << ")!" << endl;
00068     show_stackframe();
00069 
00070     _exit( 1 );
00071 }

void show_stackframe (  ) 

Handles the SEGFAULT.

Definition at line 50 of file PLInit.cpp.

00051 {
00052     void  *trace[16];
00053     char **messages = (char **)NULL;
00054     int    i = 0;
00055     int    trace_size = 0;
00056 
00057     trace_size = backtrace( trace, 16 );
00058     messages = backtrace_symbols( trace, trace_size );
00059     RioErr << "[bt] Execution path:" << endl;
00060     for( i = 0; i < trace_size; ++i )
00061         RioErr << "[bt(" << i << "/" << trace_size << ")] " << messages[i] 
00062                << endl;
00063 }

void usage ( char *  progname  ) 

Definition at line 41 of file PLInit.cpp.

00042 {
00043     cout << "Usage: " << progname << " " << Usage;
00044     cout << Usage2;
00045 }


Variable Documentation

char Usage[] [static]
Initial value:
    "[-h] [-p directory] [-v]\n"

Definition at line 33 of file PLInit.cpp.

char Usage2[] [static]
Initial value:
    "\t-h|--help\n Show this message and exit\n"
    "\t-p|--prefixdirectory<directory>\t prefix directory\n"
    "\t-v|--version\tShow version number and exit\n"

Definition at line 36 of file PLInit.cpp.

Generated on Wed Jul 4 16:03:30 2012 for RIO by  doxygen 1.6.3