Ejemplo n.º 1
0
    CPUInfo()
    {
        int info[4];

        __cpuid(info, 0);
        int c = info[0] + 1;
        _info.resize(c * 4);
        for (int i = 0; i < c; ++i) {
            __cpuid(info, i);
            for (int j = 0; j < 4; ++j)
                _info[i*4 + j] = info[j];
        }

        __cpuid(info, 0x80000000);
        c = info[0];
        _extendedInfo.resize(c * 4);
        for (int i = 0; i < c; ++i) {
            __cpuid(info, 0x80000000 | i);
            for (int j = 0; j < 4; ++j)
                _extendedInfo[i*4 + j] = info[j];
        }

        _x87 = boolValue(_info[3], 0);
        _mmx = boolValue(_info[3], 23);
        _sse = boolValue(_info[3], 25);
        _sse2 = boolValue(_info[3], 26);
        _sse3 = boolValue(_info[2], 0);
        _ssse3 = boolValue(_info[2], 9);
        _sse41 = boolValue(_info[2], 19);
        _sse42 = boolValue(_info[2], 20);
        _avx = boolValue(info[2], 28);
    }
Ejemplo n.º 2
0
void
meta_init(const char *make_mode)
{
    static int once = 0;
    char *cp;

    useMeta = TRUE;
    useFilemon = TRUE;
    writeMeta = TRUE;

    if (make_mode) {
	if (strstr(make_mode, "env"))
	    metaEnv = TRUE;
	if (strstr(make_mode, "verb"))
	    metaVerbose = TRUE;
	if (strstr(make_mode, "read"))
	    writeMeta = FALSE;
	if (strstr(make_mode, "nofilemon"))
	    useFilemon = FALSE;
	if ((cp = strstr(make_mode, "curdirok="))) {
	    metaCurdirOk = boolValue(&cp[9]);
	}
	if ((cp = strstr(make_mode, "silent="))) {
	    metaSilent = boolValue(&cp[7]);
	}
	if (strstr(make_mode, "ignore-cmd"))
	    metaIgnoreCMDs = TRUE;
	/* for backwards compatability */
	Var_Set(".MAKE.META_CREATED", "${.MAKE.META.CREATED}", VAR_GLOBAL, 0);
	Var_Set(".MAKE.META_FILES", "${.MAKE.META.FILES}", VAR_GLOBAL, 0);
    }
    if (metaVerbose && !Var_Exists(MAKE_META_PREFIX, VAR_GLOBAL)) {
	/*
	 * The default value for MAKE_META_PREFIX
	 * prints the absolute path of the target.
	 * This works be cause :H will generate '.' if there is no /
	 * and :tA will resolve that to cwd.
	 */
	Var_Set(MAKE_META_PREFIX, "Building ${.TARGET:H:tA}/${.TARGET:T}", VAR_GLOBAL, 0);
    }
    if (once)
	return;
    once = 1;
    memset(&Mybm, 0, sizeof(Mybm));
    /*
     * We consider ourselves master of all within ${.MAKE.META.BAILIWICK}
     */
    metaBailiwick = Lst_Init(FALSE);
    cp = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL, 0);
    if (cp) {
	str2Lst_Append(metaBailiwick, cp, NULL);
    }
}
Ejemplo n.º 3
0
void LayoutParser::parseLayout()
{
    static const QStringList typeValues(QString::fromLatin1("general,url,email,number,phonenumber,common").split(','));
    static const QStringList orientationValues(QString::fromLatin1("landscape,portrait").split(','));

    const QXmlStreamAttributes attributes(m_xml.attributes());
    const TagLayout::LayoutType type(enumValue("type", typeValues, TagLayout::General));
    const TagLayout::LayoutOrientation orientation(enumValue("orientation", orientationValues, TagLayout::Landscape));
    const bool uniform_font_size(boolValue(attributes.value(QLatin1String("uniform-font-size")), false));
    TagLayoutPtr new_layout(TagLayoutPtr(new TagLayout(type, orientation, uniform_font_size)));
    m_keyboard->appendLayout(new_layout);

    bool found_section(false);

    while (m_xml.readNextStartElement()) {
        const QStringRef name(m_xml.name());

        if (name == QLatin1String("section")) {
            found_section = true;
            parseSection(new_layout);
        } else {
            error(QString::fromLatin1("Expected '<section>', but got '<%1>'.").arg(name.toString()));
        }
    }

    if (not found_section) {
        error(QString::fromLatin1("Expected '<section>'."));
    }
}
Ejemplo n.º 4
0
/*
 * parseBoolValue(): parse a boolean value
 *
 * returns: 0 = OK, else error
 */
static int
parseBoolValue(const char *name, const char *value,
	optionTable_t *tableptr, const char *filename, const char *line,
	int neg)
{
	int intval = boolValue(value);

	if (intval == -1) {
		if (filename)
			printLog(stderr, "Invalid boolean value in file %s, line \"%s\"\n", filename, line);
		else
			printLog(stderr, "Invalid boolean value \"%s\" at command line option -%s\n", value, line);
		return 1;
	}
	if (neg)
		intval = !intval;
	if (tableptr->checkfunc) { /* check value with check function */
		if ((*tableptr->checkfunc)(&intval, tableptr, filename, line))
			return 1;
	} else
		*(int*)(tableptr->value) = intval;
	tableptr->isSet++;
	log(("bool value for %s is %d\n", name, *(int*)(tableptr->value)));
	return 0;
}
Ejemplo n.º 5
0
// BOOL LITERAL VALUE
rapidjson::Value SuperastCPP::createBoolValue(const bool value) {
  rapidjson::Value boolValue(rapidjson::kObjectType);
  boolValue.AddMember("type", "bool", allocator);
  boolValue.AddMember("value", value, allocator);

  return boolValue;
}
Ejemplo n.º 6
0
void NPVariantData::encode(CoreIPC::ArgumentEncoder& encoder) const
{
    encoder << m_type;

    switch (type()) {
    case NPVariantData::Void:
    case NPVariantData::Null:
        break;
    case NPVariantData::Bool:
        encoder << boolValue();
        break;
    case NPVariantData::Int32:
        encoder << int32Value();
        break;
    case NPVariantData::Double:
        encoder << doubleValue();
        break;
    case NPVariantData::String:
        encoder << stringValue();
        break;
    case NPVariantData::LocalNPObjectID:
        encoder << localNPObjectIDValue();
        break;
    case NPVariantData::RemoteNPObjectID:
        encoder << remoteNPObjectIDValue();
        break;
    }
}
Ejemplo n.º 7
0
void NPVariantData::encode(CoreIPC::ArgumentEncoder* encoder) const
{
    encoder->encode(m_type);

    switch (type()) {
    case NPVariantData::Void:
    case NPVariantData::Null:
        break;
    case NPVariantData::Bool:
        encoder->encode(boolValue());
        break;
    case NPVariantData::Int32:
        encoder->encode(int32Value());
        break;
    case NPVariantData::Double:
        encoder->encode(doubleValue());
        break;
    case NPVariantData::String:
        encoder->encode(stringValue());
        break;
    case NPVariantData::LocalNPObjectID:
        encoder->encode(localNPObjectIDValue());
        break;
    case NPVariantData::RemoteNPObjectID:
        encoder->encode(remoteNPObjectIDValue());
        break;
    }
}
Ejemplo n.º 8
0
			size_t hash() const {
				Hasher hasher;
				hasher.add(kind());
				
				switch (kind()) {
					case NULLVAL:
						break;
					case BOOLEAN:
						hasher.add(boolValue());
						break;
					case INTEGER:
						hasher.add(integerValue());
						break;
					case FLOATINGPOINT:
						hasher.add(floatValue());
						break;
					case CHARACTER:
						hasher.add(characterValue());
						break;
					case STRING:
						hasher.add(stringValue());
						break;
				}
				
				return hasher.get();
			}
