SEDNA_SEQUENCE_ITEM *ExtFunction::make_item(const xqp_tuple &t) { if (t.cells_number != 1) throw USER_EXCEPTION2(SE1003, "bad tuple_cells count (in external function's arguments)"); tuple_cell res = atomize(t.cells[0]); SEDNA_SEQUENCE_ITEM *node = (SEDNA_SEQUENCE_ITEM *)malloc(sizeof(SEDNA_SEQUENCE_ITEM)); switch (res.get_atomic_type()) { case xs_integer: node->data.type = SEDNATYPE_integer; node->data.val_integer = res.get_xs_integer(); break; case xs_float: node->data.type = SEDNATYPE_float; node->data.val_float = res.get_xs_float(); break; case xs_double: node->data.type = SEDNATYPE_double; node->data.val_double = res.get_xs_double(); break; default: res = cast(res, xs_string); node->data.type = SEDNATYPE_string; str_off_t len = res.get_strlen(); //TODO: check len < MAX_WE_CAN_ALLOC U_ASSERT(len >= 0 && len < SIZE_MAX); node->data.val_string = (SEDNA_string)malloc((size_t)len+1); res.copy_string(node->data.val_string); break; } node->next = NULL; return node; }
int pkill(int argc, char *argv){ atomize(); int pid = atoi(argv); if(terminate_task(pid) == EXIT_SUCCESS) { printfcolor(COMMAND_COLOR, "PID: %d has been successfully killed.\n", pid); } else { printfcolor(ERROR_COLOR, "PID: %d could not be killed.\n", pid); } unatomize(); return EXIT_SUCCESS; }
void PPFnResolveQName::do_next(xqp_tuple &t) { if (first_time) { child_qname.op->next(t); if (t.is_eos()) return; first_time = false; tuple_cell qname_tc = atomize(child_qname.get(t)); if (!is_string_type(qname_tc.get_atomic_type())) { throw XQUERY_EXCEPTION2(XPTY0004, "Wrong first argument of fn:resolve-QName function"); } child_qname.op->next(t); if (!(t.is_eos())) { throw XQUERY_EXCEPTION2(XPTY0004, "Wrong first argument of fn:resolve-QName function"); } qname_tc = tuple_cell::make_sure_light_atomic(qname_tc); child_elem.op->next(t); if (t.is_eos() || !child_elem.get(t).is_node()) { throw XQUERY_EXCEPTION2(XPTY0004, "Wrong second argument of fn:resolve-QName function"); } xptr node = child_elem.get(t).get_node(); child_elem.op->next(t); if (!(t.is_eos())) { throw XQUERY_EXCEPTION2(XPTY0004, "Wrong second argument of fn:resolve-QName function"); } CHECKP(node); if (getNodeType(node) != element) throw XQUERY_EXCEPTION2(XPTY0004, "Wrong second argument of fn:resolve-QName function"); scoped_ptr<InscopeNamespaceMap> inscopeNamespaces = new InscopeNamespaceMap(node, cxt->get_static_context()->getStaticallyKnownNamespaces()); t.copy(tuple_cell::atomic(xsd::QName::createResolve(qname_tc.get_str_mem(), inscopeNamespaces.get()))); } else { first_time = true; t.set_eos(); } }
static inline tuple_cell check_string_argument(xqp_tuple &t, PPOpIn &seq, bool is_empty_allowed, PPPatMatch::patmatch_type pmt, int arg_num) { seq.op->next(t); if(t.is_eos()) { if(is_empty_allowed) return EMPTY_STRING_TC; else throw XQUERY_EXCEPTION2(XPTY0004, (std::string("Invalid arity of the ") + get_argument_name(arg_num) + " of " + PPPatMatch::patmatch_type2c_string(pmt) + ". Argument contains empty sequence.").c_str()); } tuple_cell res = atomize(seq.get(t)); if(!is_string_type(res.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, (std::string("Invalid type of the ") + get_argument_name(arg_num) + " of " + PPPatMatch::patmatch_type2c_string(pmt) + " (xs_string/derived/promotable is expected).").c_str()); seq.op->next(t); if(!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, (std::string("Invalid arity of the ") + get_argument_name(arg_num) + " of " + PPPatMatch::patmatch_type2c_string(pmt) + ". Argument contains more than one item.").c_str()); return res; }
void PPFnTrace::do_next(xqp_tuple &t) { if (first_time) { first_time = false; label_child.op->next(t); if (t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Wrong arguments in function fn:trace. Label argument cannot be empty sequence."); tc = atomize(label_child.get(t)); if (!is_string_type(tc.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, "Wrong arguments in function fn:trace. Invalid label type (xs_string/derived/promotable is expected)."); label_child.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Wrong arguments in function fn:trace. Argument contains more than one item."); tc = tuple_cell::make_sure_light_atomic(tc); if (tc.get_strlen_mem() > 500) throw XQUERY_EXCEPTION2(XPTY0004, "Too long trace prefix is given in fn:trace function"); tr_globals::create_serializer(tr_globals::client->get_result_type()); } value_child.op->next(t); if (t.is_eos()) { first_time = true; } else { dostr->set_debug_info_type(se_QueryTrace); (*dostr) << tc.get_str_mem() << " "; tr_globals::serializer->prepare( dostr, cxt->get_static_context()->get_serialization_options() ); tr_globals::serializer->serialize(t); dostr->flush(); } }
void window::expand() { if( state == WINDOW_HIDDEN ) { XSelectInput ( env, hwnd, event_mask ); XMapWindow ( env, hwnd ); } atomize(env); XEvent xev = {0}; xev.type = ClientMessage; xev.xclient.window = hwnd; xev.xclient.message_type = WM_STATE; xev.xclient.format = 32; xev.xclient.data.l[0] = 2; xev.xclient.data.l[1] = WM_STATE_MAXIMIZED_VERT; xev.xclient.data.l[2] = WM_STATE_MAXIMIZED_HORZ; XSendEvent(env, DefaultRootWindow((Display*)env), False, SubstructureNotifyMask, &xev); XFlush(env); }
void PPFnCompare::do_next(xqp_tuple &t) { if (first_time) { CollationHandler* handler = is_codepoint_equal ? charset_handler->get_unicode_codepoint_collation() : cxt->get_static_context()->get_default_collation(); if (collation_child.op) { collation_child.op->next(t); if(t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid arity of the third argument. Argument contains zero items in fn:compare()"); tuple_cell col = atomize(collation_child.get(t)); if (!is_string_type(col.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid type of the third argument in fn:compare() (xs_string/derived/promotable is expected)"); collation_child.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid arity of the third argument in fn:compare(). Argument contains more than one item"); col = tuple_cell::make_sure_light_atomic(col); int res = cxt->get_static_context()->get_collation(col.get_str_mem(), &handler); if(res != 0) throw XQUERY_EXCEPTION2(FOCH0002, (static_context::get_error_description(res) + " in fn:compare().").c_str()); } tuple_cell tc1, tc2; str1_child.op->next(t); if (t.is_eos()) return; tc1 = atomize(str1_child.get(t)); if (!is_string_type(tc1.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid type of the first argument in fn:compare() (xs_string/derived/promotable is expected)"); str1_child.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid arity of the first argument in fn:compare(). Argument contains more than one item"); str2_child.op->next(t); if (t.is_eos()) return; tc2 = atomize(str2_child.get(t)); if (!is_string_type(tc2.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid type of the second argument in fn:compare() (xs_string/derived/promotable is expected)"); str2_child.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid arity of the second argument in fn:compare(). Argument contains more than one item"); first_time = false; if (is_codepoint_equal) t.copy(tuple_cell::atomic(fn_compare(tc1, tc2, handler) == 0)); else t.copy(tuple_cell::atomic((int64_t)(fn_compare(tc1, tc2, handler)))); } else { t.set_eos(); first_time = true; } }