コード例 #1
0
ファイル: WiimoteReal.cpp プロジェクト: Huanglihan/dolphin
// to be called from CPU thread
void Wiimote::QueueReport(u8 rpt_id, const void* _data, unsigned int size)
{
	auto const data = static_cast<const u8*>(_data);

	Report rpt(size + 2);
	rpt[0] = WM_SET_REPORT | WM_BT_OUTPUT;
	rpt[1] = rpt_id;
	std::copy_n(data, size, rpt.begin() + 2);
	WriteReport(std::move(rpt));
}
コード例 #2
0
ファイル: Profiler.cpp プロジェクト: KyleSanderson/SourceMod
bool ProfileEngine::GenerateReport(FILE *fp)
{
	time_t t;
	double total_time;
	prof_point_t end_time;

	InitProfPoint(end_time);
	total_time = DiffProfPoints(m_ProfStart, end_time);

	t = time(NULL);

	fprintf(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
	fprintf(fp, "<profile time=\"%d\" uptime=\"%f\">\n", (int)t, total_time);
	WriteReport(fp, &m_Natives, "natives");
	WriteReport(fp, &m_Callbacks, "callbacks");
	WriteReport(fp, &m_Functions, "functions");
	fprintf(fp, "</profile>\n");

	return true;
}
コード例 #3
0
bool ErrorReport::GenerateReport(ErrorReport::IProgressNotifier* pProgressNotifier)
{
	ErrorReport* report = this;
	BOOST_SCOPE_EXIT((report))
	{
		// Allow the crashed process to exit
		report->ReleaseApplicationLock();
	} BOOST_SCOPE_EXIT_END

	pProgressNotifier->taskStarted("Generating crash report", 3);
	
	// Initialize shared memory
	pProgressNotifier->taskStepStarted("Connecting to crashed application");
	bool bInit = Initialize();
	pProgressNotifier->taskStepEnded();
	if(!bInit)
	{
		pProgressNotifier->setError("Could not generate the crash dump.");
		pProgressNotifier->setDetailedError(m_DetailedError);
		return false;
	}
	
	if(m_pCrashInfo->architecture != ARX_ARCH) {
		pProgressNotifier->setError("Architecture mismatch between the crashed process and the crash reporter.");
		pProgressNotifier->setDetailedError(m_DetailedError);
		return false;
	}
	
	// Generate minidump
	pProgressNotifier->taskStepStarted("Generating crash dump");
	bool bCrashDump = GetCrashDump("crash.dmp");
	pProgressNotifier->taskStepEnded();
	if(!bCrashDump)
	{
		pProgressNotifier->setError("Could not generate the crash dump.");
		pProgressNotifier->setDetailedError(m_DetailedError);
		return false;
	}

	// Generate manifest
	pProgressNotifier->taskStepStarted("Generating report manifest");
	bool bCrashXml = WriteReport("crash.xml");
	pProgressNotifier->taskStepEnded();
	if(!bCrashXml)
	{
		pProgressNotifier->setError("Could not generate the manifest.");
		pProgressNotifier->setDetailedError(m_DetailedError);
		return false;
	}

	return true;
}
コード例 #4
0
ファイル: WiimoteReal.cpp プロジェクト: Huanglihan/dolphin
void Wiimote::InterruptChannel(const u16 channel, const void* const _data, const u32 size)
{
	// first interrupt/control channel sent
	if (channel != m_channel)
	{
		m_channel = channel;

		ClearReadQueue();

		EmuStart();
	}

	auto const data = static_cast<const u8*>(_data);
	Report rpt(data, data + size);
	WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetConfig()->controllers[m_index];

	// Convert output DATA packets to SET_REPORT packets.
	// Nintendo Wiimotes work without this translation, but 3rd
	// party ones don't.
	if (rpt[0] == 0xa2)
	{
		rpt[0] = WM_SET_REPORT | WM_BT_OUTPUT;
	}

	// Disallow games from turning off all of the LEDs.
	// It makes Wiimote connection status confusing.
	if (rpt[1] == WM_LEDS)
	{
		auto& leds_rpt = *reinterpret_cast<wm_leds*>(&rpt[2]);
		if (0 == leds_rpt.leds)
		{
			// Turn on ALL of the LEDs.
			leds_rpt.leds = 0xf;
		}
	}
	else if (rpt[1] == WM_WRITE_SPEAKER_DATA &&
	         (!SConfig::GetInstance().m_WiimoteEnableSpeaker ||
	         (!wm->m_status.speaker || wm->m_speaker_mute)))
	{
		// Translate speaker data reports into rumble reports.
		rpt[1] = WM_RUMBLE;
		// Keep only the rumble bit.
		rpt[2] &= 0x1;
		rpt.resize(3);
	}

	WriteReport(std::move(rpt));
}
コード例 #5
0
// ============================================================================
// Do_ListMonitoredElements
//
//	list observed elements
// ============================================================================
void	Do_ListMonitoredElements (void)
{
	API_Elem_Head**	ppHeads;
	Int32			nElems;
	GSErrCode		err = ACAPI_Element_GetObservedElements (&ppHeads, &nElems);
	if (err != NoError) {
		ErrorBeep ("ACAPI_Element_GetObservedElements", err);
		return;
	}

	for (Int32 i = 0; i < nElems; i++) {
		const API_Elem_Head& refHead = (*ppHeads)[i];
		WriteReport ("%s guid=%s", ElemID_To_Name (refHead.typeID), APIGuidToString (refHead.guid).ToCStr ().Get ());
	}

	BMKillHandle ((GSHandle *) &ppHeads);
}	// Do_ListMonitoredElements
コード例 #6
0
ファイル: sampler.cpp プロジェクト: NetBUG/topicmod
void Sampler::RunSampler(int num_iterations) {
  std::ofstream lhood_file;
  std::ofstream param_file;

  int initial_iteration = 0;
  if (FLAGS_resume) {
    initial_iteration = state_->ReadState(FLAGS_save_delay) + 1;

    vector<double> params_file =
                      state_->ReadHyperparameters(num_hyperparameters());
    SetHyperparameters(params_file);

    // sometimes, we use resume, but the parameters setting are different.
    // so if the params are not default, which means the params are updated,
    // we will just load the params from the CMD line,
    // else, just use the resume params.
    if (params_not_default_) {
      vector<double> params_cmdl = hyperparameters();
      BOOST_ASSERT(params_file.size() == params_cmdl.size());
      for (int ii = 0; ii < params_file.size(); ++ii) {
        if ((int) params_file[ii] * 1.0e10 !=
                                  (int) params_cmdl[ii] * 1.0e10) {
          cout << "Warning: parameters in CMD are not the same "
               << "as in params file." << endl;
          break;
        }
      }
    } else {
      SetHyperparameters(params_file);
    }

    lhood_file.open((FLAGS_output_location + ".lhood").c_str(), ios::app);
    param_file.open((FLAGS_output_location + ".param_hist").c_str(), ios::app);

  } else {
    lhood_file.open((FLAGS_output_location + ".lhood").c_str(), ios::out);
    param_file.open((FLAGS_output_location + ".param_hist").c_str(), ios::out);

    vector<string> param_names = hyperparameter_names();
    for (int ii = 0; ii < (int)param_names.size(); ++ii)
      param_file << param_names[ii] << "\t";
    param_file << endl;
  }

  double lhood = -1e10;

  // Write out the initial hyperparameters
  SampleCorpusVariables(initial_iteration, 0.0, 0, &param_file);
  // if ((initial_iteration / FLAGS_save_delay + 1) *
  //    FLAGS_save_delay > num_iterations) {
  if ((num_iterations - initial_iteration + 1) < FLAGS_save_delay) {
    cout << "*********************************************" << endl;
    cout << "WARNING: You're only running it for " << num_iterations -
      initial_iteration + 1 << " iterations, but every " <<
      FLAGS_save_delay << "iterations will be saved once," <<
      " so no additional state will be saved." << endl;
    cout << "*********************************************" << endl;
  }

  // std::stringstream fs;
  // fs << "mytest_" << initial_iteration << "_" << num_iterations << ".txt";
  // string filename;
  // fs >> filename;

  // std::ofstream mytest;
  // mytest.open(filename.c_str());
  // mytest << "hello" << endl;
  // mytest.close();

  // if run 0 extra iterations in resume, we simply output the same result
  if ((FLAGS_verbose_assignments || FLAGS_mallet_assignments)
         && initial_iteration == (num_iterations + 1)) {
    cout << "*********************************************" << endl;
    cout << "running for 0 iterations, writing verbose or mallet files" << endl;
    WriteReport();
    // state_->PrintStatus(initial_iteration);
    cout << "Finishing writing!" << endl;
    cout << "*********************************************" << endl;
  }

  for (int ii = initial_iteration; ii <= num_iterations; ++ii) {
    // Make runs reproducible based on the iteration (so that it doesn't matter
    // if we restart a run)
    int seed = FLAGS_rand + ii;
    srand(seed);
    boost::timer time;
    cout << " ------------ Iteration " << ii <<
      "(" << lhood << ") [seed=" << seed <<
         "] ------------ " << endl;

    if (ii > 0 && FLAGS_global_sample_delay >= 1 &&
        ii % FLAGS_global_sample_delay == 0 &&
        ii > FLAGS_global_sample_burnin)
      SampleCorpusVariables(ii, FLAGS_global_sample_step,
                            FLAGS_global_sample_reps,
                            &param_file);

    for (int dd = 0; dd < corpus_->num_docs(); ++dd) {
      // Skip test documents, as we'll do held out lhood on them later
      lib_corpora::MlSeqDoc* doc = corpus_->seq_doc(dd);
      if (IsDocSkippable(doc)) continue;

      int num_words = doc->num_tokens();
      int num_sampled = 0;

      for (int ww = 0; ww < num_words; ++ww) {
        // debug
        // int term = (*doc)[ww];
        // if (term == 144 || term == 47) {
        // cout << "found word" << endl;
        // }
        int topic = SampleWord(dd, ww);
        if (topic != -1)
          num_sampled++;
      }

      if (num_sampled == 0) {
        doc->Print();
        cout << "Warning! Doc " << dd << " had zero words" << endl;
      }

      if (dd % 250 == 0) {
        cout << "Sampling doc " << dd << "/" << corpus_->num_docs() <<
          "(" << num_words << ")" << endl;
      }
      // state_->PrintStatus(ii);
    }
    double elapsed = time.elapsed();

    if (ii > 0 && ii % FLAGS_save_delay == 0) {
      WriteReport();
    }

    lhood = WriteLhoodUpdate(&lhood_file, ii, elapsed);
    lhood_file << endl;
    lhood_file.flush();

    // PrintStatus must happen after sampling corpus variables for MLSLDA or all
    // test documents will have a predicted 0 response
    state_->PrintStatus(ii);
  }
}
コード例 #7
0
VOID
EvtIoDeviceControl(
    _In_  WDFQUEUE          Queue,
    _In_  WDFREQUEST        Request,
    _In_  size_t            OutputBufferLength,
    _In_  size_t            InputBufferLength,
    _In_  ULONG             IoControlCode
    )
/*++
Routine Description:

    This event callback function is called when the driver receives an

    (KMDF) IOCTL_HID_Xxx code when handlng IRP_MJ_INTERNAL_DEVICE_CONTROL
    (UMDF) IOCTL_HID_Xxx, IOCTL_UMDF_HID_Xxx when handling IRP_MJ_DEVICE_CONTROL

Arguments:

    Queue - A handle to the queue object that is associated with the I/O request

    Request - A handle to a framework request object.

    OutputBufferLength - The length, in bytes, of the request's output buffer,
            if an output buffer is available.

    InputBufferLength - The length, in bytes, of the request's input buffer, if
            an input buffer is available.

    IoControlCode - The driver or system defined IOCTL associated with the request

Return Value:

    NTSTATUS

--*/
{
    NTSTATUS                status;
    BOOLEAN                 completeRequest = TRUE;
    WDFDEVICE               device = WdfIoQueueGetDevice(Queue);
    PDEVICE_CONTEXT         deviceContext = NULL;
    PQUEUE_CONTEXT          queueContext = GetQueueContext(Queue);
    UNREFERENCED_PARAMETER  (OutputBufferLength);
    UNREFERENCED_PARAMETER  (InputBufferLength);

    deviceContext = GetDeviceContext(device);

    switch (IoControlCode)
    {
    case IOCTL_HID_GET_DEVICE_DESCRIPTOR:   // METHOD_NEITHER
        //
        // Retrieves the device's HID descriptor.
        //
        _Analysis_assume_(deviceContext->HidDescriptor.bLength != 0);
        status = RequestCopyFromBuffer(Request,
                            &deviceContext->HidDescriptor,
                            deviceContext->HidDescriptor.bLength);
        break;

    case IOCTL_HID_GET_DEVICE_ATTRIBUTES:   // METHOD_NEITHER
        //
        //Retrieves a device's attributes in a HID_DEVICE_ATTRIBUTES structure.
        //
        status = RequestCopyFromBuffer(Request,
                            &queueContext->DeviceContext->HidDeviceAttributes,
                            sizeof(HID_DEVICE_ATTRIBUTES));
        break;

    case IOCTL_HID_GET_REPORT_DESCRIPTOR:   // METHOD_NEITHER
        //
        //Obtains the report descriptor for the HID device.
        //
        status = RequestCopyFromBuffer(Request,
                            deviceContext->ReportDescriptor,
                            deviceContext->HidDescriptor.DescriptorList[0].wReportLength);
        break;

    case IOCTL_HID_READ_REPORT:             // METHOD_NEITHER
        //
        // Returns a report from the device into a class driver-supplied
        // buffer.
        //
        status = ReadReport(queueContext, Request, &completeRequest);
        break;

    case IOCTL_HID_WRITE_REPORT:            // METHOD_NEITHER
        //
        // Transmits a class driver-supplied report to the device.
        //
        status = WriteReport(queueContext, Request);
        break;

#ifdef _KERNEL_MODE

    case IOCTL_HID_GET_FEATURE:             // METHOD_OUT_DIRECT

        status = GetFeature(queueContext, Request);
        break;

    case IOCTL_HID_SET_FEATURE:             // METHOD_IN_DIRECT

        status = SetFeature(queueContext, Request);
        break;

    case IOCTL_HID_GET_INPUT_REPORT:        // METHOD_OUT_DIRECT

        status = GetInputReport(queueContext, Request);
        break;

    case IOCTL_HID_SET_OUTPUT_REPORT:       // METHOD_IN_DIRECT

        status = SetOutputReport(queueContext, Request);
        break;

#else // UMDF specific

    //
    // HID minidriver IOCTL uses HID_XFER_PACKET which contains an embedded pointer.
    //
    //   typedef struct _HID_XFER_PACKET {
    //     PUCHAR reportBuffer;
    //     ULONG  reportBufferLen;
    //     UCHAR  reportId;
    //   } HID_XFER_PACKET, *PHID_XFER_PACKET;
    //
    // UMDF cannot handle embedded pointers when marshalling buffers between processes.
    // Therefore a special driver mshidumdf.sys is introduced to convert such IRPs to
    // new IRPs (with new IOCTL name like IOCTL_UMDF_HID_Xxxx) where:
    //
    //   reportBuffer - passed as one buffer inside the IRP
    //   reportId     - passed as a second buffer inside the IRP
    //
    // The new IRP is then passed to UMDF host and driver for further processing.
    //

    case IOCTL_UMDF_HID_GET_FEATURE:        // METHOD_NEITHER

        status = GetFeature(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_SET_FEATURE:        // METHOD_NEITHER

        status = SetFeature(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_GET_INPUT_REPORT:  // METHOD_NEITHER

        status = GetInputReport(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_SET_OUTPUT_REPORT: // METHOD_NEITHER

        status = SetOutputReport(queueContext, Request);
        break;

#endif // _KERNEL_MODE

    case IOCTL_HID_GET_STRING:                      // METHOD_NEITHER

        status = GetString(Request);
        break;

    case IOCTL_HID_GET_INDEXED_STRING:              // METHOD_OUT_DIRECT

        status = GetIndexedString(Request);
        break;

    case IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST:  // METHOD_NEITHER
        //
        // This has the USBSS Idle notification callback. If the lower driver
        // can handle it (e.g. USB stack can handle it) then pass it down
        // otherwise complete it here as not inplemented. For a virtual
        // device, idling is not needed.
        //
        // Not implemented. fall through...
        //
    case IOCTL_HID_ACTIVATE_DEVICE:                 // METHOD_NEITHER
    case IOCTL_HID_DEACTIVATE_DEVICE:               // METHOD_NEITHER
    case IOCTL_GET_PHYSICAL_DESCRIPTOR:             // METHOD_OUT_DIRECT
        //
        // We don't do anything for these IOCTLs but some minidrivers might.
        //
        // Not implemented. fall through...
        //
    default:
        status = STATUS_NOT_IMPLEMENTED;
        break;
    }

    //
    // Complete the request. Information value has already been set by request
    // handlers.
    //
    if (completeRequest) {
        WdfRequestComplete(Request, status);
    }
}
コード例 #8
0
ファイル: if-execint.c プロジェクト: LukeMeszar/CAS
   GMC_DCL(tp_Date, DepModDate)
{
   tps_ExecSpc _ExecSpc; tp_ExecSpc ExecSpc = &_ExecSpc;
   tp_Job Job;
   tp_Tool Tool;
   tp_TClass TClass;
   tp_InpFilHdrs Inputs;
   tp_OutFilHdrs Outputs;
   tp_FileName OldErrFileName;
   tp_FilDsc OldErrFD;
   tps_FileName InFileName, OutFileName;
   tps_Str StrBuf;
   tp_FilDsc InFD, OutFD;
   tp_Status MinStatus;
   tp_FilHdr ElmFilHdr, DestFilHdr, OprFilHdr;
   tp_LocElm LocElm, FirstLE, LastLE;
   tp_FilElm FilElm;
   int i;
   boolean ErrFlag, OldIsIPC;

   Do_Log("Generating", FilHdr, LOGLEVEL_IntGenerate);
   MinStatus = DepStatus;

   Tool = FilHdr_Tool(FilHdr);
   FilHdr_ExecSpc(ExecSpc, FilHdr);
   Job = New_Job();
   ExecSpc->Job = Job;
   Inputs = ExecSpc->InpFilHdrs;
   Outputs = ExecSpc->OutFilHdrs;

   Save_ErrFile(&OldErrFileName, &OldIsIPC, &OldErrFD);
   Set_ErrFile(Job->ErrorFN, FALSE, (tp_FilDsc)NIL);
   Clr_ErrStatus(FilHdr);

   TClass = Tool_TClass(Tool);
   switch (TClass) {
      case TC_Str: {
	 break;}/*case*/;
      case TC_StructMem: {
	 FATALERROR("StructMem's should always be up-to-date");
	 break;}/*case*/;
      case TC_PrmValues: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 FirstLE = NIL; LastLE = NIL;
	 FilPVal_LocElm(&FirstLE, &LastLE,
			FilPrm_FilPVal(FilHdr_FilPrm(FilHdr)), FilHdr);
	 Set_LocElm(FilHdr, FirstLE);
	 break;}/*case*/;
      case TC_First: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 /*select*/{
	    if (FilHdr_LocElm(Inputs[0]) == 0) {
	       LocElm = Make_LocElm(NilStrFilHdr, RootFilPrm, FilHdr);
	    }else{
	       FilElm = LocElm_FilElm(FilHdr_LocElm(Inputs[0]));
	       ElmFilHdr = FilElm_FilHdr(FilElm);
	       Ret_FilElm(FilElm);
	       LocElm = Make_LocElm(ElmFilHdr, RootFilPrm, FilHdr);
	       Ret_FilHdr(ElmFilHdr); };}/*select*/;
	 Set_LocElm(FilHdr, LocElm);
	 break;}/*case*/;
      case TC_DrvDirElm: {
	 if (MinStatus > STAT_NoFile) {
	    Add_ErrStatus(FilHdr, STAT_NoFile);
	    MinStatus = STAT_NoFile; }/*if*/;
	 break;}/*case*/;
      case TC_VirDirElm: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 LocElm = 0;
	 ElmFilHdr = Do_Key(FilHdr_Father(Copy_FilHdr(Inputs[0])),
			    FilHdr_Key(StrBuf, FilHdr));
	 if (ElmFilHdr != ERROR) {
	    LocElm = Make_LocElm(ElmFilHdr, RootFilPrm, FilHdr);
	    Ret_FilHdr(ElmFilHdr); }/*if*/;
	 Set_LocElm(FilHdr, LocElm);
	 break;}/*case*/;
      case TC_Collect: {
	 FORBIDDEN(ExecSpc->NumInps < 1 || ExecSpc->NumOuts != 1);
	 FirstLE = NIL; LastLE = NIL;
	 for (i=0; i<ExecSpc->NumInps; i++) {
	    LocElm = Make_LocElm(Inputs[i], FilHdr_FilPrm(FilHdr), FilHdr);
	    Chain_LocElms(&FirstLE, &LastLE, LocElm);
	    }/*for*/;
	 Set_LocElm(FilHdr, FirstLE);
	 if (IsPntr(FilHdr)) Validate_IsPntr(FilHdr);
	 break;}/*case*/;
      case TC_ReadList: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Exec_List(FilHdr, Inputs[0], FilHdr_FilPrm(FilHdr), FALSE);
	 if (IsPntr(FilHdr)) Validate_IsPntr(FilHdr);
	 break;}/*case*/;
      case TC_SrcNames: case TC_OpNames: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 FilHdr_DataFileName(InFileName, Inputs[0]);
	 WriteSrcNames(OutFD, InFileName, (TClass == TC_OpNames));
	 Close(OutFD);
	 break;}/*case*/;
      case TC_ViewSpec: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Exec_List(FilHdr, Inputs[0], RootFilPrm, FALSE);
	 Validate_ViewSpec(FilHdr);
	 break;}/*case*/;
      case TC_CmptView: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Exec_CmptView(&ErrFlag, FilHdr, Inputs[0]);
	 if (ErrFlag) {
	    Add_ErrStatus(FilHdr, STAT_TgtValError);
	    if (MinStatus > STAT_TgtValError) {
	       MinStatus = STAT_TgtValError; }/*if*/; }/*if*/;
	 break;}/*case*/;
      case TC_Directory: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 ElmFilHdr = FilHdr_DirFilHdr(Copy_FilHdr(Inputs[0]));
	 Set_LocElm(FilHdr, Make_LocElm(ElmFilHdr, RootFilPrm, FilHdr));
	 Ret_FilHdr(ElmFilHdr);
	 break;}/*case*/;
      case TC_Name: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WritePrmOdinExpr(OutFD, Inputs[0], FilHdr_FilPrm(FilHdr));
	 Close(OutFD);
	 break;}/*case*/;
      case TC_Names: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteNames(OutFD, Inputs[0], FilHdr_FilPrm(FilHdr));
	 Close(OutFD);
	 break;}/*case*/;
      case TC_FileName: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 /*select*/{
	    if (IsAtmc(Inputs[0])) {
	       Get_WorkFileName(OutFileName, Job, FilHdr);
	       OutFD = FileName_WFilDsc(OutFileName, TRUE);
	       FilHdr_DataFileName(InFileName, Inputs[0]);
	       Writeln(OutFD, InFileName);
	       Close(OutFD);
	    }else{
	       FilHdr_Error("Input to :filename must be atomic: <%s>.\n",
			    Inputs[0]); };}/*select*/;
	 break;}/*case*/;
      case TC_FileNames: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteFlat(OutFD, Inputs[0]);
	 Close(OutFD);
	 break;}/*case*/;
      case TC_Cat: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteCat(OutFD, Inputs[0]);
	 Close(OutFD);
	 break;}/*case*/;
      case TC_Union: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Set_LocElm(FilHdr, Make_UnionLocElm(Inputs[0], FilHdr));
	 break;}/*case*/;
      case TC_PntrHo: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Set_LocElm(FilHdr, Make_PntrHoLocElm(Inputs[0], FilHdr));
	 break;}/*case*/;
      case TC_Apply: {
	 FORBIDDEN(ExecSpc->NumInps != 2 || ExecSpc->NumOuts != 1);
	 OprFilHdr = Deref(Copy_FilHdr(Inputs[1]));
	 FilHdr_DataFileName(InFileName, OprFilHdr);
	 Push_ContextFilHdr(OprFilHdr);
	 Set_LocElm(FilHdr, Make_ApplyLocElm(Inputs[0], FilHdr, InFileName));
	 Pop_ContextFilHdr();
	 break;}/*case*/;
      case TC_DerefPrmVal: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Set_LocElm(FilHdr, Make_DerefPrmValLocElm(Inputs[0], FilHdr));
	 break;}/*case*/;
      case TC_Map: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Set_LocElm(FilHdr, Make_MapLocElm(Inputs[0], FilHdr));
	 break;}/*case*/;
      case TC_Recurse: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Set_LocElm(FilHdr, Make_RecurseLocElm(Inputs[0], FilHdr));
	 break;}/*case*/;
      case TC_Extract: case TC_Delete: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Set_LocElm(FilHdr, Make_ExDelLocElm(Inputs[0], FilHdr,
					     (TClass == TC_Extract)));
	 break;}/*case*/;
      case TC_PntrElm: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 LocElm = 0;
	 ElmFilHdr = Do_Key(Copy_FilHdr(Inputs[0]), FilHdr_Key(StrBuf, FilHdr));
	 if (ElmFilHdr != ERROR) {
	    LocElm = Make_LocElm(ElmFilHdr, RootFilPrm, FilHdr);
	    Ret_FilHdr(ElmFilHdr); }/*if*/;
	 Set_LocElm(FilHdr, LocElm);
	 break;}/*case*/;
      case TC_Error: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteReport(OutFD, Inputs[0], STAT_TgtValError);
	 Close(OutFD);
	 break;}/*case*/;
      case TC_Warning: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteReport(OutFD, Inputs[0], STAT_Warning);
	 Close(OutFD);
	 break;}/*case*/;
      case TC_Label: {
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 Writeln(OutFD, FilHdr_Label(StrBuf, Inputs[0], FALSE));
	 Close(OutFD);
	 break;}/*case*/;
      case TC_Labels: {
	 FORBIDDEN(!IsList(Inputs[0]));
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteLabels(OutFD, Inputs[0]);
	 Close(OutFD);
	 break;}/*case*/;
      case TC_Id: {
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteInt(OutFD, (int)FilHdr_LocHdr(Inputs[0]));
	 Writeln(OutFD, "");
	 Close(OutFD);
	 break;}/*case*/;
      case TC_Depend: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 FirstLE = NIL; LastLE = NIL;
	 GetDepend(&FirstLE, &LastLE, Inputs[0], FilHdr);
	 Set_LocElm(FilHdr, FirstLE);
	 break;}/*case*/;
      case TC_InternalPntr: {
	 break;}/*case*/;
      case TC_TargetsPtr: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Exec_TargetsPtr(FilHdr, Inputs[0]);
	 break;}/*case*/;
      case TC_TargetsInc: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Exec_List(FilHdr, Inputs[0], RootFilPrm, TRUE);
	 break;}/*case*/;
      case TC_Targets: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 FilHdr_DataFileName(InFileName, Inputs[0]);
	 Push_ContextFilHdr(Copy_FilHdr(Inputs[0]));
	 Exec_Targets(OutFD, InFileName);
	 Pop_ContextFilHdr();
	 Close(OutFD);
	 break;}/*case*/;
      case TC_ActTargets: case TC_VirTargets: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 FilHdr_DataFileName(InFileName, Inputs[0]);
	 InFD = FileName_RFilDsc(InFileName, FALSE);
	 LocElm = NIL;
	 if (InFD != NIL) {
	    Push_ContextFilHdr(Copy_FilHdr(FilHdr));
	    LocElm = Make_TargetsLocElm(FilHdr, InFD, InFileName, DepModDate,
					 (TClass == TC_VirTargets));
	    Pop_ContextFilHdr();
	    Close(InFD); }/*if*/;
	 Set_LocElm(FilHdr, LocElm);
	 break;}/*case*/;
      case TC_VirDir: {
	 Exec_VirDir(FilHdr, Inputs[0]);
	 break;}/*case*/;
      case TC_CopyCmd: {
	 DestFilHdr = Deref(LocHdr_FilHdr
	    (FilPVal_LocHdr(FilPrm_FilPVal(FilHdr_FilPrm(FilHdr)))));
	 /*select*/{
	    if (DestFilHdr == ERROR) {
	       SystemError("+copydestdesc=(dest) parameter required.\n");
	    }else{
	       Exec_CopyCmd(FilHdr, DestFilHdr, Inputs[0]);
	       Ret_FilHdr(DestFilHdr); };}/*select*/;
	 break;}/*case*/;
      case TC_ExpandHooks: {
	 FORBIDDEN(ExecSpc->NumInps != 2 || ExecSpc->NumOuts != 1);
	 FilHdr_DataFileName(InFileName, Inputs[1]);
	 InFD = FileName_RFilDsc(InFileName, TRUE);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 ExpandHooks(OutFD, InFD, Inputs[0]);
	 Close(InFD); Close(OutFD);
	 break;}/*case*/;
      case TC_NestedHooks: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 2);
	 FilHdr_DataFileName(InFileName, Inputs[0]);
	 InFD = FileName_RFilDsc(InFileName, TRUE);
	 Get_WorkFileName(OutFileName, Job, Outputs[1]);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 NestedHooks(Outputs[0], Outputs[1], OutFD,
		     InFD, FilHdr_FilPrm(FilHdr));
	 Close(InFD); Close(OutFD);
	 break;}/*case*/;
      case TC_TextDef: {
	 FilHdr_DataFileName(InFileName, Inputs[0]);
	 InFD = FileName_RFilDsc(InFileName, TRUE);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteTextDef(FilHdr, OutFD, OutFileName, InFD, InFileName);
	 Close(InFD); Close(OutFD);
	 break;}/*case*/;
      case TC_PrefixHelp: case TC_SuffixHelp: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteSrcFilTyps(OutFD, (TClass == TC_PrefixHelp));
	 Close(OutFD);
	 break;}/*case*/;
      case TC_DrvHelp: {
	 FORBIDDEN(ExecSpc->NumInps != 1 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WriteDrvHelp(OutFD, Inputs[0]);
	 Close(OutFD);
	 break;}/*case*/;
      case TC_PrmHelp: {
	 FORBIDDEN(ExecSpc->NumInps > 2 || ExecSpc->NumOuts != 1);
	 Get_WorkFileName(OutFileName, Job, FilHdr);
	 OutFD = FileName_WFilDsc(OutFileName, TRUE);
	 WritePrmHelp(OutFD, Inputs[0], FilHdr_FilPrm(FilHdr));
	 Close(OutFD);
	 break;}/*case*/;
      default: {
	 FATALERROR("illegal system tool"); }}/*switch*/;

   ErrFlag = IsErr();
   Set_ErrFile(OldErrFileName, OldIsIPC, OldErrFD);
   if (ErrFlag) {
      Add_StatusFile(FilHdr, STAT_Error, Job->ErrorFN);
      if (MinStatus > STAT_Error) {
	 MinStatus = STAT_Error; }/*if*/; }/*if*/;
   if (MinStatus == STAT_Error && IsTargets(FilHdr)) {
      MinStatus = STAT_TgtValError; }/*if*/;

   Do_Update(FilHdr, ExecSpc->OutFilHdrs, ExecSpc->NumOuts, Job,
	     MinStatus, DepModDate, TRUE);

   Ret_Job(Job);
   Ret_ExecSpc(ExecSpc);
   }/*ExecInternal*/
