reSIProcate/stack  9694
ApiCheck.cxx
Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <iostream>
00003 #include <iomanip>
00004 
00005 #include "resip/stack/ApiCheck.hxx"
00006 #include "resip/stack/ApiCheckList.hxx"
00007 
00008 namespace resip
00009 {
00010 
00011 ApiCheck::ApiCheck( ApiEntry * list, int len)
00012 {
00013     int bad = 0;
00014 
00015     ApiEntry* p = list;
00016     ApiEntry* q = ::anonymous_resipApiSizeList;
00017     int resipListLen = sizeof(::anonymous_resipApiSizeList)/sizeof(*::anonymous_resipApiSizeList);
00018 
00019     if (list == ::anonymous_resipApiSizeList )
00020     {
00021         return;
00022     }
00023 
00024     if (resipListLen != len)
00025     {
00026         std::cerr << "reSIProcate Type verification list lengths are different."
00027                   << std::endl
00028                   << "\tEither the library and application are radically out of date" 
00029                   << std::endl
00030                   << "application length: " << len << std::endl
00031                   << "reSIProcate length: " << resipListLen << std::endl;
00032         ++bad;
00033     }
00034 
00035     std::cerr << std::setfill(' ') 
00036               << std::setw(34) << "Class" << ' '
00037               << std::setw(8) << "App" << ' '
00038               << std::setw(8) << "Lib" << ' '
00039               << std::setw(8) << "Possible Culprit Flags"
00040               << std::endl;
00041 
00042     for(int i = 0 ; i < resipListLen && i < len; ++i)
00043     {
00044         bool oops = false;
00045         if (strcmp(p[i].name, q[i].name))
00046         {
00047             std::cerr << "!!! Miss match entry for : (app)"
00048                       << p[i].name << " vs. (resip)" <<  q[i].name
00049                       << std::endl;
00050             ++bad;
00051             continue;
00052         }
00053 
00054         if (p[i].sz != q[i].sz)
00055         {
00056             ++bad;
00057             oops = true;
00058         }
00059         const char w = oops?'!':' ';
00060 
00061         std::cerr << w << w << w << std::setfill(' ')
00062                   << std::setw(30-strlen(p[i].name)) << "resip::" 
00063                   << p[i].name << ' '
00064                   << std::setw(8) << p[i].sz << ' '
00065                   << std::setw(8) << q[i].sz << ' '
00066                   << (oops?p[i].culprits:"")
00067                   << std::endl;
00068 
00069 
00070     }
00071 
00072     if (bad)
00073     {
00074         std::cerr <<"SERIOUS COMPILATION / CONFIGURATION ERRORS -- ABORTING" << std::endl;
00075 #ifndef UNDER_CE
00076         abort();
00077 #endif
00078         exit(bad);
00079     }
00080     std::cerr << std::endl;
00081 }
00082 
00083 }
00084 
00085 /* ====================================================================
00086  * The Vovida Software License, Version 1.0 
00087  * 
00088  * Copyright (c) 2000-2005 Vovida Networks, Inc.  All rights reserved.
00089  * 
00090  * Redistribution and use in source and binary forms, with or without
00091  * modification, are permitted provided that the following conditions
00092  * are met:
00093  * 
00094  * 1. Redistributions of source code must retain the above copyright
00095  *    notice, this list of conditions and the following disclaimer.
00096  * 
00097  * 2. Redistributions in binary form must reproduce the above copyright
00098  *    notice, this list of conditions and the following disclaimer in
00099  *    the documentation and/or other materials provided with the
00100  *    distribution.
00101  * 
00102  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00103  *    and "Vovida Open Communication Application Library (VOCAL)" must
00104  *    not be used to endorse or promote products derived from this
00105  *    software without prior written permission. For written
00106  *    permission, please contact vocal@vovida.org.
00107  *
00108  * 4. Products derived from this software may not be called "VOCAL", nor
00109  *    may "VOCAL" appear in their name, without prior written
00110  *    permission of Vovida Networks, Inc.
00111  * 
00112  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00113  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00114  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00115  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00116  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00117  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00118  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00119  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00120  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00121  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00122  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00123  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00124  * DAMAGE.
00125  * 
00126  * ====================================================================
00127  * 
00128  * This software consists of voluntary contributions made by Vovida
00129  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00130  * Inc.  For more information on Vovida Networks, Inc., please see
00131  * <http://www.vovida.org/>.
00132  *
00133  */