Example #1
0
/********************************************************************
* FUNCTION find_feature_entry2
* 
* Find a feature_entry_t 
*
* INPUTS:
*   modname == module name
*   feature == feature name
*   featQ == Q of feature_entry_t to use
*
* RETURNS:
*   pointer to found and removed entry or NULL if not found
*********************************************************************/
static feature_entry_t *
    find_feature_entry2 (const xmlChar *modname,
                         const xmlChar *feature,
                         dlq_hdr_t  *featQ)
{
    feature_entry_t  *feature_entry;

    for (feature_entry = (feature_entry_t *)dlq_firstEntry(featQ);
         feature_entry != NULL;
         feature_entry = (feature_entry_t *)dlq_nextEntry(feature_entry)) {

        /* match the module name */
        if (feature_entry->modname && modname &&
            xml_strcmp(feature_entry->modname, modname)) {
            continue;
        }

        /* match the feature name */
        if (xml_strcmp(feature_entry->feature, feature)) {
            continue;
        }

        return feature_entry;
    }

    return NULL;

}  /* find_feature_entry2 */
Example #2
0
/********************************************************************
* FUNCTION y_yuma_time_filter_init
* 
* initialize the yuma-time-filter server instrumentation library
* 
* INPUTS:
*    modname == requested module name
*    revision == requested version (NULL for any)
* 
* RETURNS:
*     error status
********************************************************************/
status_t
    y_yuma_time_filter_init (
        const xmlChar *modname,
        const xmlChar *revision)
{
    agt_profile_t *agt_profile;
    status_t res;

    y_yuma_time_filter_init_static_vars();

    /* change if custom handling done */
    if (xml_strcmp(modname, y_yuma_time_filter_M_yuma_time_filter)) {
        return ERR_NCX_UNKNOWN_MODULE;
    }

    if (revision && 
        xml_strcmp(revision, y_yuma_time_filter_R_yuma_time_filter)) {
        return ERR_NCX_WRONG_VERSION;
    }

    agt_profile = agt_get_profile();

    res = ncxmod_load_module(
        y_yuma_time_filter_M_yuma_time_filter,
        y_yuma_time_filter_R_yuma_time_filter,
        &agt_profile->agt_savedevQ,
        &yuma_time_filter_mod);
    if (res != NO_ERR) {
        return res;
    }
    
    /* put your module initialization code here */
    
    return res;
} /* y_yuma_time_filter_init */
CFormulaNode* CFormulaNode::getSemanticsOrCTokenNodeWrapped()
{
	for( CNode *curNode = this; curNode != 0; curNode = curNode->GetParent() )
	{
		if( curNode->GetType() == NODE_FORMULA && curNode->to_mathml_data.is_content != 0 )
		{
			if( !xml_strcmp( curNode->to_mathml_data.name, FBL_TAG_semantics ) || 
				!xml_strcmp( curNode->to_mathml_data.name, FBL_TAG_annotation ) || 
				::mml_is_cm_token( curNode->to_mathml_data.name ) )
				return (CFormulaNode*)curNode;
			else if( curNode->to_mathml_data.name == FBL_TAG_annotation_xml )
			{
				QString attrValue = _T("");
				struct HMathMLAttr mml_attr_by_this_node( getMathMLAttr() );
				if( mml_attr_by_this_node.getFilteredAttr( FBL_ATTR_encoding, attrValue ) == 0 &&
					attrValue == FBL_VAL_MathML_Content )
				{
					continue;
				}
				return (CFormulaNode*)curNode;
			}
		}
	}
	return 0;
}
int HKVisualParameter::Read_XML_VisualFeatures(
    AST_TXML_Tag *root,
    AST_TXML_Attribute *page_title,
    AST_TXML_Attribute *control,
    DRMessageManager& dmm, long dmm_page )
{
    if( page_title )
    {
        if( page_title->getValueType() == ASTVALT_TXML_Int )
            setPropertyPageNo( page_title->getIntValue() );
        else if( page_title->getValueType() == ASTVALT_TXML_String )
            setPropertyPageTitle( page_title->getStringValue() );
    }
    if( control && control->getValueType() == ASTVALT_TXML_String )
    {
        if( !xml_strcmp( control->getStringValue(), FBL_VAL_color_combo_box ) )
        {
            GUICtrlTemplate ctrl( GUI_CTRL_TEMPLATE_COLOR_COMBO_BOX, getType() );
            setGUICtrl( ctrl );
        }
        else if( !xml_strcmp( control->getStringValue(), FBL_VAL_edit_box ) )
        {
            GUICtrlTemplate ctrl( GUI_CTRL_TEMPLATE_EDIT_BOX, getType() );
            setGUICtrl( ctrl );
        }
        else if( !xml_strcmp( control->getStringValue(), FBL_VAL_open_file_edit_box ) )
        {
            GUICtrlTemplate ctrl( GUI_CTRL_TEMPLATE_OPEN_FILE_EDIT_BOX, getType() );
            setGUICtrl( ctrl );
        }
        else if( !xml_strcmp( control->getStringValue(), FBL_VAL_formulator_edit_box ) )
        {
            GUICtrlTemplate ctrl( GUI_CTRL_TEMPLATE_FORMULATOR_EDIT_BOX, getType() );
            setGUICtrl( ctrl );
        }
        else if( !xml_strcmp( control->getStringValue(), FBL_VAL_dropdown_combo_box ) )
        {
            GUICtrlTemplate ctrl( GUI_CTRL_TEMPLATE_DROPDOWN_COMBO_BOX, getType() );
            setGUICtrl( ctrl );
            QString warn2 = _T("property control (dropdown combo box) is empty");
            dmm.AddLine( dmm_page, warn2, root->getLine() );
        }
        else
        {
            QString warn1 = _T("property control name field %1 is unknown");
            dmm.AddLine( dmm_page, warn1, root->getLine(), control->getStringValue() );
        }
    }
    else
        Read_XML_ControlTag( root, dmm, dmm_page );
    return 0;
}
Example #5
0
/********************************************************************
 * FUNCTION help_cvt_str
 * 
 * Convert a string to a help_mode_t enum
 *
 * INPUTS:
 *    str == string to convert
 * RETURNS:
 *  enum value
 *********************************************************************/
