コード例 #1
0
ファイル: clocktest.c プロジェクト: rcn-ee/xenomai-3
static void *cpu_thread(void *arg)
{
	int cpuid = (long)arg;
	struct sched_param param = { .sched_priority = 1 };
	struct timespec delay = { 0, 0 };
	cpu_set_t cpu_set;

	srandom(read_reference_clock());

	CPU_ZERO(&cpu_set);
	CPU_SET(cpuid, &cpu_set);
	sched_setaffinity(0, sizeof(cpu_set), &cpu_set);
	pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);

	while (1) {
		check_reference(&per_cpu_data[cpuid]);

		check_time_warps(&per_cpu_data[cpuid]);

		delay.tv_nsec = 1000000 + random() * (100000.0 / RAND_MAX);
		nanosleep(&delay, NULL);
	}

	return NULL;
}

static void sighand(int signal)
{
	exit(0);
}
コード例 #2
0
ファイル: variables.cpp プロジェクト: TeoTwawki/dltcep
///CChitemDlg remaining part
int CChitemDlg::check_integers(const int *bytes, int storeflags, int opcode, int trigger, int block)
{
  CString tmp;
  int jr, ret;

  tmp=resolve_scriptelement(opcode, trigger, block);
  ret=0;
  if(storeflags&CHECK_STRREF)
  {
    if(storeflags&CHECK_ONLYJ) jr=2;
    else jr=0;
    switch(check_reference(bytes[0],jr))
    {
    case 1:
      ret|=BAD_STRREF;
      log("Invalid string reference: %d for %s",bytes[0], tmp);
      break;
    case 2:
      ret|=BAD_STRREF;
      log("Deleted string reference: %d for %s",bytes[0], tmp);
      break;
    case 3:
        ret|=BAD_STRREF;
        log("Titleless journal string reference: %d for %s",bytes[0], tmp);
      break;
    }
  }
  if(storeflags&CHECK_ZERO)
  {
    if (bytes[2]==0)
    {
      ret|=BAD_ATTR;
      log("Second parameter may not be zero: %s",tmp);
    }
  }
  if(storeflags&CHECK_POINT)
  {
    //check bytes[1]/bytes[2]
  }
  if(storeflags&CHECK_BYTE)
  {
    if(bytes[0]>255)
    {
      ret|=BAD_ATTR;
      log("Value %d is too large: %s",bytes[0],tmp);
    }
  }
  return ret;
}
コード例 #3
0
ファイル: Policy_Tester.cpp プロジェクト: OspreyHub/ATCD
int
Policy_Tester::create_objects (void)
{
  CORBA::PolicyList poa_policy_list;
  poa_policy_list.length (3);

  // Create the priority policy using the RT-ORB.
  RTCORBA::Priority priority = this->rt_poa_properties_->priority ();
  poa_policy_list[0] =
    this->rt_orb_->create_priority_model_policy (RTCORBA::SERVER_DECLARED,
                                                 priority);

      // Create priority Banded Connection Policy.
  RTCORBA::PriorityBands poa_priority_bands =
    this->rt_poa_properties_->priority_bands ();

  poa_policy_list[1] =
    this->rt_orb_->create_priority_banded_connection_policy (poa_priority_bands);

      // Client Protocol Policy.
  RTCORBA::ProtocolList protocol_list;
  protocol_list.length (1);

  protocol_list[0].protocol_type = IOP::TAG_INTERNET_IOP;
  protocol_list[0].orb_protocol_properties =
    TAO_Protocol_Properties_Factory::create_orb_protocol_property (IOP::TAG_INTERNET_IOP);

  protocol_list[0].transport_protocol_properties =
    TAO_Protocol_Properties_Factory::create_transport_protocol_property (IOP::TAG_INTERNET_IOP,
                                                                         this->orb_->orb_core ());

  poa_policy_list[2] =
    this->rt_orb_->create_client_protocol_policy (protocol_list);

  CORBA::Object_var object =
    this->orb_->resolve_initial_references ("RootPOA");

  this->poa_ =
    PortableServer::POA::_narrow (object.in ());

  PortableServer::POAManager_var poa_mgr =
    PortableServer::POAManager::_nil ();

  object =
    this->poa_->create_POA ("Child_POA",
                            poa_mgr.in (),
                            poa_policy_list);

  this->child_poa_ =
    RTPortableServer::POA::_narrow (object.in ());

  // Create a Corba Object reference, using the policies
  // set at the POA level.
  object =
    this->child_poa_->create_reference ("IDL:Counter:1.0");

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Reference Created!\n")));

  if (!check_reference (object.in (),
                        "Unable to create Object!\n"))
    return -1;

  Counter_var base_object = Counter::_narrow (object.in ());

  if (!check_reference (base_object.in(),
                        "Unable to create a Object!\n"))
    return -1;

  CORBA::String_var ior =
    this->orb_->object_to_string (base_object.in ());

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Activated as <%C>\n"), ior.in ()));

  FILE *output_file = ACE_OS::fopen (this->rt_poa_properties_->ior_source (), "w");
  if (output_file == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Cannot open output file for writing IOR: %s"),
                       this->rt_poa_properties_->ior_source ()),
                      -1);
  ACE_OS::fprintf (output_file, "%s", ior.in ());
  ACE_OS::fclose (output_file);

  // Now we create an object that overrides some of the policies
  // set at the POA level.


  // Create a Corba Object reference, using the policies
  // set at the POA level.

  object =
    this->child_poa_->create_reference_with_priority
    ("IDL:Counter:1.0",
     this->rt_object_properties_->priority ());

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Reference Created!\n")));

  if (!check_reference (object.in (),
                        "Unable to create a Counter Object!\n"))
    return -1;

  Counter_var over_object = Counter::_narrow (object.in ());

  if (!check_reference (over_object.in(),
                        "Unable to create Object!\n"))
    return -1;


  CORBA::String_var o_ior =
    this->orb_->object_to_string (over_object.in ());

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Activated as <%C>\n"), o_ior.in ()));

  output_file = ACE_OS::fopen (this->rt_object_properties_->ior_source (), "w");

  if (output_file == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Cannot open output file for writing IOR: %s"),
                       this->rt_object_properties_->ior_source ()),
                      -1);
  ACE_OS::fprintf (output_file, "%s", o_ior.in ());
  ACE_OS::fclose (output_file);
  return 0;
}
コード例 #4
0
ファイル: variables.cpp プロジェクト: TeoTwawki/dltcep
int CChitemDlg::check_dialog(int check_or_scan)
{
  CString *lines;
  CString tmp;
  journal_type journal;
  int fh;
  int ret, gret;
  int linecount;
  int i,j;
  trigger trigger;
  action action;
  int num_or, strref;
  int first, last;
  loc_entry tmploc;
  bool got_continue;
  bool warn = (chkflg&WARNINGS)==0;

  gret=0;
  if(check_or_scan!=SCANNING)
  {
    if(check_or_scan==CHECKING) //no JOURNAL
    {
      //checking state headers
      for(i=0;i<the_dialog.statecount;i++)
      {
        switch(check_reference(the_dialog.dlgstates[i].actorstr,1,1,0))
        {
        case 1:
          log("Actor has invalid text in state #%d",i);
          gret=TREESTATE|i;
          break;
        case 2: case 5:
          log("Actor has no included text in state #%d",i);
          gret=TREESTATE|i;
        }
        
        if(chkflg&NOSTRUCT) continue;
        if(the_dialog.dlgstates[i].trnumber<1)
        {        
          log("No transitions in state #%d",i);
          gret=TREESTATE|i;
          continue;
        }
        num_or=the_dialog.dlgstates[i].trnumber+the_dialog.dlgstates[i].trindex;
        if(num_or<1 || num_or>the_dialog.transcount)
        {
          log("Invalid last index of transitions (%d) in state #%d",num_or,i);
          gret=TREESTATE|i;
          continue;
        }

        got_continue = false;
        first = the_dialog.dlgstates[i].trindex;
        last = first + the_dialog.dlgstates[i].trnumber;
        
        for (j=first;j<last;j++)
        {
          num_or=the_dialog.dlgtrans[j].flags;
          if(!(num_or&HAS_TEXT))
          {
            if ((j!=first) && got_continue && !(num_or&HAS_TRIGGER) )
            {
              log("Unconditional continue in state #%d (response #%d) overlaps a previous continue!", i, j);
              //gret=TREESTATE|i;
              gret=TRANSSTATE|j;
            }
            got_continue = true;
          }
        }
      }
    }
    //checking transition headers
    for(i=0;i<the_dialog.transcount;i++)
    {
      num_or=the_dialog.dlgtrans[i].flags;
      if(the_dialog.dlgtrans[i].playerstr<=0)
      {
        if(num_or&HAS_TEXT)
        {
          log("Transition #%d has no player string set, despite flags.",i);
          gret=TRANSSTATE|i;
        }
      }
      else
      {
        if(!(num_or&HAS_TEXT) )
        {
          log("Transition #%d has player string set, but no flags.",i);
          gret=TRANSSTATE|i;
        }
      }
      
      //checking transition trigger reference
      j=the_dialog.dlgtrans[i].trtrindex;
      if(j<0 || j>=the_dialog.header.numtrtrigger)
      {
        if(num_or&HAS_TRIGGER)
        {
          log("Transition #%d has a wrong trigger index (%d).",i,j);
          gret=TRANSSTATE|i;
        }
      }
      else if(j)
      {
        if(!(num_or&HAS_TRIGGER) && warn)
        {
          log("Transition #%d has trigger index (%d), but no flags.",i,j);
          gret=TRANSSTATE|i;
        }
      }
      
      //checking action reference
      j=the_dialog.dlgtrans[i].actionindex;
      if(j<0 || j>=the_dialog.header.numaction)
      {
        if((num_or&HAS_ACTION) )
        {
          log("Transition #%d has a wrong action index (%d).",i,j);
          gret=TRANSSTATE|i;
        }
      }
      else if(j)
      {
        if(!(num_or&HAS_ACTION) && warn)
        {
          log("Transition #%d has action index (%d), but no flags.",i,j);
          gret=TRANSSTATE|i;
        }
      }
      
      //checking journal string ref
      strref=the_dialog.dlgtrans[i].journalstr;
      if(strref<=0)
      {
        if(num_or&HAS_JOURNAL)
        {
          log("Transition #%d has no journal string set, despite flags.",i);
          gret=TRANSSTATE|i;
        }
      }
      else
      {
        if(!(num_or&HAS_JOURNAL) )
        {
          log("Transition #%d has journal string set, but no flags.",i);
          gret=TRANSSTATE|i;
        }
        else
        {
          if((check_or_scan==JOURNAL))
          {
            if((num_or&(HAS_QUEST|HAS_SOLVED))==HAS_QUEST)
            {
              if(journals.Lookup(strref,journal))
              {
                if(!journal.string.IsEmpty())
                {
                  if (journal.string.Find(itemname)<0)
                  {
                    journal.string+=", "+itemname;
                  }
                  journal.type|=HAS_QUEST;
                  journals[strref]=journal;
                }
              }
              else
              {
                journal.type=HAS_QUEST;
                journal.string=itemname;
                journals[strref]=journal;
              }
            }
            else
            {
              journal.type=0;
              journals.Lookup(strref,journal);
              journal.type|=num_or&(HAS_QUEST|HAS_SOLVED);
              journal.string="";
              journals[strref]=journal;
            }
            continue;
          }
        }
        
        switch(check_reference(strref,2,10,0) )
        {
        case 1:
          log("Invalid journal string in transition #%d (reference: %d).",i, strref);
          gret=TRANSSTATE|i;
          break;
        case 2:
          log("Deleted journal string in transition #%d (reference: %d).",i, strref);
          gret=TRANSSTATE|i;
          break;
        case 3:
          //if this isn't a quest journal entry, don't complain about missing title
          if ((num_or&(HAS_QUEST|HAS_SOLVED))!=0)
          {
            log("Titleless journal string in transition #%d (reference: %d).",i, strref);
            gret=TRANSSTATE|i;
          }
          break;
        }
      }
      
      //checking dialog linkage
      RetrieveResref(tmp,the_dialog.dlgtrans[i].nextdlg);
      num_or=the_dialog.dlgtrans[i].stateindex;
      if(the_dialog.dlgtrans[i].flags&LEAF_NODE)
      {
        if(!tmp.IsEmpty())
        {
          log("External dialog linkage %s:%d for leaf node (state #%d)",tmp,num_or,i);
          gret=TRANSSTATE|i;
        }
      }
      else
      {
        if(tmp==SELF_REFERENCE)
        {
          if(the_dialog.header.numstates<=num_or)
          {
            log("Invalid internal link to state %d in transition %d",num_or,i);
            gret=TRANSSTATE|i;
          }
        }
        else
        {
          if(dialogs.Lookup(tmp,tmploc) )
          {
            fh=locate_file(tmploc,0);
            if(the_dialog.CheckExternalLink(fh,num_or) )
            {
              log("Invalid external link to %s:state %d in transition %d",tmp,num_or,i);
              gret=TRANSSTATE|i;
            }
            close(fh);
          }
          else
          {
            log("Invalid dialog reference: %s in transition %d",tmp,i);
            gret=TRANSSTATE|i;
          }
        }
      }
    }
  }
  //syntax checking scripts
  if(check_or_scan!=JOURNAL)
  {
    for(i=0;i<the_dialog.sttriggercount;i++)
    {
      lines=explode(the_dialog.sttriggers[i], '\n', linecount);
      if(linecount==-1)
      {
        log("Out of memory");
        return -1;
      }
      num_or=0;
      for(j=0;j<linecount;j++)
      {
        if(lines[j].IsEmpty())
        {
          ret=-44; //empty top level condition
        }
        else
        {
          ret=compile_trigger(lines[j], trigger);
          if(!pst_compatible_var())
          {
            if((trigger.opcode&0x3fff)==TR_OR)
            {
              if(num_or)
              {
                ret=-42;
              }
              num_or=trigger.bytes[0];
              if (num_or<2 && check_or_scan!=SCANNING)
              {
                ret=-47;
              }
            }
            else if(num_or) num_or--;
          }
        }
        if(ret)
        {
          if(check_or_scan!=SCANNING)
          {
            log("Invalid top level condition: %s at line #%d in %d. state trigger block (%s)", lines[j],j+1,i, get_compile_error(ret));
            gret=STATETR|i; //found errors
          }
        }
        else
        {
          ret=check_or_scan_trigger(&trigger, handle_trigger(trigger.opcode), check_or_scan, j);
          if(ret && (check_or_scan!=SCANNING) )
          {
            log("Top level condition was: %s", lines[j]);
            gret=STATETR|i;
          }
        }
      }
      if(num_or)
      {
        log("Error: %s",get_compile_error(-42));
        gret=STATETR|i;
      }
      if(lines) delete[] lines;
    }
    
    for(i=0;i<the_dialog.trtriggercount;i++)
    {
      lines=explode(the_dialog.trtriggers[i], '\n', linecount);
      if(linecount==-1)
      {
        log("Out of memory");
        return -1;
      }
      num_or=0;
      for(j=0;j<linecount;j++)
      {
        ret=compile_trigger(lines[j], trigger);
        if(!pst_compatible_var())
        {
          if((trigger.opcode&0x3fff)==TR_OR)
          {
            if(num_or) ret=-42;
            num_or=trigger.bytes[0];
            if (num_or<2 && check_or_scan!=SCANNING)
            {
              ret=-47;
            }
          }
          else if(num_or) num_or--;
        }
        if(ret)
        {        
          if(check_or_scan!=SCANNING)
          {
            log("Invalid trigger: %s in line #%d in %d. transition trigger block (%s)",lines[j],j+1,i,  get_compile_error(ret));
            gret=TRANSTR|i;
          }
        }
        else
        {
          ret=check_or_scan_trigger(&trigger, handle_trigger(trigger.opcode), check_or_scan, j);
          if(ret && (check_or_scan!=SCANNING) )
          {
            tmp = lasterrormsg;
            log("Transition trigger was: %s", lines[j]);
            lasterrormsg = tmp + "\n" + lasterrormsg;
            gret=TRANSTR|i;
          }
        }
      }
      if(num_or)
      {
        log("Invalid trigger: in line #%d in %d. transition trigger block (%s)",j, i, get_compile_error(-42));
        gret=TRANSTR|i;
      }
      if(lines) delete[] lines;
    }
  }
  //num_or stores the previous action opcode initializing it to non-special
  num_or=0; 

  for(i=0;i<the_dialog.actioncount;i++)
  {
    lines=explode(the_dialog.actions[i], '\n', linecount);
    if(linecount==-1)
    {
      log("Out of memory");
      return -1;
    }

    for(j=0;j<linecount;j++)
    {
      ret=compile_action(lines[j], action, false);
      if(ret)
      {
        if(check_or_scan!=CHECKING) continue;
        log("Invalid action: %s in line #%d in %d. action block (%s)", lines[j],j+1,i,get_compile_error(ret));
        gret=ACTIONBL|i;
      }
      else
      {
        if(check_or_scan!=JOURNAL)
        {
          ret=check_or_scan_action(&action, handle_action(action.opcode), check_or_scan, j);
          if(check_or_scan!=CHECKING) continue;
          if(ret)
          {
            log("Action was: %s", lines[j]);
            gret=ACTIONBL|i;
            continue;
          }
        }
      }
      
      if(check_or_scan==JOURNAL)
      {
        switch(action.opcode)
        {
        case AC_REMOVE_JOURNAL_IWD:case AC_QUESTDONE_IWD:
          if(has_xpvar())
          {
            journal.type=0;
            journals.Lookup(action.bytes[0], journal);
            journal.string="";
            journal.type|=HAS_SOLVED;
            journals[action.bytes[0]]=journal;
          }
          break;
        case AC_REMOVE_JOURNAL_BG: case AC_QUESTDONE_BG:
          if(!has_xpvar())
          {
            journal.type=0;
            journals.Lookup(action.bytes[0], journal);
            journal.string="";
            journal.type|=HAS_SOLVED;
            journals[action.bytes[0]]=journal;
          }
          break;
        case AC_ADD_JOURNAL:
          if(has_xpvar() || (action.bytes[3]==JT_QUEST))
          {
            if(journals.Lookup(action.bytes[0],journal))
            {
              if(!journal.string.IsEmpty())
              {
                if (journal.string.Find(itemname)<0)
                {
                  journal.string+=", "+itemname;
                }
              }
              journal.type|=HAS_QUEST;
              journals[action.bytes[0]]=journal;
            }
            else
            {
              journal.string=itemname;
              journal.type=HAS_QUEST;
              journals[action.bytes[0]]=journal;
            }
          }
          else
          {
            if (action.bytes[3]==JT_DONE)
            {
              journal.type=0;
              journals.Lookup(action.bytes[0],journal);
              journal.string="";
              journal.type|=HAS_SOLVED;
              journals[action.bytes[0]]=journal;
            }
          }    
        }
        continue;
      }

      if(chkflg&NOCUT) continue;
      if(action.opcode==AC_STCUTMD)
      {
        if((num_or!=AC_CLRACT) && (num_or!=AC_CLRALLACT))
        {
          log("Invalid action: StartCutSceneMode() without ClearActions() in line #%d in %d. action block", j+1,i);
          gret=ACTIONBL|i;
        }
        else if(action.opcode==AC_STARTCUT)
        {
          if(num_or!=AC_STCUTMD)
          {
            log("StartCutScene() without StartCutSceneMode() in line #%d in %d. action block", j+1,i);
            gret=ACTIONBL|i;
          }
        }
      }
      if((action.opcode==AC_STCUTMD) || (action.opcode==AC_STARTCUT) || (action.opcode==AC_CLRACT) || (action.opcode==AC_CLRALLACT)) num_or=action.opcode;
    }
    if(lines) delete[] lines;
  }

  return gret;
}