Ejemplo n.º 1
0
static const QoreStringNode* get_string_header_node(ExceptionSink* xsink, QoreHashNode& h, const char* header, bool allow_multiple = false) {
   AbstractQoreNode* n = h.getKeyValue(header);
   if (!n)
      return 0;

   qore_type_t t = get_node_type(n);
   if (t == NT_STRING)
      return reinterpret_cast<const QoreStringNode*>(n);
   assert(t == NT_LIST);
   if (!allow_multiple) {
      xsink->raiseException("HTTP-HEADER-ERROR", "multiple \"%s\" headers received in HTTP message", header);
      return 0;
   }
   // convert list to a comma-separated string
   QoreListNode* l = reinterpret_cast<QoreListNode*>(n);
   // get first list entry
   n = l->retrieve_entry(0);
   assert(get_node_type(n) == NT_STRING);
   QoreStringNode* rv = reinterpret_cast<QoreStringNode*>(n)->copy();
   for (size_t i = 1; i < l->size(); ++i) {
      n = l->retrieve_entry(i);
      assert(get_node_type(n) == NT_STRING);
      rv->concat(',');
      rv->concat(reinterpret_cast<QoreStringNode*>(n));
   }
   // dereference old list and save reference to return value in header hash
   h.setKeyValue(header, rv, xsink);
   return rv;
}
Ejemplo n.º 2
0
QoreNumberNode::QoreNumberNode(const AbstractQoreNode* n) : SimpleValueQoreNode(NT_NUMBER), priv(0) {
   qore_type_t t = get_node_type(n);
   if (t == NT_NUMBER) {
      priv = new qore_number_private(*reinterpret_cast<const QoreNumberNode*>(n)->priv);
      return;
   }

   if (t == NT_FLOAT) {
      priv = new qore_number_private(reinterpret_cast<const QoreFloatNode*>(n)->f);
      return;
   }

   if (t == NT_STRING) {
      priv = new qore_number_private(reinterpret_cast<const QoreStringNode*>(n)->getBuffer());
      return;
   }

   if (t == NT_INT || (t > QORE_NUM_TYPES && dynamic_cast<const QoreBigIntNode*>(n))) {
      priv = new qore_number_private(reinterpret_cast<const QoreBigIntNode*>(n)->val);
      return;
   }

   if (t != NT_BOOLEAN
       && t != NT_DATE
       && t != NT_NULL) {
      priv = new qore_number_private(0ll);
      return;
   }

   priv = new qore_number_private(n->getAsFloat());
}
Ejemplo n.º 3
0
int ConstantEntry::scanValue(const AbstractQoreNode* n) const {
   switch (get_node_type(n)) {
      case NT_LIST: {
	 ConstListIterator i(reinterpret_cast<const QoreListNode*>(n));
	 while (i.next())
	    if (scanValue(i.getValue()))
	       return -1;
	 return 0;
      }

      case NT_HASH: {
	 ConstHashIterator i(reinterpret_cast<const QoreHashNode*>(n));
	 while (i.next())
	    if (scanValue(i.getValue()))
		return -1;
	 return 0;
      }
	 
      // could have any value and could change at runtime
      case NT_OBJECT:
      case NT_FUNCREF:
	 return -1;
   }

   return 0;
}
Ejemplo n.º 4
0
AbstractQoreNode* QoreValue::assignAndSanitize(const AbstractQoreNode* n) {
   AbstractQoreNode* rv = takeIfNode();
   switch (get_node_type(n)) {
      case NT_NOTHING:
	 type = QV_Node;
	 v.n = 0;
	 break;
      case NT_INT:
         type = QV_Int;
         v.i = reinterpret_cast<const QoreBigIntNode*>(n)->val;
         break;
      case NT_FLOAT:
         type = QV_Float;
         v.f = reinterpret_cast<const QoreFloatNode*>(n)->f;
         break;
      case NT_BOOLEAN:
         type = QV_Bool;
         v.b = reinterpret_cast<const QoreBoolNode*>(n)->getValue();
         break;
      default:
         type = QV_Node;
         v.n = n->refSelf();
         break;
   }
   return rv;
}
Ejemplo n.º 5
0
static void check_constant_cycle(QoreProgram* pgm, AbstractQoreNode* n) {
   qore_type_t t = get_node_type(n);
   if (t == NT_LIST)
      check_constant_cycle_list(pgm, reinterpret_cast<QoreListNode*>(n));
   else if (t == NT_HASH)
      check_constant_cycle_hash(pgm, reinterpret_cast<QoreHashNode*>(n));
}
Ejemplo n.º 6
0
void fill_node_data_structures( int tr,
				int type)
 {/* Init fill_node_data_structures */
  Node_p list = NULL;
  Node_p node_ptr = NULL;

  list = node_ptr = get_place_list(tr,type);
  for( ; node_ptr != NULL ; node_ptr = NEXT_NODE(node_ptr))
   {/* Per ogni nodo della lista */
#ifdef SWN
    node_ptr->type = get_node_type(node_ptr,tr);
    node_ptr->fun_card = get_node_cardinality(node_ptr,tr);
    node_ptr->skip = is_independent_from_instance(node_ptr);
#endif
    if(type==INPUT || type==OUTPUT)
     node_ptr->test_arc = is_test_arc(node_ptr,type,tr);
#ifdef SWN
    if(!node_ptr->skip && type == INHIBITOR)
     node_ptr->type = COMPLEX;
#endif
   }/* Per ogni nodo della lista */
#ifdef SWN
  order_nodes(list,type);
#endif
 }/* End fill_node_data_structures */
