static inline Int _getVar(Equation e, Var var, va_list args) /* Var, Int, Var, Int, ... */ { int argc, i; Var vars[FWD_PCE_MAX_ARGS]; Any vals[FWD_PCE_MAX_ARGS]; Any savd[FWD_PCE_MAX_ARGS]; numeric_value v; for(argc = 0; (vars[argc] = va_arg(args, Var)) != NULL; argc++) { assert(argc <= FWD_PCE_MAX_ARGS); assert(instanceOfObject(vars[argc], ClassVar)); vals[argc] = va_arg(args, Expression); assert(vals[argc] != NULL); } for(i=0; i<argc; i++) { savd[i] = vars[i]->value; setVar(vars[i], vals[i]); } evaluateEquation(e, var, &v); for(i=0; i<argc; i++) setVar(vars[i], savd[i]); return ar_int_result(e, &v); }
static void put_new_attvar(Word p, atom_t name, Word value ARG_LD) { Word gp, at; assert(gTop+6 <= gMax && tTop+1 <= tMax); gp = gTop; if ( p >= (Word)lBase ) { gTop += 6; at = &gp[1]; setVar(*at); gp[0] = consPtr(&gp[1], TAG_ATTVAR|STG_GLOBAL); *p = makeRefG(&gp[0]); LTrail(p); } else { gTop += 5; at = &gp[0]; setVar(*at); *p = consPtr(&gp[0], TAG_ATTVAR|STG_GLOBAL); GTrail(p); } at[1] = FUNCTOR_att3; at[2] = name; at[3] = linkVal(value); at[4] = ATOM_nil; at[0] = consPtr(&at[1], TAG_COMPOUND|STG_GLOBAL); }
static inline void exitCyclicCopy(int flags ARG_LD) { Word p; while(popSegStack(&LD->cycle.lstack, &p, Word)) { if ( isRef(*p) ) { Word p2 = unRef(*p); if ( *p2 == VAR_MARK ) /* sharing variables */ { setVar(*p2); setVar(*p); } else { *p = *p2 | MARK_MASK; /* cyclic terms */ } } else { Word old; popSegStack(&LD->cycle.lstack, &old, Word); if ( !(flags©_ATTRS) ) { Word p2 = valPAttVar(*p & ~BOTH_MASK); assert(*p2 == VAR_MARK); setVar(*p2); } *p = consPtr(old, STG_GLOBAL|TAG_ATTVAR); } } }
bool agi::hangup(int cause) { char cause_str[16]; snprintf(cause_str,sizeof(cause_str),"%i",cause); setVar("PRI_CAUSE",cause_str); return (exec("HANGUP")==1); }
//------------------------------------------------------------------------------ int lookup(int *typeOfObject) { int i; gettoken(yytext, sizeof yytext); if (!strnicmp(yytext,"reg",3) && strlen(yytext) == 5 && isdigit(yytext[3]) && isdigit(yytext[4]) && (i=atoi(yytext+3))>=0 && i<100) { *typeOfObject=IDENTIFIER; return i+EVAL_MAX_VARS; } for (i=0;i<EVAL_MAX_VARS;i++) if (!strnicmp(varTable[i].name, yytext,sizeof(varTable[i].name))) { *typeOfObject = IDENTIFIER; return i; } for (i=0;getFunctionFromTable(i);i++) { functionType *f=getFunctionFromTable(i); if (!strcmpi(f->name, yytext)) { *typeOfObject = objectId(f->nParams); return i; } } *typeOfObject = IDENTIFIER; setLastVar(); i = setVar(-1, 0); return i; }
void ThemeEval::addDialog(const Common::String &name, const Common::String &overlays, bool enabled, int inset) { int16 x, y; uint16 w, h; ThemeLayout *layout = 0; if (overlays == "screen") { layout = new ThemeLayoutMain(inset, inset, g_system->getOverlayWidth() - 2 * inset, g_system->getOverlayHeight() - 2 * inset); } else if (overlays == "screen_center") { layout = new ThemeLayoutMain(-1, -1, -1, -1); } else if (getWidgetData(overlays, x, y, w, h)) { layout = new ThemeLayoutMain(x + inset, y + inset, w - 2 * inset, h - 2 * inset); } if (!layout) error("Error when loading dialog position for '%s'", overlays.c_str()); if (_layouts.contains(name)) delete _layouts[name]; _layouts[name] = layout; layout->setPadding( getVar("Globals.Padding.Left", 0), getVar("Globals.Padding.Right", 0), getVar("Globals.Padding.Top", 0), getVar("Globals.Padding.Bottom", 0) ); _curLayout.push(layout); _curDialog = name; setVar(name + ".Enabled", enabled ? 1 : 0); }
Word newTerm(void) { GET_LD Word t = allocGlobal(1); setVar(*t); return t; }
void AgiEngine::motionMoveObj(ScreenObjEntry *screenObj) { screenObj->direction = getDirection(screenObj->xPos, screenObj->yPos, screenObj->move_x, screenObj->move_y, screenObj->stepSize); // Update V6 if ego if (isEgoView(screenObj)) setVar(VM_VAR_EGO_DIRECTION, screenObj->direction); if (screenObj->direction == 0) motionMoveObjStop(screenObj); }
ParzenMachine::ParzenMachine(int n_inputs_,int n_outputs_,real var_) { data = NULL; setVar(var_); n_outputs = n_outputs_; n_inputs = n_inputs_; outputs = new(allocator) Sequence(1,n_outputs); n_real_examples = 0; real_examples = NULL; }
int setVarFunc(HSQUIRRELVM v) { StackHandler sa(v); if (sa.GetType(1) == OT_TABLE) { VarRefPtr vr; int res = getVarInfo(sa,vr); if (res != SQ_OK) return res; return setVar(sa,vr,vr->offsetOrAddrOrConst); } // if return SQ_ERROR; } // setVarFunc
int setVarFunc(HSQUIRRELVM v) { SquirrelVM::Init(v); // For handling multi-VM setting right StackHandler sa(v); if (sa.GetType(1) == OT_TABLE) { VarRefPtr vr; int res = getVarInfo(sa,vr); if (res != SQ_OK) return res; return setVar(sa,vr,vr->offsetOrAddrOrConst); } // if return SQ_ERROR; } // setVarFunc
int setInstanceVarFunc(HSQUIRRELVM v) { StackHandler sa(v); if (sa.GetType(1) == OT_INSTANCE) { VarRefPtr vr; void * data; int res = getInstanceVarInfo(sa,vr,data); if (res != SQ_OK) return res; return setVar(sa,vr,data); } // if return SQ_ERROR; } // setInstanceVarFunc
int setInstanceVarFunc(HSQUIRRELVM v) { SquirrelVM::Init(v); // For handling multi-VM setting right StackHandler sa(v); if (sa.GetType(1) == OT_INSTANCE) { VarRefPtr vr; void * data; int res = getInstanceVarInfo(sa,vr,data); if (res != SQ_OK) return res; return setVar(sa,vr,data); } // if return SQ_ERROR; } // setInstanceVarFunc
void setVar_i (varPrec * time, char *type, int *s2, char *cont, int *s1, varPrec * val, int *err) { char *t = (char *) malloc (sizeof (char) * (*s2 + 1)); char *c = (char *) malloc (sizeof (char) * (*s1 + 1)); memcpy (t, type, *s2); t[*s2] = '\0'; memcpy (c, cont, *s1); c[*s1] = '\0'; *err = setVar (*time, t, c, *val); }
/* 如果显示调用 typedef int (*lpFetchData)(); typedef int (*lpSaveVar)(); typedef LPCSTR (*lpGetVar)(const LPCSTR group, const LPCSTR key); typedef int(*lpShowVar)(); typedef int(*lpTest_save)(); ...... HINSTANCE hDll = LoadLibrary("fKeyValue.dll");//导入.dll动态连接库 lpFetchData fetchData=(lpFetchData)GetProcAddress(hDll,"fetchData"); lpShowVar showVar=(lpShowVar)GetProcAddress(hDll,"showVar"); lpGetVar getVar=(lpGetVar)GetProcAddress(hDll,"getVar"); ...... dosomething.... FreeLibrary(hDll); */ int main(void) { setFile("D:\\users\\goosy\\codes\\GoosyFBase\\data.ini"); //test_save(); fetchData(); showVar(); setVar("Date","safeDays","7845"); saveVar(); printf("安全天数为%s", getVar("Date","safeDays")); //MessageBoxA(0, getVar("Date","safeDays"), "安全天数为", MB_OK | MB_ICONINFORMATION); getch(); return 0; }
Func::Func(const Func& rhs): _mode(rhs._mode) { _varbuf.reserve(VARMAX); _parser.SetVarFactory(_addVar, this); // Adding pi and e, the defaults are `_pi` and `_e` _parser.DefineConst(_T("pi"), (mu::value_type)M_PI); _parser.DefineConst(_T("e"), (mu::value_type)M_E); setExpr(rhs.getExpr()); vector <string> vars = rhs.getVars(); for (unsigned int ii = 0; ii < vars.size(); ++ii){ setVar(vars[ii], rhs.getVar(vars[ii])); } }
Func& Func::operator=(const Func rhs) { _clearBuffer(); _mode = rhs._mode; // Adding pi and e, the defaults are `_pi` and `_e` _parser.DefineConst(_T("pi"), (mu::value_type)M_PI); _parser.DefineConst(_T("e"), (mu::value_type)M_E); setExpr(rhs.getExpr()); vector <string> vars = rhs.getVars(); for (unsigned int ii = 0; ii < vars.size(); ++ii){ setVar(vars[ii], rhs.getVar(vars[ii])); } return *this; }
void cParser::onSpace(void) { std::string name; if (!m_variable.empty() && !m_curVariable.empty())//两个都不为空 { if(m_varLine == m_curLine) { setError(2);//同一行上出现两个变量 return ; } else//不同行上的两个变量 {//忽略上一行无用的变量 setVar(m_curVariable); m_curVariable.clear(); } } else if( m_variable.empty() && !m_curVariable.empty()) { setVar(m_curVariable); m_curVariable.clear(); } skipSpace(); }
void AgiEngine::motionMoveObjStop(ScreenObjEntry *screenObj) { screenObj->stepSize = screenObj->move_stepSize; // This check for motionType was only done in AGI3. // But we use this motion type for mouse movement, so we need to check in any case, otherwise it will cause glitches. if (screenObj->motionType != kMotionEgo) { setFlag(screenObj->move_flag, true); } screenObj->motionType = kMotionNormal; if (isEgoView(screenObj)) { _game.playerControl = true; setVar(VM_VAR_EGO_DIRECTION, 0); } }
void AgiEngine::motionWander(ScreenObjEntry *screenObj) { uint8 originalWanderCount = screenObj->wander_count; screenObj->wander_count--; if ((originalWanderCount == 0) || (screenObj->flags & fDidntMove)) { screenObj->direction = _rnd->getRandomNumber(8); if (isEgoView(screenObj)) { setVar(VM_VAR_EGO_DIRECTION, screenObj->direction); } while (screenObj->wander_count < 6) { screenObj->wander_count = _rnd->getRandomNumber(50); // huh? } } }
void cParser::onReturn(void) { std::string name = parseVarName(); m_curVariable.clear(); m_variable.clear(); if (error()) { setError(0); ++m_curLine; return; } else { setVar(name); ++m_curLine; } }
void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled, Graphics::TextAlign align) { int typeW = -1; int typeH = -1; Graphics::TextAlign typeAlign = Graphics::kTextAlignInvalid; if (!type.empty()) { typeW = getVar("Globals." + type + ".Width", -1); typeH = getVar("Globals." + type + ".Height", -1); typeAlign = (Graphics::TextAlign)getVar("Globals." + type + ".Align", Graphics::kTextAlignInvalid); } ThemeLayoutWidget *widget = new ThemeLayoutWidget(_curLayout.top(), name, typeW == -1 ? w : typeW, typeH == -1 ? h : typeH, typeAlign == Graphics::kTextAlignInvalid ? align : typeAlign); _curLayout.top()->addChild(widget); setVar(_curDialog + "." + name + ".Enabled", enabled ? 1 : 0); }
void AgiEngine::interpretCycle() { ScreenObjEntry *screenObjEgo = &_game.screenObjTable[SCREENOBJECTS_EGO_ENTRY]; bool oldSound; byte oldScore; if (!_game.playerControl) setVar(VM_VAR_EGO_DIRECTION, screenObjEgo->direction); else screenObjEgo->direction = getVar(VM_VAR_EGO_DIRECTION); checkAllMotions(); oldScore = getVar(VM_VAR_SCORE); oldSound = getFlag(VM_FLAG_SOUND_ON); // Reset script heuristic here resetGetVarSecondsHeuristic(); _game.exitAllLogics = false; while (runLogic(0) == 0 && !(shouldQuit() || _restartGame)) { setVar(VM_VAR_WORD_NOT_FOUND, 0); setVar(VM_VAR_BORDER_TOUCH_OBJECT, 0); setVar(VM_VAR_BORDER_CODE, 0); oldScore = getVar(VM_VAR_SCORE); setFlag(VM_FLAG_ENTERED_CLI, false); _game.exitAllLogics = false; artificialDelay_CycleDone(); resetControllers(); } artificialDelay_CycleDone(); resetControllers(); screenObjEgo->direction = getVar(VM_VAR_EGO_DIRECTION); if (getVar(VM_VAR_SCORE) != oldScore || getFlag(VM_FLAG_SOUND_ON) != oldSound) _game._vm->_text->statusDraw(); setVar(VM_VAR_BORDER_TOUCH_OBJECT, 0); setVar(VM_VAR_BORDER_CODE, 0); setFlag(VM_FLAG_NEW_ROOM_EXEC, false); setFlag(VM_FLAG_RESTART_GAME, false); setFlag(VM_FLAG_RESTORE_JUST_RAN, false); if (_game.gfxMode) { updateScreenObjTable(); } _gfx->updateScreen(); //_gfx->doUpdate(); }
static int assign_in_dict(Word dp, Word val ARG_LD) { deRef(val); if ( !canBind(*val) ) { *dp = *val; } else if ( isAttVar(*val) ) { *dp = makeRef(val); } else { if ( dp < val ) { if ( unlikely(tTop+1 >= tMax) ) return TRAIL_OVERFLOW; setVar(*dp); Trail(val, makeRef(dp)); } else { *dp = makeRef(val); } } return TRUE; }
static void put_new_attvar(Word p, atom_t name, Word value ARG_LD) { Word gp, at; assert(gTop+7 <= gMax && tTop+1 <= tMax); gp = link_attvar(PASS_LD1); gTop += 6; at = &gp[1]; setVar(*at); gp[0] = consPtr(&gp[1], TAG_ATTVAR|STG_GLOBAL); at[1] = FUNCTOR_att3; at[2] = name; at[3] = linkVal(value); at[4] = ATOM_nil; at[0] = consPtr(&at[1], TAG_COMPOUND|STG_GLOBAL); trail_new_attvar(gp PASS_LD); Trail(p, makeRefG(gp)); }
void AgiEngine::changePos(ScreenObjEntry *screenObj) { bool insideBlock; int16 x, y; int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 }; int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 }; x = screenObj->xPos; y = screenObj->yPos; insideBlock = checkBlock(x, y); x += screenObj->stepSize * dx[screenObj->direction]; y += screenObj->stepSize * dy[screenObj->direction]; if (checkBlock(x, y) == insideBlock) { screenObj->flags &= ~fMotion; } else { screenObj->flags |= fMotion; screenObj->direction = 0; if (isEgoView(screenObj)) setVar(VM_VAR_EGO_DIRECTION, 0); } }
//------------------------------------------------------------------------------ int lookup(int *typeOfObject) { int i; gettoken(yytext, sizeof yytext); for (i=0;i<EVAL_MAX_VARS;i++) if (!strcmpi(varTable[i].name, yytext)) { *typeOfObject = IDENTIFIER; return i; } for (i=0;i<sizeof(fnTable)/sizeof(functionType);i++) { if (!strcmpi(fnTable[i].name, yytext)) { *typeOfObject = objectId(fnTable[i].nParams); return i; } } *typeOfObject = IDENTIFIER; setLastVar(); i = setVar(-1, 0); //(*errPtr)++; return i; }
int SimpleDMR::onAction(const ServiceDecl *serviceDecl, const ActionDecl *actionDecl, AbortableTask *task, const FrontEnd::InterfaceContext *ifctx, const FrontEnd::RequestContext& reqCtx, const NPT_HttpRequest *req, const NPT_List<NPT_String>& inputArgNames, const NPT_List<NPT_String>& inputArgValues, NPT_List<NPT_String>& outputArgValues) { WriteLocker locker(m_stateLock); if (NPT_String::Compare(serviceDecl->serviceId, "urn:upnp-org:serviceId:AVTransport") == 0) { if (NPT_String::Compare(actionDecl->name, "SetAVTransportURI") == 0) { if (inputArgValues.GetItemCount() != 3) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 718; } NPT_HttpClient httpClient; NPT_HttpRequest req(*inputArgValues.GetItem(1), NPT_HTTP_METHOD_GET, NPT_HTTP_PROTOCOL_1_1); Helper::setupHttpRequest(req); NPT_HttpResponse *resp; NPT_Result nr; HttpClientAbortCallback abortCallback(&httpClient); if (task->registerAbortCallback(&abortCallback)) { nr = httpClient.SendRequest(req, resp); task->unregisterAbortCallback(&abortCallback); } else { return 715; } if (NPT_FAILED(nr)) { return 716; } PtrHolder<NPT_HttpResponse> resp1(resp); if (resp->GetStatusCode() != 200) { return 716; } NPT_HttpHeader *hdrContentType = resp->GetHeaders().GetHeader(NPT_HTTP_HEADER_CONTENT_TYPE); if (!hdrContentType) { return 714; } setVar(DMRVAR_AVTransportURI, *inputArgValues.GetItem(1)); setVar(DMRVAR_AVTransportURIMetaData, *inputArgValues.GetItem(2)); setVar(DMRVAR_CurrentTrackMetaData, *inputArgValues.GetItem(2)); m_callback->doDmrOpen(this, *inputArgValues.GetItem(1), hdrContentType->GetValue(), *inputArgValues.GetItem(2)); return 0; } if (NPT_String::Compare(actionDecl->name, "GetMediaInfo") == 0) { if (inputArgValues.GetItemCount() != 1) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 718; } *outputArgValues.GetItem(0) = m_avtVars[DMRVAR_NumberOfTracks - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(1) = m_avtVars[DMRVAR_CurrentMediaDuration - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(2) = m_avtVars[DMRVAR_AVTransportURI - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(3) = m_avtVars[DMRVAR_AVTransportURIMetaData - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(4) = m_avtVars[DMRVAR_NextAVTransportURI - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(5) = m_avtVars[DMRVAR_NextAVTransportURIMetaData - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(6) = m_avtVars[DMRVAR_PlaybackStorageMedium - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(7) = m_avtVars[DMRVAR_RecordStorageMedium - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(8) = m_avtVars[DMRVAR_RecordMediumWriteStatus - DMRVAR_BaseIndexAVT]; return 0; } if (NPT_String::Compare(actionDecl->name, "GetTransportInfo") == 0) { if (inputArgValues.GetItemCount() != 1) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 718; } *outputArgValues.GetItem(0) = m_avtVars[DMRVAR_TransportState - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(1) = m_avtVars[DMRVAR_TransportStatus - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(2) = m_avtVars[DMRVAR_TransportPlaySpeed - DMRVAR_BaseIndexAVT]; return 0; } if (NPT_String::Compare(actionDecl->name, "GetPositionInfo") == 0) { if (inputArgValues.GetItemCount() != 1) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 718; } *outputArgValues.GetItem(0) = m_avtVars[DMRVAR_CurrentTrack - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(1) = m_avtVars[DMRVAR_CurrentTrackDuration - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(2) = m_avtVars[DMRVAR_CurrentTrackMetaData - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(3) = m_avtVars[DMRVAR_CurrentTrackURI - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(4) = m_avtVars[DMRVAR_RelativeTimePosition - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(5) = m_avtVars[DMRVAR_AbsoluteTimePosition - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(6) = m_avtVars[DMRVAR_RelativeCounterPosition - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(7) = m_avtVars[DMRVAR_AbsoluteCounterPosition - DMRVAR_BaseIndexAVT]; return 0; } if (NPT_String::Compare(actionDecl->name, "GetDeviceCapabilities") == 0) { if (inputArgValues.GetItemCount() != 1) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 718; } *outputArgValues.GetItem(0) = m_avtVars[DMRVAR_PossiblePlaybackStorageMedia - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(1) = m_avtVars[DMRVAR_PossibleRecordStorageMedia - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(2) = m_avtVars[DMRVAR_PossibleRecordQualityModes - DMRVAR_BaseIndexAVT]; return 0; } if (NPT_String::Compare(actionDecl->name, "GetTransportSettings") == 0) { if (inputArgValues.GetItemCount() != 1) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 718; } *outputArgValues.GetItem(0) = m_avtVars[DMRVAR_CurrentPlayMode - DMRVAR_BaseIndexAVT]; *outputArgValues.GetItem(1) = m_avtVars[DMRVAR_CurrentRecordQualityMode - DMRVAR_BaseIndexAVT]; return 0; } if (NPT_String::Compare(actionDecl->name, "Stop") == 0) { m_callback->doDmrStop(this); return 0; } if (NPT_String::Compare(actionDecl->name, "Play") == 0) { m_callback->doDmrPlay(this); return 0; } if (NPT_String::Compare(actionDecl->name, "Pause") == 0) { m_callback->doDmrPause(this); return 0; } if (NPT_String::Compare(actionDecl->name, "Seek") == 0) { if (inputArgValues.GetItemCount() != 3) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 718; } const NPT_String& seekMode = *inputArgValues.GetItem(1); const NPT_String& seekTarget = *inputArgValues.GetItem(2); if (seekMode.Compare("TRACK_NR") == 0) { // TODO: } else if (seekMode.Compare("REL_TIME") == 0) { NPT_UInt64 pos; if (NPT_FAILED(Helper::parseTrackDurationString(seekTarget, pos))) { // Illegal seek target return 711; } m_callback->doDmrSeekTo(this, pos); } else { // Seek mode not supported return 710; } return 0; } if (NPT_String::Compare(actionDecl->name, "Next") == 0) { return 0; } if (NPT_String::Compare(actionDecl->name, "Previous") == 0) { return 0; } return 602; } if (NPT_String::Compare(serviceDecl->serviceId, "urn:upnp-org:serviceId:RenderingControl") == 0) { if (NPT_String::Compare(actionDecl->name, "ListPresets") == 0) { if (inputArgValues.GetItemCount() != 1) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 702; } *outputArgValues.GetItem(0) = m_rcsVars[DMRVAR_PresetNameList - DMRVAR_BaseIndexRCS]; return 0; } if (NPT_String::Compare(actionDecl->name, "SelectPreset") == 0) { return 0; } if (NPT_String::Compare(actionDecl->name, "GetMute") == 0) { if (inputArgValues.GetItemCount() != 2) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 702; } *outputArgValues.GetItem(0) = m_rcsVars[DMRVAR_Mute - DMRVAR_BaseIndexRCS]; return 0; } if (NPT_String::Compare(actionDecl->name, "SetMute") == 0) { if (inputArgValues.GetItemCount() != 3) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 702; } const NPT_String& desiredMute = *inputArgValues.GetItem(2); m_callback->doDmrSetMute(this, desiredMute.Compare("true", true) == 0 || desiredMute.Compare("1") == 0); return 0; } if (NPT_String::Compare(actionDecl->name, "GetVolume") == 0) { if (inputArgValues.GetItemCount() != 2) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 702; } *outputArgValues.GetItem(0) = m_rcsVars[DMRVAR_Volume - DMRVAR_BaseIndexRCS]; return 0; } if (NPT_String::Compare(actionDecl->name, "SetVolume") == 0) { if (inputArgValues.GetItemCount() != 3) { // Invalid Args return 402; } if (inputArgValues.GetFirstItem()->Compare("0") != 0) { // Invalid InstanceID return 702; } const NPT_String& desiredVolume = *inputArgValues.GetItem(2); int volume; if (NPT_FAILED(NPT_ParseInteger(desiredVolume, volume))) { // Invalid Args return 402; } m_callback->doDmrSetVolume(this, volume); return 0; } return 602; } if (NPT_String::Compare(serviceDecl->serviceId, "urn:upnp-org:serviceId:ConnectionManager") == 0) { if (NPT_String::Compare(actionDecl->name, "GetProtocolInfo") == 0) { NPT_String v; if (getStateValue(serviceDecl->serviceId, "SourceProtocolInfo", v)) { *outputArgValues.GetItem(0) = v; } if (getStateValue(serviceDecl->serviceId, "SinkProtocolInfo", v)) { *outputArgValues.GetItem(1) = v; } return 0; } if (NPT_String::Compare(actionDecl->name, "GetCurrentConnectionIDs") == 0) { NPT_String v; if (getStateValue(serviceDecl->serviceId, "SourceProtocolInfo", v)) { *outputArgValues.GetItem(0) = v; } return 0; } if (NPT_String::Compare(actionDecl->name, "GetCurrentConnectionInfo") == 0) { *outputArgValues.GetItem(0) = "0"; *outputArgValues.GetItem(1) = "0"; *outputArgValues.GetItem(2) = ""; *outputArgValues.GetItem(3) = ""; *outputArgValues.GetItem(4) = "-1"; *outputArgValues.GetItem(5) = "Input"; // or "Output"? WTF! *outputArgValues.GetItem(6) = "OK"; return 0; } return 602; } return 501; }
SimpleDMR::SimpleDMR(Callback *callback, const UUID& uuid) : m_callback(callback) { m_uuid = uuid; m_deviceType = "urn:schemas-upnp-org:device:MediaRenderer:1"; m_friendlyName = "SimpleDMR[WTF]"; m_manufacturer = "NETGEAR Inc."; m_manufacturerURL = "http://www.netgear.com"; m_modelDescription = "GENIE SimpleDMR"; m_modelName = "SimpleDMR"; m_modelNumber = "DJ-DMR"; m_modelURL = "http://www.netgear.com"; m_serialNumber = "262471"; m_upc = "400240112011"; m_presentationURL = "http://www.netgear.com"; registerServices(g_DMRServiceTable, g_DMRServiceTableSize); registerStaticContent("icon1", "image/png", NPT_DataBuffer(g_icon120_png, g_icon120_png_size, false), false); registerStaticContent("icon2", "image/png", NPT_DataBuffer(g_icon48_png, g_icon48_png_size, false), false); registerStaticContent("icon3", "image/png", NPT_DataBuffer(g_icon32_png, g_icon32_png_size, false), false); registerStaticContent("icon4", "image/jpeg", NPT_DataBuffer(g_icon120_jpg, g_icon120_jpg_size, false), false); registerStaticContent("icon5", "image/jpeg", NPT_DataBuffer(g_icon48_jpg, g_icon48_jpg_size, false), false); registerStaticContent("icon6", "image/jpeg", NPT_DataBuffer(g_icon32_jpg, g_icon32_jpg_size, false), false); /* const char *sinkProtocolInfo = "http-get:*:image/png:*," "http-get:*:image/jpeg:*," "http-get:*:image/bmp:*," "http-get:*:image/gif:*," "http-get:*:audio/mpeg:*," "http-get:*:audio/3gpp:*," "http-get:*:audio/mp4:*," "http-get:*:audio/x-ms-wma:*," "http-get:*:audio/wav:*," "http-get:*:video/mp4:*," "http-get:*:video/mpeg:*," "http-get:*:video/x-ms-wmv:*," "http-get:*:video/x-ms-asf:*," "http-get:*:video/3gpp:*," "http-get:*:video/avi:*," "http-get:*:video/quicktime:*" ; */ const char *cms = "urn:upnp-org:serviceId:ConnectionManager"; setStateValue(cms, "SourceProtocolInfo", ""); // setStateValue(cms, "SinkProtocolInfo", sinkProtocolInfo); setStateValue(cms, "CurrentConnectionIDs", "0"); /* const char *avt = "urn:upnp-org:serviceId:AVTransport"; setStateValue(avt, "TransportState", "NO_MEDIA_PRESENT"); setStateValue(avt, "TransportStatus", "OK"); setStateValue(avt, "PlaybackStorageMedium", "NONE"); setStateValue(avt, "RecordStorageMedium", "NOT_IMPLEMENTED"); setStateValue(avt, "PossiblePlaybackStorageMedia", "NONE,NETWORK,UNKNOWN,HDD"); setStateValue(avt, "PossibleRecordStorageMedia", "NOT_IMPLEMENTED"); setStateValue(avt, "CurrentPlayMode", "NORMAL"); setStateValue(avt, "TransportPlaySpeed", "1"); setStateValue(avt, "RecordMediumWriteStatus", "NOT_IMPLEMENTED"); setStateValue(avt, "CurrentRecordQualityMode", "NOT_IMPLEMENTED"); setStateValue(avt, "PossibleRecordQualityModes", "NOT_IMPLEMENTED"); setStateValue(avt, "NumberOfTracks", "0"); setStateValue(avt, "CurrentTrack", "0"); setStateValue(avt, "CurrentTrackDuration", "00:00:00"); setStateValue(avt, "CurrentMediaDuration", "00:00:00"); setStateValue(avt, "CurrentTrackMetaData", ""); setStateValue(avt, "CurrentTrackURI", ""); setStateValue(avt, "AVTransportURI", ""); setStateValue(avt, "AVTransportURIMetaData", ""); setStateValue(avt, "NextAVTransportURI", "NOT_IMPLEMENTED"); setStateValue(avt, "NextAVTransportURIMetaData", "NOT_IMPLEMENTED"); setStateValue(avt, "RelativeTimePosition", "00:00:00"); setStateValue(avt, "AbsoluteTimePosition", "NOT_IMPLEMENTED"); setStateValue(avt, "RelativeCounterPosition", "-1"); setStateValue(avt, "AbsoluteCounterPosition", "-1"); setStateValue(avt, "CurrentTransportActions", ""); const char *rcs = "urn:upnp-org:serviceId:RenderingControl"; setStateValue(rcs, "PresetNameList", "FactoryDefaults"); setStateValue(rcs, "Mute", "0"); setStateValue(rcs, "Volume", "100"); */ setVar(DMRVAR_TransportState, "NO_MEDIA_PRESENT"); setVar(DMRVAR_TransportStatus, "OK"); setVar(DMRVAR_PlaybackStorageMedium, "NONE"); setVar(DMRVAR_RecordStorageMedium, "NOT_IMPLEMENTED"); setVar(DMRVAR_PossiblePlaybackStorageMedia, "NONE,NETWORK,UNKNOWN,HDD"); setVar(DMRVAR_PossibleRecordStorageMedia, "NOT_IMPLEMENTED"); setVar(DMRVAR_CurrentPlayMode, "NORMAL"); setVar(DMRVAR_TransportPlaySpeed, "1"); setVar(DMRVAR_RecordMediumWriteStatus, "NOT_IMPLEMENTED"); setVar(DMRVAR_CurrentRecordQualityMode, "NOT_IMPLEMENTED"); setVar(DMRVAR_PossibleRecordQualityModes, "NOT_IMPLEMENTED"); setVar(DMRVAR_NumberOfTracks, "0"); setVar(DMRVAR_CurrentTrack, "0"); setVar(DMRVAR_CurrentTrackDuration, "00:00:00"); setVar(DMRVAR_CurrentMediaDuration, "00:00:00"); setVar(DMRVAR_CurrentTrackMetaData, ""); setVar(DMRVAR_CurrentTrackURI, ""); setVar(DMRVAR_AVTransportURI, ""); setVar(DMRVAR_AVTransportURIMetaData, ""); setVar(DMRVAR_NextAVTransportURI, "NOT_IMPLEMENTED"); setVar(DMRVAR_NextAVTransportURIMetaData, "NOT_IMPLEMENTED"); setVar(DMRVAR_RelativeTimePosition, "00:00:00"); setVar(DMRVAR_AbsoluteTimePosition, "NOT_IMPLEMENTED"); setVar(DMRVAR_RelativeCounterPosition, "-1"); setVar(DMRVAR_AbsoluteCounterPosition, "-1"); setVar(DMRVAR_CurrentTransportActions, ""); setVar(DMRVAR_PresetNameList, "FactoryDefaults"); setVar(DMRVAR_Mute, "0"); setVar(DMRVAR_Volume, "100"); }
void GameDatabaseV2::load(Common::SeekableReadStream &sourceS) { int16 version = sourceS.readUint16LE(); // Manhole:NE, Rodney's Funscreen and LGOP2 are version 54 // The earlier EGA version of Manhole is version 40 if (version != 54 && version != 40) warning("Unknown database version, known versions are 54 and 40"); char header[6]; sourceS.read(header, 6); if (strncmp(header, "ADVSYS", 6)) warning ("Unexpected database header, expected ADVSYS"); uint32 textOffs = 0, objectsOffs = 0, objectsSize = 0, textSize; uint16 objectCount = 0, varObjectCount = 0; sourceS.readUint16LE(); // skip sub-version sourceS.skip(18); // skip program name if (version == 40) { sourceS.readUint16LE(); // skip unused objectCount = sourceS.readUint16LE(); _gameStateSize = sourceS.readUint16LE() * 2; objectsOffs = sourceS.readUint16LE() * 512; textOffs = sourceS.readUint16LE() * 512; _mainCodeObjectIndex = sourceS.readUint16LE(); varObjectCount = 0; // unused in V1 objectsSize = 0; // unused in V1 } else if (version == 54) { textOffs = sourceS.readUint16LE() * 512; objectCount = sourceS.readUint16LE(); varObjectCount = sourceS.readUint16LE(); _gameStateSize = sourceS.readUint16LE() * 2; sourceS.readUint16LE(); // unknown objectsOffs = sourceS.readUint16LE() * 512; sourceS.readUint16LE(); // unknown _mainCodeObjectIndex = sourceS.readUint16LE(); sourceS.readUint16LE(); // unknown objectsSize = sourceS.readUint32LE() * 2; } textSize = objectsOffs - textOffs; debug(0, "textOffs = %08X; textSize = %08X; objectCount = %d; varObjectCount = %d; gameStateSize = %d; objectsOffs = %08X; objectsSize = %d; _mainCodeObjectIndex = %04X\n", textOffs, textSize, objectCount, varObjectCount, _gameStateSize, objectsOffs, objectsSize, _mainCodeObjectIndex); _gameState = new byte[_gameStateSize + 2]; memset(_gameState, 0, _gameStateSize + 2); setVar(1, objectCount); sourceS.seek(textOffs); _gameText = new char[textSize]; sourceS.read(_gameText, textSize); // "Decrypt" the text data for (uint32 i = 0; i < textSize; i++) _gameText[i] += 0x1E; sourceS.seek(objectsOffs); if (version == 40) { // Initialize the object array for (uint32 i = 0; i < objectCount; i++) _objects.push_back(NULL); // Read two "sections" of objects // It seems the first section is data while the second one is code. // The interpreter however doesn't care which section the objects come from. for (int section = 0; section < 2; section++) { while (!sourceS.eos()) { int16 objIndex = sourceS.readUint16LE(); debug("objIndex = %04X; section = %d", objIndex, section); if (objIndex == 0) break; Object *obj = new ObjectV1(); obj->load(sourceS); _objects[objIndex - 1] = obj; } } } else if (version == 54) { for (uint32 i = 0; i < objectCount; i++) { Object *obj = new ObjectV2(); int objSize = obj->load(sourceS); // Objects are aligned on 2-byte-boundaries, skip unused bytes sourceS.skip(objSize % 2); _objects.push_back(obj); } } }