reSIProcate/DialogUsageManager  9694
limpc.cxx
Go to the documentation of this file.
00001 #if defined(HAVE_CONFIG_HXX)
00002 #include "resip/stack/config.hxx"
00003 #endif
00004 
00005 #include <cstring>
00006 #include <cassert>
00007 
00008 #ifndef __APPLE__
00009 bool TRUE=true;
00010 bool FALSE=false;
00011 #endif
00012 
00013 #include "UserAgent.hxx"
00014 #include "resip/stack/SipStack.hxx"
00015 #include "resip/stack/Uri.hxx"
00016 #include "rutil/Logger.hxx"
00017 
00018 #ifdef USE_SSL
00019 #include "resip/stack/ssl/Security.hxx"
00020 #endif
00021 
00022 #include <signal.h>
00023 
00024 using namespace resip;
00025 using namespace std;
00026 
00027 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP
00028 
00029 static bool finished = false;
00030 
00031 static void
00032 signalHandler(int signo)
00033 {
00034    std::cerr << "Shutting down" << endl;
00035    finished = true;
00036 }
00037 
00038 int
00039 main(int argc, char* argv[])
00040 {
00041 #ifndef _WIN32
00042    if ( signal( SIGPIPE, SIG_IGN) == SIG_ERR)
00043    {
00044       cerr << "Couldn't install signal handler for SIGPIPE" << endl;
00045       exit(-1);
00046    }
00047 #endif
00048 
00049    if ( signal( SIGINT, signalHandler ) == SIG_ERR )
00050    {
00051       cerr << "Couldn't install signal handler for SIGINT" << endl;
00052       exit( -1 );
00053    }
00054 
00055    if ( signal( SIGTERM, signalHandler ) == SIG_ERR )
00056    {
00057       cerr << "Couldn't install signal handler for SIGTERM" << endl;
00058       exit( -1 );
00059    }
00060 
00061    try
00062    {
00063       UserAgent ua(argc, argv);
00064       ua.startup();
00065       
00066       InfoLog(<< argv[0] << " starting");
00067       while(!finished)
00068       {
00069          ua.process();
00070       }
00071    }
00072    catch (BaseSecurity::Exception& e)
00073    {
00074       WarningLog (<< "Couldn't set up security object");
00075       exit(-1);
00076    }
00077    catch (BaseException& e)
00078    {
00079       ErrLog (<< "Caught: " << e);
00080       exit(-1);
00081    }
00082    catch( ... )
00083    {
00084       ErrLog( << "Caught non-resip exception" );
00085       exit(-1);
00086    }
00087 
00088    return 0;
00089 }
00090 
00091 /* ====================================================================
00092  * The Vovida Software License, Version 1.0 
00093  * 
00094  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00095  * 
00096  * Redistribution and use in source and binary forms, with or without
00097  * modification, are permitted provided that the following conditions
00098  * are met:
00099  * 
00100  * 1. Redistributions of source code must retain the above copyright
00101  *    notice, this list of conditions and the following disclaimer.
00102  * 
00103  * 2. Redistributions in binary form must reproduce the above copyright
00104  *    notice, this list of conditions and the following disclaimer in
00105  *    the documentation and/or other materials provided with the
00106  *    distribution.
00107  * 
00108  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00109  *    and "Vovida Open Communication Application Library (VOCAL)" must
00110  *    not be used to endorse or promote products derived from this
00111  *    software without prior written permission. For written
00112  *    permission, please contact vocal@vovida.org.
00113  *
00114  * 4. Products derived from this software may not be called "VOCAL", nor
00115  *    may "VOCAL" appear in their name, without prior written
00116  *    permission of Vovida Networks, Inc.
00117  * 
00118  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00119  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00120  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00121  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00122  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00123  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00124  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00125  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00126  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00127  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00128  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00129  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00130  * DAMAGE.
00131  * 
00132  * ====================================================================
00133  * 
00134  * This software consists of voluntary contributions made by Vovida
00135  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00136  * Inc.  For more information on Vovida Networks, Inc., please see
00137  * <http://www.vovida.org/>.
00138  *
00139  */