Ejemplo n.º 9
0
bool XmlTools::loadBoolValue(std::string section, std::string variable, bool defValue)
{
    coConfigBool boolValue(config, QString(variable.c_str()), QString(section.c_str()));
    if (boolValue.hasValidValue())
        return boolValue;
    else
        return defValue;
}
Ejemplo n.º 10
0
void ConfigCenter::addBooleanParam2(const std::string& path1,
				    const std::string& path2,
				    bool& value)
{
  assert(!path1.empty() && !path2.empty());
  BooleanValue boolValue(value);
  boolValue.path.push_back(path1);
  boolValue.path.push_back(path2);
  m_booleanValues.push_back(boolValue);
}
Ejemplo n.º 11
0
void LayoutParser::parseBinding(const TagBindingContainerPtr &binding_container)
{
    static const QStringList actionValues(QString::fromLatin1(
        "insert,shift,backspace,space,cycle,layout_menu,sym,return,commit,"
        "decimal_separator,plus_minus_toggle,switch,on_off_toggle,compose,"
        "left,up,right,down,close,tab,dead,left-layout,right-layout,command"
    ).split(','));
    Q_ASSERT(actionValues.count() == Key::NumActions);

    const QXmlStreamAttributes attributes(m_xml.attributes());
    const TagBinding::Action action(enumValue("action", actionValues, TagBinding::Insert));
    const QString label(attributes.value(QLatin1String("label")).toString());
    const QString secondary_label(attributes.value(QLatin1String("secondary_label")).toString());
    const QString accents(attributes.value(QLatin1String("accents")).toString());
    const QString accented_labels(attributes.value(QLatin1String("accented_labels")).toString());
    const QString cycleset(attributes.value(QLatin1String("cycleset")).toString());
    const QString sequence(attributes.value(QLatin1String("sequence")).toString());
    const QString icon(attributes.value(QLatin1String("icon")).toString());
    const bool dead(boolValue(attributes.value(QLatin1String("dead")), false));
    const bool quick_pick(boolValue(attributes.value(QLatin1String("quick_pick")), false));
    const bool rtl(boolValue(attributes.value(QLatin1String("rtl")), false));
    const bool enlarge(boolValue(attributes.value(QLatin1String("enlarge")), false));
    TagBindingPtr new_binding(new TagBinding(action, label, secondary_label, accents,
                                             accented_labels, cycleset, sequence, icon,
                                             dead, quick_pick, rtl, enlarge));

    binding_container->setBinding(new_binding);

    while (m_xml.readNextStartElement()) {
        const QStringRef name(m_xml.name());

        if (name == QLatin1String("modifiers")) {
            parseModifiers(new_binding);
        } else {
            error(QString::fromLatin1("Expected '<modifiers>', but got '<%1>'.").arg(name.toString()));
        }
    }
}
QVariant VcsBaseClientSettings::value(const QString &key) const
{
    switch (valueType(key)) {
    case QVariant::Int:
        return intValue(key);
    case QVariant::Bool:
        return boolValue(key);
    case QVariant::String:
        return stringValue(key);
    case QVariant::Invalid:
        return QVariant();
    default:
        return QVariant();
    }
}
Ejemplo n.º 13
0
WaylandEvent readEvent(QXmlStreamReader &xml, bool request)
{
    WaylandEvent event;
    event.request = request;
    event.name = byteArrayValue(xml, "name");
    while (xml.readNextStartElement()) {
        if (xml.name() == "arg") {
            WaylandArgument argument;
            argument.name = byteArrayValue(xml, "name");
            argument.type = byteArrayValue(xml, "type");
            argument.interface = byteArrayValue(xml, "interface");
            argument.summary = byteArrayValue(xml, "summary");
            argument.allowNull = boolValue(xml, "allowNull");
            event.arguments << argument;
        }

        xml.skipCurrentElement();
    }
    return event;
}
Ejemplo n.º 14
0
			bool operator==(const Constant& other) const {
				if (kind() != other.kind()) {
					return false;
				}
				
				switch (kind()) {
					case NULLVAL:
						return true;
					case BOOLEAN:
						return boolValue() == other.boolValue();
					case INTEGER:
						return integerValue() == other.integerValue();
					case FLOATINGPOINT:
						return floatValue() == other.floatValue();
					case CHARACTER:
						return characterValue() == other.characterValue();
					case STRING:
						return stringValue() == other.stringValue();
				}
				
				return false;
			}
