static void ms_printticket_start( void* data, const char** attributes) { int32 index; int32 val; UNUSED_PARAM(void*, data); if ( !pt_initialise(&pt_new) ) { pt_xml_set_error(XPSPT_ERROR_OUTOFMEM, (uint8*)"Out of memory creating PrintTicket."); return; } index = xml_find_attr((char**)attributes, (uint8*)"version"); if ( index < 0 ) { pt_xml_set_error(XPSPT_ERROR_SYNTAX, (uint8*)"PrintTicket version attribute missing."); return; } if ( !xml_get_integer((char*)attributes[index + 1], &val) ) { pt_xml_set_error(XPSPT_ERROR_SYNTAX, (uint8*)"PrintTicket version attribute not an integer."); return; } if ( val > 1 ) { pt_xml_set_error(XPSPT_ERROR_RANGECHECK, (uint8*)"PrintTicket version attribute value not recognised."); } }
static void ms_value_start( void* data, const char** attributes) { int32 index; XML_QNAME* qname; PTUserData* pUserData = (PTUserData*) data; HQASSERT(pUserData != NULL, "No user data"); /* Get type of value element cdata */ pUserData->xsd_type = XSD_UNDEFINED; index = xml_find_attr((char**)attributes, (uint8*)"type"); if ( index >= 0 ) { if ( !xml_get_qname(pUserData, (char*)attributes[index + 1], &qname) ) { pt_xml_set_error(XPSPT_ERROR_SYNTAX, (uint8*)"Value type attribute is not a qualified name."); return; } if ( strcmp((char*)qname->localpart, "decimal") == 0 ) { pUserData->xsd_type = XSD_DECIMAL; } else if ( strcmp((char*)qname->localpart, "integer") == 0 ) { pUserData->xsd_type = XSD_INTEGER; } else if ( strcmp((char*)qname->localpart, "QName") == 0) { pUserData->xsd_type = XSD_QNAME; } else if ( strcmp((char*)qname->localpart, "string") == 0 ) { pUserData->xsd_type = XSD_STRING; } xml_qname_free(&qname); if ( pUserData->xsd_type == XSD_UNDEFINED ) { pt_xml_set_error(XPSPT_ERROR_RANGECHECK, (uint8*)"Value type attribute not recognised."); return; } } else { /* Default to string if no type specified */ pUserData->xsd_type = XSD_STRING; } /* Initialize/reset value cache */ if ( !initValueData (pUserData) ) { pt_xml_set_error(XPSPT_ERROR_OUTOFMEM, (uint8*)"Out of memory allocating Value cache."); } if ( !pt_add_new_param(pt_new, PT_PARAM_VALUE, NULL) ) { pt_xml_set_error(XPSPT_ERROR_OUTOFMEM, (uint8*)"Out of memory adding Value."); releaseValueData (pUserData); } }
int obj_get_perlin_type(t_xtree *tree) { char *tmp; if (tree) { tmp = xml_find_attr(tree->attr, "TYPE"); if (my_strcmp(tmp, "WOOD") == 0) return (WOOD); if (my_strcmp(tmp, "MARBEL") == 0) return (MARBLE); return (NONE); } return (NONE); }
int obj_get_perlin_ceil(t_xtree *tree) { char *tmp; if (tree) { tmp = xml_find_attr(tree->attr, "CEIL"); if (my_strcmp(tmp, "ON") == 0) return (1); if (my_strcmp(tmp, "OFF") == 0) return (0); return (0); } return (0); }
int obj_get_perlin_apply(t_xtree *tree) { char *tmp; if (tree) { tmp = xml_find_attr(tree->attr, "APPLY"); if (my_strcmp(tmp, "BUMP") == 0) return (APP_BUMP); if (my_strcmp(tmp, "TEXTURE") == 0) return (APP_TEXT); if (my_strcmp(tmp, "BUMP_TEXTURE") == 0) return (APP_BUMP_TEXT); return (1); } return (1); }
static void ms_option_start( void* data, const char** attributes) { int32 index; XML_QNAME* qname = NULL; PTUserData* pUserData = (PTUserData*) data; /* Option elements are not required to always have a name attribute */ index = xml_find_attr((char**)attributes, (uint8*)"name"); if ( index >= 0 ) { if ( !xml_get_qname(pUserData, (char*)attributes[index + 1], &qname) ) { pt_xml_set_error(XPSPT_ERROR_SYNTAX, (uint8*)"Option name attribute is not a qualified name."); return; } } if ( !pt_add_new_param(pt_new, PT_PARAM_OPTION, qname) ) { xml_qname_free(&qname); pt_xml_set_error(XPSPT_ERROR_OUTOFMEM, (uint8*)"Out of memory adding Option."); } }
static void ms_feature_start( void* data, const char** attributes) { int32 index; XML_QNAME* qname; PTUserData* pUserData = (PTUserData*) data; index = xml_find_attr((char**)attributes, (uint8*)"name"); if ( index < 0 ) { pt_xml_set_error(XPSPT_ERROR_SYNTAX, (uint8*)"Feature name attribute missing."); return; } if ( !xml_get_qname(pUserData, (char*)attributes[index + 1], &qname) ) { pt_xml_set_error(XPSPT_ERROR_SYNTAX, (uint8*)"Feature name attribute is not a qualified name."); return; } if ( !pt_add_new_param(pt_new, PT_PARAM_FEATURE, qname) ) { xml_qname_free(&qname); pt_xml_set_error(XPSPT_ERROR_OUTOFMEM, (uint8*)"Out of memory adding Feature."); } }
/******************************************************************** * FUNCTION mgr_rpc_dispatch * * Dispatch an incoming <rpc-reply> response * handle the <rpc-reply> element * called by mgr_top.c: * This function is registered with top_register_node * for the module 'netconf', top-node 'rpc-reply' * * INPUTS: * scb == session control block * top == top element descriptor *********************************************************************/ void mgr_rpc_dispatch (ses_cb_t *scb, xml_node_t *top) { obj_template_t *rpyobj; mgr_rpc_rpy_t *rpy; mgr_rpc_req_t *req; xml_attr_t *attr; xmlChar *msg_id; ncx_module_t *mod; mgr_rpc_cbfn_t handler; ncx_num_t num; status_t res; #ifdef DEBUG if (!scb || !top) { SET_ERROR(ERR_INTERNAL_PTR); return; } #endif /* init local vars */ res = NO_ERR; msg_id = NULL; req = NULL; /* make sure any real session has been properly established */ if (scb->type != SES_TYP_DUMMY && scb->state != SES_ST_IDLE) { log_error("\nError: mgr_rpc: skipping incoming message '%s'", top->qname); mgr_xml_skip_subtree(scb->reader, top); return; } /* check if the reply template is already cached */ rpyobj = NULL; mod = ncx_find_module(NC_MODULE, NULL); if (mod != NULL) { rpyobj = ncx_find_object(mod, NC_RPC_REPLY_TYPE); } if (rpyobj == NULL) { SET_ERROR(ERR_NCX_DEF_NOT_FOUND); mgr_xml_skip_subtree(scb->reader, top); return; } /* get the NC RPC message-id attribute; should be present * because the send-rpc function put a message-id in <rpc> */ attr = xml_find_attr(top, 0, NCX_EL_MESSAGE_ID); if (attr && attr->attr_val) { msg_id = xml_strdup(attr->attr_val); } if (msg_id == NULL) { mgr_xml_skip_subtree(scb->reader, top); log_info("\nmgr_rpc: incoming message with no message-id"); return; } /* the current node is 'rpc-reply' in the netconf namespace * First get a new RPC reply struct */ rpy = new_reply(); if (rpy == NULL) { m__free(msg_id); log_error("\nError: mgr_rpc: skipping incoming message"); mgr_xml_skip_subtree(scb->reader, top); return; } else { rpy->msg_id = msg_id; } /* get the NCX RPC group-id attribute if present */ attr = xml_find_attr(top, xmlns_ncx_id(), NCX_EL_GROUP_ID); if (attr && attr->attr_val) { res = ncx_decode_num(attr->attr_val, NCX_BT_UINT32, &num); if (res == NO_ERR) { rpy->group_id = num.u; } } /* find the request that goes with this reply */ if (rpy->msg_id != NULL) { req = find_request(scb, rpy->msg_id); if (req == NULL) { #ifdef MGR_RPC_DEBUG log_debug("\nmgr_rpc: got request found for msg (%s) " "on session %d", rpy->msg_id, scb->sid); #endif mgr_xml_skip_subtree(scb->reader, top); mgr_rpc_free_reply(rpy); return; } else { dlq_remove(req); } } /* have a request/reply pair, so parse the reply * as a val_value_t tree, stored in rpy->reply */ rpy->res = mgr_val_parse_reply(scb, rpyobj, (req != NULL) ? req->rpc : ncx_get_gen_anyxml(), top, rpy->reply); if (rpy->res != NO_ERR && LOGINFO) { log_info("\nmgr_rpc: got invalid reply on session %d (%s)", scb->sid, get_error_string(rpy->res)); } /* check that there is nothing after the <rpc-reply> element */ if (rpy->res==NO_ERR && !xml_docdone(scb->reader) && LOGINFO) { log_info("\nmgr_rpc: got extra nodes in reply on session %d", scb->sid); } /* invoke the reply handler */ if (req != NULL) { handler = (mgr_rpc_cbfn_t)req->replycb; (*handler)(scb, req, rpy); } /* only reset the session state to idle if was not changed * to SES_ST_SHUTDOWN_REQ during this RPC call */ if (scb->state == SES_ST_IN_MSG) { scb->state = SES_ST_IDLE; } #ifdef MGR_RPC_DEBUG print_errors(); clear_errors(); #endif } /* mgr_rpc_dispatch */