Esempio n. 1
0
void update_provider_statistics (int prov)
{
	// the descriptors array holds a textual printable output. I'm piggybacking on that fact
	// and doing minor string parsing, rather than keep all the src_description structs in 
  	// memory. Let's not forget this is PoC code

	char *desc = descriptors[prov];
	
	if (desc)
	{
		// get last tab..
		char *col = strrchr (desc,'\t');
		// get penultimate tab
		if (col)
		{
		   *col ='\0';
		   col = strrchr (desc,'\t');
		   if (col)
		   {
		   *(col) = '\0';
	
	char humanReadableRX [15];
	char humanReadableTX [15];

   if (wantPackets)
      sprintf(desc + strlen(desc), "\t%7lld\t%7lld", descriptorCounts[prov].nstat_rxpackets, descriptorCounts[prov].nstat_txpackets);
   else
      if (wantHumanReadable)
	{
	  humanReadable(descriptorCounts[prov].nstat_rxbytes, humanReadableRX);
	  humanReadable(descriptorCounts[prov].nstat_txbytes, humanReadableTX);
	  sprintf(desc + strlen(desc), "\t%s\t%s", humanReadableRX, humanReadableTX);

	}
	else
	{
      sprintf(desc + strlen(desc), "\t%lld\t%lld", descriptorCounts[prov].nstat_rxbytes, descriptorCounts[prov].nstat_txbytes);
	}

		   }
		}

	}
}
Esempio n. 2
0
    Fingerprint* findFingerprint(OtrlUserState userState, const QString &fp, const QString &user)
    {
        Fingerprint *fingerprint = nullptr;

        for(ConnContext *context = userState->context_root;
                context != nullptr; context = context->next)
        {
            if(user != QLatin1String(context->username)) {
                continue;
            }
            for(fingerprint = context->fingerprint_root.next;
                    fingerprint != nullptr; fingerprint = fingerprint->next)
            {
                if(humanReadable(fingerprint->fingerprint) == fp) {
                    return fingerprint;
                }
            }
        }

        return fingerprint;
    }