1 /*
2  * $Id$
3  *
4  * Copyright (C) 2001-2003 FhG Fokus
5  *
6  * This file is part of Kamailio, a free SIP server.
7  *
8  * Kamailio is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version
12  *
13  * Kamailio is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22 
23 #ifndef _CPL_RUN_H
24 #define _CPL_RUN_H
25 
26 #include "../../core/str.h"
27 #include "../../core/parser/msg_parser.h"
28 
29 #define SCRIPT_END               0
30 #define SCRIPT_DEFAULT           1
31 #define SCRIPT_TO_BE_CONTINUED   2
32 #define SCRIPT_RUN_ERROR         -1
33 #define SCRIPT_FORMAT_ERROR      -2
34 
35 #define CPL_RUN_OUTGOING               (1<<0)
36 #define CPL_RUN_INCOMING               (1<<1)
37 #define CPL_IS_STATEFUL                (1<<2)
38 #define CPL_FORCE_STATEFUL             (1<<3)
39 #define CPL_LOC_SET_MODIFIED           (1<<5)
40 #define CPL_PROXY_DONE                 (1<<6)
41 #define CPL_RURI_DUPLICATED            (1<<10)
42 #define CPL_TO_DUPLICATED              (1<<11)
43 #define CPL_FROM_DUPLICATED            (1<<12)
44 #define CPL_SUBJECT_DUPLICATED         (1<<13)
45 #define CPL_ORGANIZATION_DUPLICATED    (1<<14)
46 #define CPL_USERAGENT_DUPLICATED       (1<<15)
47 #define CPL_ACCEPTLANG_DUPLICATED      (1<<16)
48 #define CPL_PRIORITY_DUPLICATED        (1<<17)
49 
50 #define STR_NOT_FOUND           ((str*)0xffffffff)
51 
52 
53 struct cpl_interpreter {
54 	unsigned int flags;
55 	str user;              /* user */
56 	str script;            /* CPL script */
57 	char *ip;              /* instruction pointer */
58 	int recv_time;         /* receiving time stamp */
59 	struct sip_msg *msg;
60 	struct location *loc_set;     /* location set */
61 	/* pointers to the string-headers needed for switches; can point directly
62 	 * into the sip_msg structure (if no proxy took places) or to private
63 	 * buffers into shm_memory (after a proxy happened); if a hdr is copy into a
64 	 * private buffer, a corresponding flag will be set (xxxx_DUPLICATED) */
65 	str *ruri;
66 	str *to;
67 	str *from;
68 	str *subject;
69 	str *organization;
70 	str *user_agent;
71 	str *accept_language;
72 	str *priority;
73 	/* grouped date the is needed when doing proxy */
74 	struct proxy_st {
75 		unsigned short ordering;
76 		unsigned short recurse;
77 		/* I have to know which will be the last location that will be proxy */
78 		struct location *last_to_proxy;
79 		/* shortcuts to the subnodes */
80 		char *busy;
81 		char *noanswer;
82 		char *redirect;
83 		char *failure;
84 		char *default_;
85 	}proxy;
86 };
87 
88 struct cpl_interpreter* new_cpl_interpreter( struct sip_msg *msg, str *script);
89 
90 void free_cpl_interpreter(struct cpl_interpreter *intr);
91 
92 int cpl_run_script( struct cpl_interpreter *cpl_intr );
93 
94 #endif
95 
96 
97