Ejemplo n.º 7
0
static void build_trap145(ib_mad_notice_attr_t * n, ib_portid_t * port)
{
	n->generic_type = 0x80 | IB_NOTICE_TYPE_INFO;
	n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port));
	n->g_or_v.generic.trap_num = cl_hton16(145);
	n->issuer_lid = cl_hton16((uint16_t) port->lid);
	n->data_details.ntc_145.new_sys_guid = cl_hton64(0x1234567812345678);
}
Ejemplo n.º 8
0
bool is_container(const AbstractQoreNode* n) {
   switch (get_node_type(n)) {
      case NT_OBJECT:
      case NT_LIST:
      case NT_HASH:
	 return true;
   }
   return false;
}
Ejemplo n.º 9
0
void qore_relative_time::set(const QoreValue v) {
   switch (v.type) {
      case QV_Bool: {
         set(0, 0, 0, 0, 0, (int)v.v.b, 0);
         break;
      }
      case QV_Int: {
         zero();
         addSecondsTo(v.v.i);
         break;
      }
      case QV_Float: {
         zero();
         addSecondsTo(v.v.f);
         break;
      }
      case QV_Node:
         switch (get_node_type(v.v.n)) {
            case NT_BOOLEAN: {
               set(0, 0, 0, 0, 0, (int)reinterpret_cast<const QoreBoolNode*>(v.v.n)->getValue(), 0);
               break;
            }
            case NT_INT: {
               addSecondsTo(reinterpret_cast<const QoreBigIntNode*>(v.v.n)->val, 0);
               break;
            }
            case NT_FLOAT: {
               double f = reinterpret_cast<const QoreFloatNode*>(v.v.n)->f;
               zero();
               addSecondsTo(f);
               break;
            }
            case NT_STRING: {
               const char* str = reinterpret_cast<const QoreStringNode*>(v.v.n)->getBuffer();
               set(str);
               break;
            }
            case NT_DATE: {
               const DateTimeNode* d = reinterpret_cast<const DateTimeNode*>(v.v.n);
               if (d->priv->relative)
                  set(d->priv->d.rel);
               else {
                  zero();
                  addSecondsTo(d->priv->d.abs.epoch, d->priv->d.abs.us);
               }
               break;
            }
            default:
               double f = v.v.n ? v.v.n->getAsFloat() : 0.0;
               zero();
               addSecondsTo(f);
               break;
         }
         break;
   }
}
Ejemplo n.º 10
0
static void build_trap129(ib_mad_notice_attr_t * n, ib_portid_t * port)
{
	n->generic_type = 0x80 | IB_NOTICE_TYPE_URGENT;
	n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port));
	n->g_or_v.generic.trap_num = cl_hton16(129);
	n->issuer_lid = cl_hton16((uint16_t) port->lid);
	n->data_details.ntc_129_131.lid = n->issuer_lid;
	n->data_details.ntc_129_131.pad = 0;
	n->data_details.ntc_129_131.port_num = (uint8_t) error_port;
}
Ejemplo n.º 11
0
static void build_trap144_local(ib_mad_notice_attr_t * n, ib_portid_t * port)
{
	n->generic_type = 0x80 | IB_NOTICE_TYPE_INFO;
	n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port));
	n->g_or_v.generic.trap_num = cl_hton16(144);
	n->issuer_lid = cl_hton16((uint16_t) port->lid);
	n->data_details.ntc_144.lid = n->issuer_lid;
	n->data_details.ntc_144.new_cap_mask = cl_hton32(get_cap_mask(port));
	n->data_details.ntc_144.local_changes =
	    TRAP_144_MASK_OTHER_LOCAL_CHANGES;
}
Ejemplo n.º 12
0
/*******************************************************************************
 * This function takes the base address of the CCN's programmer's view (PV) and
 * the node ID of a Request Node (RN-D or RN-I). It returns the maximum number
 * of master interfaces resident on that node. This number is equal to the least
 * significant two bits of the node type ID + 1.
 ******************************************************************************/
