00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "Programs.h"
00023 #include "Ingredients.h"
00024 #include "Root.h"
00025 #include "BaseClasses.h"
00026 #include "ParseNode.h"
00027 #include "ASN1Codes.h"
00028 #include "Engine.h"
00029 #include "Logging.h"
00030 #include "freemheg.h"
00031
00032 #include <sys/timeb.h>
00033 #ifdef __FreeBSD__
00034 #include <sys/time.h>
00035 #else
00036 #include <time.h>
00037 #endif
00038
00039 #include "config.h"
00040 #include "compat.h"
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 MHProgram::MHProgram()
00051 {
00052 m_fInitiallyAvailable = true;
00053 }
00054
00055 void MHProgram::Initialise(MHParseNode *p, MHEngine *engine)
00056 {
00057 MHIngredient::Initialise(p, engine);
00058 MHParseNode *pCmdNode = p->GetNamedArg(C_NAME);
00059
00060 if (pCmdNode)
00061 {
00062 pCmdNode->GetArgN(0)->GetStringValue(m_Name);
00063 }
00064
00065 MHParseNode *pAvail = p->GetNamedArg(C_INITIALLY_AVAILABLE);
00066
00067 if (pAvail)
00068 {
00069 m_fInitiallyAvailable = pAvail->GetArgN(0)->GetBoolValue();
00070 }
00071
00072
00073
00074 m_fInitiallyActive = false;
00075 }
00076
00077 void MHProgram::PrintMe(FILE *fd, int nTabs) const
00078 {
00079 MHIngredient::PrintMe(fd, nTabs);
00080 PrintTabs(fd, nTabs);
00081 fprintf(fd, ":Name ");
00082 m_Name.PrintMe(fd, 0);
00083 fprintf(fd, "\n");
00084
00085 if (! m_fInitiallyAvailable)
00086 {
00087 PrintTabs(fd, nTabs);
00088 fprintf(fd, ":InitiallyAvailable false");
00089 fprintf(fd, "\n");
00090 }
00091 }
00092
00093
00094 void MHProgram::Activation(MHEngine *engine)
00095 {
00096 if (m_fRunning)
00097 {
00098 return;
00099 }
00100
00101 MHIngredient::Activation(engine);
00102 m_fRunning = true;
00103 engine->EventTriggered(this, EventIsRunning);
00104 }
00105
00106
00107 void MHProgram::Deactivation(MHEngine *engine)
00108 {
00109 if (! m_fRunning)
00110 {
00111 return;
00112 }
00113
00114
00115 MHIngredient::Deactivation(engine);
00116 }
00117
00118 void MHResidentProgram::PrintMe(FILE *fd, int nTabs) const
00119 {
00120 PrintTabs(fd, nTabs);
00121 fprintf(fd, "{:ResidentPrg ");
00122 MHProgram::PrintMe(fd, nTabs + 1);
00123 PrintTabs(fd, nTabs);
00124 fprintf(fd, "}\n");
00125 }
00126
00127 static void SetSuccessFlag(const MHObjectRef &success, bool result, MHEngine *engine)
00128 {
00129 engine->FindObject(success)->SetVariableValue(result);
00130 }
00131
00132
00133 static int GetInt(MHParameter *parm, MHEngine *engine)
00134 {
00135 MHUnion un;
00136 un.GetValueFrom(*parm, engine);
00137 un.CheckType(MHUnion::U_Int);
00138 return un.m_nIntVal;
00139 }
00140
00141
00142 static void GetString(MHParameter *parm, MHOctetString &str, MHEngine *engine)
00143 {
00144 MHUnion un;
00145 un.GetValueFrom(*parm, engine);
00146 un.CheckType(MHUnion::U_String);
00147 str.Copy(un.m_StrVal);
00148 }
00149
00150 void MHResidentProgram::CallProgram(bool fIsFork, const MHObjectRef &success, const MHSequence<MHParameter *> &args, MHEngine *engine)
00151 {
00152 if (! m_fAvailable)
00153 {
00154 Preparation(engine);
00155 }
00156
00157
00158 Activation(engine);
00159 MHLOG(MHLogDetail, QString("Calling program %1").arg(m_Name.Printable()));
00160
00161 try
00162 {
00163
00164 if (m_Name.Equal("GCD"))
00165 {
00166 if (args.Size() == 2)
00167 {
00168 struct timeb timebuffer;
00169 #if HAVE_FTIME
00170 ftime(&timebuffer);
00171 #elif HAVE_GETTIMEOFDAY
00172 struct timeval time;
00173 struct timezone zone;
00174
00175 if (gettimeofday(&time, &zone) == -1)
00176 {
00177 MHLOG(MHLogDetail, QString("gettimeofday() failed"));
00178 }
00179
00180 timebuffer.time = time.tv_sec;
00181 timebuffer.timezone = zone.tz_minuteswest;
00182 timebuffer.dstflag = zone.tz_dsttime;
00183 #else
00184 #error Configuration error? No ftime() or gettimeofday()?
00185 #endif
00186
00187 timebuffer.time -= timebuffer.timezone * 60;
00188
00189 int nTimeAsSecs = timebuffer.time % (24 * 60 * 60);
00190
00191
00192 int nModJulianDate = 40587 + timebuffer.time / (24 * 60 * 60);
00193
00194 engine->FindObject(*(args.GetAt(0)->GetReference()))->SetVariableValue(nModJulianDate);
00195 engine->FindObject(*(args.GetAt(1)->GetReference()))->SetVariableValue(nTimeAsSecs);
00196 SetSuccessFlag(success, true, engine);
00197 }
00198 else
00199 {
00200 SetSuccessFlag(success, false, engine);
00201 }
00202 }
00203
00204 else if (m_Name.Equal("FDa"))
00205 {
00206 if (args.Size() == 4)
00207 {
00208
00209 MHOctetString format;
00210 GetString(args.GetAt(0), format, engine);
00211 int date = GetInt(args.GetAt(1), engine);
00212 int time = GetInt(args.GetAt(2), engine);
00213
00214 time_t timet = (date - 40587) * (24 * 60 * 60) + time;
00215 struct tm *timeStr = gmtime(&timet);
00216 MHOctetString result;
00217
00218 for (int i = 0; i < format.Size(); i++)
00219 {
00220 unsigned char ch = format.GetAt(i);
00221 char buffer[5];
00222
00223 if (ch == '%')
00224 {
00225 i++;
00226
00227 if (i == format.Size())
00228 {
00229 break;
00230 }
00231
00232 ch = format.GetAt(i);
00233 buffer[0] = 0;
00234
00235 switch (ch)
00236 {
00237 case 'Y':
00238 sprintf(buffer, "%04d", timeStr->tm_year + 1900);
00239 break;
00240 case 'y':
00241 sprintf(buffer, "%02d", timeStr->tm_year % 100);
00242 break;
00243 case 'X':
00244 sprintf(buffer, "%02d", timeStr->tm_mon + 1);
00245 break;
00246 case 'x':
00247 sprintf(buffer, "%1d", timeStr->tm_mon + 1);
00248 break;
00249 case 'D':
00250 sprintf(buffer, "%02d", timeStr->tm_mday);
00251 break;
00252 case 'd':
00253 sprintf(buffer, "%1d", timeStr->tm_mday);
00254 break;
00255 case 'H':
00256 sprintf(buffer, "%02d", timeStr->tm_hour);
00257 break;
00258 case 'h':
00259 sprintf(buffer, "%1d", timeStr->tm_hour);
00260 break;
00261 case 'I':
00262
00263 if (timeStr->tm_hour == 12 || timeStr->tm_hour == 0)
00264 {
00265 strcpy(buffer, "12");
00266 }
00267 else
00268 {
00269 sprintf(buffer, "%02d", timeStr->tm_hour % 12);
00270 }
00271
00272 break;
00273 case 'i':
00274
00275 if (timeStr->tm_hour == 12 || timeStr->tm_hour == 0)
00276 {
00277 strcpy(buffer, "12");
00278 }
00279 else
00280 {
00281 sprintf(buffer, "%1d", timeStr->tm_hour % 12);
00282 }
00283
00284 break;
00285 case 'M':
00286 sprintf(buffer, "%02d", timeStr->tm_min);
00287 break;
00288 case 'm':
00289 sprintf(buffer, "%1d", timeStr->tm_min);
00290 break;
00291 case 'S':
00292 sprintf(buffer, "%02d", timeStr->tm_sec);
00293 break;
00294 case 's':
00295 sprintf(buffer, "%1d", timeStr->tm_sec);
00296 break;
00297
00298 case 'A':
00299
00300 if (timeStr->tm_hour < 12)
00301 {
00302 strcpy(buffer, "AM");
00303 }
00304 else
00305 {
00306 strcpy(buffer, "PM");
00307 }
00308
00309 break;
00310 case 'a':
00311
00312 if (timeStr->tm_hour < 12)
00313 {
00314 strcpy(buffer, "am");
00315 }
00316 else
00317 {
00318 strcpy(buffer, "pm");
00319 }
00320
00321 break;
00322 default:
00323 buffer[0] = ch;
00324 buffer[1] = 0;
00325 }
00326
00327 result.Append(buffer);
00328 }
00329 else
00330 {
00331 result.Append(MHOctetString(&ch, 1));
00332 }
00333 }
00334
00335 MHParameter *pResString = args.GetAt(3);
00336 engine->FindObject(*(pResString->GetReference()))->SetVariableValue(result);
00337 SetSuccessFlag(success, true, engine);
00338 }
00339 else
00340 {
00341 SetSuccessFlag(success, false, engine);
00342 }
00343 }
00344
00345 else if (m_Name.Equal("GDW"))
00346 {
00347 if (args.Size() == 2)
00348 {
00349 int date = GetInt(args.GetAt(0), engine);
00350
00351 time_t timet = (date - 40587) * (24 * 60 * 60);
00352 struct tm *timeStr = gmtime(&timet);
00353
00354 engine->FindObject(*(args.GetAt(1)->GetReference()))->SetVariableValue(timeStr->tm_wday);
00355 SetSuccessFlag(success, true, engine);
00356 }
00357 else
00358 {
00359 SetSuccessFlag(success, false, engine);
00360 }
00361 }
00362
00363 else if (m_Name.Equal("Rnd"))
00364 {
00365 if (args.Size() == 2)
00366 {
00367 int nLimit = GetInt(args.GetAt(0), engine);
00368 MHParameter *pResInt = args.GetAt(1);
00369 int r = random() % nLimit + 1;
00370 engine->FindObject(
00371 *(pResInt->GetReference()))->SetVariableValue(r);
00372 SetSuccessFlag(success, true, engine);
00373 }
00374 else
00375 {
00376 SetSuccessFlag(success, false, engine);
00377 }
00378 }
00379
00380 else if (m_Name.Equal("CTC"))
00381 {
00382
00383 if (args.Size() == 2)
00384 {
00385 MHOctetString string;
00386 GetString(args.GetAt(0), string, engine);
00387 MHContentRef result;
00388 result.m_ContentRef.Copy(string);
00389 engine->FindObject(*(args.GetAt(1)->GetReference()))->SetVariableValue(result);
00390 SetSuccessFlag(success, true, engine);
00391 }
00392 else
00393 {
00394 SetSuccessFlag(success, false, engine);
00395 }
00396 }
00397
00398 else if (m_Name.Equal("CTO"))
00399 {
00400
00401 if (args.Size() == 3)
00402 {
00403 MHObjectRef result;
00404 GetString(args.GetAt(0), result.m_GroupId, engine);
00405 result.m_nObjectNo = GetInt(args.GetAt(1), engine);
00406 engine->FindObject(*(args.GetAt(2)->GetReference()))->SetVariableValue(result);
00407 SetSuccessFlag(success, true, engine);
00408 }
00409 else
00410 {
00411 SetSuccessFlag(success, false, engine);
00412 }
00413 }
00414
00415 else if (m_Name.Equal("GSL"))
00416 {
00417 if (args.Size() == 2)
00418 {
00419
00420 MHOctetString string;
00421 GetString(args.GetAt(0), string, engine);
00422 MHParameter *pResInt = args.GetAt(1);
00423 SetSuccessFlag(success, true, engine);
00424 engine->FindObject(*(pResInt->GetReference()))->SetVariableValue(string.Size());
00425 }
00426 else
00427 {
00428 SetSuccessFlag(success, false, engine);
00429 }
00430 }
00431
00432 else if (m_Name.Equal("GSS"))
00433 {
00434 if (args.Size() == 4)
00435 {
00436 MHOctetString string;
00437 GetString(args.GetAt(0), string, engine);
00438 int nBeginExtract = GetInt(args.GetAt(1), engine);
00439 int nEndExtract = GetInt(args.GetAt(2), engine);
00440
00441 if (nBeginExtract < 1)
00442 {
00443 nBeginExtract = 1;
00444 }
00445
00446 if (nBeginExtract > string.Size())
00447 {
00448 nBeginExtract = string.Size();
00449 }
00450
00451 if (nEndExtract < 1)
00452 {
00453 nEndExtract = 1;
00454 }
00455
00456 if (nEndExtract > string.Size())
00457 {
00458 nEndExtract = string.Size();
00459 }
00460
00461 MHParameter *pResString = args.GetAt(3);
00462
00463 engine->FindObject(*(pResString->GetReference()))->SetVariableValue(
00464 MHOctetString(string, nBeginExtract - 1, nEndExtract - nBeginExtract + 1));
00465 SetSuccessFlag(success, true, engine);
00466 }
00467 else
00468 {
00469 SetSuccessFlag(success, false, engine);
00470 }
00471 }
00472
00473 else if (m_Name.Equal("SSS"))
00474 {
00475 if (args.Size() == 4)
00476 {
00477
00478 MHOctetString string, searchString;
00479 GetString(args.GetAt(0), string, engine);
00480 int nStart = GetInt(args.GetAt(1), engine);
00481
00482 if (nStart < 1)
00483 {
00484 nStart = 1;
00485 }
00486
00487 GetString(args.GetAt(2), searchString, engine);
00488
00489 int nPos;
00490
00491 for (nPos = nStart - 1; nPos <= string.Size() - searchString.Size(); nPos++)
00492 {
00493 int i;
00494
00495 for (i = 0; i < searchString.Size(); i++)
00496 {
00497 if (searchString.GetAt(i) != string.GetAt(i + nPos))
00498 {
00499 break;
00500 }
00501 }
00502
00503 if (i == searchString.Size())
00504 {
00505 break;
00506 }
00507 }
00508
00509
00510 MHParameter *pResInt = args.GetAt(3);
00511 SetSuccessFlag(success, true, engine);
00512
00513 if (nPos <= string.Size() - searchString.Size())
00514 {
00515
00516 engine->FindObject(*(pResInt->GetReference()))->SetVariableValue(nPos + 1);
00517 }
00518 else
00519 {
00520 engine->FindObject(*(pResInt->GetReference()))->SetVariableValue(-1);
00521 }
00522 }
00523 else
00524 {
00525 SetSuccessFlag(success, false, engine);
00526 }
00527 }
00528
00529 else if (m_Name.Equal("SES"))
00530 {
00531 if (args.Size() == 5)
00532 {
00533
00534
00535 MHOctetString string, searchString;
00536 GetString(args.GetAt(0), string, engine);
00537 int nStart = GetInt(args.GetAt(1), engine);
00538
00539 if (nStart < 1)
00540 {
00541 nStart = 1;
00542 }
00543
00544 GetString(args.GetAt(2), searchString, engine);
00545
00546 int nPos;
00547
00548 for (nPos = nStart - 1; nPos <= string.Size() - searchString.Size(); nPos++)
00549 {
00550 int i;
00551
00552 for (i = 0; i < searchString.Size(); i++)
00553 {
00554 if (searchString.GetAt(i) != string.GetAt(i + nPos))
00555 {
00556 break;
00557 }
00558 }
00559
00560 if (i == searchString.Size())
00561 {
00562 break;
00563 }
00564 }
00565
00566
00567 MHParameter *pResString = args.GetAt(3);
00568 MHParameter *pResInt = args.GetAt(4);
00569 SetSuccessFlag(success, true, engine);
00570
00571 if (nPos <= string.Size() - searchString.Size())
00572 {
00573
00574 engine->FindObject(*(pResInt->GetReference()))->SetVariableValue(nPos + 1 + searchString.Size());
00575
00576 MHOctetString resultString(string, nStart - 1, nPos - nStart + 1);
00577 engine->FindObject(*(pResString->GetReference()))->SetVariableValue(resultString);
00578 }
00579 else
00580 {
00581 engine->FindObject(*(pResInt->GetReference()))->SetVariableValue(-1);
00582 engine->FindObject(*(pResString->GetReference()))->SetVariableValue(MHOctetString(""));
00583 }
00584 }
00585 else
00586 {
00587 SetSuccessFlag(success, false, engine);
00588 }
00589 }
00590
00591 else if (m_Name.Equal("GSI"))
00592 {
00593
00594 if (args.Size() == 2)
00595 {
00596 MHOctetString string;
00597 GetString(args.GetAt(0), string, engine);
00598 MHParameter *pResInt = args.GetAt(1);
00599
00600
00601
00602 QString str = QString::fromUtf8((const char *)string.Bytes(), string.Size());
00603 int nResult = engine->GetContext()->GetChannelIndex(str);
00604 engine->FindObject(*(pResInt->GetReference()))->SetVariableValue(nResult);
00605 SetSuccessFlag(success, nResult >= 0, engine);
00606 }
00607 else
00608 {
00609 SetSuccessFlag(success, false, engine);
00610 }
00611 }
00612
00613 else if (m_Name.Equal("TIn"))
00614 {
00615
00616 if (args.Size() == 1)
00617 {
00618 int nChannel = GetInt(args.GetAt(0), engine);
00619 bool res = nChannel >= 0 ? engine->GetContext()->TuneTo(
00620 nChannel, engine->GetTuneInfo()) : false;
00621 SetSuccessFlag(success, res, engine);
00622 }
00623 else
00624 {
00625 SetSuccessFlag(success, false, engine);
00626 }
00627 }
00628 else if (m_Name.Equal("TII"))
00629 {
00630
00631 if (args.Size() == 1)
00632 {
00633 int tuneinfo = GetInt(args.GetAt(0), engine);
00634 engine->SetTuneInfo(tuneinfo);
00635 SetSuccessFlag(success, true, engine);
00636 }
00637 else
00638 {
00639 SetSuccessFlag(success, false, engine);
00640 }
00641 }
00642 else if (m_Name.Equal("BSI"))
00643 {
00644
00645
00646
00647 if (args.Size() == 5)
00648 {
00649 int channelId = GetInt(args.GetAt(0), engine);
00650 int netId, origNetId, transportId, serviceId;
00651
00652 bool res = engine->GetContext()->GetServiceInfo(channelId, netId, origNetId,
00653 transportId, serviceId);
00654
00655 if (res)
00656 {
00657 engine->FindObject(*(args.GetAt(1)->GetReference()))->SetVariableValue(netId);
00658 engine->FindObject(*(args.GetAt(2)->GetReference()))->SetVariableValue(origNetId);
00659 engine->FindObject(*(args.GetAt(3)->GetReference()))->SetVariableValue(transportId);
00660 engine->FindObject(*(args.GetAt(4)->GetReference()))->SetVariableValue(serviceId);
00661 }
00662
00663 SetSuccessFlag(success, res, engine);
00664 }
00665 else
00666 {
00667 SetSuccessFlag(success, false, engine);
00668 }
00669 }
00670 else if (m_Name.Equal("GBI"))
00671 {
00672
00673 MHERROR("GetBootInfo ResidentProgram is not implemented");
00674 }
00675 else if (m_Name.Equal("CCR"))
00676 {
00677
00678
00679
00680
00681 if (args.Size() == 3)
00682 {
00683 MHUnion un;
00684 un.GetValueFrom(*(args.GetAt(0)), engine);
00685 un.CheckType(MHUnion::U_ContentRef);
00686 MHContentRef fileName;
00687 fileName.Copy(un.m_ContentRefVal);
00688 QString csPath = engine->GetPathName(fileName.m_ContentRef);
00689 bool result = false;
00690 QByteArray text;
00691
00692
00693 if (! csPath.isEmpty())
00694 {
00695 result = engine->GetContext()->GetCarouselData(csPath, text);
00696 }
00697
00698
00699 MHParameter *pResFlag = args.GetAt(1);
00700 engine->FindObject(*(pResFlag->GetReference()))->SetVariableValue(result);
00701 MHParameter *pResCR = args.GetAt(2);
00702
00703 engine->FindObject(*(pResCR->GetReference()))->SetVariableValue(fileName);
00704 SetSuccessFlag(success, true, engine);
00705 }
00706 else
00707 {
00708 SetSuccessFlag(success, false, engine);
00709 }
00710 }
00711 else if (m_Name.Equal("CGR"))
00712 {
00713
00714
00715 MHERROR("CheckGroupIDRef ResidentProgram is not implemented");
00716 }
00717 else if (m_Name.Equal("VTG"))
00718 {
00719
00720 MHERROR("VideoToGraphics ResidentProgram is not implemented");
00721 }
00722 else if (m_Name.Equal("SWA"))
00723 {
00724
00725
00726 MHERROR("SetWidescreenAlignment ResidentProgram is not implemented");
00727 }
00728 else if (m_Name.Equal("GDA"))
00729 {
00730
00731 MHERROR("GetDisplayAspectRatio ResidentProgram is not implemented");
00732 }
00733 else if (m_Name.Equal("CIS"))
00734 {
00735
00736 MHERROR("CI_SendMessage ResidentProgram is not implemented");
00737 }
00738 else if (m_Name.Equal("SSM"))
00739 {
00740
00741 MHERROR("SetSubtitleMode ResidentProgram is not implemented");
00742 }
00743
00744 else if (m_Name.Equal("WAI"))
00745 {
00746
00747
00748 if (args.Size() == 1)
00749 {
00750 MHOctetString result;
00751 result.Copy(engine->MHEGEngineProviderIdString);
00752 result.Append(" ");
00753 result.Append(engine->GetContext()->GetReceiverId());
00754 result.Append(" ");
00755 result.Append(engine->GetContext()->GetDSMCCId());
00756 engine->FindObject(*(args.GetAt(0)->GetReference()))->SetVariableValue(result);
00757 SetSuccessFlag(success, true, engine);
00758 }
00759 else
00760 {
00761 SetSuccessFlag(success, false, engine);
00762 }
00763 }
00764
00765 else if (m_Name.Equal("DBG"))
00766 {
00767 QString message = "DEBUG: ";
00768
00769 for (int i = 0; i < args.Size(); i++)
00770 {
00771 MHUnion un;
00772 un.GetValueFrom(*(args.GetAt(i)), engine);
00773
00774 switch (un.m_Type)
00775 {
00776 case MHUnion::U_Int:
00777 message.append(QString("%1").arg(un.m_nIntVal));
00778 break;
00779 case MHParameter::P_Bool:
00780 message.append(un.m_fBoolVal ? "True" : "False");
00781 break;
00782 case MHParameter::P_String:
00783 message.append(QString::fromUtf8((const char *)un.m_StrVal.Bytes(), un.m_StrVal.Size()));
00784 break;
00785 case MHParameter::P_ObjRef:
00786 message.append(un.m_ObjRefVal.Printable());
00787 break;
00788 case MHParameter::P_ContentRef:
00789 message.append(un.m_ContentRefVal.Printable());
00790 break;
00791 case MHParameter::P_Null:
00792 break;
00793 }
00794 }
00795
00796 MHLOG(MHLogNotifications, message);
00797 }
00798
00799 else if (m_Name.Equal("SBI"))
00800 {
00801
00802
00803 MHERROR("SetBroadcastInterrupt ResidentProgram is not implemented");
00804 }
00805
00806 else if (m_Name.Equal("GIS"))
00807 {
00808
00809 MHERROR("GetICStatus ResidentProgram is not implemented");
00810 }
00811
00812 else
00813 {
00814 MHERROR(QString("Unknown ResidentProgram %1").arg(m_Name.Printable()));
00815 }
00816 }
00817 catch (char const *)
00818 {
00819
00820 SetSuccessFlag(success, false, engine);
00821
00822 }
00823
00824 Deactivation(engine);
00825
00826
00827 if (fIsFork)
00828 {
00829 engine->EventTriggered(this, EventAsyncStopped);
00830 }
00831 }
00832
00833 MHRemoteProgram::MHRemoteProgram()
00834 {
00835
00836 }
00837
00838 MHRemoteProgram::~MHRemoteProgram()
00839 {
00840
00841 }
00842
00843 void MHRemoteProgram::Initialise(MHParseNode *p, MHEngine *engine)
00844 {
00845 MHProgram::Initialise(p, engine);
00846
00847 }
00848
00849 void MHRemoteProgram::PrintMe(FILE *fd, int nTabs) const
00850 {
00851 PrintTabs(fd, nTabs);
00852 fprintf(fd, "{:RemotePrg");
00853 MHProgram::PrintMe(fd, nTabs + 1);
00854 fprintf(fd, "****TODO\n");
00855 PrintTabs(fd, nTabs);
00856 fprintf(fd, "}\n");
00857 }
00858
00859 MHInterChgProgram::MHInterChgProgram()
00860 {
00861
00862 }
00863
00864 MHInterChgProgram::~MHInterChgProgram()
00865 {
00866
00867 }
00868
00869 void MHInterChgProgram::Initialise(MHParseNode *p, MHEngine *engine)
00870 {
00871 MHProgram::Initialise(p, engine);
00872
00873 }
00874
00875 void MHInterChgProgram::PrintMe(FILE *fd, int nTabs) const
00876 {
00877 PrintTabs(fd, nTabs);
00878 fprintf(fd, "{:InterchgPrg");
00879 MHProgram::PrintMe(fd, nTabs + 1);
00880 fprintf(fd, "****TODO\n");
00881 PrintTabs(fd, nTabs);
00882 fprintf(fd, "}\n");
00883 }
00884
00885
00886 void MHCall::Initialise(MHParseNode *p, MHEngine *engine)
00887 {
00888 MHElemAction::Initialise(p, engine);
00889 m_Succeeded.Initialise(p->GetArgN(1), engine);
00890
00891 MHParseNode *args = p->GetArgN(2);
00892
00893 for (int i = 0; i < args->GetSeqCount(); i++)
00894 {
00895 MHParameter *pParm = new MHParameter;
00896 m_Parameters.Append(pParm);
00897 pParm->Initialise(args->GetSeqN(i), engine);
00898 }
00899 }
00900
00901 void MHCall::PrintArgs(FILE *fd, int nTabs) const
00902 {
00903 m_Succeeded.PrintMe(fd, nTabs);
00904 fprintf(fd, " ( ");
00905
00906 for (int i = 0; i < m_Parameters.Size(); i++)
00907 {
00908 m_Parameters.GetAt(i)->PrintMe(fd, 0);
00909 }
00910
00911 fprintf(fd, " )\n");
00912 }
00913
00914 void MHCall::Perform(MHEngine *engine)
00915 {
00916
00917 Target(engine)->CallProgram(m_fIsFork, m_Succeeded, m_Parameters, engine);
00918 }