Exemple #1
0
bool SymbolTable::ResolveExternTable(SymbolTable &RefST, CallBackFunction)
{
	bool fRetVal = true;

	//Go through each extern symbol in the parameter symboltable
	for(SymbolMap::iterator ExtSymbolIter = ExternSymbols.begin(); ExtSymbolIter != ExternSymbols.end(); ExtSymbolIter++)
	{
		//For each extern symbol, see if it's resolved in this symboltable
		SymbolMap::iterator SymbolIter = RefST.ResolvedSymbols.find(ExtSymbolIter->first);
		//Also make sure that it is a label. Other types can't be externally linked.
		if(SymbolIter != RefST.ResolvedSymbols.end() && SymbolIter->second->SymbolType == SymLabel)
		{
			//Found it, update the symbol.
			if(ExtSymbolIter->second->pSymbol)
			{
				CallBack(Error, string("Multiply defined external symbol: ")+=(ExtSymbolIter->first), ExtSymbolIter->second->LocationStack);
				CallBack(Info, "See definition.", ExtSymbolIter->second->pSymbol->LocationStack);
				CallBack(Info, "See definition.", SymbolIter->second->LocationStack);
				fRetVal = false;
			}
			else
				ExtSymbolIter->second->pSymbol = SymbolIter->second;
		}
	}

	return fRetVal;
}
Exemple #2
0
/*
 * Cancel hes been received, still waiting for response.
 * Do not fail if timeout
 */