static unsigned int ccn_get_rni_mcount(uintptr_t periphbase,
				       unsigned int rn_id)
{
	unsigned int rn_type_id;

	/* Use the node id to find the type of RN-I/D node */
	rn_type_id = get_node_type(ccn_reg_read(periphbase,
						rn_id + RNI_REGION_ID_START,
						REGION_ID_OFFSET));

	/* Return the number master interfaces based on node type */
	return rn_type_id_to_master_cnt(rn_type_id);
}
Ejemplo n.º 13
0
QoreNumberNode* QoreNumberNode::toNumber(const AbstractQoreNode* n) {
   qore_type_t t = get_node_type(n);
   
   if (t == NT_NUMBER)
      return reinterpret_cast<const QoreNumberNode*>(n)->numberRefSelf();
   
   if (t == NT_FLOAT)
      return new QoreNumberNode(reinterpret_cast<const QoreFloatNode*>(n)->f);

   if (t == NT_STRING)
      return new QoreNumberNode(reinterpret_cast<const QoreStringNode*>(n)->getBuffer());

   if (t == NT_INT || (t > QORE_NUM_TYPES && dynamic_cast<const QoreBigIntNode*>(n)))
      return new QoreNumberNode(reinterpret_cast<const QoreBigIntNode*>(n)->val);

   return new QoreNumberNode(n ? n->getAsFloat() : 0.0);
}
Ejemplo n.º 14
0
Archivo: parser.c Proyecto: monkin/xcss
static void xcss_parse(syntree_t res) {
	xcss_node_type_t nd_type;
	str_it_t e = str_end(syntree_str(res));
	if(nd_type = get_node_type(syntree_position(res), e)) {
		syntree_named_start(res, nd_type);
		if(err())
			return;
		switch(nd_type) {
			case XCSS_NODE_RULE:
				parse_node_rule(res);
				break;
			case XCSS_NODE_NAMESPACE:
				parse_node_namespace(res);
				break;
			case XCSS_NODE_CLASS:
				parse_node_class(res);
				break;
			case XCSS_NODE_COMMENT:
				parse_node_comment(res);
				break;
			case XCSS_NODE_INCLUDE:
				parse_node_include(res);
				break;
			default: {
				assert(0); /* Invalid node type*/
			}
		}
		if(err())
			return;
		syntree_named_end(res);
	} else {
		str_it_t i = syntree_position(res);
		str_it_t e = str_end(syntree_str(res));
		p_skip_spaces(i, e);
		syntree_seek(res, i);
		if(i!=e) {
			err_set(e_xcss_syntax);
			return;
		}
	}
	return;
}
Ejemplo n.º 15
0
void ConstantEntry::del(ExceptionSink* xsink) {
   if (saved_node) {
      node->deref(xsink);
      saved_node->deref(xsink);
#ifdef DEBUG
      node = 0;
      saved_node = 0;
#endif
   }
   else if (node) {
      // abort if an object is present and we are calling deref without an ExceptionSink object
      assert(get_node_type(node) != NT_OBJECT || xsink);
      node->deref(xsink);
#ifdef DEBUG
      node = 0;
#endif
   }

   deref();
}
Ejemplo n.º 16
0
int ForEachStatement::parseInitImpl(LocalVar *oflag, int pflag) {
   int lvids = 0;

   // turn off top-level flag for statement vars
   pflag &= (~PF_TOP_LEVEL);

   const QoreTypeInfo *argTypeInfo = 0;
   if (var)
      var = var->parseInit(oflag, pflag, lvids, argTypeInfo);

   qore_type_t t = get_node_type(var);
   if (t != NT_VARREF && t != NT_SELF_VARREF)
      parse_error("foreach variable expression is not a variable reference (got type '%s' instead)", get_type_name(var));

   if (list) {
      argTypeInfo = 0;
      list = list->parseInit(oflag, pflag, lvids, argTypeInfo);
   }
   if (code)
      code->parseInitImpl(oflag, pflag);

   // save local variables
   if (lvids)
      lvars = new LVList(lvids);

   qore_type_t typ = list->getType();

   is_ref = (typ == NT_PARSEREFERENCE);

   // check for "keys <hash>" specialization
   if (!is_ref && typ == NT_TREE) {
      QoreTreeNode* t = reinterpret_cast<QoreTreeNode*>(list);
      if (t->getOp() == OP_KEYS)
         is_keys = true;
   }

   return 0;
}
Ejemplo n.º 17
0
QoreValue::QoreValue(const AbstractQoreNode* n) {
   switch (get_node_type(n)) {
      case NT_NOTHING:
	 type = QV_Node;
	 v.n = 0;
	 return;
      case NT_INT:
	 type = QV_Int;
	 v.i = reinterpret_cast<const QoreBigIntNode*>(n)->val;
	 return;
      case NT_FLOAT:
	 type = QV_Float;
	 v.f = reinterpret_cast<const QoreFloatNode*>(n)->f;
	 return;
      case NT_BOOLEAN:
	 type = QV_Bool;
	 v.b = reinterpret_cast<const QoreBoolNode*>(n)->getValue();
	 return;
   }
   type = QV_Node;
   // n cannot be 0 here because we covered the NT_NOTHING case above
   v.n = n->refSelf();
}
Ejemplo n.º 18
0
static int print_node_value(spinNodeHandle hNode )
{
	char displayName[MAX_BUFF_LEN];
	size_t displayNameLength = MAX_BUFF_LEN;
	char value[MAX_BUFF_LEN];
	size_t valueLength = MAX_BUFF_LEN;
	spinNodeType type;
	char out_string[256];

	if( get_node_type(&type,hNode) < 0 ) return -1;

	if( get_display_name(displayName,&displayNameLength,hNode) < 0 ) return -1;

	if( type == CategoryNode ){
		sprintf(out_string,"%s", displayName);
	} else {
		if( get_node_value_string(value,&valueLength,hNode) < 0 ) return -1;
		sprintf(out_string,"%s:  %s", displayName,value);
	}
	printf("%s\n",out_string);

	return 0;
}
Ejemplo n.º 19
0
// return the pseudo class for the given node
static QoreClass* pseudo_get_class(const AbstractQoreNode *n) {
    return pseudo_get_class(get_node_type(n));
}
Ejemplo n.º 20
0
	bool DomNode::is_comment() const
	{
		return get_node_type() == COMMENT_NODE;
	}