help_mode_t
    help_cvt_str (const xmlChar *str)
{
    if (!xml_strcmp(str, NCX_EL_BRIEF)) {
        return HELP_MODE_BRIEF;
    } else if (!xml_strcmp(str, NCX_EL_NORMAL)) {
        return HELP_MODE_NORMAL;
    } else if (!xml_strcmp(str, NCX_EL_FULL)) {
        return HELP_MODE_FULL;
    }
    return HELP_MODE_NONE;

} /* help_cvt_str */
Example #6
0
/********************************************************************
* FUNCTION check_manager_hello
*
* Verify that the same NETCONF protocol verion is supported
* by the manager and this server
* 
* INPUTS:
*    scb == session control block
*    val == value struct for the hello message to check
*
* RETURNS:
*   status
*********************************************************************/
static status_t
    check_manager_hello (ses_cb_t *scb,
                         val_value_t *val)
{
    val_value_t  *caps, *cap;

    /* look for the NETCONF base capability string */
    caps = val_find_child(val, NC_MODULE, NCX_EL_CAPABILITIES);
    if (caps && caps->res == NO_ERR) {

        if (ncx_protocol_enabled(NCX_PROTO_NETCONF11)) {
            for (cap = val_find_child(caps, NC_MODULE, NCX_EL_CAPABILITY);
                 cap != NULL;
                 cap = val_find_next_child(caps, NC_MODULE, 
                                           NCX_EL_CAPABILITY, cap)) {
                if (cap->res == NO_ERR) {
                    if (!xml_strcmp(VAL_STR(cap), CAP_BASE_URN11)) {
                        if (LOGDEBUG3) {
                            log_debug3("\nagt_hello: set "
                                       "protocol to base:1.1");
                        }
                        return ses_set_protocol(scb, NCX_PROTO_NETCONF11);
                    }
                }
            }
        }

        if (ncx_protocol_enabled(NCX_PROTO_NETCONF10)) {
            for (cap = val_find_child(caps, NC_MODULE, NCX_EL_CAPABILITY);
                 cap != NULL;
                 cap = val_find_next_child(caps, NC_MODULE, 
                                           NCX_EL_CAPABILITY, cap)) {
                if (cap->res == NO_ERR) {
                    if (!xml_strcmp(VAL_STR(cap), CAP_BASE_URN)) {
                        if (LOGDEBUG3) {
                            log_debug3("\nagt_hello: set "
                                       "protocol to base:1.0");
                        }
                        return ses_set_protocol(scb, NCX_PROTO_NETCONF10);
                    }
                }
            }
        }
    }

    log_info("\nagt_hello: no NETCONF base:1.0 or base:1.1 URI found");
    return ERR_NCX_MISSING_VAL_INST;

} /* check_manager_hello */
/********************************************************************
* FUNCTION pattern_changed
*
* Check if the pattern-stmt changed at all
*
* INPUTS:
*   oldpat == old pattern struct to check
*   newpat == new pattern struct to check
*
* RETURNS:
*   1 if struct changed
*   0 if struct not changed
*********************************************************************/
static uint32
    pattern_changed (const typ_pattern_t *oldpat,
                     const typ_pattern_t *newpat)
{
    const ncx_errinfo_t *olderr, *newerr;
    
    /* check pattern string is the same */
    if ((!oldpat && newpat) || (oldpat && !newpat)) {
        return 1;
    } else if (oldpat && newpat) {
        if (xml_strcmp(oldpat->pat_str, 
                       newpat->pat_str)) {
            return 1;
        }
    } else {
        return 0;       /* no pattern defined */
    }

    olderr = (oldpat) ? &oldpat->pat_errinfo : NULL;
    newerr = (newpat) ? &newpat->pat_errinfo : NULL;

    /* pattern string is the same, check error stuff */
    return errinfo_changed(olderr, newerr);
    
}  /* pattern_changed */
/********************************************************************
 * FUNCTION add_alias
 * 
 * Add the alias record
 *
 * INPUTS:
 *   alias == alias to add
 *
 * RETURNS:
 *   status
 *********************************************************************/