static void		ProcessParams (TextParams		*textPars,
							   TextParamsInd	*parHdlInd,
							   GSHandle			parHdl)
{
	API_MDCLParameter	par;
	Int32				n, i;
	bool				unknown, badValue, badType;
	GSErrCode			err;

	WriteReport ("Passed parameters");

	if (parHdl == NULL) {
		WriteReport ("  [no params]");
		return;
	}

	err = ACAPI_Goodies (APIAny_GetMDCLParameterNumID, parHdl, &n);
	WriteReport ("  num: %d", n);

	for (i = 1; i <= n; i++) {
		BNZeroMemory (&par, sizeof (API_MDCLParameter));
		par.index = i;
		err = ACAPI_Goodies (APIAny_GetMDCLParameterID, parHdl, &par);
		if (err == NoError) {

			switch (par.type) {
				case MDCLPar_int:
						WriteReport ("  [%d]  (%s) \"%s\" %d",     i, "  int", par.name, par.int_par);
						break;
				case MDCLPar_pointer:
						WriteReport ("  [%d]  (%s) \"%s\" %p",     i, "  ptr", par.name, par.ptr_par);
						break;
				case MDCLPar_float:
						WriteReport ("  [%d]  (%s) \"%s\" %lf",    i, "float", par.name, par.float_par);
						break;
				case MDCLPar_string:
						WriteReport ("  [%d]  (%s) \"%s\" \"%s\"", i, "  str", par.name, par.string_par);
						break;
			}

			unknown  = false;
			badValue = false;
			badType  = false;

			if (CHEqualCStrings (par.name, "pen")) {
				if (par.type == MDCLPar_int) {
					if (par.int_par > 1 && par.int_par < 256)
						textPars->pen = (short) par.int_par;
					else
						badValue = true;
					parHdlInd->penInd = (short) i;
				} else
					badType = true;

			} else if (CHEqualCStrings (par.name, "size")) {
				if (par.type == MDCLPar_float) {
					if (par.float_par > 0.0001)
						textPars->size = par.float_par;
					else
						badValue = true;
					parHdlInd->sizeInd = (short) i;
				} else
					badType = true;

			} else if (CHEqualCStrings (par.name, "content")) {
				if (par.type == MDCLPar_string) {
					strncpy (textPars->content, par.string_par, 255);
					textPars->content [255] = '\0';
					parHdlInd->contentInd   = (short) i;
				} else
					badType = true;

			} else
				unknown = true;

			if (unknown)
				WriteReport ("       ## unknown parameter ##");
			if (badValue)
				WriteReport ("       ## bad value ##");
			if (badType)
				WriteReport ("       ## bad type ##");

		} else
			ErrorBeep ("APIAny_GetMDCLParameterID", err);
	}

	return;
}		// ProcessParams