static void
StunState_Cancelled(STUN_TRANSACTION_DATA* trans,
                    STUN_SIGNAL            sig,
                    uint8_t*               payload)
{
  switch (sig)
  {
  case STUN_SIGNAL_BindResp:
  {
    StunRespStruct* pMsgIn = (StunRespStruct*)payload;
    StunMessage*    pResp  = &pMsgIn->stunRespMessage;

    StopTimer(trans, STUN_SIGNAL_TimerRetransmit);
    trans->ttl = pMsgIn->ttl;
    if ( StoreBindResp(trans, pResp) )
    {
      BindRespCallback(trans, (struct sockaddr*)&pMsgIn->srcAddr);
    }
    else
    {
      CallBack(trans, StunResult_MalformedResp);
    }
    trans->stats.BindRespReceived_AfterCancel++;
    SetNextState(trans, STUN_STATE_Idle);
    break;
  }

  case STUN_SIGNAL_BindRespError:
  {
    CallBack(trans, StunResult_BindFail);
    trans->stats.BindRespErrReceived++;
    SetNextState(trans, STUN_STATE_Idle);
    break;
  }

  case STUN_SIGNAL_TimerRetransmit:
  {
    CancelRetryTimeoutHandler(trans);
    break;
  }

  case STUN_SIGNAL_DeAllocate:
  {
    StopTimer(trans, STUN_SIGNAL_TimerRetransmit);
    SetNextState(trans, STUN_STATE_Idle);
    break;
  }
  case STUN_SIGNAL_Cancel:
    /* Ignore */
    break;

  default:
    StunAllState(trans, sig);
    break;
  }

} /* StunState_Cancelled() */
Exemple #3
0
void ListDir(const std::string& path, bool directories, void (*CallBack)(const std::string& filename, void* param), void* param, std::list<std::string> *liste)
{
    namespace bfs = boost::filesystem;
    bfs::path fullPath(path);

    if(!fullPath.has_extension())
        return;

    bfs::path parentPath = fullPath.parent_path();
    std::string extension = fullPath.extension().string();
    std::transform(extension.begin(), extension.end(), extension.begin(), tolower);

    for(bfs::directory_iterator it = bfs::directory_iterator(parentPath); it != bfs::directory_iterator(); ++it)
    {
        if(bfs::is_directory(it->status()) && !directories)
            continue;

        bfs::path curPath = it->path();
        curPath.make_preferred();

        std::string curExt = curPath.extension().string();
        std::transform(curExt.begin(), curExt.end(), curExt.begin(), tolower);
        if(curExt != extension)
            continue;

        if(CallBack)
            CallBack(curPath.string(), param);
        if(liste)
            liste->push_back(curPath.string());
    }

    if(liste)
        liste->sort();
}
Exemple #4
0
static void
CancelRetryTimeoutHandler(STUN_TRANSACTION_DATA* trans)
{
  STUN_CLIENT_DATA* client = trans->client;
  uint32_t max;

  if (trans->stunBindReq.stuntrace)
  {
    max = STUNTRACE_MAX_RETRANSMITS;
  }
  else
  {
    max = STUNCLIENT_MAX_RETRANSMITS;
  }


  if ( (trans->retransmits < max)
       && (stunTimeoutList[trans->retransmits] != 0) ) /* can be 0 terminated if
                                                        * using fewer
                                                        * retransmits
                                                        **/
  {
    StartNextRetransmitTimer(trans);
    trans->retransmits++;
  }
  else
  {
    StunPrint(client->logUserData, client->Log_cb, StunInfoCategory_Trace,
              "<STUNCLIENT:%02d> Cancel complete", trans->inst);
    CallBack(trans, StunResult_CancelComplete);
    SetNextState(trans, STUN_STATE_Idle);
  }
}
Exemple #5
0
void Timer::TimerProc ()
{
    if (bStop)
        Stop();

    CallBack(Context);
}
/**
Provides support for passing notification events to clients of the cards functions.
*/
void TSDIOFunctionCallback::DoStateChange(TPBusState aNewState, TInt aReasonCode)
	{
	if (iBusState != aNewState)
		{
		iBusState = aNewState;
		SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Calling Back to client. iBusState = %d", iBusState)); // @SymTraceDataInternalTechnology
		switch(iBusState)
			{
			case EPBusCardAbsent:
				SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusCardAbsent (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
				CallBack(ESdioNotifyCardRemoved);
				break;

			case EPBusOff:
				SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusOff (%d)", aReasonCode)); // @SymTraceDataInternalTechnology

				switch (aReasonCode)
					{
					case KErrNone:
					case KErrTimedOut:
						CallBack(ESdioNotifyPowerDown);
						break;
					case KErrNotReady:
						// card detected following door close
						CallBack(ESdioNotifyCardInserted);
						break;
					case KErrAbort:
						CallBack(ESdioNotifyEmergencyPowerDown);
						break;
					default:
						CallBack(ESdioNotifyPowerUp);
						break;
					}
				break;

			case EPBusPoweringUp:
				SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusPoweringUp (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
				break;

			case EPBusOn:
				SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusOn (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
				CallBack(ESdioNotifyPowerUp);
				break;

			case EPBusPsuFault:
				SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusPsuFault (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
				CallBack(ESdioNotifyPsuFault);
				break;

			case EPBusPowerUpPending:
				SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusPowerUpPending (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
				break;
			
			default:	
				SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EWarning), "Unknown State Change (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
				break;
			}
		}
	}
Exemple #7
0
/**
  Return a keypress or optionally timeout if a timeout value was passed in.
  An optional callback function is called every second when waiting for a
  timeout.

  @param  Key           EFI Key information returned
  @param  TimeoutInSec  Number of seconds to wait to timeout
  @param  CallBack      Callback called every second during the timeout wait

  @return EFI_SUCCESS  Key was returned
  @return EFI_TIMEOUT  If the TimoutInSec expired

**/
EFI_STATUS
EFIAPI
EblGetCharKey (
  IN OUT EFI_INPUT_KEY            *Key,
  IN     UINTN                    TimeoutInSec,
  IN     EBL_GET_CHAR_CALL_BACK   CallBack   OPTIONAL
  )
{
  EFI_STATUS    Status;
  UINTN         WaitCount;
  UINTN         WaitIndex;
  EFI_EVENT     WaitList[2];

  WaitCount   = 1;
  WaitList[0] = gST->ConIn->WaitForKey;
  if (TimeoutInSec != 0) {
    // Create a time event for 1 sec duration if we have a timeout
    gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &WaitList[1]);
    gBS->SetTimer (WaitList[1], TimerPeriodic, EFI_SET_TIMER_TO_SECOND);
    WaitCount++;
  }

  for (;;) {
    Status = gBS->WaitForEvent (WaitCount, WaitList, &WaitIndex);
    ASSERT_EFI_ERROR (Status);

    switch (WaitIndex) {
    case 0:
      // Key event signaled
      Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);
      if (!EFI_ERROR (Status)) {
        if (WaitCount == 2) {
          gBS->CloseEvent (WaitList[1]);
        }
        return EFI_SUCCESS;
      }
      break;

    case 1:
      // Periodic 1 sec timer signaled
      TimeoutInSec--;
      if (CallBack != NULL) {
        // Call the users callback function if registered
        CallBack (TimeoutInSec);
      }
      if (TimeoutInSec == 0) {
        gBS->CloseEvent (WaitList[1]);
        return EFI_TIMEOUT;
      }
      break;
    default:
      ASSERT (FALSE);
    }
  }
}
Exemple #8
0
void MKS_SxCxSyCySxy(int w, int h, unsigned char *s,void (*CallBack)(void))
{
 unsigned x1,y1,x2,y2,xy,xy2;
 double aux1,aux2;
 double *cos_sin_x_t;
 int k;
 int x,y;

 cos_sin_x_t=(double *)alloca((w+1)*sizeof(double));
 if (!cos_sin_x_t)
    return;
 x1=x2=0;
 for (x=w; x; --x)
    {
     cos_sin_x_t[x]=(t255cos(x2)+t255sin(x1))*tsinConst;
     if (!(x&3)) x1++;
     MA1_IncAng(x1,4);
     MA1_IncAng(x2,3);
    }
 CallBack();

 y1=y2=xy=0;
 for (k=0,y=0;y<h;y++)
    {
     xy2=xy;
     aux2=(t255cos(y1)+t255sin(y2))*tsinConst;
     for (x=w; x; k++,--x)
        {
         aux1=cos_sin_x_t[x];
         s[k]=64+(int)(10*(aux1+aux2+tsin(xy2)));
         if (x&1) xy2++;
         MA1_IncAng(xy2,3);
        }
     if (y&1) { y1++; y2++; xy++; }
     MA1_IncAng(y1,2);
     MA1_IncAng(y2,2);
     MA1_IncAng(xy,3);
     CallBack();
    }
}
Exemple #9
0
/* That's the original code (3.08 s for the total init)

   for (k=0,y=0;y<pla3h;y++)
   for (x=0;x<pla3w;k++,x++)
      {
       PLA3_Map[k]=64+10*( sin(x/30) + cos(y/46) +
         cos(x/37) + sin(y/70) +
         sin((x+y)/43) +
         cos(hypot(256-x,150-y)/20)
         );
      }
*/
void MKS_SxCxSyCySxyCh(int w, int h, unsigned char *s,void (*CallBack)(void))
{
 double x1,y1,x2,y2,xy,xy2;
 double aux1,aux2;
 double *cos_sin_x_t;
 int k;
 int x,y,w2,h2;

 w2=w>>1; h2=h>>1;
 // Precalculate the sin(x/37)+cos(x/30) values (ones and not pla3h times)
 cos_sin_x_t=(double *)alloca((w+1)*sizeof(double));
 if (!cos_sin_x_t)
    return;
 x1=x2=0;
 for (x=w; x; --x)
    {
     cos_sin_x_t[x]=(t255cos(x2)+t255sin(x1))*tsinConst;
     MA1_IncAngRad(x1,1/30.0);
     MA1_IncAngRad(x2,1/37.0);
    }

 CallBack();
 y1=y2=xy=0;
 for (k=0,y=0;y<h;y++)
    {
     xy2=xy;
     aux2=(t255cos(y1)+t255sin(y2))*tsinConst;
     for (x=w; x; k++,--x)
        {
         aux1=cos_sin_x_t[x];
         s[k]=64+(int)(10*(aux1+aux2+tsin(xy2)+cos(hypot(w2-x,h2-y)/20)));
         MA1_IncAngRad(xy2,1/43.0);
        }
     MA1_IncAngRad(y1,1/46.0);
     MA1_IncAngRad(y2,1/70.0);
     MA1_IncAngRad(xy,1/43.0);
     CallBack();
    }
}
Exemple #10
0
bool SymbolTable::Check(CallBackFunction) const
{
	bool fRetVal = true;

	//check all the unresolved Symbols
	for(SymbolMap::const_iterator SymbolIter = UnresolvedSymbols.begin(); SymbolIter != UnresolvedSymbols.end(); SymbolIter++)
	{
		CallBack(Error, string("Unresolved symbol: ")+=(SymbolIter->first), SymbolIter->second->LocationStack);
		fRetVal = false;
	}

	return fRetVal;
}
Exemple #11
0
CComChannel* CKadHandler::PrepareChannel(const CNodeAddress& Address, CKadNode* pNode)
{
	CComChannel* pChannel = NULL;
	if(CSafeAddress* pAddress = Address.GetAssistent()) // if node is firewalled
	{
		// Note: we can not send a direct packet we must always stream
		// we dont want to use assistant nodes to relay packets, its enough thay broker the connection for us

		if(!pAddress->IsValid())
			return NULL; //node dont have an assistant and is not directly reachable, we cant communicate right now

		const CMyAddress* pMyAddress = GetParent<CKademlia>()->Fwh()->GetAddress(Address.GetProtocol());
		if(pMyAddress->GetAssistent()) // and we are two
		{
			GetParent<CKademlia>()->Fwh()->SendTunnel(Address, false);
			if(pAddress->GetPort() == 0)
				return NULL; // node can't tunnel, we could only use a callback if we ware open, but we are closed, so we cant communicate at all
			pChannel = Rendevouz(Address); 
		}
		else
		{
			GetParent<CKademlia>()->Fwh()->SendTunnel(Address, true);
			pChannel = CallBack(Address, false);
		}
	}
	else
		pChannel = Connect(Address);
	
	if(pChannel)
	{
		bool bAdded = false;
		SKadData* pData = pChannel->GetData<SKadData>(&bAdded);
		ASSERT(bAdded);

		pData->pNode = pNode;
		pChannel->AddUpLimit(pNode->GetUpLimit());
		pChannel->AddDownLimit(pNode->GetDownLimit());

		SendInit(pNode, pChannel);
		
		// Encrypt and authenticate all channels by default
		bool bEncrypt = true;
		bool bAuthenticate = true;
		pChannel->SetQueueLock(true);

		m_KeyExchanges.insert(TExchangeMap::value_type(SKadNode(pNode, pChannel), SKeyExchange(bEncrypt, bAuthenticate, 0)));
		ResumeExchange(pNode);
	}
	return pChannel;
}
Exemple #12
0
unsigned int FindFiles(DIR_ENTRY_LIST **list, const char *dir, const char *mask, void CallBack(DIR_ENTRY_LIST *ptr))
{
	DIR_ENTRY_LIST *top = NULL;
	unsigned int i = 0;
	
	char find[256];
	strcpy(find, dir);
	strcat(find, mask);
	
	DIR_ENTRY de;
	unsigned int err;
	LockSched();
	if (FindFirstFile(&de, find, &err))
	{
		DIR_ENTRY_LIST *prev, *de_list;
		top = malloc(sizeof(DIR_ENTRY_LIST));
		de_list = top;
		do
		{
			strcpy(de_list->path, de.folder_name);
			strcat(de_list->path, "\\");
			strcat(de_list->path, de.file_name);
			strcpy(de_list->dir,   de.folder_name);
			strcpy(de_list->fname, de.file_name);
			
			
			de_list->file_size        = de.file_size;
			de_list->file_attr        = de.file_attr;
			de_list->create_date_time = de.create_date_time;
			
			if (CallBack) CallBack(de_list);
			
			
			prev = de_list;
			de_list->next = malloc(sizeof(DIR_ENTRY_LIST));
			de_list = de_list->next;
			de_list->prev = prev;
			i++;
		}
		while (FindNextFile(&de, &err));
		top->prev = NULL;
		mfree(prev->next);
		prev->next = NULL;
	}
	UnlockSched();
	FindClose(&de, &err);
	*list = top;
	return i;
}
Exemple #13
0
void timer::tick(U16 ms)
{
  if(!_running)
    return;

  _count += ms;

  if(_callback_set & !_isr_flag)
  {
    if(_count >= ms)
    {
      _isr_flag = true;
      CallBack();
    }
  }
}
Exemple #14
0
// Process callback and call dispatcher
void MuxTimer::_callback()
{
  // Define a vector containing all new callbacks
  std::vector<CallBack> new_callbacks;

  // Get the current callback information
  auto callback = getCallBacks().begin();

  // Get the callback time
  TimePoint callback_time = callback->time;

  // Get the current time
  TimePoint current_time = Clock::now();

  // Create a timer event for this callback
  const TimerEvent evt;

  // Go through each channel associated with this callback
  auto range = getCallBacks().equal_range(*callback);
  for (auto it = range.first; it != range.second; ++it)
  {
    // Get the channel id
    int id = callback->id;

    // Call the dispatcher for this channel
    TimerDispatcher::dispatch(id, evt);

    // Get the period for this channel
    long period = getChannels()[id - 1].period;

    // Compute this channel next callback time
    TimePoint next_time = current_time + MilliSeconds(period);

    // Push this future callback in the vector
    new_callbacks.push_back(CallBack(id, next_time));
  }

  // Erase already processed callbacks
  getCallBacks().erase(*callback);

  // Push all future callback to the callback container
  for (CallBack cb : new_callbacks)
  {
    // Insert the next callback for this channel
    getCallBacks().insert(cb);
  }
}
Exemple #15
0
void MKS_SinDisCentSf(int w, int h, unsigned char *s, int sw, int sh,
                      double Bsize, void (*CallBack)())
{
 int temp,i,j,t2;

 Bsize=MA1_FromRad(1/Bsize);
 for (i=0; i<h; i++)
    {
     t2=(sh-i)*(sh-i);
     for (j=w; j; s++,--j)
      {
       temp=Bsize*sqrt(t2+(sw-j)*(sw-j));
       *s=(t255sin(temp%TrigTableSize)+255)>>3;
      }
     CallBack();
    }
}
Exemple #16
0
void MuxTimer::_initialize()
{
  // Change the running flag to true
  getStatus() = true;

  // Get the current time
  TimePoint current_time = Clock::now();

  // Go through each channel
  for (Channel& channel : getChannels())
  {
    // Compute this channel next callback time
    TimePoint callback_time = current_time + MilliSeconds(channel.period);

    // Insert this callback in the container
    getCallBacks().insert(CallBack(channel.id, callback_time));
  }
}
Exemple #17
0
static void
CommonRetryTimeoutHandler(STUN_TRANSACTION_DATA* trans,
                          StunResult_T           stunResult,
                          const char*            errStr,
                          STUN_STATE             FailedState)
{
  STUN_CLIENT_DATA* client = trans->client;

  uint32_t max;

  if (trans->stunBindReq.stuntrace)
  {
    max = STUNTRACE_MAX_RETRANSMITS;
  }
  else
  {
    max = STUNCLIENT_MAX_RETRANSMITS;
  }

  if ( (trans->retransmits < max)
       && (stunTimeoutList[trans->retransmits] != 0) ) /* can be 0 terminated if
                                                        * using fewer
                                                        * retransmits
                                                        **/
  {
    char peer [SOCKADDR_MAX_STRLEN] = {0,};
    sockaddr_toString( (struct sockaddr*) &trans->stunBindReq.serverAddr, peer,
                       sizeof (peer), true );

    StunPrint(client->logUserData, client->Log_cb, StunInfoCategory_Trace,
              "<STUNCLIENT:%02d> Retrans %s Retry: %d to %s",
              trans->inst, errStr, trans->retransmits + 1, peer);
    RetransmitLastReq(trans, &trans->stunBindReq.serverAddr);
    StartNextRetransmitTimer(trans);
    trans->retransmits++;
    trans->stats.Retransmits++;
  }
  else
  {
    CallBack(trans, stunResult);
    SetNextState(trans, FailedState);
    trans->stats.Failures++;
  }
}
Exemple #18
0
void MKS_C2ySySiCx(int w, int h, unsigned char *s, void (*CallBack)())
{
 int temp;
 int i,j,X,Y;

 temp=30;
 for (Y=0,i=h; i; --i)
    {
     int Yv=cos_table[Y*2]+sin_table[Y]+sin_table[temp];
     for (X=0,j=w; j; s++,--j)
        {
         *s=(Yv+cos_table[X]+1020)>>4;
         MA1_IncAng(X,8);
        }
     MA1_IncAng(Y,6);
     MA1_IncAng(temp,5);
     CallBack();
    }
}
Exemple #19
0
Symbol *SymbolTable::ReferenceSymbol(const LocationVector &LocationStack, const string &ssymbol, CallBackFunction)
{
	bool fWarn = false;
	string sSymbol = ssymbol;
	if(sSymbol.size() > MAX_IDENTIFIER_CHAR)
	{
		sSymbol.resize(MAX_IDENTIFIER_CHAR);
		fWarn = true;
	}
	SymbolMap::iterator SymbolIter;

	//See if the symbol has been resolved
	SymbolIter = ResolvedSymbols.find(sSymbol);
	if(SymbolIter != ResolvedSymbols.end())
		//the symbol has been resolved already
		return SymbolIter->second;
	SymbolIter = ExternSymbols.find(sSymbol);
	if(SymbolIter != ExternSymbols.end())
		//the symbol has been resolved already
		return SymbolIter->second;
	else
	{	//The symbol has not been resolved yet
		//see if the symbol has been referenced before
		SymbolIter = UnresolvedSymbols.find(sSymbol);
		if(SymbolIter != UnresolvedSymbols.end())
			//the symbol was referenced already
			return SymbolIter->second;
		else
		{	//this is the first reference to this symbol. Create a new symbol for it
			if(fWarn)
			{
				sprintf(sMessageBuffer, "Identifier '%.63s' truncated to %u characters.", sSymbol.c_str(), MAX_IDENTIFIER_CHAR);
				CallBack(Warning, sMessageBuffer, LocationStack);
			}
			Symbol *pSymbol = new Symbol(LocationStack, sSymbol, Addressability);
			//Add the symbol to the unresolved symbol table
			UnresolvedSymbols.insert( SymbolMap::value_type(sSymbol, pSymbol) );
			return pSymbol;
		}
	}
}
Exemple #20
0
int ReadTreeRecursive(git_repository &repo, git_tree * tree, CStringA base, int (*CallBack) (const unsigned char *, const char *, int, const char *, unsigned int, int, void *),void *data)
{
	size_t count = git_tree_entrycount(tree);
	for (int i = 0; i < count; i++)
	{
		const git_tree_entry *entry = git_tree_entry_byindex(tree, i);
		if (entry == NULL)
			continue;
		int mode = git_tree_entry_attributes(entry);
		if( CallBack(git_tree_entry_id(entry)->id,
			base,
			base.GetLength(),
			git_tree_entry_name(entry),
			mode,
			0,
			data) == READ_TREE_RECURSIVE
		  )
		{
			if(mode&S_IFDIR)
			{
				git_object *object = NULL;
				git_tree_entry_2object(&object, &repo, entry);
				if (object == NULL)
					continue;
				CStringA parent = base;
				parent += git_tree_entry_name(entry);
				parent += "/";
				ReadTreeRecursive(repo, (git_tree*)object, parent, CallBack, data);
				git_object_free(object);
			}
		}

	}

	return 0;
}
Exemple #21
0
_CPU_NANOD_LIB_HIFI_COMMON_
void HIFI_DmaIsr()
{
    uint32 channel;
    uint32 rawStatus;
    pFunc CallBack;

    do
    {
        rawStatus = (uint32)(DmaReg2->StatusTfr);
        DmaReg2->ClearTfr = rawStatus;

        channel = 0;
        do
        {
            for(; channel < DMA_CHN_MAX; channel++)
            {
                if (((uint32)(rawStatus)) & ((uint32)(0x01) << channel))
                {
                    rawStatus &= ~(0x01u << channel);
                    break;
                }
            }

            CallBack = HIFI_DmaIsrCallBack[channel];
            if (CallBack)
            {
                HIFI_DmaIsrCallBack[channel] = 0;
                CallBack();
            }

        }while (rawStatus & 0x07);

    }while((uint32)(DmaReg->StatusTfr) & 0x07);

}
void EditFrame::HideView()
{
    hide();

    CallBack(EB_ON_CLOSE);
}
void EditFrame::ShowView()
{
    show();

    CallBack(EB_ON_SHOW);
}
Exemple #24
0
} PLUGINFUNCTIONEND

PLUGINFUNCTION(Call)
{
    // Prepare input
    SystemProc *proc = PrepareProc(TRUE);
    if (proc == NULL)
      return;

    SYSTEM_LOG_ADD(_T("Call "));
    SYSTEM_LOG_ADD(proc->DllName);
    SYSTEM_LOG_ADD(_T("::"));
    SYSTEM_LOG_ADD(proc->ProcName);
    //SYSTEM_LOG_ADD(_T("\n"));
    SYSTEM_LOG_POST;
    if (proc->ProcResult != PR_CALLBACK)
        ParamAllocate(proc);
    ParamsIn(proc);

#ifndef SYSTEM_X64
    // Make the call
    if (proc->ProcResult != PR_ERROR)
    {
        switch (proc->ProcType)
        {
        case PT_NOTHING:
            if (proc->ProcResult == PR_CALLBACK) 
                proc = CallBack(proc);
            break;
        case PT_PROC:
        case PT_VTABLEPROC:
            proc = CallProc(proc); break;
        case PT_STRUCT:
            CallStruct(proc); break;
        }
    }

    // Process output
    if ((proc->Options & POPT_ALWRETURN) != 0)
    {
        // Always return flag set - return separate return and result
        ParamsOut(proc);
        GlobalFree(system_pushstring(GetResultStr(proc)));
    } else
    {
        if (proc->ProcResult != PR_OK)
        {
            ProcParameter pp;
            // Save old return param
            pp = proc->Params[0];

            // Return result instead of return value
            proc->Params[0].Value = BUGBUG64(int) GetResultStr(proc);
            proc->Params[0].Type = PAT_TSTRING;
            // Return all params
            ParamsOut(proc);

            // Restore old return param
            proc->Params[0] = pp;
        } else 
            ParamsOut(proc);        
    }

    if (proc->ProcResult != PR_CALLBACK)
    {
        // Deallocate params if not callback
        ParamsDeAllocate(proc);

        // if not callback - check for unload library option
        if ((proc->Options & POPT_UNLOAD) 
            && (proc->ProcType == PT_PROC) 
            && (proc->Dll != NULL)) 
            FreeLibrary(proc->Dll); // and unload it :)

        // In case of POPT_ERROR - first pop will be proc error
        if ((proc->Options & POPT_ERROR) != 0) system_pushint(LastError);
    }    

    // If proc is permanent?
    if ((proc->Options & POPT_PERMANENT) == 0)
        GlobalFree((HANDLE) proc); // No, free it
#else
    // Fake the behavior of the System plugin for the LoadImage API function.
    // Otherwise, it is not yet implemented on 64-bit Windows.
    if (lstrcmp(proc->ProcName, "LoadImageA") == 0)
    {
      HANDLE res = LoadImage((HINSTANCE)proc->Params[1].Value,
        (LPCSTR)proc->Params[2].Value,
        (UINT)proc->Params[3].Value,
        (int)proc->Params[4].Value,
        (int)proc->Params[5].Value,
        (UINT)proc->Params[6].Value);
      ParamsOut(proc);
      system_pushintptr((INT_PTR)res);
    }
    else
    {
      ParamsOut(proc);
      system_pushintptr(0);
    }
#endif
} PLUGINFUNCTIONEND
Exemple #25
0
} PLUGINFUNCTIONEND

