| 75 | typedef std::map<string,SIPMethodType> SipMethodMap; |
| 76 | static SipMethodMap gMethodMap; |
| 77 | SIPMethodType SipMessage::str2MethodType(string &methodname) |
| 78 | { |
| 79 | if (gMethodMap.size() == 0) { |
| 80 | // init the map |
| 81 | #define HELPER_ONE_SIP_METHOD(name) gMethodMap.insert(SipMethodPair(#name, Method##name)); |
| 82 | HELPER_ONE_SIP_METHOD(ACK) |
| 83 | HELPER_ONE_SIP_METHOD(BYE) |
| 84 | HELPER_ONE_SIP_METHOD(CANCEL) |
| 85 | HELPER_ONE_SIP_METHOD(INVITE) |
| 86 | HELPER_ONE_SIP_METHOD(MESSAGE) |
| 87 | HELPER_ONE_SIP_METHOD(OPTIONS) |
| 88 | HELPER_ONE_SIP_METHOD(INFO) |
| 89 | HELPER_ONE_SIP_METHOD(REFER) |
| 90 | HELPER_ONE_SIP_METHOD(NOTIFY) |
| 91 | HELPER_ONE_SIP_METHOD(SUBSCRIBE) |
| 92 | HELPER_ONE_SIP_METHOD(PRACK) |
| 93 | HELPER_ONE_SIP_METHOD(UPDATE) |
| 94 | HELPER_ONE_SIP_METHOD(REGISTER) |
| 95 | HELPER_ONE_SIP_METHOD(PUBLISH) |
| 96 | gMethodMap.insert(SipMethodPair("",MethodUndefined)); // empty string maps to Undefined method. |
| 97 | } |
| 98 | //for (SipMethodMap::iterator i = gMethodMap.begin(); i != gMethodMap.end(); ++i) { |
| 99 | // printf("SipMethodMap %s = %d\n",i->first,i->second); |
| 100 | //} |
| 101 | |
| 102 | if (methodname == NULL) { return MethodUndefined; } |
| 103 | SipMethodMap::iterator it = gMethodMap.find(methodname); |
| 104 | if (it == gMethodMap.end()) { printf("MethodMap %s not found\n",methodname); } |
| 105 | return it == gMethodMap.end() ? MethodUndefined : it->second; |
| 106 | } |
| 107 | SIPMethodType SipMessage::smGetMethod() const |
| 108 | { |
| 109 | if (omsg()->sip_method == NULL) { |