예제 #1
0
파일: main.c 프로젝트: twistround/pbis
static
DWORD
LwSmCmdSet(
    int argc,
    char** ppArgv
    )
{
    DWORD dwError = ERROR_SUCCESS;
    BOOLEAN booleanValue = FALSE;

    if (argc != 3)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_ERROR(dwError);
    }

    if (!strcmp(ppArgv[1], "watchdog"))
    {
        dwError = ParseBoolean(ppArgv[2], &booleanValue);
        BAIL_ON_ERROR(dwError);

        dwError = LwSmSetGlobal(LW_SM_GLOBAL_SETTING_WATCHDOG, booleanValue);
        BAIL_ON_ERROR(dwError);
    }

error:

    return dwError;
}
예제 #2
0
/**
 * @brief Parse a line in control file.
 */
bool
ReaderParam(Reader *rd, const char *keyword, char *target)
{
	/*
	 * result
	 */
	if (CompareKeyword(keyword, "INFILE") ||
		CompareKeyword(keyword, "INPUT"))
	{
		ASSERT_ONCE(rd->infile == NULL);

		rd->infile = pstrdup(target);
	}
	else if (CompareKeyword(keyword, "LOGFILE"))
	{
		ASSERT_ONCE(rd->logfile == NULL);

		rd->logfile = pstrdup(target);
	}
	else if (CompareKeyword(keyword, "PARSE_BADFILE"))
	{
		ASSERT_ONCE(rd->parse_badfile == NULL);

		rd->parse_badfile = pstrdup(target);
	}
	else if (CompareKeyword(keyword, "PARSE_ERRORS") ||
			 CompareKeyword(keyword, "MAX_ERR_CNT"))
	{
		ASSERT_ONCE(rd->max_parse_errors < -1);
		rd->max_parse_errors = ParseInt64(target, -1);
		if (rd->max_parse_errors == -1)
			rd->max_parse_errors = INT64_MAX;
	}
	else if (CompareKeyword(keyword, "LOAD") ||
			 CompareKeyword(keyword, "LIMIT"))
	{
		ASSERT_ONCE(rd->limit == INT64_MAX);
		rd->limit = ParseInt64(target, 0);
	}
	else if (CompareKeyword(keyword, "CHECK_CONSTRAINTS"))
	{
		rd->checker.check_constraints = ParseBoolean(target);
	}
	else if (CompareKeyword(keyword, "ENCODING"))
	{
		ASSERT_ONCE(rd->checker.encoding < 0);
		rd->checker.encoding = pg_valid_client_encoding(target);
		if (rd->checker.encoding < 0)
			ereport(ERROR,
					(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
					 errmsg("invalid encoding for parameter \"ENCODING\": \"%s\"",
						target)));
	}
	else if (rd->parser == NULL ||
			!ParserParam(rd->parser, keyword, target))
		return false;

	return true;
}
예제 #3
0
파일: writer.c 프로젝트: Komzpa/pg_bulkload
/**
 * @brief Parse a line in control file.
 */
bool
WriterParam(Writer *self, const char *keyword, char *value)
{
	if (CompareKeyword(keyword, "VERBOSE"))
	{
		self->verbose = ParseBoolean(value);
	}
	else if (!self->param(self, keyword, value))
		return false;

	return true;
}
예제 #4
0
파일: LuaParser.cpp 프로젝트: Dmytry/spring
bool LuaTable::GetBool(int key, bool def) const
{
	if (!PushValue(key)) {
		return def;
	}
	bool value;
	if (!ParseBoolean(L, -1, value)) {
		lua_pop(L, 1);
		return def;
	}
	lua_pop(L, 1);
	return value;
}
예제 #5
0
static void
ParseOptions(Datum options, Reader **rd, Writer **wt, time_t tm)
{
	List		   *defs;
	List		   *rest_defs = NIL;
	ListCell	   *cell;
	DefElem		   *opt;
	char		   *keyword;
	char		   *value;
	char		   *type = NULL;
	char		   *writer = NULL;
	bool			multi_process = false;

	Assert(*rd == NULL);
	Assert(*wt == NULL);

	/* parse for each option */
	defs = untransformRelOptions(options);
	foreach (cell, defs)
	{
		opt = lfirst(cell);
		if (opt->arg == NULL)
			ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
					errmsg("option \"%s\" has no value", opt->defname)));

		keyword = opt->defname;
		value = strVal(opt->arg);

		if (CompareKeyword(keyword, "TYPE"))
		{
			ASSERT_ONCE(type == NULL);
			type = value;
		}
		else if (CompareKeyword(keyword, "WRITER") ||
				 CompareKeyword(keyword, "LOADER"))
		{
			ASSERT_ONCE(writer == NULL);
			writer = value;
		}
		else if (CompareKeyword(keyword, "MULTI_PROCESS"))
		{
			multi_process = ParseBoolean(value);
		}
		else
		{
			rest_defs = lappend(rest_defs, opt);
			continue;
		}
	}
