MCSensorType MCSensorTypeFromString(MCStringRef p_string) { if (MCStringIsEqualToCString(p_string, "location", kMCCompareCaseless)) return kMCSensorTypeLocation; else if (MCStringIsEqualToCString(p_string, "heading", kMCCompareCaseless)) return kMCSensorTypeHeading; else if (MCStringIsEqualToCString(p_string, "acceleration", kMCCompareCaseless)) return kMCSensorTypeAcceleration; else if (MCStringIsEqualToCString(p_string, "rotation rate", kMCCompareCaseless)) return kMCSensorTypeRotationRate; return kMCSensorTypeUnknown; }
Boolean MCF_setslantlongstring(uint2 &style, MCStringRef data) { if (MCStringIsEqualToCString(data, "oblique", kMCCompareCaseless)) { style |= FA_OBLIQUE; return True; } if (MCStringIsEqualToCString(data, "italic", kMCCompareCaseless)) { style |= FA_ITALIC; return True; } return False; }
Boolean MCF_setexpandstring(uint2 &style, MCStringRef data) { uint2 w; for (w = FE_UNDEFINED ; w <= FE_ULTRAEXPANDED ; w++) if (MCStringIsEqualToCString(data, expandstrings[w], kMCCompareCaseless)) break; if (w <= FE_ULTRAEXPANDED) { style &= ~FA_EXPAND; style |= w << 4; return True; } return False; }
Boolean MCF_setweightstring(uint2 &style, MCStringRef data) { uint2 w; for (w = MCFW_UNDEFINED ; w <= MCFW_ULTRABOLD ; w++) if (MCStringIsEqualToCString(data, weightstrings[w], kMCCompareCaseless)) break; if (w <= MCFW_ULTRABOLD) { style &= ~FA_WEIGHT; style |= w; return True; } return False; }
bool MCSessionFindMatchingSession(MCSessionIndexRef p_index, MCStringRef p_session_id, MCSession *&r_session) { MCAutoStringRef t_remote_addr_str; const char *t_remote_addr = NULL; if (!MCS_getenv(MCSTR("REMOTE_ADDR"), &t_remote_addr_str)) t_remote_addr = ""; else t_remote_addr = MCStringGetCString(*t_remote_addr_str); for (uint32_t i = 0; i < p_index->session_count; i++) { if (MCStringIsEqualToCString(p_session_id, p_index->session[i]->id, kMCCompareExact) && MCCStringEqual(p_index->session[i]->ip, t_remote_addr)) { r_session = p_index->session[i]; return true; } } return false; }
void MCLicenseSetRevLicenseLimits(MCExecContext& ctxt, MCArrayRef p_settings) { if(!MCenvironmentactive) return; bool t_case_sensitive = ctxt . GetCaseSensitive(); MCValueRef t_value; MCStringRef t_string; if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("token"), t_value) && ctxt . ConvertToString(t_value, t_string)) { MCValueRelease(MClicenseparameters . license_token); MClicenseparameters . license_token = t_string; } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("name"), t_value) && ctxt . ConvertToString(t_value, t_string)) { MCValueRelease(MClicenseparameters . license_name); MClicenseparameters . license_name = t_string; } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("organization"), t_value) && ctxt . ConvertToString(t_value, t_string)) { MCValueRelease( MClicenseparameters . license_organization); MClicenseparameters . license_organization = t_string; } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("class"), t_value)) { MCAutoStringRef t_class; MCLicenseClass t_license_class; if (ctxt . ConvertToString(t_value, &t_class) && MCStringToLicenseClass(*t_class, t_license_class)) { MClicenseparameters . license_class = t_license_class; } else MClicenseparameters . license_class = kMCLicenseClassNone; } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("multiplicity"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { MClicenseparameters . license_multiplicity = MCNumberFetchAsUnsignedInteger(*t_number); } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("scriptlimit"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { integer_t t_limit; t_limit = MCNumberFetchAsInteger(*t_number); MClicenseparameters . script_limit = t_limit <= 0 ? 0 : t_limit; } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("dolimit"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { integer_t t_limit; t_limit = MCNumberFetchAsInteger(*t_number); MClicenseparameters . do_limit = t_limit <= 0 ? 0 : t_limit; } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("usinglimit"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { integer_t t_limit; t_limit = MCNumberFetchAsInteger(*t_number); MClicenseparameters . using_limit = t_limit <= 0 ? 0 : t_limit; } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("insertlimit"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { integer_t t_limit; t_limit = MCNumberFetchAsInteger(*t_number); MClicenseparameters . insert_limit = t_limit <= 0 ? 0 : t_limit; } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("deploy"), t_value)) { static struct { const char *tag; uint32_t value; } s_deploy_map[] = { { "windows", kMCLicenseDeployToWindows }, { "macosx", kMCLicenseDeployToMacOSX }, { "linux", kMCLicenseDeployToLinux }, { "ios", kMCLicenseDeployToIOS }, { "android", kMCLicenseDeployToAndroid }, { "winmobile", kMCLicenseDeployToWinMobile }, { "meego", kMCLicenseDeployToLinuxMobile }, { "server", kMCLicenseDeployToServer }, { "ios-embedded", kMCLicenseDeployToIOSEmbedded }, { "android-embedded", kMCLicenseDeployToIOSEmbedded }, { "html5", kMCLicenseDeployToHTML5 }, { "filemaker", kMCLicenseDeployToFileMaker }, }; MClicenseparameters . deploy_targets = 0; MCAutoStringRef t_params; if (ctxt . ConvertToString(t_value, &t_params)) { MCAutoArrayRef t_split_strings; MCValueRef t_fetched_string; if (MCStringSplit(*t_params, MCSTR(","), nil, kMCCompareExact, &t_split_strings)) { for(uint32_t i = 0; i < MCArrayGetCount(*t_split_strings); i++) { // Fetch the string value created with MCStringSplit MCArrayFetchValueAtIndex(*t_split_strings, i+1, t_fetched_string); for(uint32_t j = 0; j < sizeof(s_deploy_map) / sizeof(s_deploy_map[0]); j++) if (MCStringIsEqualToCString((MCStringRef)t_fetched_string, s_deploy_map[j] . tag, kMCStringOptionCompareCaseless)) { MClicenseparameters . deploy_targets |= s_deploy_map[j] . value; break; } } } } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("addons"), t_value) && MCValueIsArray(t_value)) { MCValueRelease(MClicenseparameters . addons); MCArrayCopy((MCArrayRef)t_value, MClicenseparameters . addons); } }
// MW-2011-11-23: [[ Array TextStyle ]] Convert a textStyle name into the enum. Exec_stat MCF_parsetextstyle(MCStringRef data, Font_textstyle &style) { if (MCStringIsEqualToCString(data, "bold", kMCCompareCaseless)) style = FTS_BOLD; else if (MCStringIsEqualToCString(data, "condensed", kMCCompareCaseless)) style = FTS_CONDENSED; else if (MCStringIsEqualToCString(data, "expanded", kMCCompareCaseless)) style = FTS_EXPANDED; else if (MCStringIsEqualToCString(data, "italic", kMCCompareCaseless)) style = FTS_ITALIC; else if (MCStringIsEqualToCString(data, "oblique", kMCCompareCaseless)) style = FTS_OBLIQUE; else if (MCStringIsEqualToCString(data, MCboxstring, kMCCompareCaseless)) style = FTS_BOX; else if (MCStringIsEqualToCString(data, MCthreedboxstring, kMCCompareCaseless)) style = FTS_3D_BOX; else if (MCStringIsEqualToCString(data, MCunderlinestring, kMCCompareCaseless)) style = FTS_UNDERLINE; else if (MCStringIsEqualToCString(data, MCstrikeoutstring, kMCCompareCaseless)) style = FTS_STRIKEOUT; else if (MCStringIsEqualToCString(data, MCgroupstring, kMCCompareCaseless) || MCStringIsEqualToCString(data, MClinkstring, kMCCompareCaseless)) style = FTS_LINK; else { MCeerror->add(EE_OBJECT_BADSTYLE, 0, 0, data); return ES_ERROR; } return ES_NORMAL; }
Exec_stat MCF_parsetextatts(Properties which, MCStringRef data, uint4 &flags, MCStringRef &fname, uint2 &height, uint2 &size, uint2 &style) { int2 i1; switch (which) { case P_TEXT_ALIGN: flags &= ~F_ALIGNMENT; if (MCStringIsEqualToCString(data, MCleftstring, kMCCompareCaseless) || MCStringIsEmpty(data)) flags |= F_ALIGN_LEFT; else if (MCStringIsEqualToCString(data, MCcenterstring, kMCCompareCaseless)) flags |= F_ALIGN_CENTER; else if (MCStringIsEqualToCString(data, MCrightstring, kMCCompareCaseless)) flags |= F_ALIGN_RIGHT; else if (MCStringIsEqualToCString(data, MCjustifystring, kMCCompareCaseless)) flags |= F_ALIGN_JUSTIFY; else { MCeerror->add(EE_OBJECT_BADALIGN, 0, 0, data); return ES_ERROR; } break; case P_TEXT_FONT: {// MW-2012-02-17: [[ IntrinsicUnicode ]] Strip any lang tag from the // fontname. uindex_t t_offset; if (MCStringFirstIndexOfChar(data, ',', 0, kMCCompareExact, t_offset)) /* UNCHECKED */ MCStringCopySubstring(data, MCRangeMake(t_offset + 1, MCStringGetLength(data) - (t_offset + 1)), fname); else fname = MCValueRetain(data); } break; case P_TEXT_HEIGHT: if (!MCU_stoi2(data, i1)) { MCeerror->add (EE_OBJECT_TEXTHEIGHTNAN, 0, 0, data); return ES_ERROR; } height = i1; break; case P_TEXT_SIZE: if (MCStringIsEmpty(data)) i1 = 0; else if (!MCU_stoi2(data, i1)) { MCeerror->add (EE_OBJECT_TEXTSIZENAN, 0, 0, data); return ES_ERROR; } size = i1; break; case P_TEXT_STYLE: { // MW-2012-02-17: [[ SplitTextAttrs ]] If the string is empty, then // return 0 for the style - indicating to unset the property. if (MCStringIsEmpty(data)) style = 0; else { style = FA_DEFAULT_STYLE; uindex_t t_start_pos, t_end_pos; t_end_pos = 0; while (t_end_pos < MCStringGetLength(data)) { t_start_pos = t_end_pos; // skip spaces at the beginning or after a comma (if any) MCU_skip_spaces(data, t_start_pos); uindex_t t_comma; if (!MCStringFirstIndexOfChar(data, ',', t_start_pos, kMCCompareExact, t_comma)) t_end_pos = MCStringGetLength(data); else t_end_pos = t_comma; MCAutoStringRef tdata; /* UNCHECKED */ MCStringCopySubstring(data, MCRangeMake(t_start_pos, t_end_pos - t_start_pos), &tdata); t_end_pos++; if (MCF_setweightstring(style, *tdata)) continue; if (MCF_setexpandstring(style, *tdata)) continue; if (MCF_setslantlongstring(style, *tdata)) continue; if (MCStringIsEqualToCString(*tdata, MCplainstring, kMCCompareCaseless)) { style = FA_DEFAULT_STYLE; continue; } if (MCStringIsEqualToCString(*tdata, MCmixedstring, kMCCompareCaseless)) { style = FA_DEFAULT_STYLE; continue; } if (MCStringIsEqualToCString(*tdata, MCboxstring, kMCCompareCaseless)) { style &= ~FA_3D_BOX; style |= FA_BOX; continue; } if (MCStringIsEqualToCString(*tdata, MCthreedboxstring, kMCCompareCaseless)) { style &= ~FA_BOX; style |= FA_3D_BOX; continue; } if (MCStringIsEqualToCString(*tdata, MCunderlinestring, kMCCompareCaseless)) { style |= FA_UNDERLINE; continue; } if (MCStringIsEqualToCString(*tdata, MCstrikeoutstring, kMCCompareCaseless)) { style |= FA_STRIKEOUT; continue; } if (MCStringIsEqualToCString(*tdata, MCgroupstring, kMCCompareCaseless) || MCStringIsEqualToCString(*tdata, MClinkstring, kMCCompareCaseless)) { style |= FA_LINK; continue; } MCeerror->add(EE_OBJECT_BADSTYLE, 0, 0, data); return ES_ERROR; } } } break; default: break; } return ES_NORMAL; }