Ejemplo n.º 15
0
void LayoutParser::parseKey(const TagRowPtr &row)
{
    static const QStringList styleValues(QString::fromLatin1("normal,special,deadkey").split(','));
    static const QStringList widthValues(QString::fromLatin1("small,medium,large,x-large,xx-large,stretched").split(','));

    const QXmlStreamAttributes attributes(m_xml.attributes());
    const TagKey::Style style(enumValue("style", styleValues, TagKey::Normal));
    const TagKey::Width width(enumValue("width", widthValues, TagKey::Medium));
    const bool rtl(boolValue(attributes.value(QLatin1String("rtl")), false));
    const QString id(attributes.value(QLatin1String("id")).toString());
    TagKeyPtr new_key(new TagKey(style, width, rtl, id));

    row->appendElement(new_key);

    while (m_xml.readNextStartElement()) {
        const QStringRef name(m_xml.name());

        if (name == QLatin1String("binding")) {
            if (not new_key->binding()) {
                parseBinding(new_key);
            } else {
                error(QString::fromLatin1("Expected only one '<binding>', but got another one."));
            }
        } else if (name == QLatin1String("extended")) {
            if (not new_key->extended()) {
                parseExtended(new_key);
            } else {
                error(QString::fromLatin1("Expected only one '<extended>', but got another one."));
            }
        } else {
            error(QString::fromLatin1("Expected '<binding>' or '<extended>', but got '<%1>'.").arg(name.toString()));
        }
    }

    if (not new_key->binding()) {
        error(QString::fromLatin1("Expected exactly one '<binding>' but got none."));
    }
}
Ejemplo n.º 16
0
void LayoutParser::parseSection(const TagLayoutPtr &layout)
{
    static const QStringList typeValues(QString::fromLatin1("sloppy,non-sloppy").split(','));

    const QXmlStreamAttributes attributes(m_xml.attributes());
    const QString id(attributes.value(QLatin1String("id")).toString());
    const bool movable(boolValue(attributes.value(QLatin1String("movable")), true));
    const TagSection::SectionType type(enumValue("type", typeValues, TagSection::Sloppy));
    const QString style(attributes.value(QLatin1String("style")).toString());

    if (id.isEmpty()) {
        error("Expected non-empty 'id' attribute in '<section>'.");
        return;
    }


    TagSectionPtr new_section(new TagSection(id, movable, type, style));
    layout->appendSection(new_section);

    bool found_row(false);

    while (m_xml.readNextStartElement()) {
        const QStringRef name(m_xml.name());

        if (name == QLatin1String("row")) {
            parseRow(new_section);
            found_row = true;
        } else {
            error(QString::fromLatin1("Expected '<row>', but got '<%1>'.").arg(name.toString()));
        }
    }

    if (not found_row) {
        error(QString::fromLatin1("Expected '<row>'."));
    }

}
Ejemplo n.º 17
0
void LayoutParser::parseKeyboard()
{
    const QXmlStreamAttributes attributes(m_xml.attributes());
    const QString version(attributes.value(QLatin1String("version")).toString());
    const QString actual_version(version.isEmpty() ? "1.0" : version);
    const QString title(attributes.value(QLatin1String("title")).toString());
    const QString language(attributes.value(QLatin1String("language")).toString());
    const QString catalog(attributes.value(QLatin1String("catalog")).toString());
    const bool autocapitalization(boolValue(attributes.value(QLatin1String("autocapitalization")), true));
    m_keyboard = TagKeyboardPtr(new TagKeyboard(actual_version, title, language,
                                                catalog, autocapitalization));

    while (m_xml.readNextStartElement()) {
        const QStringRef name(m_xml.name());

        if (name == QLatin1String("import")) {
            parseImport();
        } else if (name == QLatin1String("layout")) {
            parseLayout();
        } else {
            error(QString::fromLatin1("Expected '<layout>' or '<import>', but got '<%1>'.").arg(name.toString()));
        }
    }
}
Ejemplo n.º 18
0
Archivo: vm.c Proyecto: erik/atto
TValue vm_interpret(AttoVM* vm, AttoBlock* block, int start, int argc)
{
    DEBUGF("Interpret block: %d ops\n", block->code->size);
    int error            = 0;
    TValue* max          = (TValue*)(block->code->elements + start + block->code->size);
    TValue *pc_val       = (TValue*)(block->code->elements + start);
    Instruction i        = TV2INST(*pc_val);
    Stack *stack         = &block->stack;
    const char* opcode_names[] = { OPCODE_NAMES };
    const char* op_name = NULL;

    int x;
    for(x = 0; pc_val < max && !error; ++x) {

        op_name = i >= NUM_OPS ? "unknown" : opcode_names[i];

        if(i >= NUM_OPS) {
            ERROR("bad opcode: %d", i);
        }

        DEBUGF("[%d]\t%s (%d)\n", x, op_name, i);
        switch(i) {
        case OP_NOP:
            DISPATCH;
        case OP_POP:
            EXPECT_ON_STACK(1);
            TValue v = pop(stack);
            valueDestroy(&v);
            DISPATCH;
        case OP_DUP: {
            EXPECT_ON_STACK(1);
            TValue v = pop(stack);
            push(stack, v);
            push(stack, v);
            DISPATCH;
        }
        case OP_SWAP: {
            EXPECT_ON_STACK(2);
            TValue f = pop(stack);
            TValue s = pop(stack);
            push(stack, f);
            push(stack, s);
            DISPATCH;
        }
        case OP_ADD:
        case OP_SUB:
        case OP_MUL:
        case OP_DIV:
        case OP_MOD:
        case OP_POW: {
            EXPECT_ON_STACK(2);
            TValue b = pop(stack);
            TValue a = pop(stack);
            TValue res = MathOp(i, a, b);

            push(stack, res);

            DISPATCH;
        }
        case OP_OR:
        case OP_AND:
        case OP_XOR: {
            EXPECT_ON_STACK(2);
            TValue b = pop(stack);
            TValue a = pop(stack);
            TValue res = BitwiseOp(i, a, b);

            push(stack, res);

            DISPATCH;
        }
        case OP_NOT: {
            EXPECT_ON_STACK(1);
            TValue a = pop(stack);
            push(stack, createNumber(~(long)TV2NUM(a)));
            DISPATCH;
        }
        case OP_EQ:
        case OP_LT:
        case OP_GT:
        case OP_LTE:
        case OP_GTE:
        case OP_CMP: {
            EXPECT_ON_STACK(2);
            TValue b = pop(stack);
            TValue a = pop(stack);
            TValue res = ComparisonOp(i, a, b);

            push(stack, res);

            DISPATCH;
        }
        case OP_IF: {
            EXPECT_ON_STACK(1);
            TValue t = pop(stack);
            if(boolValue(t)) {
                NEXTINST;
            }
            DISPATCH;
        }
        case OP_JMP: {
            EXPECT_ON_STACK(1);
            long jmp = (long)TV2NUM(pop(stack));
            if(jmp + pc_val >= max || jmp + (long)pc_val < 0) {
                ERROR("Invalid jump: %ld", jmp);
            }
            pc_val += jmp;
            DISPATCH;
        }
        case OP_PUSHCONST: {
            int index = TV2INST(*++pc_val);
            if(index >= (int)block->k->size) {
                ERROR("Constant index out of bounds: %d", index);
            }
            TValue k = getIndex(block->k, index);

            push(stack, k);
            DISPATCH;
        }
        case OP_PUSHVAR: {
            int index = TV2INST(*++pc_val);

            if(index < 0 || index >= block->sizev) {
                ERROR("Variable index out of bounds: %d", index);
            }

            DEBUGF("PUSHVAR, index %d, value >> %s\n", index, TValue_to_string(block->vars[index]));

            TValue var = block->vars[index];
            var.value.var.index = index;

            block->vars[index] = var;

            push(stack, var);
            DISPATCH;
        }
        case OP_SETVAR: {
            EXPECT_ON_STACK(2);
            TValue var = pop(stack);

            if(var.type != TYPE_VAR) {
                ERROR("Expected a var, but got %s", TValue_type_to_string(var));
            }

            int index = var.value.var.index;

            TValue *val = malloc(sizeof(TValue));

            *val = pop(stack);

            block->vars[index] = createVar(val);

            DEBUGF("SETVAR, index %d, value >> %s\n", index, TValue_to_string(block->vars[index]));

            DISPATCH;
        }
        case OP_VALUEVAR: {
            EXPECT_ON_STACK(1);
            TValue var = pop(stack);

            if(var.type != TYPE_VAR) {
                ERROR("Expected a var, but got %s", TValue_type_to_string(var));
            }

            Value val = *var.value.var.value;
            AttoType type = var.value.var.type;

            TValue t;
            t.value = val;
            t.type = type;

            push(stack, t);
            DISPATCH;
        }
        case OP_BOOLVALUE: {
            EXPECT_ON_STACK(1);

            TValue tos = pop(stack);

            int bool = boolValue(tos);

            valueDestroy(&tos);

            push(stack, createBool(bool));
            DISPATCH;
        }
        case OP_CONCAT: {
            EXPECT_ON_STACK(2);
            TValue top = pop(stack);
            TValue sec = pop(stack);

            if(!(top.type == TYPE_STRING && sec.type == TYPE_STRING)) {
                ERROR("Expected two string values, but got %s and %s", TValue_type_to_string(sec),
                      TValue_type_to_string(top));
            }

            char *top_s = TV2STR(top);
            char *sec_s = TV2STR(sec);


            char *str = malloc(strlen(top_s) + strlen(sec_s));

            strcpy(str, sec_s);
            strcat(str, top_s);

            valueDestroy(&top);
            valueDestroy(&sec);

            push(stack, createString(str, strlen(str), 0));
            free(str);
            DISPATCH;
        }
        case OP_PRINT: {
            EXPECT_ON_STACK(1);
            TValue v = pop(stack);
            char *str = TValue_to_string(v);

            printf("%s", str);

            if(v.type == TYPE_NUMBER) free(str);
            valueDestroy(&v);
            DISPATCH;
        }
        case OP_READLINE: {
            char *buf = malloc(BUFSIZ);
            memset(buf, '\0', BUFSIZ);
            if(fgets(buf, BUFSIZ, stdin) ) {
                char *nl = strchr(buf, '\n');
                if(nl) {
                    *nl = '\0';
                }
            }

            unsigned len = strlen(buf) + 1;
            push(stack, createString(buf, len, 0));

            free(buf);
            DISPATCH;
        }
        case OP_DUMPSTACK:
            print_stack(*stack);
            DISPATCH;

        case OP_CLEARSTACK: {
            Stack s = StackNew();
            StackDestroy(&block->stack);
            *stack = s;
            DISPATCH;
        }
        case OP_CALL: {
            EXPECT_ON_STACK(2);
            TValue fcn = pop(stack);
            TValue num = pop(stack);

            // FIXME: this explodes when types aren't right :(
            if(fcn.type != TYPE_FUNCTION || num.type != TYPE_NUMBER) {
                ERROR("Expected function and numeric values, but got %s and %s", TValue_type_to_string(fcn),
                      TValue_type_to_string(num));
            }

            int nargs = (int)TV2NUM(num);

            EXPECT_ON_STACK(nargs);

            int j;
            for(j = 0; j < nargs; ++j) {
                TValue v = pop(stack);
                push(&fcn.value.function.b->stack, v);
            }

            TValue ret = vm_interpret(vm, fcn.value.function.b, 0, nargs);

            if(ret.type != TYPE_NULL) {
                push(stack, ret);
            }

            valueDestroy(&fcn);
            valueDestroy(&num);
            valueDestroy(&fcn);

            DISPATCH;
        }
        case OP_RETURN: {
            EXPECT_ON_STACK(1);

            TValue ret = pop(stack);

            DEBUGF("Finished block, returning with %s\n", TValue_to_string(ret));

            return ret;

            DISPATCH;
        }
        default:
            ERROR("Unrecognized opcode: %d", i);
        }
    }

    DEBUGLN("Finished block");
    return createNull();
}
Ejemplo n.º 19
0
bool SubversionSettings::hasAuthentication() const
{
    return boolValue(useAuthenticationKey) && !stringValue(userKey).isEmpty();
}
Ejemplo n.º 20
0
void XmlTools::saveBoolValue(bool bool_value, std::string section, std::string variable)
{
    coConfigBool boolValue(config, QString(variable.c_str()), QString(section.c_str()));
    boolValue = bool_value;
    saveToXml();
}
Ejemplo n.º 21
0
// ----------------------------------------------------------------------------
// TextLanguage::readLanguageDefinition
//
// Reads in a text definition of a language. See slade.pk3 for
// formatting examples
// ----------------------------------------------------------------------------
bool TextLanguage::readLanguageDefinition(MemChunk& mc, string source)
{
	Tokenizer tz;

	// Open the given text data
	if (!tz.openMem(mc, source))
	{
		Log::warning(1, S_FMT("Warning: Unable to open %s", source));
		return false;
	}

	// Parse the definition text
	ParseTreeNode root;
	if (!root.parse(tz))
		return false;

	// Get parsed data
	for (unsigned a = 0; a < root.nChildren(); a++)
	{
		auto node = root.getChildPTN(a);

		// Create language
		TextLanguage* lang = new TextLanguage(node->getName());

		// Check for inheritance
		if (!node->inherit().IsEmpty())
		{
			TextLanguage* inherit = fromId(node->inherit());
			if (inherit)
				inherit->copyTo(lang);
			else
				Log::warning(
					1,
					S_FMT("Warning: Language %s inherits from undefined language %s",
						  node->getName(),
						  node->inherit())
				);
		}

		// Parse language info
		for (unsigned c = 0; c < node->nChildren(); c++)
		{
			auto child = node->getChildPTN(c);

			// Language name
			if (S_CMPNOCASE(child->getName(), "name"))
				lang->setName(child->stringValue());

			// Comment begin
			else if (S_CMPNOCASE(child->getName(), "comment_begin"))
			{
				lang->setCommentBeginList(child->stringValues());
			}

			// Comment end
			else if (S_CMPNOCASE(child->getName(), "comment_end"))
			{
				lang->setCommentEndList(child->stringValues());
			}

			// Line comment
			else if (S_CMPNOCASE(child->getName(), "comment_line"))
			{
				lang->setLineCommentList(child->stringValues());
			}

			// Preprocessor
			else if (S_CMPNOCASE(child->getName(), "preprocessor"))
				lang->setPreprocessor(child->stringValue());

			// Case sensitive
			else if (S_CMPNOCASE(child->getName(), "case_sensitive"))
				lang->setCaseSensitive(child->boolValue());

			// Doc comment
			else if (S_CMPNOCASE(child->getName(), "comment_doc"))
				lang->setDocComment(child->stringValue());

			// Keyword lookup link
			else if (S_CMPNOCASE(child->getName(), "keyword_link"))
				lang->word_lists_[WordType::Keyword].lookup_url = child->stringValue();

			// Constant lookup link
			else if (S_CMPNOCASE(child->getName(), "constant_link"))
				lang->word_lists_[WordType::Constant].lookup_url = child->stringValue();

			// Function lookup link
			else if (S_CMPNOCASE(child->getName(), "function_link"))
				lang->f_lookup_url_ = child->stringValue();

			// Jump blocks
			else if (S_CMPNOCASE(child->getName(), "blocks"))
			{
				for (unsigned v = 0; v < child->nValues(); v++)
					lang->jump_blocks_.push_back(child->stringValue(v));
			}
			else if (S_CMPNOCASE(child->getName(), "blocks_ignore"))
			{
				for (unsigned v = 0; v < child->nValues(); v++)
					lang->jb_ignore_.push_back(child->stringValue(v));
			}

			// Block begin
			else if (S_CMPNOCASE(child->getName(), "block_begin"))
				lang->block_begin_ = child->stringValue();

			// Block end
			else if (S_CMPNOCASE(child->getName(), "block_end"))
				lang->block_end_ = child->stringValue();

			// Preprocessor block begin
			else if (S_CMPNOCASE(child->getName(), "pp_block_begin"))
			{
				for (unsigned v = 0; v < child->nValues(); v++)
					lang->pp_block_begin_.push_back(child->stringValue(v));
			}

			// Preprocessor block end
			else if (S_CMPNOCASE(child->getName(), "pp_block_end"))
			{
				for (unsigned v = 0; v < child->nValues(); v++)
					lang->pp_block_end_.push_back(child->stringValue(v));
			}

			// Word block begin
			else if (S_CMPNOCASE(child->getName(), "word_block_begin"))
			{
				for (unsigned v = 0; v < child->nValues(); v++)
					lang->word_block_begin_.push_back(child->stringValue(v));
			}

			// Word block end
			else if (S_CMPNOCASE(child->getName(), "word_block_end"))
			{
				for (unsigned v = 0; v < child->nValues(); v++)
					lang->word_block_end_.push_back(child->stringValue(v));
			}

			// Keywords
			else if (S_CMPNOCASE(child->getName(), "keywords"))
			{
				// Go through values
				for (unsigned v = 0; v < child->nValues(); v++)
				{
					string val = child->stringValue(v);

					// Check for '$override'
					if (S_CMPNOCASE(val, "$override"))
					{
						// Clear any inherited keywords
						lang->clearWordList(WordType::Keyword);
					}

					// Not a special symbol, add as keyword
					else
						lang->addWord(WordType::Keyword, val);
				}
			}

			// Constants
			else if (S_CMPNOCASE(child->getName(), "constants"))
			{
				// Go through values
				for (unsigned v = 0; v < child->nValues(); v++)
				{
					string val = child->stringValue(v);

					// Check for '$override'
					if (S_CMPNOCASE(val, "$override"))
					{
						// Clear any inherited constants
						lang->clearWordList(WordType::Constant);
					}

					// Not a special symbol, add as constant
					else
						lang->addWord(WordType::Constant, val);
				}
			}

			// Types
			else if (S_CMPNOCASE(child->getName(), "types"))
			{
				// Go through values
				for (unsigned v = 0; v < child->nValues(); v++)
				{
					string val = child->stringValue(v);

					// Check for '$override'
					if (S_CMPNOCASE(val, "$override"))
					{
						// Clear any inherited constants
						lang->clearWordList(WordType::Type);
					}

					// Not a special symbol, add as constant
					else
						lang->addWord(WordType::Type, val);
				}
			}

			// Properties
			else if (S_CMPNOCASE(child->getName(), "properties"))
			{
				// Go through values
				for (unsigned v = 0; v < child->nValues(); v++)
				{
					string val = child->stringValue(v);

					// Check for '$override'
					if (S_CMPNOCASE(val, "$override"))
					{
						// Clear any inherited constants
						lang->clearWordList(WordType::Property);
					}

					// Not a special symbol, add as constant
					else
						lang->addWord(WordType::Property, val);
				}
			}

			// Functions
			else if (S_CMPNOCASE(child->getName(), "functions"))
			{
				bool lang_has_void = lang->isWord(Keyword, "void") || lang->isWord(Type, "void");
				if (lang->id_ != "zscript")
				{
					// Go through children (functions)
					for (unsigned f = 0; f < child->nChildren(); f++)
					{
						auto   child_func = child->getChildPTN(f);
						string params;

						// Simple definition
						if (child_func->nChildren() == 0)
						{
							if (child_func->stringValue(0).empty())
							{
								if (lang_has_void)
									params = "void";
								else
									params = "";
							}
							else
							{
								params = child_func->stringValue(0);
							}

							// Add function
							lang->addFunction(
								child_func->getName(),
								params,
								"",
								"",
								!child_func->getName().Contains("."),
								child_func->type());

							// Add args
							for (unsigned v = 1; v < child_func->nValues(); v++)
								lang->addFunction(child_func->getName(), child_func->stringValue(v));
						}

						// Full definition
						else
						{
							string         name = child_func->getName();
							vector<string> args;
							string         desc       = "";
							string         deprecated = "";
							for (unsigned p = 0; p < child_func->nChildren(); p++)
							{
								auto child_prop = child_func->getChildPTN(p);
								if (child_prop->getName() == "args")
								{
									for (unsigned v = 0; v < child_prop->nValues(); v++)
										args.push_back(child_prop->stringValue(v));
								}
								else if (child_prop->getName() == "description")
									desc = child_prop->stringValue();
								else if (child_prop->getName() == "deprecated")
									deprecated = child_prop->stringValue();
							}

							if (args.empty() && lang_has_void)
								args.push_back("void");

							for (unsigned as = 0; as < args.size(); as++)
								lang->addFunction(name, args[as], desc, deprecated, as == 0, child_func->type());
						}
					}
				}
				// ZScript function info which cannot be parsed from (g)zdoom.pk3
				else
				{
					zfunc_ex_prop ex_prop;
					for (unsigned f = 0; f < child->nChildren(); f++)
					{
						auto child_func = child->getChildPTN(f);
						for (unsigned p = 0; p < child_func->nChildren(); ++p)
						{
							auto child_prop = child_func->getChildPTN(p);
							if (child_prop->getName() == "description")
								ex_prop.description = child_prop->stringValue();
							else if (child_prop->getName() == "deprecated_f")
								ex_prop.deprecated_f = child_prop->stringValue();
						}
						lang->zfuncs_ex_props_.emplace(child_func->getName(), ex_prop);
					}
				}
			}
		}
	}

	return true;
}
Ejemplo n.º 22
0
// -----------------------------------------------------------------------------
// Reads a colour configuration from text data [mc]
// -----------------------------------------------------------------------------
bool ColourConfiguration::readConfiguration(MemChunk& mc)
{
	// Parse text
	Parser parser;
	parser.parseText(mc);

	// Get 'colours' block
	auto colours = parser.parseTreeRoot()->childPTN("colours");
	if (colours)
	{
		// Read all colour definitions
		for (unsigned a = 0; a < colours->nChildren(); a++)
		{
			auto def = colours->childPTN(a);

			// Read properties
			for (unsigned b = 0; b < def->nChildren(); b++)
			{
				auto  prop = def->childPTN(b);
				auto& col  = cc_colours[def->name()];
				col.exists = true;

				// Colour name
				if (prop->name() == "name")
					col.name = prop->stringValue();

				// Colour group (for config ui)
				else if (prop->name() == "group")
					col.group = prop->stringValue();

				// Colour
				else if (prop->name() == "rgb")
					col.colour.set(prop->intValue(0), prop->intValue(1), prop->intValue(2));

				// Alpha
				else if (prop->name() == "alpha")
					col.colour.a = prop->intValue();

				// Additive
				else if (prop->name() == "additive")
					col.blend_additive = prop->boolValue();

				else
					Log::warning(fmt::format("Unknown colour definition property \"{}\"", prop->name()));
			}
		}
	}

	// Get 'theme' block
	auto theme = parser.parseTreeRoot()->childPTN("theme");
	if (theme)
	{
		// Read all theme definitions
		for (unsigned a = 0; a < theme->nChildren(); a++)
		{
			auto prop = theme->childPTN(a);

			if (prop->name() == "line_hilight_width")
				line_hilight_width = prop->floatValue();

			else if (prop->name() == "line_selection_width")
				line_selection_width = prop->floatValue();

			else if (prop->name() == "flat_alpha")
				flat_alpha = prop->floatValue();

			else
				Log::warning(fmt::format("Unknown theme property \"{}\"", prop->name()));
		}
	}

	return true;
}
Ejemplo n.º 23
0
NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
{
    /* prepare VLC command line */
    const char *ppsz_argv[32];
    int ppsz_argc = 0;

#ifndef NDEBUG
    ppsz_argv[ppsz_argc++] = "--no-plugins-cache";
#endif

    /* locate VLC module path */
#ifdef XP_MACOSX
    ppsz_argv[ppsz_argc++] = "--vout=vout_macosx";
#elif defined(XP_WIN)
    HKEY h_key;
    DWORD i_type, i_data = MAX_PATH + 1;
    char p_data[MAX_PATH + 1];
    if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
                      0, KEY_READ, &h_key ) == ERROR_SUCCESS )
    {
         if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
                              (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
         {
             if( i_type == REG_SZ )
             {
                 strcat( p_data, "\\plugins" );
                 ppsz_argv[ppsz_argc++] = "--plugin-path";
                 ppsz_argv[ppsz_argc++] = p_data;
             }
         }
         RegCloseKey( h_key );
    }
    ppsz_argv[ppsz_argc++] = "--no-one-instance";

#endif /* XP_MACOSX */

    /* common settings */
    ppsz_argv[ppsz_argc++] = "-vv";
    ppsz_argv[ppsz_argc++] = "--no-stats";
    ppsz_argv[ppsz_argc++] = "--no-media-library";
    ppsz_argv[ppsz_argc++] = "--intf=dummy";
    ppsz_argv[ppsz_argc++] = "--no-video-title-show";
    ppsz_argv[ppsz_argc++] = "--no-xlib";

    bool b_autoloop = false;

    /* parse plugin arguments */
    for( int i = 0; (i < argc) && (ppsz_argc < 32); i++ )
    {
       /* fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]); */

        if( !strcmp( argn[i], "target" )
         || !strcmp( argn[i], "mrl")
         || !strcmp( argn[i], "filename")
         || !strcmp( argn[i], "src") )
        {
            psz_target = argv[i];
        }
        else if( !strcmp( argn[i], "text" ) )
        {
            set_bg_text( argv[i] );
        }
        else if( !strcmp( argn[i], "autoplay")
              || !strcmp( argn[i], "autostart") )
        {
            set_autoplay(boolValue(argv[i]));
        }
        else if( !strcmp( argn[i], "fullscreen" )
              || !strcmp( argn[i], "allowfullscreen" ) )
        {
            set_enable_fs( boolValue(argv[i]) );
        }
        else if( !strcmp( argn[i], "mute" ) )
        {
            if( boolValue(argv[i]) )
            {
                ppsz_argv[ppsz_argc++] = "--volume=0";
            }
        }
        else if( !strcmp( argn[i], "loop")
              || !strcmp( argn[i], "autoloop") )
        {
            b_autoloop = boolValue(argv[i]);
        }
        else if( !strcmp( argn[i], "toolbar" ) )
        {
            set_show_toolbar( boolValue(argv[i]) );
        }
        else if( !strcmp( argn[i], "bgcolor" ) )
        {
            set_bg_color( argv[i] );
        }
    }

    libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv);
    if( !libvlc_instance )
        return NPERR_GENERIC_ERROR;

    vlc_player::open(libvlc_instance);

    vlc_player::set_mode(b_autoloop ? libvlc_playback_mode_loop :
                                      libvlc_playback_mode_default);

    /*
    ** fetch plugin base URL, which is the URL of the page containing the plugin
    ** this URL is used for making absolute URL from relative URL that may be
    ** passed as an MRL argument
    */
    NPObject *plugin = NULL;

    if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) )
    {
        /*
        ** is there a better way to get that info ?
        */
        static const char docLocHref[] = "document.location.href";
        NPString script;
        NPVariant result;

        script.UTF8Characters = docLocHref;
        script.UTF8Length = sizeof(docLocHref)-1;

        if( NPN_Evaluate(p_browser, plugin, &script, &result) )
        {
            if( NPVARIANT_IS_STRING(result) )
            {
                NPString &location = NPVARIANT_TO_STRING(result);

                psz_baseURL = (char *) malloc(location.UTF8Length+1);
                if( psz_baseURL )
                {
                    strncpy(psz_baseURL, location.UTF8Characters, location.UTF8Length);
                    psz_baseURL[location.UTF8Length] = '\0';
                }
            }
            NPN_ReleaseVariantValue(&result);
        }
        NPN_ReleaseObject(plugin);
    }

    if( psz_target )
    {
        // get absolute URL from src
        char *psz_absurl = getAbsoluteURL(psz_target);
        psz_target = psz_absurl ? psz_absurl : strdup(psz_target);
    }

    /* assign plugin script root class */
    /* new APIs */
    p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();

    if( !events.init() )
        return NPERR_GENERIC_ERROR;

    libvlc_media_player_t *p_md = getMD();
    if( p_md ) {
      libvlc_event_manager_t *p_em;
      p_em = libvlc_media_player_event_manager( getMD() );
      events.hook_manager( p_em, this );
    }

    return NPERR_NO_ERROR;
}
Ejemplo n.º 24
0
// ---------------------------------------------------------------------------
// T_SIPAdapter::CheckSettingsL
// Checks saved settings.
// ---------------------------------------------------------------------------
//
void T_SIPAdapter::CheckSettingsL(  )
    {
    __UHEAP_MARK;

    CSIPProfileRegistryObserver* observer = 
        CSIPProfileRegistryObserver::NewLC(); // CS:1
    CSIPManagedProfileRegistry* registry =
        CSIPManagedProfileRegistry::NewLC( *observer ); // CS:2
    RPointerArray<CSIPProfile> profiles;
    CleanupClosePushL( profiles ); // CS:3
    registry->ProfilesL( profiles );

    EUNIT_ASSERT( 3 == profiles.Count() );

    TUint32 tuintValue( KErrNone );
    TBuf8<100> bufValue;
    TBool boolValue( EFalse );

    // First SIP profile.
    CSIPManagedProfile* profile = 
        static_cast<CSIPManagedProfile*>( profiles[0] );

    const TDesC8* provider1 = NULL;
    profile->GetParameter( KSIPProviderName, provider1 );
    bufValue.Copy( *provider1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProviderId1() == bufValue );

    TSIPProfileTypeInfo type1 = profile->Type();
    bufValue.Num( type1.iSIPProfileClass );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( TSIPProfileTypeInfo::EIms == type1.iSIPProfileClass );

    profile->GetParameter( KSIPAccessPointId, tuintValue );
    bufValue.Num( tuintValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( 1 < tuintValue );
    tuintValue = 0;

    const TDesC8* puid1 = NULL;
    profile->GetParameter( KSIPUserAor, puid1 );
    bufValue.Copy( *puid1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KPublicUsername1() == bufValue );

    profile->GetParameter( KSIPSigComp, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( ETrue == boolValue );
    boolValue = EFalse;

    profile->GetParameter( KSIPSecurityNegotiation, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( ETrue == boolValue );
    boolValue = ETrue;

    profile->GetParameter( KSIPAutoRegistration, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = EFalse;

    const TDesC8* proxy1 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPServerAddress, proxy1 );
    bufValue.Copy( *proxy1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyAddress1() == bufValue );

    const TDesC8* proxyUser1 = NULL;
    profile->GetParameter( KSIPPrivateIdentity, proxyUser1 );
    bufValue.Copy( *proxyUser1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KPrivateIdentity1() == bufValue );

    const TDesC8* proxyPw1 = NULL;
    TInt error = profile->GetParameter( KSIPOutboundProxy, KSIPDigestPassword, proxyPw1 );
    
    // Passwords are changed to write only (in API) so can't read the contents.      
    EUNIT_ASSERT( KErrPermissionDenied == error );
    error = KErrNone;

    const TDesC8* proxyRealm1 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPDigestRealm, proxyRealm1 );
    bufValue.Copy( *proxyRealm1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyRealm1() == bufValue );

    const TDesC8* registrarUri1 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPServerAddress, registrarUri1 );
    bufValue.Copy( *registrarUri1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarAddr1() == bufValue );

    const TDesC8* registrarPw1 = NULL;
    error = profile->GetParameter( KSIPRegistrar, KSIPDigestPassword, registrarPw1 );
    EUNIT_ASSERT( KErrPermissionDenied == error );
    error = KErrNone;

    const TDesC8* registrarRealm1 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPDigestRealm, registrarRealm1 );
    bufValue.Copy( *registrarRealm1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarRealm1() == bufValue );

    profile->GetParameter( KSIPDefaultProfile, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( ETrue == boolValue );
    boolValue = EFalse;

    profile->GetParameter( KSIPProfileLocked, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( ETrue == boolValue );
    boolValue = ETrue;

    // Second SIP profile.
    profile = NULL;
    profile = static_cast<CSIPManagedProfile*>( profiles[1] );

    const TDesC8* provider2 = NULL;
    profile->GetParameter( KSIPProviderName, provider2 );
    bufValue.Copy( *provider2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProviderId2() == bufValue );

    TSIPProfileTypeInfo type2 = profile->Type();
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( TSIPProfileTypeInfo::EInternet == type2.iSIPProfileClass );

    profile->GetParameter( KSIPSnapId, tuintValue );
    bufValue.Num( tuintValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( 1 < tuintValue );
    tuintValue = 0;

    const TDesC8* puid2 = NULL;
    profile->GetParameter( KSIPUserAor, puid2 );
    bufValue.Copy( *puid2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KPublicUsername2() == bufValue );

    profile->GetParameter( KSIPSigComp, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = ETrue;

    profile->GetParameter( KSIPSecurityNegotiation, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = ETrue;

    profile->GetParameter( KSIPAutoRegistration, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = ETrue;

    const TDesC8* proxy2 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPServerAddress, proxy2 );
    bufValue.Copy( *proxy2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyAddress2() == bufValue );

    const TDesC8* proxyUsr2 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPDigestUserName, proxyUsr2 );
    bufValue.Copy( *proxyUsr2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyUsername2() == bufValue );

    const TDesC8* proxyPw2 = NULL;
    error = profile->GetParameter( KSIPOutboundProxy, KSIPDigestPassword, proxyPw2 );
    EUNIT_ASSERT( KErrPermissionDenied == error );
    error = KErrNone;

    const TDesC8* proxyRealm2 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPDigestRealm, proxyRealm2 );
    bufValue.Copy( *proxyRealm2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyRealm2() == bufValue );

    const TDesC8* registrarUri2 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPServerAddress, registrarUri2 );
    bufValue.Copy( *registrarUri2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarAddr2() == bufValue );

    const TDesC8* registrarUsr2 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPDigestUserName, registrarUsr2 );
    bufValue.Copy( *registrarUsr2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarUsername2() == bufValue );

    const TDesC8* registrarPw2 = NULL;
    error = profile->GetParameter( KSIPRegistrar, KSIPDigestPassword, registrarPw2 );
    EUNIT_ASSERT( KErrPermissionDenied == error );
    error = KErrNone;

    const TDesC8* registrarRealm2 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPDigestRealm, registrarRealm2 );
    bufValue.Copy( *registrarRealm2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarRealm2() == bufValue );

    profile->GetParameter( KSIPDefaultProfile, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = ETrue;

    // Profile not locked, SIPAdapter did not handle the setting, setting not
    // stored, should return KErrNotFound.
    TInt err = profile->GetParameter( KSIPProfileLocked, boolValue );
    DBG_PRINT_2( "read KSIPProfileLocked from profile, error code %d", err );
    EUNIT_ASSERT( KErrNotFound == err );


    // Third SIP profile.
    profile = NULL;
    profile = static_cast<CSIPManagedProfile*>( profiles[2] );

    const TDesC8* provider3 = NULL;
    profile->GetParameter( KSIPProviderName, provider3 );
    bufValue.Copy( *provider3 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProviderId3() == bufValue );


    profile = NULL;
    // &profiles, registry, observer
    CleanupStack::PopAndDestroy( 3, observer );

    __UHEAP_MARKEND;
    }
Ejemplo n.º 25
0
NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
{
    /* prepare VLC command line */
    const char *ppsz_argv[32];
    int ppsz_argc = 0;

#ifndef NDEBUG
    ppsz_argv[ppsz_argc++] = "--no-plugins-cache";
#endif

    /* locate VLC module path */
#ifdef XP_MACOSX
    ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
    ppsz_argv[ppsz_argc++] = "--vout=minimal_macosx";
#elif defined(XP_WIN)
    HKEY h_key;
    DWORD i_type, i_data = MAX_PATH + 1;
    char p_data[MAX_PATH + 1];
    if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
                      0, KEY_READ, &h_key ) == ERROR_SUCCESS )
    {
         if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
                              (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
         {
             if( i_type == REG_SZ )
             {
                 strcat( p_data, "\\plugins" );
                 ppsz_argv[ppsz_argc++] = "--plugin-path";
                 ppsz_argv[ppsz_argc++] = p_data;
             }
         }
         RegCloseKey( h_key );
    }
    ppsz_argv[ppsz_argc++] = "--no-one-instance";

#endif /* XP_MACOSX */

    /* common settings */
    ppsz_argv[ppsz_argc++] = "-vv";
    ppsz_argv[ppsz_argc++] = "--no-stats";
    ppsz_argv[ppsz_argc++] = "--no-media-library";
    ppsz_argv[ppsz_argc++] = "--intf=dummy";
    ppsz_argv[ppsz_argc++] = "--no-video-title-show";

    const char *progid = NULL;

    /* parse plugin arguments */
    for( int i = 0; (i < argc) && (ppsz_argc < 32); i++ )
    {
       /* fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]); */

        if( !strcmp( argn[i], "target" )
         || !strcmp( argn[i], "mrl")
         || !strcmp( argn[i], "filename")
         || !strcmp( argn[i], "src") )
        {
            psz_target = argv[i];
        }
        else if( !strcmp( argn[i], "text" ) )
        {
            free( psz_text );
            psz_text = strdup( argv[i] );
        }
        else if( !strcmp( argn[i], "autoplay")
              || !strcmp( argn[i], "autostart") )
        {
            b_autoplay = boolValue(argv[i]);
        }
        else if( !strcmp( argn[i], "fullscreen" ) )
        {
            if( boolValue(argv[i]) )
            {
                ppsz_argv[ppsz_argc++] = "--fullscreen";
            }
            else
            {
                ppsz_argv[ppsz_argc++] = "--no-fullscreen";
            }
        }
        else if( !strcmp( argn[i], "mute" ) )
        {
            if( boolValue(argv[i]) )
            {
                ppsz_argv[ppsz_argc++] = "--volume=0";
            }
        }
        else if( !strcmp( argn[i], "loop")
              || !strcmp( argn[i], "autoloop") )
        {
            if( boolValue(argv[i]) )
            {
                ppsz_argv[ppsz_argc++] = "--loop";
            }
            else
            {
                ppsz_argv[ppsz_argc++] = "--no-loop";
            }
        }
        else if( !strcmp( argn[i], "version")
              || !strcmp( argn[i], "progid") )
        {
            progid = argv[i];
        }
        else if( !strcmp( argn[i], "toolbar" ) )
        {
/* FIXME: Remove this when toolbar functionality has been implemented on
 * MacOS X and Win32 for Firefox/Mozilla/Safari. */
#ifdef XP_UNIX
            b_toolbar = boolValue(argv[i]);
#endif
        }
    }

    libvlc_exception_t ex;
    libvlc_exception_init(&ex);

    libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, &ex);
    if( libvlc_exception_raised(&ex) )
    {
        libvlc_exception_clear(&ex);
        return NPERR_GENERIC_ERROR;
    }

    libvlc_media_list = libvlc_media_list_new(libvlc_instance,&ex);
    if( libvlc_exception_raised(&ex) )
    {
        libvlc_exception_clear(&ex);
        return NPERR_GENERIC_ERROR;
    }

    /*
    ** fetch plugin base URL, which is the URL of the page containing the plugin
    ** this URL is used for making absolute URL from relative URL that may be
    ** passed as an MRL argument
    */
    NPObject *plugin = NULL;

    if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) )
    {
        /*
        ** is there a better way to get that info ?
        */
        static const char docLocHref[] = "document.location.href";
        NPString script;
        NPVariant result;

        script.utf8characters = docLocHref;
        script.utf8length = sizeof(docLocHref)-1;

        if( NPN_Evaluate(p_browser, plugin, &script, &result) )
        {
            if( NPVARIANT_IS_STRING(result) )
            {
                NPString &location = NPVARIANT_TO_STRING(result);

                psz_baseURL = (char *) malloc(location.utf8length+1);
                if( psz_baseURL )
                {
                    strncpy(psz_baseURL, location.utf8characters, location.utf8length);
                    psz_baseURL[location.utf8length] = '\0';
                }
            }
            NPN_ReleaseVariantValue(&result);
        }
        NPN_ReleaseObject(plugin);
    }

    if( psz_target )
    {
        // get absolute URL from src
        char *psz_absurl = getAbsoluteURL(psz_target);
        psz_target = psz_absurl ? psz_absurl : strdup(psz_target);
    }

    /* assign plugin script root class */
    /* new APIs */
    p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();

    return NPERR_NO_ERROR;
}
Ejemplo n.º 26
0
 virtual void Save(void)
 {
     m_lnb.SetPolarityInverted(boolValue());
 }