static bool
BufferedWriterParam(BufferedWriter *self, const char *keyword, char *value)
{
	if (CompareKeyword(keyword, "TABLE") ||
		CompareKeyword(keyword, "OUTPUT"))
	{
		ASSERT_ONCE(self->base.output == NULL);

		self->base.relid = RangeVarGetRelid(makeRangeVarFromNameList(
						stringToQualifiedNameList(value)), NoLock, false);
		self->base.output = get_relation_name(self->base.relid);
	}
	else if (CompareKeyword(keyword, "DUPLICATE_BADFILE"))
	{
		ASSERT_ONCE(self->base.dup_badfile == NULL);
		self->base.dup_badfile = pstrdup(value);
	}
	else if (CompareKeyword(keyword, "DUPLICATE_ERRORS"))
	{
		ASSERT_ONCE(self->base.max_dup_errors < -1);
		self->base.max_dup_errors = ParseInt64(value, -1);
		if (self->base.max_dup_errors == -1)
			self->base.max_dup_errors = INT64_MAX;
	}
	else if (CompareKeyword(keyword, "ON_DUPLICATE_KEEP"))
	{
		const ON_DUPLICATE values[] =
		{
			ON_DUPLICATE_KEEP_NEW,
			ON_DUPLICATE_KEEP_OLD
		};

		self->base.on_duplicate = values[choice(keyword, value, ON_DUPLICATE_NAMES, lengthof(values))];
	}
	else if (CompareKeyword(keyword, "TRUNCATE"))
	{
		self->base.truncate = ParseBoolean(value);
	}
	else
		return false;	/* unknown parameter */

	return true;
}
예제 #7
0
static bool
BinaryParserParam(BinaryParser *self, const char *keyword, char *value)
{
	if (CompareKeyword(keyword, "COL"))
	{
		BinaryParam(&self->fields, &self->nfield, value, self->preserve_blanks, false);

		if (self->fields[self->nfield - 1].character)
			self->fields[self->nfield - 1].str =
				palloc(self->fields[self->nfield - 1].len * MAX_CONVERSION_GROWTH + 1);
	}
	else if (CompareKeyword(keyword, "PRESERVE_BLANKS"))
	{
		self->preserve_blanks = ParseBoolean(value);
	}
	else if (CompareKeyword(keyword, "STRIDE"))
	{
		ASSERT_ONCE(self->rec_len == 0);
		self->rec_len = ParseInt32(value, 1);
	}
	else if (CompareKeyword(keyword, "SKIP") ||
			 CompareKeyword(keyword, "OFFSET"))
	{
		ASSERT_ONCE(self->offset < 0);
		self->offset = ParseInt64(value, 0);
	}
	else if (CompareKeyword(keyword, "FILTER"))
	{
		ASSERT_ONCE(!self->filter.funcstr);
		self->filter.funcstr = pstrdup(value);
	}
	else
		return false;	/* unknown parameter */

	return true;
}
예제 #8
0
Exec_stat MCAndroidPlayerControl::Set(MCNativeControlProperty p_property, MCExecPoint &ep)
{
    bool t_bool = false;
    int32_t t_integer;
    
    jobject t_view;
    t_view = GetView();
    
    switch (p_property)
    {
        case kMCNativeControlPropertyContent:
        {
            bool t_success = true;
            MCCStringFree(m_path);
            t_success = MCCStringClone(ep.getcstring(), m_path);
            if (MCCStringBeginsWith(m_path, "http://") || MCCStringBeginsWith(m_path, "https://"))
            {
                MCAndroidObjectRemoteCall(t_view, "setUrl", "bs", &t_success, m_path);
            }
            else
            {
                char *t_resolved_path = nil;
                bool t_is_asset = false;
                const char *t_asset_path = nil;
                
                t_resolved_path = MCS_resolvepath(m_path);
                t_is_asset = path_to_apk_path(t_resolved_path, t_asset_path);
                
                MCAndroidObjectRemoteCall(t_view, "setFile", "bsb", &t_success, t_is_asset ? t_asset_path : t_resolved_path, t_is_asset);
                
                MCCStringFree(t_resolved_path);
            }
            return ES_NORMAL;
        }
            
        case kMCNativeControlPropertyShowController:
        {
            if (!ParseBoolean(ep, t_bool))
                return ES_ERROR;
            MCAndroidObjectRemoteCall(t_view, "setShowController", "vb", nil, t_bool);
            return ES_NORMAL;
        }
            
        case kMCNativeControlPropertyCurrentTime:
        {
            if (!ParseInteger(ep, t_integer))
                return ES_ERROR;
            MCAndroidObjectRemoteCall(t_view, "setCurrentTime", "vi", nil, t_integer);
            return ES_NORMAL;
        }
            
        case kMCNativeControlPropertyLooping:
        {
            if (!ParseBoolean(ep, t_bool))
                return ES_ERROR;
            MCAndroidObjectRemoteCall(t_view, "setLooping", "vb", nil, t_bool);
            return ES_NORMAL;
        }
            
        default:
            break;
    }
    
    return MCAndroidControl::Set(p_property, ep);
}
예제 #9
0
void UserSettings::FromXml(TiXmlElement* xml) {
  for (TiXmlElement* element = xml->FirstChildElement(); element; element = element->NextSiblingElement()) {
    wxString elementName = wxString(element->Value(), wxConvUTF8);

    if (elementName != _T("Setting")) {
      WLOG(wxString::Format(_T("UserSettings::FromXml: Unknown element: %s"), elementName));
      continue;
    }

    const char* cSettingName = element->Attribute("name");
    if (!cSettingName) {
      WLOG(_T("UserSettings::FromXml: setting doesn't have a name"));
      continue;
    }

    const char* cSettingValue = element->GetText();
    
    wxString n = wxString(cSettingName, wxConvUTF8);
    wxString v;
    if (!cSettingValue) {
      v = wxEmptyString;
    } else {
      v = wxString(cSettingValue, wxConvUTF8);
    }

    v.Trim(true).Trim(false);

    if (n == _T("IconSize")) AssignSettingValue(IconSize, v);
    if (n == _T("Locale")) Locale = v;
    if (n == _T("PortableAppsPath")) PortableAppsPath = v;
    if (n == _T("DocumentsPath")) DocumentsPath = v;
    if (n == _T("MusicPath")) MusicPath = v;
    if (n == _T("PicturesPath")) PicturesPath = v;
    if (n == _T("VideosPath")) VideosPath = v;
    if (n == _T("Skin")) Skin = v;
    if (n == _T("Rotated")) Rotated = ParseBoolean(v);
    if (n == _T("NextUpdateCheckTime")) {
      const wxChar* c = NextUpdateCheckTime.ParseFormat(v, ISO_DATE_FORMAT);
      if (!c) NextUpdateCheckTime = wxDateTime::Now();
    }
    if (n == _T("AlwaysOnTop")) AlwaysOnTop = ParseBoolean(v);
    if (n == _T("AutoHideApplication")) AutoHideApplication = ParseBoolean(v);
    if (n == _T("UniqueApplicationInstance")) UniqueApplicationInstance = ParseBoolean(v);
    if (n == _T("ShowDeleteIconMessage")) ShowDeleteIconMessage = ParseBoolean(v);
    if (n == _T("ShowEjectDriveMessage")) ShowEjectDriveMessage = ParseBoolean(v);
    if (n == _T("RunMultiLaunchOnStartUp")) RunMultiLaunchOnStartUp = ParseBoolean(v);
    if (n == _T("HotKeyControl")) HotKeyControl = ParseBoolean(v);
    if (n == _T("HotKeyAlt")) HotKeyAlt = ParseBoolean(v);
    if (n == _T("HotKeyShift")) HotKeyShift = ParseBoolean(v);
    if (n == _T("HotKeyKey")) AssignSettingValue(HotKeyKey, v);
    if (n == _T("CloseAppsOnEject")) CloseAppsOnEject = ParseBoolean(v);
    if (n == _T("MinimizeOnClose")) MinimizeOnClose = ParseBoolean(v);
    if (n == _T("ShowMinimizeMessage")) ShowMinimizeMessage = ParseBoolean(v);

  }

}