static status_t
    add_alias (alias_cb_t *alias)
{
    dlq_hdr_t  *aliasQ = get_aliasQ();
    alias_cb_t *curalias;
    int         ret;

    if (aliasQ == NULL) {
        SET_ERROR(ERR_INTERNAL_VAL);
        free_alias(alias);
        return ERR_INTERNAL_VAL;
    }

    for (curalias = (alias_cb_t *)dlq_firstEntry(aliasQ);
         curalias != NULL;
         curalias = (alias_cb_t *)dlq_nextEntry(curalias)) {

        ret = xml_strcmp(curalias->name, alias->name);
        if (ret == 0) {
            SET_ERROR(ERR_NCX_DUP_ENTRY);
            free_alias(alias);
            return ERR_NCX_DUP_ENTRY;
        } else if (ret > 0) {
            dlq_insertAhead(alias, curalias);
            return NO_ERR;
        }
    }

    /* new last entry */
    dlq_enque(alias, aliasQ);
    return NO_ERR;

}  /* add_alias */
void CLineNode::InsertMML_CM_construct_set__parse( AST_TXML_Compound *_tags, 
	int& is_x, std::vector<AST_TXML_Tag*>& bvar_nodes, std::vector<AST_TXML_Tag*>& cond_nodes )
{
	AST_TXML_Node *_n = 0;
	long k;
	for( k = 0; k < _tags->getChildNumber(); k++ )
	{
		_n = _tags->getChild( k );
		if( _n && _n->getNodeType() == ASTT_TXML_Tag )
		{
			if( !xml_strcmp(((AST_TXML_Tag*)_n)->getTagName(), 
							FBL_TAG_bvar ))
				bvar_nodes.push_back((AST_TXML_Tag*)_n);
			else
				break;
		}
	}
	if( k < _tags->getChildNumber() )
	{
		if( (_n = _tags->getChild( k )) != NULL )
		{
			if( _n->getNodeType() == ASTT_TXML_Tag )
			{
				if( !xml_strcmp(((AST_TXML_Tag*)_n)->getTagName(), FBL_TAG_condition ))
					cond_nodes.push_back((AST_TXML_Tag*)_n);
			}
			k++;
		}
	}
	if( k < _tags->getChildNumber() )
	{
		if( k != _tags->getChildNumber() - 1 )
		{
			//bvar_nodes.erase(cond_nodes.begin(),cond_nodes.end());
			//bvar_nodes.erase(bvar_nodes.begin(),bvar_nodes.end());
			//cond_nodes.erase(cond_nodes.begin(),cond_nodes.end());
			bvar_nodes.clear();
			cond_nodes.clear();
		}
		else
		{
			_n = _tags->getChild( k );
			if( _n && _n->getNodeType() == ASTT_TXML_Tag )
				is_x = 1;
		}
	}   	
}       	
Example #10
0
QString CFormulaNode::getMathMLNodeDescription()
{
	QString res = _T("");
	if( isAutodetectContent() )
	{
		QString res = getMathMLNodeDescription_IterateParent();
		if( res.length() ) return res;
		res = _T("autodetected by content");
	}
	else if( !isRWMMLSupport() )
		res = _T("unsupported in MathML");
	else if( isIgnoreContentConversion() )
		res = _T("auxiliary");
	else if( to_mathml_data.type.length() && 
			 !xml_strcmp(to_mathml_data.type, "table") &&
			 to_mathml_data.name.length() )
		res = _T("<mtable>");
	else if( to_mathml_data.type.length() && !xml_strcmp(to_mathml_data.type, "bracket") )
		res = _T("<mfence>");
	else if( to_mathml_data.name.length() )
	{
		QString op = _T("");
		if( to_mathml_data.name == FBL_TAG_apply )
			op = getApplyOp();
		res = QString( _T("\"") ) + to_mathml_data.name + QString( _T("\"") );
		if( op.length() )
			res += QString( _T(" (") ) + op + QString( _T(")") );
	}
	else if( to_mathml_data.value.length() && to_mathml_data.type.length() )
		res = QString( _T("\"") ) + to_mathml_data.type + QString( _T("\"") );
	else if( to_mathml_data.mathml_template_string.length() && !isReferenced() )
	{
		res = _T("");
		for( long i = 0; i < to_mathml_data.mathml_template_string.length() && 
								  to_mathml_data.mathml_template_string.at(i) != QChar('\n'); i++ )
		{
			res.append( to_mathml_data.mathml_template_string.at(i) );
		}
	}

	if( res.length() == 0 )
		return getMathMLNodeDescription_IterateParent();

	res += _T(" element");
	return res;
}
Example #11
0
/********************************************************************
* FUNCTION find_feature_entry
* 
* Find a feature_entry_t
*
* INPUTS:
*   featstr == feature string parm to use
*   featQ == Q of feature_entry_t to use
*
* RETURNS:
*   pointer to found entry or NULL if not found
*********************************************************************/
static feature_entry_t *
    find_feature_entry (const xmlChar *featstr,
                        dlq_hdr_t  *featQ)
{
    uint32 len = 0;
    boolean splitdone = FALSE;
    status_t res = split_feature_string(featstr, &len);
    if (res == NO_ERR) {
        splitdone = TRUE;
    }

    feature_entry_t  *feature_entry = (feature_entry_t *)dlq_firstEntry(featQ);
    for (; feature_entry != NULL;
         feature_entry = (feature_entry_t *)dlq_nextEntry(feature_entry)) {

        if (splitdone && feature_entry->modname) {
            /* match the module name */
            uint32 len2 = xml_strlen(feature_entry->modname);
            if (len != len2) {
                continue;
            }
            if (xml_strncmp(feature_entry->modname, featstr, len)) {
                continue;
            }
        }

        /* match the feature name */
        if (splitdone) {
            if (xml_strcmp(feature_entry->feature, &featstr[len+1])) {
                continue;
            }
        } else {
            if (xml_strcmp(feature_entry->feature, featstr)) {
                continue;
            }
        }

        return feature_entry;
    }

    return NULL;

}  /* find_feature_entry */
CFormulaNode* CLineNode::InsertMML_CM_construct_vector( 
        enum TAG2MML /*tag_id*/, QString rows, AST_TXML_Tag *xml_node )
{
	/*static*/ MMLContent_TT_Vector vec2insert;