Ejemplo n.º 27
0
// -----------------------------------------------------------------------------
// Reads a UDMF property definition from a parsed tree [node]
// -----------------------------------------------------------------------------
void UDMFProperty::parse(ParseTreeNode* node, std::string_view group)
{
	// Set group and property name
	group_    = group;
	property_ = node->name();

	// Check for basic definition
	if (node->nChildren() == 0)
	{
		name_ = node->stringValue();
		return;
	}

	// Otherwise, read node data
	for (unsigned a = 0; a < node->nChildren(); a++)
	{
		auto prop     = node->childPTN(a);
		auto pn_lower = StrUtil::lower(prop->name());

		// Property type
		if (pn_lower == "type")
		{
			auto val_lower = StrUtil::lower(prop->stringValue());

			if (val_lower == "bool")
				type_ = Type::Boolean;
			else if (val_lower == "int")
				type_ = Type::Int;
			else if (val_lower == "float")
				type_ = Type::Float;
			else if (val_lower == "string")
				type_ = Type::String;
			else if (val_lower == "colour")
				type_ = Type::Colour;
			else if (val_lower == "actionspecial")
				type_ = Type::ActionSpecial;
			else if (val_lower == "sectorspecial")
				type_ = Type::SectorSpecial;
			else if (val_lower == "thingtype")
				type_ = Type::ThingType;
			else if (val_lower == "angle")
				type_ = Type::Angle;
			else if (val_lower == "texture_wall")
				type_ = Type::TextureWall;
			else if (val_lower == "texture_flat")
				type_ = Type::TextureFlat;
			else if (val_lower == "id")
				type_ = Type::ID;
		}

		// Property name
		else if (pn_lower == "name")
			name_ = prop->stringValue();

		// Default value
		else if (pn_lower == "default")
		{
			switch (type_)
			{
			case Type::Boolean: default_value_ = prop->boolValue(); break;
			case Type::Int: default_value_ = prop->intValue(); break;
			case Type::Float: default_value_ = prop->floatValue(); break;
			case Type::String: default_value_ = prop->stringValue(); break;
			case Type::ActionSpecial: default_value_ = prop->intValue(); break;
			case Type::SectorSpecial: default_value_ = prop->intValue(); break;
			case Type::ThingType: default_value_ = prop->intValue(); break;
			case Type::Angle: default_value_ = prop->intValue(); break;
			case Type::TextureWall: default_value_ = prop->stringValue(); break;
			case Type::TextureFlat: default_value_ = prop->stringValue(); break;
			case Type::ID: default_value_ = prop->intValue(); break;
			default: default_value_ = prop->stringValue(); break;
			}

			// Not sure why I have to do this here, but for whatever reason prop->getIntValue() doesn't work
			// if the value parsed was hex (or it could be to do with the colour type? who knows)
			if (type_ == Type::Colour)
				default_value_ = StrUtil::asInt(prop->stringValue());

			has_default_ = true;
		}

		// Property is a flag
		else if (pn_lower == "flag")
			flag_ = true;

		// Property is a SPAC trigger
		else if (pn_lower == "trigger")
			trigger_ = true;

		// Possible values
		else if (pn_lower == "values")
		{
			switch (type_)
			{
			case Type::Boolean:
				for (unsigned b = 0; b < prop->nValues(); b++)
					values_.emplace_back(prop->boolValue(b));
				break;
			case Type::Int:
			case Type::ActionSpecial:
			case Type::SectorSpecial:
			case Type::ThingType:
				for (unsigned b = 0; b < prop->nValues(); b++)
					values_.emplace_back(prop->intValue(b));
				break;
			case Type::Float:
				for (unsigned b = 0; b < prop->nValues(); b++)
					values_.emplace_back(prop->floatValue(b));
				break;
			default:
				for (unsigned b = 0; b < prop->nValues(); b++)
					values_.emplace_back(prop->stringValue(b));
				break;
			}
		}

		// Show always
		else if (pn_lower == "show_always")
			show_always_ = prop->boolValue();
	}
}
Ejemplo n.º 28
0
// -----------------------------------------------------------------------------
// Reads archive formats configuration file from [mc]
// -----------------------------------------------------------------------------
bool Archive::loadFormats(MemChunk& mc)
{
	Parser parser;
	if (!parser.parseText(mc))
		return false;

	auto root         = parser.parseTreeRoot();
	auto formats_node = root->child("archive_formats");
	for (unsigned a = 0; a < formats_node->nChildren(); a++)
	{
		auto          fmt_desc = (ParseTreeNode*)formats_node->child(a);
		ArchiveFormat fmt{ fmt_desc->name() };

		for (unsigned p = 0; p < fmt_desc->nChildren(); p++)
		{
			auto prop = (ParseTreeNode*)fmt_desc->child(p);

			// Format name
			if (StrUtil::equalCI(prop->name(), "name"))
				fmt.name = prop->stringValue();

			// Supports dirs
			else if (StrUtil::equalCI(prop->name(), "supports_dirs"))
				fmt.supports_dirs = prop->boolValue();

			// Entry names have extensions
			else if (StrUtil::equalCI(prop->name(), "names_extensions"))
				fmt.names_extensions = prop->boolValue();

			// Max entry name length
			else if (StrUtil::equalCI(prop->name(), "max_name_length"))
				fmt.max_name_length = prop->intValue();

			// Entry format (id)
			else if (StrUtil::equalCI(prop->name(), "entry_format"))
				fmt.entry_format = prop->stringValue();

			// Extensions
			else if (StrUtil::equalCI(prop->name(), "extensions"))
			{
				for (unsigned e = 0; e < prop->nChildren(); e++)
				{
					auto ext = (ParseTreeNode*)prop->child(e);
					fmt.extensions.emplace_back(ext->name(), ext->stringValue());
				}
			}

			// Prefer uppercase entry names
			else if (StrUtil::equalCI(prop->name(), "prefer_uppercase"))
				fmt.prefer_uppercase = prop->boolValue();
		}

		Log::info(3, wxString::Format("Read archive format %s: \"%s\"", fmt.id, fmt.name));
		if (fmt.supports_dirs)
			Log::info(3, "  Supports folders");
		if (fmt.names_extensions)
			Log::info(3, "  Entry names have extensions");
		if (fmt.max_name_length >= 0)
			Log::info(3, wxString::Format("  Max entry name length: %d", fmt.max_name_length));
		for (auto ext : fmt.extensions)
			Log::info(3, wxString::Format("  Extension \"%s\" = \"%s\"", ext.first, ext.second));

		formats.push_back(fmt);
	}

	// Add builtin 'folder' format
	ArchiveFormat fmt_folder("folder");
	fmt_folder.name             = "Folder";
	fmt_folder.names_extensions = true;
	fmt_folder.supports_dirs    = true;
	formats.push_back(fmt_folder);

	return true;
}