Ejemplo n.º 21
0
/****************************************************************************
  Name          : avnd_cb_create
 
  Description   : This routine creates & initializes AvND control block.
 
  Arguments     : None.
 
  Return Values : if successfull, ptr to AvND control block
                  else, 0
 
  Notes         : None
******************************************************************************/
AVND_CB *avnd_cb_create()
{
	AVND_CB *cb = avnd_cb;
	uns32 rc = NCSCC_RC_SUCCESS;
	SaVersionT ntfVersion = { 'A', 0x01, 0x01 };
	SaNtfCallbacksT ntfCallbacks = { NULL, NULL };
	SaVersionT immVersion = { 'A', 2, 1 };
	char *val;

	TRACE_ENTER();

	/* assign the AvND pool-id (used by hdl-mngr) */
	cb->pool_id = NCS_HM_POOL_ID_COMMON;

	/* assign the default states */
	cb->admin_state = SA_AMF_ADMIN_UNLOCKED;
	cb->oper_state = SA_AMF_OPERATIONAL_ENABLED;
	cb->term_state = AVND_TERM_STATE_UP;
	cb->led_state = AVND_LED_STATE_RED;
	cb->stby_sync_state = AVND_STBY_IN_SYNC;

	/* assign the default timeout values (in nsec) */
	cb->msg_resp_intv = AVND_AVD_MSG_RESP_TIME * 1000000;

	cb->hb_duration_tmr.is_active = FALSE;
	cb->hb_duration_tmr.type = AVND_TMR_HB_DURATION;
	cb->hb_duration = AVSV_DEF_HB_DURATION;

	if ((val = getenv("AVSV_HB_DURATION")) != NULL) {
		cb->hb_duration = strtoll(val, NULL, 0);
		if (cb->hb_duration == 0) {
			/* no value or non convertable value, revert to default */
			cb->hb_duration = AVSV_DEF_HB_DURATION;
		}
	}

	/* initialize the AvND cb lock */
	m_NCS_LOCK_INIT(&cb->lock);
	TRACE_1("Initialized the AvND lock");

	/* initialize the PID monitor lock */
	m_NCS_LOCK_INIT(&cb->mon_lock);

	/* iniialize the error escaltion paramaets */
	cb->node_err_esc_level = AVND_ERR_ESC_LEVEL_0;

	immutil_saImmOmInitialize(&cb->immOmHandle, NULL, &immVersion);

	/*** initialize avnd dbs ***/

	/* initialize su db */
	if (NCSCC_RC_SUCCESS != avnd_sudb_init(cb))
		goto err;

	/* initialize comp db */
	if (NCSCC_RC_SUCCESS != avnd_compdb_init(cb))
		goto err;

	/* initialize healthcheck db */
	avnd_hcdb_init(cb);

	avnd_cb->type = get_node_type();

	/* initialize pg db */
	if (NCSCC_RC_SUCCESS != avnd_pgdb_init(cb))
		goto err;

	/* initialize pid_mon list */
	avnd_pid_mon_list_init(cb);

	/* initialize nodeid to mdsdest mapping db */
	if (NCSCC_RC_SUCCESS != avnd_nodeid_to_mdsdest_map_db_init(cb))
		goto err;

	/* initialize available internode components db */
	if (NCSCC_RC_SUCCESS != avnd_internode_avail_comp_db_init(cb))
		goto err;

	/* NTFA Initialization */
	rc = saNtfInitialize(&cb->ntfHandle, &ntfCallbacks, &ntfVersion);
	if (rc != SA_AIS_OK) {
		/* log the error code here */
		LOG_ER("saNtfInitialize Failed (%u)", rc);
		goto err;
	}

	immutil_saImmOmInitialize(&cb->immOmHandle, NULL, &immVersion);
	TRACE_LEAVE();
	return cb;

 err:
	if (cb)
		avnd_cb_destroy(cb);
	TRACE_LEAVE();
	return 0;
}
Ejemplo n.º 22
0
	bool DomNode::is_document_type() const
	{
		return get_node_type() == DOCUMENT_TYPE_NODE;
	}
