Beispiel #1
0
string JackDriver::MatchPortName(const char* name, const char** ports, int alias, const std::string& type)
{
    char alias1[REAL_JACK_PORT_NAME_SIZE+1];
    char alias2[REAL_JACK_PORT_NAME_SIZE+1];
    char* aliases[2];
  
    aliases[0] = alias1;
    aliases[1] = alias2;
  
    for (int i = 0; ports && ports[i]; ++i) {
        
        jack_port_id_t port_id2 = fGraphManager->GetPort(ports[i]);
        JackPort* port2 = (port_id2 != NO_PORT) ? fGraphManager->GetPort(port_id2) : NULL;
        
        if (port2) {
            int res = port2->GetAliases(aliases);
            string name_str;
            if (res >= alias) {
                name_str = string(aliases[alias-1]);
            } else {
                name_str = string(ports[i]);
            }
            string sub_name = RemoveLast(name);
            if ((name_str.find(sub_name) != string::npos) && (type == string(port2->GetType()))) {
                return name_str;
            }
        }
    }
    
    return "";
}
Beispiel #2
0
bool DoubleValidator::TransferToWindow() {
	auto str = wxString::Format("%g", *value);
	if (decimal_sep != '.')
		std::replace(str.begin(), str.end(), (wxChar)'.', decimal_sep);
	if (str.find(decimal_sep) != str.npos) {
		while (str.Last() == '0')
			str.RemoveLast();
	}
	static_cast<wxTextCtrl *>(GetWindow())->SetValue(str);
	return true;
}
Beispiel #3
0
void List::RemoveAt( int index )
{
    if( index == 0 )
        RemoveFirst();
    else if( index == count - 1 )
        RemoveLast();
    else {
        int curItemIdx = 0;
        ListItem* curItem = first;
        while( curItem != 0 && curItemIdx < index )
        {
            curItem = curItem->nextItem;
            curItemIdx++;

        }
        curItem->previousItem->nextItem = curItem->nextItem;
        curItem->nextItem->previousItem = curItem->previousItem;
        free( (void*)curItem );
        count--;
    }
}
Beispiel #4
0
void GStringList::RemoveAll()
{
	int n = Size();
	for(int i=0; i<n;i++)
		delete (GString *)RemoveLast();
}
Beispiel #5
0
int ServerQAction(int *addr, short *port, int *op, int *flags, int *jobid, 
                  void *p1, void *p2, void *p3, void *p4, void *p5, void *p6, void *p7, void *p8)
{
  int status;
  switch (*op)
  {
  case SrvRemoveLast:
  {
    status = RemoveLast();
    break;
  }
  case SrvAbort:
    {
      ServerSetDetailProc(0);
      KillThread();
      AbortJob(GetCurrentJob());
      ReleaseCurrentJob();
      SetCurrentJob(0);
      if (*(int *)p1)
      {
        SrvJob *job;
        while ((job = NextJob(0)) != 0)
          AbortJob(job);
      }
      status = StartThread();
      break;
    }
  case SrvAction:
    {

      SrvActionJob job;
      job.h.addr  = MdsGetClientAddr();
      job.h.port  = *port;
      job.h.op    = *op;
      job.h.length = sizeof(job);
      job.h.flags = *flags;
      job.h.jobid = *jobid;
      job.tree = strcpy(malloc(strlen((char *)p1)+1),(char *)p1);
      job.shot = *(int *)p2;
      job.nid = *(int *)p3;
      status = QJob((SrvJob *)&job);
      break;
    }
  case SrvClose:
    {
      SrvCloseJob job;
      job.h.addr  = MdsGetClientAddr();
      job.h.port  = *port;
      job.h.op    = *op;
      job.h.length = sizeof(job);
      job.h.flags = *flags;
      job.h.jobid = *jobid;
      status = QJob((SrvJob *)&job);
      break;
    }
  case SrvCreatePulse:
    {
      SrvCreatePulseJob job;
      job.h.addr  = MdsGetClientAddr();
      job.h.port  = *port;
      job.h.op    = *op;
      job.h.length = sizeof(job);
      job.h.flags = *flags;
      job.h.jobid = *jobid;
      job.tree = strcpy(malloc(strlen((char *)p1)+1),(char *)p1);
      job.shot = *(int *)p2;
      status = QJob((SrvJob *)&job);
      break;
    }
  case SrvSetLogging:
    {
      Logging = *(int *)p1;
      break;
    }
  case SrvCommand:
    {
      SrvCommandJob job;
      job.h.addr  = MdsGetClientAddr();
      job.h.port  = *port;
      job.h.op    = *op;
      job.h.length = sizeof(job);
      job.h.flags = *flags;
      job.h.jobid = *jobid;
      job.table = strcpy(malloc(strlen((char *)p1)+1),(char *)p1);
      job.command = strcpy(malloc(strlen((char *)p2)+1),(char *)p2);
      status = QJob((SrvJob *)&job);
      break;
    }
  case SrvMonitor:
    {
      SrvMonitorJob job;
      job.h.addr  = MdsGetClientAddr();
      job.h.port  = *port;
      job.h.op    = *op;
      job.h.length = sizeof(job);
      job.h.flags = *flags;
      job.h.jobid = *jobid;
      job.tree = strcpy(malloc(strlen((char *)p1)+1),(char *)p1);
      job.shot = *(int *)p2;
      job.phase  = *(int *)p3;
      job.nid  = *(int *)p4;
      job.on   = *(int *)p5;
      job.mode = *(int *)p6;
      job.server = strcpy(malloc(strlen((char *)p7)+1),(char *)p7);
      job.status = *(int *)p8; 
      status = QJob((SrvJob *)&job);
      break;
    }
  case SrvShow:
    {
      status = ShowCurrentJob((struct descriptor_xd *)p1);
      break;
    }
  case SrvStop:
    {
      printf("%s, Server stop requested\n",Now());
      exit(0);
      break;
    }
  }
  return status;
}