summaryrefslogtreecommitdiffstats
path: root/src/parser/definitions.cpp
blob: ef2e51de4f645d3387006037f33ba8b33d2ee197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
    Copyright (C) 2005-2009  Michel de Boer <michel@twinklephone.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include <assert.h>
#include "definitions.h"
#include "parse_ctrl.h"

string method2str(const t_method &m, const string &unknown) {
	switch (m) {
	case INVITE:		return "INVITE";
	case ACK:		return "ACK";
	case OPTIONS:		return "OPTIONS";
	case BYE:		return "BYE";
	case CANCEL:		return "CANCEL";
	case REGISTER:		return "REGISTER";
	case PRACK:		return "PRACK";
	case SUBSCRIBE:		return "SUBSCRIBE";
	case NOTIFY:		return "NOTIFY";
	case REFER:		return "REFER";
	case INFO:		return "INFO";
	case MESSAGE:		return "MESSAGE";
	case PUBLISH:		return "PUBLISH";
	case METHOD_UNKNOWN:	return unknown;
	default:		assert(false);
	}
	return unknown;
}

t_method str2method(const string &s) {
	if (s == "INVITE") return INVITE;
	if (s == "ACK") return ACK;
	if (s == "OPTIONS") return OPTIONS;
	if (s == "BYE") return BYE;
	if (s == "CANCEL") return CANCEL;
	if (s == "REGISTER") return REGISTER;
	if (s == "PRACK") return PRACK;
	if (s == "SUBSCRIBE") return SUBSCRIBE;
	if (s == "NOTIFY") return NOTIFY;
	if (s == "REFER") return REFER;
	if (s == "INFO") return INFO;
	if (s == "MESSAGE") return MESSAGE;
	if (s == "PUBLISH") return PUBLISH;

	return METHOD_UNKNOWN;
}