Ejemplo n.º 23
0
void qore_absolute_time::set(const AbstractQoreZoneInfo* n_zone, const QoreValue v) {
   switch (v.type) {
      case QV_Bool: {
         zone = n_zone;
         epoch = v.v.b ? 1 : 0;
         us = 0;
         break;
      }
      case QV_Int: {
         set(n_zone, v.v.i, 0);
         break;
      }
      case QV_Float: {
         set(v.v.f, n_zone);
         break;
      }
      case QV_Node:
         switch (get_node_type(v.v.n)) {
            case NT_BOOLEAN: {
               zone = n_zone;
               epoch = reinterpret_cast<const QoreBoolNode*>(v.v.n)->getValue();
               us = 0;
               break;
            }
            case NT_INT: {
               set(n_zone, reinterpret_cast<const QoreBigIntNode*>(v.v.n)->val, 0);
               break;
            }
            case NT_FLOAT: {
               double f = reinterpret_cast<const QoreFloatNode*>(v.v.n)->f;
               set(f, n_zone);
               break;
            }
            case NT_STRING: {
               const char* str = reinterpret_cast<const QoreStringNode*>(v.v.n)->getBuffer();
               set(str, n_zone);
               break;
            }
            case NT_DATE: {
               const DateTimeNode* d = reinterpret_cast<const DateTimeNode*>(v.v.n);
               if (d->priv->relative) {
                  int64 us = d->priv->d.rel.getRelativeMicroseconds();
                  int64 s = us / 1000000;
                  us -= s * 1000000;
                  set(n_zone, s, us);
               }
               else
                  set(d->priv->d.abs);
               break;
            }
            default: {
               double f = v.v.n ? v.v.n->getAsFloat() : 0.0;
               set(f, n_zone);
               break;
            }
         }
         break;
      default:
         assert(false);
         break;
   }
}
Ejemplo n.º 24
0
// specialization for foreach ... in (keys <hash>) {}
int ForEachStatement::execKeys(QoreValue& return_value, ExceptionSink* xsink) {
   // instantiate local variables
   LVListInstantiator lvi(lvars, xsink);

   assert(get_node_type(list) == NT_TREE);
   QoreTreeNode* t = reinterpret_cast<QoreTreeNode*>(list);

   QoreHashNodeHolder hash(reinterpret_cast<QoreHashNode*>(t->left->eval(xsink)), xsink);
   if (*xsink || !code)
      return 0;

   qore_type_t hnt = get_node_type(*hash);

   // create an empty reference holder for a temporary hash in case the operand is an object
   ReferenceHolder<QoreHashNode> hh(xsink);
   const QoreHashNode* h;

   // if the result is not a hash, then return
   if (hnt == NT_OBJECT) {
      hh = reinterpret_cast<const QoreObject *>(*hash)->getRuntimeMemberHash(xsink);
      if (*xsink)
	 return 0;
      h = *hh;
   }
   else if (hnt != NT_HASH) {
      return 0;
   }
   else
      h = reinterpret_cast<const QoreHashNode*>(*hash);

   ConstHashIterator hi(h);

   int rc = 0;

   int i = 0;

   while (hi.next()) {
      {
	 LValueHelper n(var, xsink);
	 if (!n)
	    break;

	 // assign variable to current key value in list
	 if (n.assign(new QoreStringNode(hi.getKey())))
	    break;
      }

      // set offset in thread-local data for "$#"
      ImplicitElementHelper eh(i++);

      // execute "foreach" body
      if (((rc = code->execImpl(return_value, xsink)) == RC_BREAK) || *xsink) {
	 rc = 0;
	 break;
      }

      if (rc == RC_RETURN)
	 break;
      else if (rc == RC_CONTINUE)
	 rc = 0;
   }

   return rc;
}
Ejemplo n.º 25
0
void qore_queue_private::clearIntern(ExceptionSink* xsink) {
   while (head) {
      printd(5, "qore_queue_private::clearIntern() this: %p deleting %p (node %p type %s)\n", this, head, head->node, get_node_type(head->node));
      QoreQueueNode* w = head->next;
      head->del(xsink);
      head = w;
   }
   head = 0;
   tail = 0;
}
Ejemplo n.º 26
0
status_t
fs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
	uint32 *_flags, bool reenter)
{
	nspace *ns = (nspace*)_vol->private_volume;
	vnode *newNode = NULL;
	ntfs_inode *ni = NULL;
	status_t result = B_NO_ERROR;

	if (!reenter)
		LOCK_VOL(ns);

	ERRPRINT("fs_read_vnode - ENTER\n");

	_node->private_node = NULL;
	_node->ops = &gNTFSVnodeOps;
	_flags = 0;

	newNode = (vnode*)ntfs_calloc(sizeof(vnode));
	if (newNode != NULL) {
		char *name = NULL;

		ni = ntfs_inode_open(ns->ntvol, vnid);
		if (ni == NULL) {
			result = ENOENT;
			goto exit;
		}

		// get the node type
		result = get_node_type(ni, _type);
		if (result != B_OK)
			goto exit;

		newNode->vnid = vnid;
		newNode->parent_vnid = ntfs_get_parent_ref(ni);

		if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
			set_mime(newNode, ".***");
		else {
			name = (char*)malloc(MAX_PATH);
			if (name != NULL) {
				if (utils_inode_get_name(ni, name,MAX_PATH) == 1)
					set_mime(newNode, name);
				free(name);
			}
		}

		_node->private_node = newNode;
	} else
		result = ENOMEM;

exit:
	if (ni != NULL)
		ntfs_inode_close(ni);

	if (result != B_OK && newNode != NULL)
		free(newNode);

	ERRPRINT("fs_read_vnode - EXIT, result is %s\n", strerror(result));

	if (!reenter)
		UNLOCK_VOL(ns);

	return result;
}
Ejemplo n.º 27
0
	bool DomNode::is_notation() const
	{
		return get_node_type() == NOTATION_NODE;
	}
