reSIProcate/stack  9694
MethodTypes.cxx
Go to the documentation of this file.
00001 #if defined(HAVE_CONFIG_H)
00002 #include "config.h"
00003 #endif
00004 
00005 #include <string.h>
00006 #include <cstdio>
00007 #include <cassert>
00008 
00009 #include "resip/stack/MethodTypes.hxx"
00010 #include "resip/stack/Symbols.hxx"
00011 #include "rutil/Data.hxx"
00012 
00013 using namespace resip;
00014 
00015 #define defineMethod(_enum, _name, _rfc) _name
00016 
00017 // !dlb! this file will be subsumed by MethodHash.cxx on auto-generate
00018 // move into MethodHash.cxx -- generated from MethodTypes.hxx -- !ah! indeed, yuck!
00019 namespace resip{
00020 
00021 Data MethodNames[] = 
00022 {
00023    defineMethod(UNKNOWN, "UNKNOWN", "NA"),
00024    defineMethod(ACK, "ACK", "RFC ????"),
00025    defineMethod(BYE, "BYE", "RFC ????"),
00026    defineMethod(CANCEL, "CANCEL", "RFC ????"),
00027    defineMethod(INVITE, "INVITE", "RFC ????"),
00028    defineMethod(NOTIFY, "NOTIFY", "RFC ????"),
00029    defineMethod(OPTIONS, "OPTIONS", "RFC ????"),
00030    defineMethod(REFER, "REFER", "RFC ????"),
00031    defineMethod(REGISTER, "REGISTER", "RFC ????"),
00032    defineMethod(SUBSCRIBE, "SUBSCRIBE", "RFC ????"),
00033    defineMethod(RESPONSE, "RESPONSE", "RFC ????"),
00034    defineMethod(MESSAGE, "MESSAGE", "RFC ????"),
00035    defineMethod(INFO, "INFO", "RFC ????"),
00036    defineMethod(PRACK, "PRACK", "RFC ????"),
00037    defineMethod(PUBLISH, "PUBLISH", "RFC ????"),
00038    defineMethod(SERVICE, "SERVICE", "!RFC"),
00039    defineMethod(UPDATE,"UPDATE", "RFC ????")
00040 };
00041 }
00042 #include "MethodHash.hxx"
00043 
00044 const Data&
00045 resip::getMethodName(MethodTypes t) 
00046 {
00047     if (t < UNKNOWN ||  t >= MAX_METHODS) 
00048         t=UNKNOWN;
00049     return MethodNames[t];
00050 }
00051 
00052 MethodTypes
00053 resip::getMethodType(const Data& name)
00054 {
00055    // note: use data to prevent copying shared data
00056    return getMethodType(name.data(), (int)name.size());
00057 }
00058 
00059 MethodTypes
00060 resip::getMethodType(const char* name, int len)
00061 {
00062    const struct methods* m = MethodHash::in_word_set(name, len);
00063    return m ? m->type : UNKNOWN;
00064 }
00065 
00066 // ?dlb? why aren't we using the lib strncasecmp?
00067 int strncasecmp(const char* a, const char* b, int len)
00068 {
00072    for (int i = 0; i < len; i++)
00073    {
00074       int c = tolower(a[i]) - tolower(b[i]);
00075       if (c) return c;
00076    }
00077    return 0;
00078 }
00079 
00080 /* ====================================================================
00081  * The Vovida Software License, Version 1.0 
00082  * 
00083  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00084  * 
00085  * Redistribution and use in source and binary forms, with or without
00086  * modification, are permitted provided that the following conditions
00087  * are met:
00088  * 
00089  * 1. Redistributions of source code must retain the above copyright
00090  *    notice, this list of conditions and the following disclaimer.
00091  * 
00092  * 2. Redistributions in binary form must reproduce the above copyright
00093  *    notice, this list of conditions and the following disclaimer in
00094  *    the documentation and/or other materials provided with the
00095  *    distribution.
00096  * 
00097  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00098  *    and "Vovida Open Communication Application Library (VOCAL)" must
00099  *    not be used to endorse or promote products derived from this
00100  *    software without prior written permission. For written
00101  *    permission, please contact vocal@vovida.org.
00102  *
00103  * 4. Products derived from this software may not be called "VOCAL", nor
00104  *    may "VOCAL" appear in their name, without prior written
00105  *    permission of Vovida Networks, Inc.
00106  * 
00107  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00108  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00109  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00110  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00111  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00112  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00113  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00114  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00115  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00116  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00117  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00118  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00119  * DAMAGE.
00120  * 
00121  * ====================================================================
00122  * 
00123  * This software consists of voluntary contributions made by Vovida
00124  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00125  * Inc.  For more information on Vovida Networks, Inc., please see
00126  * <http://www.vovida.org/>.
00127  *
00128  */