	if( !xml_node->getTags() )
		return InsertMML_CM_construct_empty_vector( xml_node );

	std::vector<AST_TXML_Tag*> matrixrow_nodes;
	AST_TXML_Node *_xml_child;
	AST_TXML_Tag *_child;

	for( long i = 0; i < xml_node->getTags()->getChildNumber(); i++ )
	{
		if( (_xml_child = xml_node->getTags()->getChild( i )) != NULL &&
			 _xml_child->getNodeType() == ASTT_TXML_Tag )
		{
			_child = (AST_TXML_Tag*)_xml_child;
			if( rows.length() && 
				xml_strcmp( _child->getTagName(), rows ) )
				break;
			matrixrow_nodes.push_back( _child );
		}
	}

	if( matrixrow_nodes.size() == 0 )
		return InsertMML_CM_construct_empty_vector( xml_node );

	/*static*/ MMLContent_TT_mrow _empty_row;
	CFormulaNode *_node = InsertMMLFormulaNode( _empty_row.getRoot() );
	_empty_row.reset();
	if( !_node ) return InsertMML_CM_construct_empty_vector( xml_node );
	CLineNode *_line = _node->getFormulaLineChild( 0 );
	if( !_line ) return InsertMML_CM_construct_empty_vector( xml_node );

	_line->InsertMML_CM_create_markup_rigid_token( FBL_TAG_mo, _T("(") );
	vec2insert.set( matrixrow_nodes, (int) rows.length() );
	CFormulaNode *_row = _line->InsertMMLFormulaNode( vec2insert.getRoot() );
	vec2insert.reset();
	if( _row )
	{
		_row->to_mathml_data.name = _T("");
		_row->to_mathml_data.is_content = CONTENT_MATHML_CONVERTION2__RECURSIVE_TREE;
	}
	_line->InsertMML_CM_create_markup_rigid_token( FBL_TAG_mo, _T(")") );

	_CM_basic_Node_property( _node, xml_node );
	if( rows.length() )
		_node->to_mathml_data.is_content = CONTENT_MATHML_CONVERTION2__RECURSIVE_TREE_MATRIX;
	else
		_node->to_mathml_data.is_content = CONTENT_MATHML_CONVERTION2__RECURSIVE_TREE;

	return _node;
}
Example #13
0
/********************************************************************
 * FUNCTION output_pattern_diff
 * 
 *  Output the differences report for one pattern clause and
 *  any of its sub-clauses, within a leaf, leaf-list, or 
 *  typedef definition
 *
 * INPUTS:
 *    cp == parameter block to use
 *    oldpat == old internal pattern
 *    newpat == new internal pattern
 *    patnum == index number of pattern in the Q [1 .. N]
 *
 *********************************************************************/
static void
    output_pattern_diff (yangdiff_diffparms_t *cp,
                         const typ_pattern_t *oldpat,
                         const typ_pattern_t *newpat,
                         uint32 patnum)
{
    const ncx_errinfo_t *olderr, *newerr;
    const xmlChar       *oldstr, *newstr;
    xmlChar              buff[NCX_MAX_NUMLEN+16], *p;

    oldstr = (oldpat) ? oldpat->pat_str : NULL;
    newstr = (newpat) ? newpat->pat_str : NULL;

    olderr = (oldpat) ? &oldpat->pat_errinfo : NULL;
    newerr = (newpat) ? &newpat->pat_errinfo : NULL;

    p = buff;
    p += xml_strcpy(p, YANG_K_PATTERN);
    *p++ = ' ';
    *p++ = '[';
    p += (uint32)sprintf((char *)p, "%u", patnum);
    *p++ = ']';
    *p = 0;
    
    if (!oldstr && newstr) {
        /* pattern added in new revision */
        output_diff(cp, buff, oldstr, newstr, FALSE);
        indent_in(cp);
        output_errinfo_diff(cp, olderr, newerr);
        indent_out(cp);
    } else if (oldstr && !newstr) {
        /* pattern removed in new revision */
        output_diff(cp, buff, oldstr, newstr, FALSE);
        indent_in(cp);
        output_errinfo_diff(cp, olderr, newerr);
        indent_out(cp);
    } else if (oldstr && newstr) {
        /* check if pattern changed */
        if (xml_strcmp(oldstr, newstr)) {
            output_diff(cp, buff, oldstr, newstr, FALSE);
            indent_in(cp);
            output_errinfo_diff(cp, olderr, newerr);
            indent_out(cp);
        } else if (errinfo_changed(olderr, newerr)) {
            output_mstart_line(cp, buff, oldstr, FALSE);
            indent_in(cp);
            output_errinfo_diff(cp, olderr, newerr);
            indent_out(cp);
        }
    }

} /* output_pattern_diff */
/********************************************************************
 * FUNCTION insert_event_cb
 * 
 * Insert a new event control block
 *
 * INPUTS:
 *   newcb == control block to insert
 *********************************************************************/