Ejemplo n.º 28
0
	bool DomNode::is_document_fragment() const
	{
		return get_node_type() == DOCUMENT_FRAGMENT_NODE;
	}
Ejemplo n.º 29
0
AbstractQoreNode* QoreXmlReader::getXmlData(ExceptionSink* xsink, const QoreEncoding* data_ccsid, int pflags, int min_depth) {
   xml_stack xstack;

   QORE_TRACE("getXMLData()");
   int rc = 1;

   while (rc == 1) {
      int nt = nodeTypeSkipWhitespace();
      // get node name
      const char* name = constName();
      if (!name)
	 name = "--";

      if (nt == -1) // ERROR
	 break;

      if (nt == XML_READER_TYPE_ELEMENT) {
	 int depth = QoreXmlReader::depth();
	 xstack.checkDepth(depth);

	 AbstractQoreNode* n = xstack.getNode();
	 // if there is no node pointer, then make a hash
	 if (!n) {
	    QoreHashNode* h = new QoreHashNode;
	    xstack.setNode(h);
	    xstack.push(h->getKeyValuePtr(name), depth);
	 }
	 else { // node ptr already exists
	    QoreHashNode* h = n->getType() == NT_HASH ? reinterpret_cast<QoreHashNode*>(n) : 0;
	    if (!h) {
	       h = new QoreHashNode;
	       xstack.setNode(h);
	       h->setKeyValue("^value^", n, 0);
	       xstack.incValueCount();
	       xstack.push(h->getKeyValuePtr(name), depth);
	    }
	    else {
	       // see if key already exists
	       AbstractQoreNode* v;
	       bool exists;
	       v = h->getKeyValueExistence(name, exists);

	       if (!exists)
		  xstack.push(h->getKeyValuePtr(name), depth);
	       else {
		  if (!(pflags & XPF_PRESERVE_ORDER)) {
		     QoreListNode* vl = get_node_type(v) == NT_LIST ? reinterpret_cast<QoreListNode*>(v) : 0;
		     // if it's not a list, then make into a list with current value as first entry
		     if (!vl) {
			AbstractQoreNode** vp = h->getKeyValuePtr(name);
			vl = new QoreListNode;
			vl->push(v);
			(*vp) = vl;
		     }
		     xstack.push(vl->get_entry_ptr(vl->size()), depth);
		  }
		  else {
		     // see if last key was the same, if so make a list if it's not
		     const char* lk = h->getLastKey();
		     bool get_value = false;
		     if (keys_are_equal(name, lk, get_value)) {
			// get actual key value if there was a suffix
			if (get_value)
			   v = h->getKeyValue(lk);

			QoreListNode* vl = get_node_type(v) == NT_LIST ? reinterpret_cast<QoreListNode*>(v) : 0;
			// if it's not a list, then make into a list with current value as first entry
			if (!vl) {
			   AbstractQoreNode** vp = h->getKeyValuePtr(lk);
			   vl = new QoreListNode;
			   vl->push(v);
			   (*vp) = vl;
			}
			xstack.push(vl->get_entry_ptr(vl->size()), depth);
		     }
		     else {
			QoreString ns;
			int c = 1;
			while (true) {
			   ns.sprintf("%s^%d", name, c);
			   if (!h->existsKey(ns.getBuffer()))
			      break;
			   c++;
			   ns.clear();
			}
			xstack.push(h->getKeyValuePtr(ns.getBuffer()), depth);
		     }
		  }
	       }
	    }
	 }
	 // add attributes to structure if possible
	 if (hasAttributes()) {
	    ReferenceHolder<QoreHashNode> h(new QoreHashNode, xsink);
	    while (moveToNextAttribute(xsink) == 1) {
	       const char* aname = constName();
	       QoreStringNode* value = getValue(data_ccsid, xsink);
	       if (!value)
		  return 0;
	       h->setKeyValue(aname, value, xsink);
	    }
	    if (*xsink)
	       return 0;

	    // make new new a hash and assign "^attributes^" key
	    QoreHashNode* nv = new QoreHashNode;
	    nv->setKeyValue("^attributes^", h.release(), xsink);
	    xstack.setNode(nv);
	 }
	 //printd(5, "%s: type: %d, hasValue: %d, empty: %d, depth: %d\n", name, nt, xmlTextReaderHasValue(reader), xmlTextReaderIsEmptyElement(reader), depth);
      }
      else if (nt == XML_READER_TYPE_TEXT) {
	 int depth = QoreXmlReader::depth();
	 xstack.checkDepth(depth);

	 const char* str = constValue();
	 if (str) {
            QoreStringNodeHolder val(getValue(data_ccsid, xsink));
	    if (!val)
	       return 0;

	    AbstractQoreNode* n = xstack.getNode();
	    if (n) {
	       QoreHashNode* h = n->getType() == NT_HASH ? reinterpret_cast<QoreHashNode*>(n) : 0;
	       if (h) {
		  if (!xstack.getValueCount())
		     h->setKeyValue("^value^", val.release(), xsink);
		  else {
		     QoreString kstr;
		     kstr.sprintf("^value%d^", xstack.getValueCount());
		     h->setKeyValue(kstr.getBuffer(), val.release(), xsink);
		  }
	       }
	       else { // convert value to hash and save value node
		  h = new QoreHashNode;
		  xstack.setNode(h);
		  h->setKeyValue("^value^", n, 0);
		  xstack.incValueCount();

		  QoreString kstr;
		  kstr.sprintf("^value%d^", 1);
		  h->setKeyValue(kstr.getBuffer(), val.release(), xsink);
	       }
	       xstack.incValueCount();
	    }
	    else
	       xstack.setNode(val.release());
	 }
      }
      else if (nt == XML_READER_TYPE_CDATA) {
	 int depth = QoreXmlReader::depth();
	 xstack.checkDepth(depth);

	 const char* str = constValue();
	 if (str) {
	    QoreStringNode* val = getValue(data_ccsid, xsink);
	    if (!val)
	       return 0;

	    AbstractQoreNode* n = xstack.getNode();
	    if (n && n->getType() == NT_HASH) {
	       QoreHashNode* h = reinterpret_cast<QoreHashNode*>(n);
	       if (!xstack.getCDataCount())
		  h->setKeyValue("^cdata^", val, xsink);
	       else {
		  QoreString kstr;
		  kstr.sprintf("^cdata%d^", xstack.getCDataCount());
		  h->setKeyValue(kstr.getBuffer(), val, xsink);
	       }
	    }
	    else { // convert value to hash and save value node
	       QoreHashNode* h = new QoreHashNode;
	       xstack.setNode(h);
	       if (n) {
		  h->setKeyValue("^value^", n, 0);
		  xstack.incValueCount();
	       }

	       h->setKeyValue("^cdata^", val, xsink);
	    }
	    xstack.incCDataCount();
	 }
      }
      rc = read();

      if (min_depth > 0 && QoreXmlReader::depth() < min_depth) {
         rc = 0;
         break;
      }
   }
   return rc ? 0 : xstack.getVal();
}
Ejemplo n.º 30
0
	bool DomNode::is_processing_instruction() const
	{
		return get_node_type() == PROCESSING_INSTRUCTION_NODE;
	}