#include <stdio.h>#include <string.h>#include <stdlib.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <unistd.h>#include <libxml/xmlmemory.h>#include <libxml/parser.h>#include "../../parser/parse_uri.h"#include "../../dprint.h"#include "../../str.h"#include "../../ut.h"#include "CPL_tree.h"#include "sub_list.h"#include "cpl_log.h"

Go to the source code of this file.
Defines | |
| #define | append_double_str_attr(_p_, _s1_, _s2_, _end_, _error_) |
| #define | append_short_attr(_p_, _n_, _end_, _error_) |
| #define | append_str_attr(_p_, _s_, _end_, _error_) |
| #define | BAD_CPL "CPL script doesn't respect CPL grammar" |
| #define | BAD_CPL_LEN (sizeof(BAD_CPL)-1) |
| #define | BAD_XML "CPL script is not a valid XML document" |
| #define | BAD_XML_LEN (sizeof(BAD_XML)-1) |
| #define | check_overflow(_p_, _offset_, _end_, _error_) |
| #define | ENC_ERR "Encoding of the CPL script failed" |
| #define | ENC_ERR_LEN (sizeof(ENC_ERR)-1) |
| #define | ENCONDING_BUFFER_SIZE 65536 |
| #define | FOR_ALL_ATTR(_node, _attr) for( (_attr)=(_node)->properties ; (_attr) ; (_attr)=(_attr)->next) |
| #define | get_attr_val(_attr_name_, _val_, _error_) |
| #define | MAX_EMAIL_BODY_SIZE 512 |
| #define | MAX_EMAIL_HDR_SIZE 7 |
| #define | MAX_EMAIL_SUBJECT_SIZE 32 |
| #define | NULL_CPL "Empty CPL script" |
| #define | NULL_CPL_LEN (sizeof(NULL_CPL)-1) |
| #define | set_attr_type(_p_, _type_, _end_, _error_) |
Typedefs | |
| typedef unsigned short | length_type |
| typedef length_type * | length_type_ptr |
Enumerations | |
| enum | { EMAIL_TO, EMAIL_HDR_NAME, EMAIL_KNOWN_HDR_BODY, EMAIL_UNKNOWN_HDR_BODY } |
Functions | |
| static char * | decode_mail_url (char *p, char *p_end, char *url, unsigned char *nr_attr) |
| static int | encode_address_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_address_switch_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_lang_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_location_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_log_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_lookup_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_mail_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| int | encode_node (xmlNodePtr node, char *p, char *p_end) |
| static int | encode_priority_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_proxy_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_redirect_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_reject_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_rmvloc_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_string_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_string_switch_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_sub_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_subaction_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_time_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| static int | encode_time_switch_attr (xmlNodePtr node, char *node_ptr, char *buf_end) |
| int | encodeCPL (str *xml, str *bin, str *log) |
| int | init_CPL_parser (char *DTD_filename) |
Variables | |
| static xmlValidCtxt | cvp |
| static xmlDtdPtr | dtd |
| static struct node * | list = 0 |
| #define append_double_str_attr | ( | _p_, | |||
| _s1_, | |||||
| _s2_, | |||||
| _end_, | |||||
| _error_ | ) |
| #define append_short_attr | ( | _p_, | |||
| _n_, | |||||
| _end_, | |||||
| _error_ | ) |
Value:
do{\ check_overflow(_p_,sizeof(length_type),_end_,_error_);\ *((length_type_ptr)(_p_)) = htons((length_type)(_n_));\ (_p_) += sizeof(length_type);\ }while(0)
Definition at line 76 of file cpl_parser.c.
Referenced by encode_address_switch_attr(), encode_location_attr(), encode_lookup_attr(), encode_priority_attr(), encode_proxy_attr(), encode_redirect_attr(), encode_reject_attr(), encode_string_switch_attr(), and encode_sub_attr().
| #define append_str_attr | ( | _p_, | |||
| _s_, | |||||
| _end_, | |||||
| _error_ | ) |
Definition at line 83 of file cpl_parser.c.
Referenced by encode_address_attr(), encode_lang_attr(), encode_location_attr(), encode_log_attr(), encode_priority_attr(), encode_reject_attr(), encode_rmvloc_attr(), encode_string_attr(), and encode_time_attr().
| #define BAD_CPL "CPL script doesn't respect CPL grammar" |
| #define BAD_CPL_LEN (sizeof(BAD_CPL)-1) |
| #define BAD_XML "CPL script is not a valid XML document" |
| #define BAD_XML_LEN (sizeof(BAD_XML)-1) |
| #define check_overflow | ( | _p_, | |||
| _offset_, | |||||
| _end_, | |||||
| _error_ | ) |
| #define ENC_ERR "Encoding of the CPL script failed" |
| #define ENC_ERR_LEN (sizeof(ENC_ERR)-1) |
| #define ENCONDING_BUFFER_SIZE 65536 |
| #define FOR_ALL_ATTR | ( | _node, | |||
| _attr | ) | for( (_attr)=(_node)->properties ; (_attr) ; (_attr)=(_attr)->next) |
Definition at line 57 of file cpl_parser.c.
Referenced by encode_address_attr(), encode_address_switch_attr(), encode_lang_attr(), encode_location_attr(), encode_log_attr(), encode_lookup_attr(), encode_mail_attr(), encode_priority_attr(), encode_proxy_attr(), encode_redirect_attr(), encode_reject_attr(), encode_rmvloc_attr(), encode_string_attr(), encode_string_switch_attr(), encode_sub_attr(), encode_subaction_attr(), encode_time_attr(), and encode_time_switch_attr().
| #define get_attr_val | ( | _attr_name_, | |||
| _val_, | |||||
| _error_ | ) |
Definition at line 105 of file cpl_parser.c.
Referenced by encode_address_attr(), encode_address_switch_attr(), encode_location_attr(), encode_log_attr(), encode_lookup_attr(), encode_priority_attr(), encode_proxy_attr(), encode_redirect_attr(), encode_reject_attr(), encode_rmvloc_attr(), encode_string_attr(), encode_string_switch_attr(), encode_sub_attr(), encode_subaction_attr(), encode_time_attr(), and encode_time_switch_attr().
| #define MAX_EMAIL_BODY_SIZE 512 |
| #define MAX_EMAIL_HDR_SIZE 7 |
| #define MAX_EMAIL_SUBJECT_SIZE 32 |
| #define NULL_CPL "Empty CPL script" |
| #define NULL_CPL_LEN (sizeof(NULL_CPL)-1) |
| #define set_attr_type | ( | _p_, | |||
| _type_, | |||||
| _end_, | |||||
| _error_ | ) |
Value:
do{\ check_overflow(_p_,sizeof(length_type),_end_,_error_);\ *((length_type_ptr)(_p_)) = htons((length_type)(_type_));\ (_p_) += sizeof(length_type);\ }while(0)\
Definition at line 69 of file cpl_parser.c.
Referenced by decode_mail_url(), encode_address_attr(), encode_address_switch_attr(), encode_lang_attr(), encode_location_attr(), encode_log_attr(), encode_lookup_attr(), encode_priority_attr(), encode_proxy_attr(), encode_redirect_attr(), encode_reject_attr(), encode_rmvloc_attr(), encode_string_attr(), encode_string_switch_attr(), encode_sub_attr(), encode_time_attr(), and encode_time_switch_attr().
| typedef unsigned short length_type |
Definition at line 49 of file cpl_parser.c.
| typedef length_type* length_type_ptr |
Definition at line 50 of file cpl_parser.c.
| anonymous enum |
Definition at line 52 of file cpl_parser.c.
| static char* decode_mail_url | ( | char * | p, | |
| char * | p_end, | |||
| char * | url, | |||
| unsigned char * | nr_attr | |||
| ) | [inline, static] |
Definition at line 124 of file cpl_parser.c.
References BODY_ATTR, BODY_EMAILHDR_LEN, BODY_EMAILHDR_STR, buf, EMAIL_HDR_NAME, EMAIL_KNOWN_HDR_BODY, EMAIL_TO, EMAIL_UNKNOWN_HDR_BODY, hex2int(), len, LM_DBG, LM_ERR, MAX_EMAIL_BODY_SIZE, MAX_EMAIL_HDR_SIZE, MAX_EMAIL_SUBJECT_SIZE, set_attr_type, SUBJECT_ATTR, SUBJECT_EMAILHDR_LEN, SUBJECT_EMAILHDR_STR, TO_ATTR, URL_MAILTO_LEN, and URL_MAILTO_STR.
Referenced by encode_mail_attr().
| static int encode_address_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 287 of file cpl_parser.c.
References append_str_attr, ATTR_PTR, CONTAINS_ATTR, FOR_ALL_ATTR, get_attr_val, IS_ATTR, _str::len, LM_ERR, NR_OF_ATTR, set_attr_type, and SUBDOMAIN_OF_ATTR.
Referenced by encode_node().
| static int encode_address_switch_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 333 of file cpl_parser.c.
References append_short_attr, ATTR_PTR, DESTINATION_VAL, FIELD_ATTR, FOR_ALL_ATTR, get_attr_val, HOST_VAL, LM_ERR, NR_OF_ATTR, ORIGIN_VAL, ORIGINAL_DESTINATION_VAL, PORT_VAL, _str::s, set_attr_type, SUBFIELD_ATTR, TEL_VAL, and USER_VAL.
Referenced by encode_node().
| static int encode_lang_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 406 of file cpl_parser.c.
References append_str_attr, ATTR_PTR, FOR_ALL_ATTR, _str::len, LM_ERR, MATCHES_SUBTAG_ATTR, MATCHES_TAG_ATTR, NR_OF_ATTR, _str::s, and set_attr_type.
Referenced by encode_node().
| static int encode_location_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 828 of file cpl_parser.c.
References append_short_attr, append_str_attr, ATTR_PTR, CLEAR_ATTR, FOR_ALL_ATTR, get_attr_val, _str::len, LM_ERR, NO_VAL, NR_OF_ATTR, parse_uri(), PRIORITY_ATTR, _str::s, set_attr_type, URL_ATTR, and YES_VAL.
Referenced by encode_node().
| static int encode_log_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 1128 of file cpl_parser.c.
References append_str_attr, ATTR_PTR, COMMENT_ATTR, FOR_ALL_ATTR, get_attr_val, _str::len, LM_ERR, MAX_COMMENT_SIZE, MAX_NAME_SIZE, NAME_ATTR, NR_OF_ATTR, _str::s, and set_attr_type.
Referenced by encode_node().
| static int encode_lookup_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 772 of file cpl_parser.c.
References append_short_attr, ATTR_PTR, CLEAR_ATTR, FOR_ALL_ATTR, get_attr_val, _str::len, LM_ERR, LM_WARN, NO_VAL, NR_OF_ATTR, _str::s, set_attr_type, SOURCE_REG_STR, SOURCE_REG_STR_LEN, and YES_VAL.
Referenced by encode_node().
| static int encode_mail_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 1173 of file cpl_parser.c.
References ATTR_PTR, decode_mail_url(), FOR_ALL_ATTR, LM_ERR, and NR_OF_ATTR.
Referenced by encode_node().
| int encode_node | ( | xmlNodePtr | node, | |
| char * | p, | |||
| char * | p_end | |||
| ) |
Definition at line 1277 of file cpl_parser.c.
References ADDRESS_NODE, ADDRESS_SWITCH_NODE, ANCILLARY_NODE, BUSY_NODE, check_overflow, CPL_NODE, DEFAULT_NODE, encode_address_attr(), encode_address_switch_attr(), encode_lang_attr(), encode_location_attr(), encode_log_attr(), encode_lookup_attr(), encode_mail_attr(), encode_priority_attr(), encode_proxy_attr(), encode_redirect_attr(), encode_reject_attr(), encode_rmvloc_attr(), encode_string_attr(), encode_string_switch_attr(), encode_sub_attr(), encode_subaction_attr(), encode_time_attr(), encode_time_switch_attr(), FAILURE_NODE, GET_NODE_SIZE, INCOMING_NODE, LANGUAGE_NODE, LANGUAGE_SWITCH_NODE, LM_ERR, LOCATION_NODE, LOG_NODE, LOOKUP_NODE, MAIL_NODE, NOANSWER_NODE, NODE_TYPE, NOT_PRESENT_NODE, NOTFOUND_NODE, NR_OF_ATTR, NR_OF_KIDS, OTHERWISE_NODE, OUTGOING_NODE, PRIORITY_NODE, PRIORITY_SWITCH_NODE, PROXY_NODE, REDIRECT_NODE, REDIRECTION_NODE, REJECT_NODE, REMOVE_LOCATION_NODE, SET_KID_OFFSET, SIMPLE_NODE_SIZE, STRING_NODE, STRING_SWITCH_NODE, SUB_NODE, SUBACTION_NODE, SUCCESS_NODE, TIME_NODE, and TIME_SWITCH_NODE.
Referenced by encodeCPL().
| static int encode_priority_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 471 of file cpl_parser.c.
References append_short_attr, append_str_attr, ATTR_PTR, EMERGENCY_STR, EMERGENCY_STR_LEN, EMERGENCY_VAL, EQUAL_ATTR, FOR_ALL_ATTR, get_attr_val, GREATER_ATTR, _str::len, LESS_ATTR, LM_ERR, NON_URGENT_STR, NON_URGENT_STR_LEN, NON_URGENT_VAL, NORMAL_STR, NORMAL_STR_LEN, NORMAL_VAL, NR_OF_ATTR, PRIOSTR_ATTR, _str::s, set_attr_type, UNKNOWN_PRIO_VAL, URGENT_STR, URGENT_STR_LEN, and URGENT_VAL.
Referenced by encode_node().
| static int encode_proxy_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 946 of file cpl_parser.c.
References append_short_attr, ATTR_PTR, FIRSTONLY_VAL, FOR_ALL_ATTR, get_attr_val, _str::len, LM_ERR, NO_VAL, NR_OF_ATTR, ORDERING_ATTR, PARALLEL_VAL, RECURSE_ATTR, _str::s, SEQUENTIAL_VAL, set_attr_type, str2int(), TIMEOUT_ATTR, and YES_VAL.
Referenced by encode_node().
| static int encode_redirect_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 1086 of file cpl_parser.c.
References append_short_attr, ATTR_PTR, FOR_ALL_ATTR, get_attr_val, LM_ERR, NO_VAL, NR_OF_ATTR, PERMANENT_ATTR, _str::s, set_attr_type, and YES_VAL.
Referenced by encode_node().
| static int encode_reject_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 1020 of file cpl_parser.c.
References append_short_attr, append_str_attr, ATTR_PTR, BUSY_STR, BUSY_STR_LEN, BUSY_VAL, ERROR_STR, ERROR_STR_LEN, ERROR_VAL, FOR_ALL_ATTR, get_attr_val, _str::len, LM_ERR, NOTFOUND_STR, NOTFOUND_STR_LEN, NOTFOUND_VAL, NR_OF_ATTR, REASON_ATTR, REJECT_STR, REJECT_STR_LEN, REJECT_VAL, _str::s, set_attr_type, STATUS_ATTR, and str2int().
Referenced by encode_node().
| static int encode_rmvloc_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 895 of file cpl_parser.c.
References append_str_attr, ATTR_PTR, FOR_ALL_ATTR, get_attr_val, _str::len, LM_ERR, LOCATION_ATTR, NR_OF_ATTR, parse_uri(), _str::s, and set_attr_type.
Referenced by encode_node().
| static int encode_string_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 585 of file cpl_parser.c.
References append_str_attr, ATTR_PTR, CONTAINS_ATTR, FOR_ALL_ATTR, get_attr_val, IS_ATTR, _str::len, LM_ERR, NR_OF_ATTR, and set_attr_type.
Referenced by encode_node().
| static int encode_string_switch_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 532 of file cpl_parser.c.
References append_short_attr, ATTR_PTR, DISPLAY_VAL, FIELD_ATTR, FOR_ALL_ATTR, get_attr_val, LM_ERR, NR_OF_ATTR, ORGANIZATION_VAL, _str::s, set_attr_type, SUBJECT_VAL, and USER_AGENT_VAL.
Referenced by encode_node().
| static int encode_sub_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 1237 of file cpl_parser.c.
References append_short_attr, ATTR_PTR, FOR_ALL_ATTR, get_attr_val, LM_ERR, NR_OF_ATTR, REF_ATTR, _str::s, search_the_list(), and set_attr_type.
Referenced by encode_node().
| static int encode_subaction_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 1204 of file cpl_parser.c.
References append_to_list(), FOR_ALL_ATTR, get_attr_val, LM_ERR, and _str::s.
Referenced by encode_node().
| static int encode_time_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 687 of file cpl_parser.c.
References append_str_attr, ATTR_PTR, BYDAY_ATTR, BYHOUR_ATTR, BYMINUTE_ATTR, BYMONTH_ATTR, BYMONTHDAY_ATTR, BYSECOND_ATTR, BYSETPOS_ATTR, BYWEEKNO_ATTR, BYYEARDAY_ATTR, COUNT_ATTR, DTEND_ATTR, DTSTART_ATTR, DURATION_ATTR, FOR_ALL_ATTR, FREQ_ATTR, get_attr_val, INTERVAL_ATTR, _str::len, LM_ERR, NR_OF_ATTR, set_attr_type, UNTIL_ATTR, and WKST_ATTR.
Referenced by encode_node().
| static int encode_time_switch_attr | ( | xmlNodePtr | node, | |
| char * | node_ptr, | |||
| char * | buf_end | |||
| ) | [inline, static] |
Definition at line 627 of file cpl_parser.c.
References append_double_str_attr, ATTR_PTR, FOR_ALL_ATTR, get_attr_val, _str::len, LM_ERR, NR_OF_ATTR, set_attr_type, and TZID_ATTR.
Referenced by encode_node().
Definition at line 1478 of file cpl_parser.c.
References append_log(), BAD_CPL, BAD_CPL_LEN, BAD_XML, BAD_XML_LEN, buf, compile_logs(), cvp, delete_list(), dtd, ENC_ERR, ENC_ERR_LEN, encode_node(), ENCONDING_BUFFER_SIZE, ERR, ERR_LEN, _str::len, LF, LF_LEN, LM_ERR, NULL_CPL, NULL_CPL_LEN, reset_logs(), and _str::s.
Referenced by do_script_action(), and mi_cpl_load().
| int init_CPL_parser | ( | char * | DTD_filename | ) |
Definition at line 1537 of file cpl_parser.c.
References cvp, dtd, LM_ERR, and NULL.
Referenced by cpl_init().
xmlValidCtxt cvp [static] |
xmlDtdPtr dtd [static] |
Definition at line 44 of file cpl_parser.c.
1.5.6