PLUGINFUNCTION(Call)
{
    // Prepare input
    SystemProc *proc = PrepareProc(TRUE);
    SYSTEM_LOG_ADD("Call ");
    SYSTEM_LOG_ADD(proc->DllName);
    SYSTEM_LOG_ADD("::");
    SYSTEM_LOG_ADD(proc->ProcName);
    SYSTEM_LOG_ADD("\n");
    if (proc->ProcResult != PR_CALLBACK)
        ParamAllocate(proc);
    ParamsIn(proc);

    // Make the call
    if (proc->ProcResult != PR_ERROR)
    {
        switch (proc->ProcType)
        {
        case PT_NOTHING:
            if (proc->ProcResult == PR_CALLBACK) 
                proc = CallBack(proc);
            break;
        case PT_PROC:
        case PT_VTABLEPROC:
            proc = CallProc(proc); break;
        case PT_STRUCT:
            CallStruct(proc); break;
        }
    }

    // Process output
    if ((proc->Options & POPT_ALWRETURN) != 0)
    {
        // Always return flag set - return separate return and result
        ParamsOut(proc);
        GlobalFree(pushstring(GetResultStr(proc)));
    } else
    {
        if (proc->ProcResult != PR_OK)
        {
            ProcParameter pp;
            // Save old return param
            pp = proc->Params[0];

            // Return result instead of return value
            proc->Params[0].Value = (int) GetResultStr(proc);
            proc->Params[0].Type = PAT_STRING;
            // Return all params
            ParamsOut(proc);

            // Restore old return param
            proc->Params[0] = pp;
        } else 
            ParamsOut(proc);        
    }

    if (proc->ProcResult != PR_CALLBACK)
    {
        // Deallocate params if not callback
        ParamsDeAllocate(proc);

        // if not callback - check for unload library option
        if ((proc->Options & POPT_UNLOAD) 
            && (proc->ProcType == PT_PROC) 
            && (proc->Dll != NULL)) 
            FreeLibrary(proc->Dll); // and unload it :)

        // In case of POPT_ERROR - first pop will be proc error
        if ((proc->Options & POPT_ERROR) != 0) pushint(LastError);
    }    

    // If proc is permanent?
    if ((proc->Options & POPT_PERMANENT) == 0)
        GlobalFree((HANDLE) proc); // No, free it
} PLUGINFUNCTIONEND
Exemple #26
0
unsigned int FindFilesRec(DIR_ENTRY_LIST **list, const char *dir, FIND_UIDS *fu, void CallBack(DIR_ENTRY_LIST *ptr))
{
	DIR_ENTRY_LIST *top = NULL;
	
	unsigned int total = 0;
	
	char path[256];
	char find[256];
	char folder_name[128];
	
	strcpy(find, dir);
	strcat(find, "*");
	
	DIR_ENTRY de;
	unsigned int err;
	LockSched();
	if (FindFirstFile(&de, find, &err))
	{
		DIR_ENTRY_LIST *ptr = NULL;
		DIR_ENTRY_LIST *prev = NULL;
		if (*list)
		{
			ptr = *list;
		}
		else
		{
			top = malloc(sizeof(DIR_ENTRY_LIST));
			top->prev = NULL;
			ptr = top;
		}
		do
		{
			//isdir
			if (de.file_attr & FA_DIRECTORY)
			{
				strcpy(path, de.folder_name);
				strcat(path, "\\");
				strcat(path, de.file_name);
				strcat(path, "\\");
				total += FindFilesRec(&ptr, path, fu, CallBack);
				prev = ptr->prev;
			}
			else
			{
				if (fu)
				{
					unsigned int uid;
					for (int i = 0; i < MAX_UIDS; i++)
					{
						uid = GetExtUidByFileName(de.file_name);
						if (uid == fu->data[i]) goto COPY_DATA;
					}
				}
				else
				{
					COPY_DATA:
						strcpy(ptr->path, de.folder_name);
						strcat(ptr->path, "\\");
						strcat(ptr->path, de.file_name);
						strcpy(ptr->dir, de.folder_name);
						strcpy(ptr->fname, de.file_name);
						ptr->file_size        = de.file_size;
						ptr->file_attr        = de.file_attr;
						ptr->create_date_time = de.create_date_time;
						
						if (CallBack) CallBack(ptr);
						
						prev = ptr;
						ptr->next = malloc(sizeof(DIR_ENTRY_LIST));
						ptr = ptr->next;
						ptr->prev = prev;
						
						total++;
				}
			}
		}
		while (FindNextFile(&de, &err));
		if (*list)
		{
			*list = ptr;
		}
		else
		{
			if (prev)
			{
				mfree(prev->next);
				prev->next = NULL;
			}
			*list = top;
		}
#ifdef NEWSGOLD
		FindClose(&de, &err);
#endif
	}
#ifndef NEWSGOLD
	FindClose(&de, &err);
#endif
	UnlockSched();
	return total;
}
void EditFrame::OnAddEmptyObject()
{
    CallBack(ES_ON_ADD_EMPTY_OBJECT);
}
Exemple #28
0
void ListDir(const std::string& path, bool directories, void (*CallBack)(const std::string& filename, void* param), void* param, std::list<std::string> *liste)
{
    // Pfad zum Ordner, wo die Dateien gesucht werden sollen
    std::string rpath = path.substr(0, path.find_last_of('/') + 1);

    // Pfad in Kleinbuchstaben umwandeln
    std::string filen(path);
    std::transform(path.begin(), path.end(), filen.begin(), tolower);

    //LOG.lprintf("%s\n", filen.c_str());
    // Dateiendung merken
    size_t pos = path.find_last_of('.');
    if(pos == std::string::npos)
        return;

    std::string endung = path.substr(pos + 1);

#ifdef _WIN32
    HANDLE hFile;
    WIN32_FIND_DATAA wfd;

    hFile = FindFirstFileA(path.c_str(), &wfd);
    if(hFile != INVALID_HANDLE_VALUE)
    {
        do
        {
            std::string whole_path = rpath + wfd.cFileName;

            bool push = true;
            if(!directories && ( (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) )
                push = false;

            if(push)
            {
                if(CallBack)
                    CallBack(whole_path.c_str(), param);
                if(liste)
                    liste->push_back(whole_path);
            }
        }
        while(FindNextFileA(hFile, &wfd));

        FindClose(hFile);
    }
#else
    DIR* dir_d;
    dirent* dir = NULL;
    if ((dir_d = opendir(rpath.c_str())) != NULL)
    {
        while( (dir = readdir(dir_d)) != NULL)
        {
            struct stat file_stat;
            std::string whole_path = rpath + dir->d_name;

            stat(whole_path.c_str(), &file_stat);

            bool push = true;
            if(!directories && S_ISDIR(file_stat.st_mode))
                push = false;

            if(push)
            {
                std::string ende = dir->d_name;
                size_t pos = ende.find_last_of('.');
                if(pos == std::string::npos)
                    continue;

                ende = ende.substr(pos + 1);

                if(endung != ende)
                    std::transform(ende.begin(), ende.end(), ende.begin(), tolower);

                //LOG.lprintf("%s == %s\n", endung.c_str(), ende.c_str());

                if(endung != ende)
                    continue;

                if(CallBack)
                    CallBack(whole_path, param);
                if(liste)
                    liste->push_back(whole_path);
            }
        }
        closedir(dir_d);
        if(liste)
            liste->sort();
    }
#endif // _WIN32

}
Exemple #29
0
Symbol *SymbolTable::ResolveSymbol(const LocationVector &LocationStack, const string &ssymbol, CallBackFunction, SymbolEnum SymbolType)
{
	Symbol *pSymbol;
	bool fWarn = false;
	string sSymbol = ssymbol;
	if(sSymbol.size() > MAX_IDENTIFIER_CHAR)
	{
		sSymbol.resize(MAX_IDENTIFIER_CHAR);
		fWarn = true;
	}
	SymbolMap::iterator SymbolIter;

	//See if the symbol has been defined before
	SymbolIter = ResolvedSymbols.find(sSymbol);
	if(SymbolIter != ResolvedSymbols.end())
	{	//the symbol has been defined already
		if(SymbolIter->second->SymbolType == SymLabel && SymbolType == SymExtern)
			//extern referring to label in same file
			//This allows both the implementing and using programs to use the same header.
			//*NOTE: Should we give a warning?
			return SymbolIter->second;
		sprintf(sMessageBuffer, "Symbol '%.63s' already defined as %.31s.", SymbolIter->first.c_str(), sSymbols[SymbolIter->second->SymbolType]);
		CallBack(Error, sMessageBuffer, LocationStack);
		sprintf(sMessageBuffer, "See definition of '%.63s'.", SymbolIter->first.c_str());
		CallBack(Info, sMessageBuffer, SymbolIter->second->LocationStack);
		return NULL;
	}
	SymbolIter = ExternSymbols.find(sSymbol);
	if(SymbolIter != ExternSymbols.end())
	{	//the symbol has been defined already

		if(SymbolType == SymLabel)
		{
			//Allow a label to override and extern.
			//This allows both the implementing and using programs to use the same header.
			//*NOTE: Should we give a warning?
			pSymbol = SymbolIter->second;
			ExternSymbols.erase(SymbolIter);
			goto CreateSymbol;
		}
		if(SymbolType == SymExtern)
			//Another extern will just point to the same external label.
			//This could happen from multiple headers declaring the extern.
			return SymbolIter->second;
		else
		{
			sprintf(sMessageBuffer, "Symbol '%.63s' already defined as %.31s.", SymbolIter->first.c_str(), sSymbols[SymbolIter->second->SymbolType]);
			CallBack(Error, sMessageBuffer, LocationStack);
			sprintf(sMessageBuffer, "See definition of '%.63s'.", SymbolIter->first.c_str());
			CallBack(Info, sMessageBuffer, SymbolIter->second->LocationStack);
			return NULL;
		}
	}

	//See if the symbol has been referenced yet
	SymbolIter = UnresolvedSymbols.find(sSymbol);
	if(SymbolIter == UnresolvedSymbols.end())
	{
		//The symbol has not been referenced yet. Create a new symbol for it
		if(fWarn)
		{
			sprintf(sMessageBuffer, "Identifier '%.63s' truncated to %u characters.", sSymbol.c_str(), MAX_IDENTIFIER_CHAR);
			CallBack(Warning, sMessageBuffer, LocationStack);
		}
		pSymbol = new Symbol(LocationStack, sSymbol, Addressability);
	}
	else
	{
		pSymbol = SymbolIter->second;
		UnresolvedSymbols.erase(SymbolIter);
	}

CreateSymbol:
	//Move it into the resolved symbol table.
	pSymbol->LocationStack = LocationStack;
	pSymbol->SymbolType = SymbolType;
	if(SymbolType == SymExtern)
		ExternSymbols.insert(SymbolMap::value_type(pSymbol->sSymbol, pSymbol));
	else
		ResolvedSymbols.insert(SymbolMap::value_type(pSymbol->sSymbol, pSymbol));
	
	return pSymbol;
}
Exemple #30
0
bool Disassembler::Disassemble(LocationVector &LocationStack, istream &InputStream, SymbolList &Symbols)
{
	bool fRetVal = true;
	unsigned int i, TempChar;
	JMT::ByteData ByteData;

	if(fRunOnce)
		throw "Disassembler called twice on the same program!";
	fRunOnce = true;

	//First read starting address.
	for(i = 0; i < sizeof(uint64); i++)
	{
		TempChar = InputStream.get();
		if(TempChar == -1)	//EOF
			break;
		//The address in the file is always little endian
#ifdef BIG_ENDIAN_BUILD
		ByteData.Bytes[sizeof(uint64) - i - 1] = TempChar;
#else
		ByteData.Bytes[i] = TempChar;
#endif
		LocationStack.rbegin()->second++;
	}
	if(i < sizeof(uint64))
	{
		CallBack(Fatal, "Unexpected end of file.", LocationStack);
		return false;
	}
	StartAddress = ByteData.UI64;

	//Then read ending address
	for(i = 0; i < sizeof(uint64); i++)
	{
		TempChar = InputStream.get();
		if(TempChar == -1)	//EOF
			break;
		//The address in the file is always little endian
#ifdef BIG_ENDIAN_BUILD
		ByteData.Bytes[sizeof(uint64) - i - 1] = TempChar;
#else
		ByteData.Bytes[i] = TempChar;
#endif
		LocationStack.rbegin()->second++;
	}
	if(i < sizeof(uint64))
	{
		CallBack(Fatal, "Unexpected end of file.", LocationStack);
		return false;
	}
	EndAddress = StartAddress + ByteData.UI64;

	//Check addresses
	if(EndAddress < StartAddress)
	{
		CallBack(Fatal, "Program end address is less than start address.", LocationStack);
		return false;
	}

	//Create program origin
	TheProg.fDynamicAddress = false;
	TheProg.Address = StartAddress;

	//Create program segment
	TheProg.Segments.push_back(new Segment(LocationStack, Addressability, 0));

	//Add the pre-existing symbols
	for(SymbolList::iterator SymbolIter = Symbols.begin(); SymbolIter != Symbols.end(); SymbolIter++)
		DisassembleSymbol(SymbolIter->first, SymbolIter->second, SymbolIter->third);

	//Try to disassemble instructions. Instructions have highest priority.
	uint64 Address = StartAddress;
	if(ToLower(TheProg.sFileName.Ext) == "obj")
	{
		if(!DisassembleInstructions(LocationStack, InputStream, Address))
			return false;
	}
	else	//"bin"
	{
		if(!DisassembleData(LocationStack, InputStream, Address))
			return false;
	}

	if(Address < EndAddress)
	{
		CallBack(Error, "Unexpected end of file.", LocationStack);
		return false;
	}

	//Create labels
	list<Element *>::iterator ElemIter = (*TheProg.Segments.begin())->Sequence.begin();
	for(LabelMap::iterator LabelIter = Labels.begin(); LabelIter != Labels.end(); LabelIter++)
	{
		//Find the element this label points to
		while(ElemIter != (*TheProg.Segments.begin())->Sequence.end() && (*ElemIter)->Address < LabelIter->first)
			ElemIter++;

		if(ElemIter == (*TheProg.Segments.begin())->Sequence.end())
		{
			ElemIter--;
			if((*ElemIter)->Address + (*ElemIter)->Size != LabelIter->first)
				throw "Disassembler: Ran out of elements while adding labels!";
			//Label points to end of program
			ElemIter++;
		}
		else if((*ElemIter)->Address != LabelIter->first)
			throw "Disassembler: Label points to inside an instruction!";

		//Add the label to the sequence
		Label *pLabel = new Label(LocationStack, LabelIter->second->sSymbol, *TheProg.Segments.begin());
		(*TheProg.Segments.begin())->Sequence.insert(ElemIter, pLabel);
		LabelIter->second->pLabel = pLabel;
		if(ElemIter != (*TheProg.Segments.begin())->Sequence.end())
		{
			if(!TheProg.TheSymbolTable.ResolveSymbol((*ElemIter)->LocationStack, LabelIter->second->sSymbol, CallBack, SymLabel))
				throw "ResolveSymbol in Disassembler failed!";
			pLabel->pElement = *ElemIter;
		}
		else
			if(!TheProg.TheSymbolTable.ResolveSymbol((*(*TheProg.Segments.begin())->Sequence.rbegin())->LocationStack, LabelIter->second->sSymbol, CallBack, SymLabel))
				throw "ResolveSymbol in Disassembler failed!";
	}

	return fRetVal;
}