static void
    insert_event_cb (event_cb_t *newcb)
{
    /* insert sorted by module-name, event-name */
    event_cb_t *cb = (event_cb_t *)dlq_firstEntry(&event_cbQ);
    for (; cb; cb = (event_cb_t *)dlq_nextEntry(cb)) {
        int ret = xml_strcmp(newcb->modname, cb->modname);
        if (ret < 0) {
            dlq_insertAhead(newcb, cb);
            return;
        } else if (ret == 0) {
            int ret2 = xml_strcmp(newcb->event, cb->event);
            if (ret2 <= 0) {
                dlq_insertAhead(newcb, cb);
                return;
            }
        }
    }

    /* new last entry */
    dlq_enque(newcb, &event_cbQ);

} /* insert_event_cb */
/********************************************************************
 * FUNCTION find_event_cb
 * 
 * Find a specified event control block
 *
 * INPUTS:
 *   modname == module name
 *   event == eventname
 *   curcb == current starting point; NULL to use start
 * RETURNS:
 *   found record or NULL if not found
 *********************************************************************/
static event_cb_t *
    find_event_cb (const xmlChar *modname,
                   const xmlChar *event,
                   event_cb_t *curcb)
{
    event_cb_t *cb = (curcb) ? 
        (event_cb_t *)dlq_nextEntry(curcb) :
        (event_cb_t *)dlq_firstEntry(&event_cbQ);
    for (; cb; cb = (event_cb_t *)dlq_nextEntry(cb)) {
        int ret = xml_strcmp(modname, cb->modname);
        if (ret < 0) {
            return NULL;
        } else if (ret == 0) {
            int ret2 = xml_strcmp(event, cb->event);
            if (ret2 < 0) {
                return NULL;
            } else if (ret2 == 0) {
                return cb;
            }
        }
    }
    return NULL;

} /* find_event_cb */
Example #16
0
static agt_cb_commit_complete_set_t* find_callback_set( const xmlChar *modname )
{
    agt_cb_commit_complete_set_t* cbSet;

    for ( cbSet = ( agt_cb_commit_complete_set_t* )dlq_firstEntry( &callbackQ );
          cbSet != NULL;
          cbSet = ( agt_cb_commit_complete_set_t* )dlq_nextEntry( cbSet ) )
    {
        if ( xml_strcmp( modname, cbSet->modname ) )
        {
            return cbSet;
        }
    }

    return NULL;
}
Example #17
0
/********************************************************************
* FUNCTION match_name
* 
* Get the next token which must be a string which matches name
*
* INPUTS:
*   tkc == token chain
*   name  == name to match
*
* RETURNS:
*   status of the operation
*********************************************************************/
static status_t 
    match_name (tk_chain_t  *tkc,
                const xmlChar *name)
{
    status_t res;

    /* get the next token */
    res = consume_tk(tkc, TK_TT_TSTRING);
    if (res == NO_ERR) {
        if (xml_strcmp(TK_CUR_VAL(tkc), name)) {
            res = ERR_NCX_WRONG_VAL;
        }
    }
    return res;

} /* match_name */
Example #18
0
cfg_transaction_id_t agt_trans_id_get(rpc_msg_t *msg)
{
    val_value_t* chval, *val = msg->rpc_input;
    //ncx_btype_t btyp;
    for (chval = (val_value_t *)dlq_firstEntry(&val->v.childQ);
             chval != NULL;
             chval = (val_value_t *)dlq_nextEntry(chval)) 
    {
        if (!xml_strcmp(chval->name, "trans-id"))
          if (chval->btyp == NCX_BT_UINT64)
          {
              return (cfg_transaction_id_t)chval->v.num.ul;
          }
    }
    return 0;
}
static agt_cb_queue_notification_set_t* find_callback_set( const xmlChar *modname )
{
    agt_cb_queue_notification_set_t* cbSet;

    for ( cbSet = ( agt_cb_queue_notification_set_t* )dlq_firstEntry( &callbackQ );
          cbSet != NULL;
          cbSet = ( agt_cb_queue_notification_set_t* )dlq_nextEntry( cbSet ) )
    {
        if ( 0==xml_strcmp( modname, cbSet->modname ) )
        {
            return cbSet;
        }
    }

    return NULL;
}
Example #20
0
/********************************************************************
* FUNCTION find_prefix_val
*
* Find the namespace prefix for the specified namespace ID
* by the prefix value itself
*
* INPUTS:
*    msg  == message to search
*    pfix == prefix to check for
*
* RETURNS:
*   namespace ID in the mapping or 0 if not found
*********************************************************************/
static xmlns_id_t
find_prefix_val (xml_msg_hdr_t *msg,
                 const xmlChar *pfix)
{
    const xmlns_pmap_t  *pmap;

    for (pmap = (const xmlns_pmap_t *)dlq_firstEntry(&msg->prefixQ);
            pmap != NULL;
            pmap = (const xmlns_pmap_t *)dlq_nextEntry(pmap)) {

        if (!xml_strcmp(pmap->nm_pfix, pfix)) {
            return pmap->nm_id;
        }
    }
    return XMLNS_NULL_NS_ID;

}  /* find_prefix_val */
CFormulaNode* CLineNode::InsertMMLFormulaNode_OTHERS_byMML( QString mml_name, AST_TXML_Compound *node )
{
	FXmlBtn *ptrFXmlBtn = 0;
	long _toolbar_no = -1, _button_no = -1;

	if( ::getCurrentToolBarSet()->getButtonCoordByMathMLTag( mml_name, _toolbar_no, _button_no ) == -1 )
	{
		if( xml_strcmp( mml_name, FBL_TAG_merror ) )
		{
			QString mess = _T("Unexpected tag \"") + mml_name + _T("\"");
			InsertMMLFormulaNode_MERROR( mess );
		}
		return NULL;
	}
	ptrFXmlBtn = ::getCurrentToolBarSet()->getButtonCalc( _toolbar_no, _button_no );
	return InsertMMLFormulaNode_OTHERS( ptrFXmlBtn, node );
}
CFormulaNode* CLineNode::InsertMMLFormulaNode_OTHERS_byID( const QString& _id, AST_TXML_Tag *node )
{
	FXmlBtn *ptrFXmlBtn = 0;
	long _toolbar_no = -1, _button_no = -1;

	if( ::getCurrentToolBarSet()->getButtonCoordByID( _id, _toolbar_no, _button_no ) == -1 )
	{
		if( xml_strcmp( node->getTagName(), FBL_TAG_merror ) )
		{
			QString mess = _T("Unexpected tag \"") + node->getTagName() + _T("\"");
			InsertMMLFormulaNode_MERROR( mess );
		}
		return NULL;
	}
	ptrFXmlBtn = ::getCurrentToolBarSet()->getButtonCalc( _toolbar_no, _button_no );
	return InsertMMLFormulaNode_OTHERS( ptrFXmlBtn, node );
}
CFormulaNode* CLineNode::InsertMMLFormulaNode_MFRAC( AST_TXML_Tag *node )
{
	long numalign;
	long denomalign;
	unsigned char bevelled = 0;
	RealFde attr_width = LINETHICKNESS_DEFAULT;
	::bb_read_attr_linethickness( node, FBL_ATTR_linethickness, attr_width );

	long v, h;
	v = TO_BOTTOM;
	h = HORISONTAL_CENTER;
	::bb_read_attr_align_horizontal( node, FBL_ATTR_numalign, h );
	numalign = v | h;

	v = TO_TOP;
	h = HORISONTAL_CENTER;
	::bb_read_attr_align_horizontal( node, FBL_ATTR_denomalign, h );
	denomalign = v | h;

	AST_TXML_Attribute *_attr = node->getAttribute( FBL_ATTR_bevelled );
	if( _attr && 
		_attr->getValueType() == ASTVALT_TXML_String &&
		!xml_strcmp( _attr->getStringValue(), FBL_VAL_true ) )
		bevelled = 1;

	CFormulaNode* mfrac_node = bevelled ?
		InsertMMLFormulaNode_OTHERS_byID( HF_BTNID_DEFAULT_BEVELLED_MFRAC, node ) :
		InsertMMLFormulaNode_OTHERS_byMML( node );
	if( mfrac_node )
	{
		mfrac_node->SetChildFrameAlignType( 0, numalign );
		mfrac_node->SetChildFrameAlignType( 1, denomalign );
		mfrac_node->setLinethickness( 0, attr_width );

		struct HMathMLAttr mml_attr(_T( ""), _T("") );	// not one of the predefined tokens
		mml_attr.set( ::getCurrentFormulatorStyle().getUnit2PX(), node, _T("") /*has no body*/ );
		mml_attr.accountAttr( FBL_ATTR_linethickness );
		mml_attr.accountAttr( FBL_ATTR_numalign );
		mml_attr.accountAttr( FBL_ATTR_denomalign );
		mfrac_node->CNodeInfo_Property::setUnfilteredAttr( mml_attr );
	}
	return mfrac_node;
}
Example #24
0
/********************************************************************
* FUNCTION find_request
*
* Find an RPC request but do not remove it
* 
*
* The NETCONF protocol actually allows duplicates in
* the message-id attribute, but if a message is cancelled
* then only the first match is deleted
*
* INPUTS:
*   scb == session control block
*   msg_id == ID for the mgr_rpc_req_t to find
*
* RETURNS:
*   pointer to the request or NULL if not found
*********************************************************************/
static mgr_rpc_req_t *
    find_request (ses_cb_t *scb,
                  const xmlChar *msg_id)
{
    mgr_scb_t *mscb;
    mgr_rpc_req_t *req;

    mscb = mgr_ses_get_mscb(scb);

    for (req = (mgr_rpc_req_t *)dlq_firstEntry(&mscb->reqQ);
         req != NULL;
         req = (mgr_rpc_req_t *)dlq_nextEntry(req)) {
        if (!xml_strcmp(msg_id, req->msg_id)) {
            return req;
        }
    }
    return NULL;

}  /* find_request */
Example #25
0
/********************************************************************
* FUNCTION ncx_compare_strs
* 
* Compare 2 ncx_str_t union contents
*
* INPUTS:
*     str1 == first string
*     str2 == second string
*     btyp == expected data type 
*             (NCX_BT_STRING, NCX_BT_INSTANCE_ID)
* RETURNS:
*     -1 if str1 is < str2
*      0 if str1 == str2   (also for error, after SET_ERROR called)
*      1 if str1 is > str2
*********************************************************************/
int32
    ncx_compare_strs (const ncx_str_t *str1,
                      const ncx_str_t *str2,
                      ncx_btype_t  btyp)
{
#ifdef DEBUG
    if (!str1 || !str2) {
        SET_ERROR(ERR_INTERNAL_PTR);
        return 0;
    }
#endif

    if (!typ_is_string(btyp)) {
        SET_ERROR(ERR_INTERNAL_VAL);
        return 0;
    }   

    return xml_strcmp(*str1, *str2);

    /*NOTREACHED*/
}  /* ncx_compare_strs */
Example #26
0
/********************************************************************
* FUNCTION rpc_err_get_errtag_enum
*
* Get the RPC error-tag enum for an error-tag string
*
* INPUTS:
*   errtag == error-tag string to check
*
* RETURNS:
*   enum for this error-tag
*********************************************************************/
rpc_err_t
    rpc_err_get_errtag_enum (const xmlChar *errtag)
{
    rpc_err_t   errcode;

#ifdef DEBUG
    if (!errtag) {
        SET_ERROR(ERR_INTERNAL_PTR);
        return RPC_ERR_NONE;
    }
#endif

    for (errcode = RPC_ERR_IN_USE;
         errcode <= RPC_ERR_LAST_ERROR;
         errcode++) {

        if (!xml_strcmp(errtag, rpc_err_map[errcode].errtag)) {
            return rpc_err_map[errcode].errid;
        }
    }
    return RPC_ERR_NONE;

} /* rpc_err_get_errtag_enum */
Example #27
0
/********************************************************************
* FUNCTION ncx_find_feature_que
* 
* Find a ncx_feature_t struct in the specified Q
*
* INPUTS:
*    featureQ == Q of ncx_feature_t to search
*    name == feature name to find
*
* RETURNS:
*    pointer to found feature or NULL if not found
*********************************************************************/
ncx_feature_t *
    ncx_find_feature_que (dlq_hdr_t *featureQ,
                          const xmlChar *name)
{
    ncx_feature_t *feature;

#ifdef DEBUG
    if (!featureQ || !name) {
        SET_ERROR(ERR_INTERNAL_PTR);
        return NULL;
    }
#endif

    for (feature = (ncx_feature_t *)dlq_firstEntry(featureQ);
         feature != NULL;
         feature = (ncx_feature_t *)dlq_nextEntry(feature)) {

        if (!xml_strcmp(feature->name, name)) {
            return feature;
        }
    }
    return NULL;
         
} /* ncx_find_feature_que */
Example #28
0
/********************************************************************
* FUNCTION ncx_find_iffeature
* 
* Search a Q of ncx_iffeature_t structs for a match
*
* INPUTS:
*    iffeatureQ == address of Q to search
*    prefix == prefix to check for
*              a NULL value indicates the current module
*    name == feature name string to find
*********************************************************************/
ncx_iffeature_t *
    ncx_find_iffeature (dlq_hdr_t *iffeatureQ,
                        const xmlChar *prefix,
                        const xmlChar *name,
                        const xmlChar *modprefix)
{
    ncx_iffeature_t  *iff;

#ifdef DEBUG
    if (!iffeatureQ || !name) {
        SET_ERROR(ERR_INTERNAL_PTR);
        return NULL;
    }
#endif

    for (iff = (ncx_iffeature_t *)
             dlq_firstEntry(iffeatureQ);
         iff != NULL;
         iff = (ncx_iffeature_t *)dlq_nextEntry(iff)) {

        /* check if name fields the same */
        if (iff->name && !xml_strcmp(iff->name, name)) {

            /* check if prefix fields reference
             * different modules, if set or implied
             */
            if (!ncx_prefix_different(prefix,
                                      iff->prefix,
                                      modprefix)) {
                return iff;
            }
        }
    }
    return NULL;
    
} /* ncx_find_iffeature */
Example #29
0
/********************************************************************
* FUNCTION mgr_xml_skip_subtree
* 
* Already encountered an error, so advance nodes until the
* matching start-node is reached or a terminating error occurs
*   - end of input
*   - start depth level reached
*
* INPUTS:
*   reader == XmlReader already initialized from File, Memory,
*             or whatever
*   startnode  == xml_node_t of the start node of the sub-tree to skip
* RETURNS:
*   status of the operation
* SIDE EFFECTS:
*   the xmlreader state is advanced until the current node is the
*   end node of the specified start node or a fatal error occurs
*********************************************************************/
status_t 
    mgr_xml_skip_subtree (xmlTextReaderPtr reader,
                          const xml_node_t *startnode)
{
    xml_node_t       node;
    const xmlChar   *qname, *badns;
    uint32           len;
    int              ret, depth, nodetyp;
    xmlns_id_t       nsid;
    boolean          done, justone;
    status_t         res;

#ifdef DEBUG
    if (!reader || !startnode) {
        return SET_ERROR(ERR_INTERNAL_PTR);
    }
#endif

    justone = FALSE;

    switch (startnode->nodetyp) {
    case XML_NT_START:
        break;
    case XML_NT_EMPTY:
        return NO_ERR;
    case XML_NT_STRING:
        justone = TRUE;
        break;
    case XML_NT_END:
        return NO_ERR;
    default:
        return SET_ERROR(ERR_INTERNAL_VAL);
    }
    xml_init_node(&node);
    res = mgr_xml_consume_node_noadv(reader, &node);
    if (res == NO_ERR) {
        res = xml_endnode_match(startnode, &node);
        if (res == NO_ERR) {
            xml_clean_node(&node);
            return NO_ERR;
        }
    }

    xml_clean_node(&node);
    if (justone) {
        return NO_ERR;
    }

    done = FALSE;
    while (!done) {

        /* advance the node pointer */
        ret = xmlTextReaderRead(reader);
        if (ret != 1) {
            /* fatal error */
            return ERR_XML_READER_EOF;
        }

        /* get the node depth to match the end node correctly */
        depth = xmlTextReaderDepth(reader);
        if (depth == -1) {
            /* not sure if this can happen, treat as fatal error */
            return ERR_XML_READER_INTERNAL;
        } else if (depth <= startnode->depth) {
            /* this depth override will cause errors to be ignored
             *   - wrong namespace in matching end node
             *   - unknown namespace in matching end node
             *   - wrong name in 'matching' end node
             */
            done = TRUE;
        }

        /* get the internal nodetype, check it and convert it */
        nodetyp = xmlTextReaderNodeType(reader);

        /* get the element QName */
        qname = xmlTextReaderConstName(reader);
        if (qname) {
            /* check for namespace prefix in the name 
             * only error is 'unregistered namespace ID'
             * which doesn't matter in this case
             */
            nsid = 0;
            (void)xml_check_ns(reader, qname, &nsid, &len, &badns);
        } else {
            qname = (const xmlChar *)"";
        }

        /* check the normal case to see if the search is done */
        if (depth == startnode->depth &&
            !xml_strcmp(qname, startnode->qname) &&
            nodetyp == XML_ELEMENT_DECL) {
            done = TRUE;
        }

#ifdef XML_UTIL_DEBUG
        log_debug3("\nxml_skip: %s L:%d T:%s",
               qname, depth, xml_get_node_name(nodetyp));
#endif
    }

    return NO_ERR;

}  /* mgr_xml_skip_subtree */
Example #30
0
/********************************************************************
* FUNCTION y_starter_init
* 
* initialize the starter server instrumentation library
* 
* INPUTS:
*    modname == requested module name
*    revision == requested version (NULL for any)
* 
* RETURNS:
*     error status
********************************************************************/
status_t y_starter_init (
    const xmlChar *modname,
    const xmlChar *revision)
{
    status_t res = NO_ERR;
    agt_profile_t *agt_profile = agt_get_profile();

    y_starter_init_static_vars();

    /* change if custom handling done */
    if (xml_strcmp(modname, y_starter_M_starter)) {
        return ERR_NCX_UNKNOWN_MODULE;
    }

    if (revision && xml_strcmp(revision, y_starter_R_starter)) {
        return ERR_NCX_WRONG_VERSION;
    }
    res = ncxmod_load_module(
        y_starter_M_starter,
        y_starter_R_starter,
        &agt_profile->agt_savedevQ,
        &starter_mod);
    if (res != NO_ERR) {
        return res;
    }

    starter_obj = ncx_find_object(
        starter_mod,
        y_starter_N_starter);
    if (starter_mod == NULL) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }
    starter_start_vnf_obj = ncx_find_object(
        starter_mod,
        y_starter_N_starter_start_vnf);
    if (starter_mod == NULL) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }
    starter_kill_vnf_obj = ncx_find_object(
        starter_mod,
        y_starter_N_starter_kill_vnf);
    if (starter_mod == NULL) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }
    starter_get_load_obj = ncx_find_object(
        starter_mod,
        y_starter_N_starter_get_load);
    if (starter_mod == NULL) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }
    starter_get_processes_obj = ncx_find_object(
        starter_mod,
        y_starter_N_starter_get_processes);
    if (starter_mod == NULL) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }
    processData_obj = ncx_find_object(
        starter_mod,
        y_starter_N_processData);
    if (starter_mod == NULL) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }
    processDone_obj = ncx_find_object(
        starter_mod,
        y_starter_N_processDone);
    if (starter_mod == NULL) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }
    res = agt_rpc_register_method(
        y_starter_M_starter,
        y_starter_N_starter_start_vnf,
        AGT_RPC_PH_VALIDATE,
        y_starter_starter_start_vnf_validate);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_rpc_register_method(
        y_starter_M_starter,
        y_starter_N_starter_start_vnf,
        AGT_RPC_PH_INVOKE,
        y_starter_starter_start_vnf_invoke);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_rpc_register_method(
        y_starter_M_starter,
        y_starter_N_starter_kill_vnf,
        AGT_RPC_PH_VALIDATE,
        y_starter_starter_kill_vnf_validate);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_rpc_register_method(
        y_starter_M_starter,
        y_starter_N_starter_kill_vnf,
        AGT_RPC_PH_INVOKE,
        y_starter_starter_kill_vnf_invoke);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_rpc_register_method(
        y_starter_M_starter,
        y_starter_N_starter_get_load,
        AGT_RPC_PH_VALIDATE,
        y_starter_starter_get_load_validate);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_rpc_register_method(
        y_starter_M_starter,
        y_starter_N_starter_get_load,
        AGT_RPC_PH_INVOKE,
        y_starter_starter_get_load_invoke);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_rpc_register_method(
        y_starter_M_starter,
        y_starter_N_starter_get_processes,
        AGT_RPC_PH_VALIDATE,
        y_starter_starter_get_processes_validate);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_rpc_register_method(
        y_starter_M_starter,
        y_starter_N_starter_get_processes,
        AGT_RPC_PH_INVOKE,
        y_starter_starter_get_processes_invoke);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_cb_register_callback(
        y_starter_M_starter,
        (const xmlChar *)"/starter",
        y_starter_R_starter,
        starter_starter_edit);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_cb_register_callback(
        y_starter_M_starter,
        (const xmlChar *)"/starter/appName",
        y_starter_R_starter,
        starter_starter_appName_edit);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_cb_register_callback(
        y_starter_M_starter,
        (const xmlChar *)"/starter/appParams",
        y_starter_R_starter,
        starter_starter_appParams_edit);
    if (res != NO_ERR) {
        return res;
    }

    res = agt_cb_register_callback(
        y_starter_M_starter,
        (const xmlChar *)"/starter/capabilities",
        y_starter_R_starter,
        starter_starter_capabilities_edit);
    if (res != NO_ERR) {
        return res;
    }

    /* put your module initialization code here */
    
    return res;
} /* y_starter_init */