Ejemplo n.º 1
0
int
main(int argc, char **argv) {
  int     blockSize = 1;
  int     numUIDs   = 1;
  int     doThrash  = 0;

  int arg=1;
  int err=0;
  while (arg < argc) {
    if        (strcmp(argv[arg], "-p") == 0) {
      numUIDs = atoi(argv[++arg]);
      if (numUIDs < blockSize)
        blockSize = numUIDs;

    } else if (strcmp(argv[arg], "-n") == 0) {
      //SYS_UIDset_euid_namespace(argv[++arg]);

    } else if (strcmp(argv[arg], "-E") == 0) {
      //SYS_UIDset_euid_server(argv[++arg]);

    } else if (strcmp(argv[arg], "-thrash") == 0) {
      doThrash = 1;

    } else {
      fprintf(stderr, "%s: unknown option '%s'\n", argv[0], argv[arg]);
      err++;
    }
    arg++;
  }
  if ((err) || (numUIDs == 0)) {
    fprintf(stderr, "%s: [-p n] [-n ns] [-E server] [-d ms]\n", argv[0]);
    fprintf(stderr, "  -p n       print n UIDs and exit.\n");
    fprintf(stderr, "  -n ns      use namespace ns.\n");
    fprintf(stderr, "  -E server  contact EUID server 'server'.\n");
    fprintf(stderr, "  -thrash    debug; get UIDs as fast as possible using blocksize 1.\n");
    fprintf(stderr, "             This is not what you want.  Don't use it.\n");
    exit(1);
  }

  UIDserver  *uids = UIDserverInitialize(blockSize, 0);

  while (doThrash)
    getUID(uids);  //  Forever or never.

  while (numUIDs > 0) {
    fprintf(stdout, F_U64"\n", getUID(uids));
    numUIDs--;
  }

  exit(0);
}
Ejemplo n.º 2
0
int PortFE1::setLoop(const int type){
    UN_Info e1info = UID::breakUID(getUID());
    uint8 ch = e1info.E1.E1;
    switch( type ) {
    case dev_and_line_loop:
        driver.setPortLoopOut(ch, 1);
        driver.setPortLoopIn(ch, 1);
        break;
    case line_loop:
        driver.setPortLoopOut(ch, 1);
        driver.setPortLoopIn(ch, 0);
        break;
    case dev_loop:
        driver.setPortLoopOut(ch, 0);
        driver.setPortLoopIn(ch, 1);
        break;
    case no_loop:
        driver.setPortLoopOut(ch, 0);
        driver.setPortLoopIn(ch, 0);
        break;
    default:
        return -1;
    }
    return 0x5A;
}
Ejemplo n.º 3
0
long EmergenceLog::getLastUID() {   
    string logLine = "-1,READFAIL,READFAIL,READFAIL,READFAIL,\n";
    string prevLogLine = "-1,READFAIL,READFAIL,READFAIL,READFAIL,\n";
    
    string fileName = getLogDirPath() + _fileName;
    
    std::ifstream mFile;
    
    mFile.open(fileName.c_str());
    if (mFile.is_open()) {
        while (mFile.good()) {
            // last line is garbage
            prevLogLine = logLine;
            getline(mFile, logLine);
        }
        mFile.close();
    }     
        
    return getUID(prevLogLine);
    
    //long len = length();
    //if (len < 0) {
    //    return -1;
    //}
    //return getUID(len);
    
    //string line = getLine(len);
    //string uid;
    //istringstream liness(line);
    //getline(liness, uid, ',');
    //return atol(uid.c_str());
}
Ejemplo n.º 4
0
/**
 * Print a conditional branch instruction.
 * 
 * @param curBlock    the current block
 * @param trueBlock   the destination block if the value on top of the stack is
 *                    non-zero
 * @param falseBlock  the destination block if the value on top of the stack is
 *                    zero
 */
void JVMWriter::printBranchInstruction(const BasicBlock *curBlock,
                                       const BasicBlock *trueBlock,
                                       const BasicBlock *falseBlock) {
    if(trueBlock == falseBlock) {
        printSimpleInstruction("pop");
        printBranchInstruction(curBlock, trueBlock);
    } else if(!falseBlock) {
        printPHICopy(curBlock, trueBlock);
        printSimpleInstruction("ifne", getLabelName(trueBlock));
    } else {
        std::string labelname = getLabelName(trueBlock);
        if(isa<PHINode>(trueBlock->begin()))
            labelname += "$phi" + utostr(getUID());
        printSimpleInstruction("ifne", labelname);
        
        if(isa<PHINode>(falseBlock->begin()))
            printPHICopy(curBlock, falseBlock);
        printSimpleInstruction("goto", getLabelName(falseBlock));
        
        if(isa<PHINode>(trueBlock->begin())) {
            printLabel(labelname);
            printPHICopy(curBlock, trueBlock);
            printSimpleInstruction("goto", getLabelName(trueBlock));
        }
    }
}
Ejemplo n.º 5
0
bool KU_User::operator ==(const KU_User &other) const
{
  if ( getUID() == other.getUID() &&
       getName() == other.getName() )
    return true;
  else
    return false;
}
Ejemplo n.º 6
0
void ComponentAttachParticleSystem::handleActionDeleteActor( const ActionDeleteActor *message ) {
	ASSERT(message, "Null parameter: message");
	
	if (message->id == getUID()) {
		ASSERT(world, "world has not yet been set");
		world->particleEngine->remove(handle);
		active=false;
	}
}
Ejemplo n.º 7
0
void mob::hit(hitData &data) {
	RakNet::BitStream dataPacket; //The bitstream
	dataPacket.Write<RakNet::MessageID>(gamePackets::COMBAT_ENTITY); //Message ID
	dataPacket.Write<RakNet::MessageID>(gamePackets::COMBAT_ENTITY_HIT); //Message ID
	dataPacket.Write<int>(getUID()); //Send the combat entities unique ID
	dataPacket.Write<hitData>(data);
	this->getParentMap()->broadcastPacket(dataPacket);
	this->::combatEntity::hit(data);
}
Ejemplo n.º 8
0
void CPlayer::skillDamage(AdvancedAttribute targetAttr)
{
    CMonster *pTargetMonster = dynamic_cast<CMonster *>(getTargetObject());
    if(pTargetMonster != NULL)
    {
		  AdvancedAttribute monsterAdv = pTargetMonster->getAdvAttr();
        pTargetMonster->addHate(getUID(), targetAttr.iHP - monsterAdv.iHP);
    }
    CUnitObject::skillDamage(targetAttr);
}
Ejemplo n.º 9
0
/*
 * ֻ�аﶨ��VCG��CHVC���ж�Ӧ��RC6400��
 * ����ڰ�ʱ����Ҫ�Ը�CHVC�����������ʵ��
 */
bool CHVC::bandToVCG(VCG* v) {
    BandVCG = v;
    if( BandVCG ) {
        LinkChannel->setDownStream(BandVCG->getUID());
    }
    else {
        LinkChannel->setDownStream(getUID());
    }
    return true;
}
Ejemplo n.º 10
0
bool PortFE1::setPortEnable(uint8 en, bool save) {
    UN_Info e1info = UID::breakUID(getUID());
    uint8 ch = e1info.E1.E1;
    driver.setPortEnable(ch, en);
    if( save ) {
        ConfigData->TXEN = en;
        return saveConfig();
    }
    return true;
}
Ejemplo n.º 11
0
// used with 'hf search'
int HF15Reader(const char *Cmd, bool verbose) {
	uint8_t uid[8] = {0,0,0,0,0,0,0,0};	
	if (!getUID(uid)) {
		if (verbose) PrintAndLogEx(WARNING, "No tag found.");
		return 0;
	}

	PrintAndLogEx(NORMAL, " UID  : %s", sprintUID(NULL, uid));
	PrintAndLogEx(NORMAL, " TYPE : %s", getTagInfo_15(uid));
	return 1;
}
Ejemplo n.º 12
0
void ege::Element::setFireOn(int32_t _groupIdSource, int32_t _type, float _power, const vec3& _center) {
	float previousLife = m_life;
	m_life += _power;
	m_life = std::avg(0.0f, m_life, m_lifeMax);
	if (m_life <= 0) {
		EGE_DEBUG("[" << getUID() << "] element is killed ..." << getType());
	}
	if (m_life != previousLife) {
		onLifeChange();
	}
}
Ejemplo n.º 13
0
/**
 * Print a select instruction.
 * 
 * @param cond      the condition
 * @param trueVal   the return value of the instruction if the condition is
 *                  non-zero
 * @param falseVal  the return value of the instruction if the condition is
 *                  zero
 */
void JVMWriter::printSelectInstruction(const Value *cond,
                                       const Value *trueVal,
                                       const Value *falseVal) {
    std::string labelname = "select" + utostr(getUID());
    printValueLoad(cond);
    printSimpleInstruction("ifeq", labelname + "a");
    printValueLoad(trueVal);
    printSimpleInstruction("goto", labelname + "b");
    printLabel(labelname + "a");
    printValueLoad(falseVal);
    printLabel(labelname + "b");
}
Ejemplo n.º 14
0
Tile* Board::getTile(int row, int col) {
	Tile* found_tile;

	if (row < 1 || row > vert_tiles || col < 1 || col > hori_tiles) {
		found_tile = &NULL_tile;
	}
	else {
		int index = getUID(row, col)-1;
		found_tile = &board_tiles[index];
	}
	
	return found_tile;
}
Ejemplo n.º 15
0
uint32 CHVC::getProtectPartner(void) {
    UN_Info info = UID::breakUID(getUID());
    if( info.chvc.group == 0 ) {
        info.chvc.group = 1;
    }
    else {
        info.chvc.group = 0;
    }
    ST_Chvc_channel partner;
    partner.slot = info.chvc.slot;
    partner.group = info.chvc.group;
    partner.channel = info.chvc.channel;
    return UID::makeUID(&partner);
}
status_t ChromiumHTTPDataSource::connect(
        const char *uri,
        const KeyedVector<String8, String8> *headers,
        off64_t offset) {
    Mutex::Autolock autoLock(mLock);

    uid_t uid;
    if (getUID(&uid)) {
        mDelegate->setUID(uid);
    }
    LOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, "connect on behalf of uid %d", uid);

    return connect_l(uri, headers, offset);
}
Ejemplo n.º 17
0
 void fillInPluginDescription (PluginDescription& desc) const
 {
     desc.name = getName();
     desc.fileOrIdentifier = module->file.getFullPathName();
     desc.uid = getUID();
     desc.lastFileModTime = module->file.getLastModificationTime();
     desc.pluginFormatName = "LADSPA";
     desc.category = getCategory();
     desc.manufacturerName = plugin != nullptr ? String (plugin->Maker) : String::empty;
     desc.version = getVersion();
     desc.numInputChannels  = getNumInputChannels();
     desc.numOutputChannels = getNumOutputChannels();
     desc.isInstrument = false;
 }
Ejemplo n.º 18
0
int main(int argc, char** argv)
{
	int id;
	char username[128];
	const char* baseUrl = "http://172.27.0.1:8000/pam";


	printf("Authenticate: %d\n", httpAuthenticate("pepito", "juanito", baseUrl));

	int res = getUID(baseUrl,"pepito", username, &id);
	printf("GetUID:res: %d, username: %s, id: %d\n", res, username, id);

	*username = '******';
	res = getName(baseUrl, 10000, username, &id);
	printf("GetName:res: %d, username: %s, id: %d\n", res, username, id);

}
Ejemplo n.º 19
0
bool buildUTGMessage(int32 ID, SnapUnitigMesg *utg) {
  MultiAlignT *ma = ScaffoldGraph->tigStore->loadMultiAlign(ID, TRUE);

  if (ma == NULL)
    return(false);

  utg->eaccession    = AS_UID_fromInteger(getUID(uidServer));
  utg->iaccession    = ID;
  utg->coverage_stat = ScaffoldGraph->tigStore->getUnitigCoverageStat(ID);
  utg->microhet_prob = ScaffoldGraph->tigStore->getUnitigMicroHetProb(ID);
  utg->status        = ScaffoldGraph->tigStore->getUnitigStatus(ID);
  utg->status        = (utg->status == AS_UNASSIGNED ? AS_UNIQUE : utg->status);
  utg->length        = GetMultiAlignLength(ma);
  utg->consensus     = Getchar(ma->consensus, 0);
  utg->quality       = Getchar(ma->quality, 0);
  utg->forced        = 0;
  utg->num_frags     = GetNumIntMultiPoss(ma->f_list);
  utg->num_vars      = 0;
  utg->f_list        = (SnapMultiPos*)safe_malloc(utg->num_frags * sizeof(SnapMultiPos));
  utg->v_list        = NULL;

  if (utg->consensus == NULL)
    fprintf(stderr, "buildUTGMessage()-- unitig %d missing consensus sequence\n",
            utg->iaccession);
  assert(utg->consensus != NULL);
  if (utg->length != strlen(utg->consensus))
    fprintf(stderr, "buildUTGMessage()-- unitig %d length %d != consensus string length "F_SIZE_T"\n",
            utg->iaccession, utg->length, strlen(utg->consensus));
  assert(utg->length == strlen(utg->consensus));

  for (int32 i=0; i<utg->num_frags; i++) {
    IntMultiPos  *imp = GetIntMultiPos(ma->f_list, i);

    utg->f_list[i].type          = imp->type;
    utg->f_list[i].eident        = FRGmap.lookup(imp->ident);
    utg->f_list[i].position      = imp->position;
    utg->f_list[i].delta_length  = imp->delta_length;
    utg->f_list[i].delta         = imp->delta;
  }

  return(true);
}
void VesselSceneNode::loadState(const VesselSceneNodeState& state)
{
    Log::writeToLog(Log::L_DEBUG, "Loading VesselSceneNode state, UID: ", uid);
    if (state.uid != uid)
        throw UID_Mismatch();
    setPosition(state.pos);
    setRotation(state.rot);
    orbitername = state.orbiterName;

    for (UINT i = 0; i < state.dockingStatus.size(); ++i)
    {
        dockingPorts[i].docked = state.dockingStatus[i].docked;
        if (state.dockingStatus[i].docked)
        {
            Log::writeToLog(Log::L_DEBUG, "Half-docking ourPort (VUID: ", getUID(), " PID: ", i,
                ") to theirPort (VUID: ", state.dockingStatus[i].dockedTo.vesselUID, " PID: ", 
                state.dockingStatus[i].dockedTo.portID, ")");
            dockingPorts[i].dockedTo = state.dockingStatus[i].dockedTo;
        }
    }

}
Ejemplo n.º 21
0
bool Process::operator==(const Process &other) const
{
  if(this==&other)
    return true;

  if( getPath()!=other.getPath() )
    return false;
  if( getName()!=other.getName() )
    return false;
  if( !Base::ViaPointer::equal( getMD5(), other.getMD5() ) )
    return false;
  if( !Base::ViaPointer::equal( getPID(), other.getPID() ) )
    return false;
  if( !Base::ViaPointer::equal( getUID(), other.getUID() ) )
    return false;
  if( getUsername()!=other.getUsername() )
    return false;
  if( !Base::ViaPointer::equal( getParameters(), other.getParameters() ) )
    return false;
  if( !Base::ViaPointer::equal( getReferenceURL().get(), other.getReferenceURL().get() ) )
    return false;
  // if all fields are identical, Processes are identical too.
  return true;
}
Ejemplo n.º 22
0
void rice::p2p::past::gc::GCPastImpl::refresh(GCIdSet* ids, ::rice::Continuation* command)
{
    auto const logger = npc(npc(environment)->getLogManager())->getLogger(GCPastImpl::class_(), instance);
    if(npc(logger)->level <= ::rice::environment::logging::Logger::FINE)
        npc(logger)->log(::java::lang::StringBuilder().append(u"REFRESH: CALLED WITH "_j)->append(npc(ids)->numElements())
            ->append(u" ELEMENTS"_j)->toString());

    if(npc(ids)->numElements() == 0) {
        npc(command)->receiveResult(new ::java::lang::ObjectArray(int32_t(0)));
        return;
    }
    auto const array = npc(ids)->asArray_();
    auto start = java_cast< GCId* >((*array)[int32_t(0)]);
    if(npc(logger)->level <= ::rice::environment::logging::Logger::FINE)
        npc(logger)->log(::java::lang::StringBuilder().append(u"REFRESH: GETTINGS ALL HANDLES OF "_j)->append(static_cast< ::java::lang::Object* >(start))->toString());

    sendRequest(npc(start)->getId(), static_cast< ::rice::p2p::past::messaging::PastMessage* >(new ::rice::p2p::past::gc::messaging::GCLookupHandlesMessage(getUID(), npc(start)->getId(), getLocalNodeHandle(), npc(start)->getId())), static_cast< ::rice::Continuation* >(new GCPastImpl_refresh_3(this, logger, array, ids, ::java::lang::StringBuilder().append(u"GCLookupHandles for "_j)->append(static_cast< ::java::lang::Object* >(npc(start)->getId()))->toString(), command)));
}
Ejemplo n.º 23
0
/**
 * parses common HF 15 CMD parameters and prepares some data structures
 * Parameters:
 *  **cmd   	command line
 */
int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd) {
	int temp;
	uint8_t *req = c->d.asBytes;
	uint8_t uid[8] = {0x00};
	uint32_t reqlen = 0;

	// strip
	while (**cmd==' ' || **cmd=='\t') (*cmd)++;
	
	if (strstr(*cmd, "-2") == *cmd) {
	 	c->arg[1] = 0; // use 1of256
	 	(*cmd) += 2;
	}

	// strip
	while (**cmd==' ' || **cmd=='\t') (*cmd)++;
	
	if (strstr(*cmd, "-o") == *cmd) {
	 	req[reqlen] = ISO15_REQ_OPTION;
	 	(*cmd) += 2;
	}
	
	// strip
	while (**cmd == ' ' || **cmd == '\t') (*cmd)++;
	
	switch (**cmd) {
		case 0:
			PrintAndLogEx(WARNING, "missing addr");
			return 0;
			break;
		case 'u':
		case 'U':
			// unaddressed mode may not be supported by all vendors
			req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY;
			req[reqlen++] = iso15cmd;
			break;
		case '*':
			// we scan for the UID ourself
			req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
			req[reqlen++] = iso15cmd;

			if (!getUID(uid)) {
				PrintAndLogEx(WARNING, "No tag found");
				return 0;
			}
			memcpy(&req[reqlen], uid, sizeof(uid));
			PrintAndLogEx(NORMAL, "Detected UID %s", sprintUID(NULL, uid));
			reqlen += sizeof(uid);
			break;			
		default:
			req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
			req[reqlen++] = iso15cmd;
			
		    // parse UID
			for (int i=0; i<8 && (*cmd)[i*2] && (*cmd)[i*2+1]; i++) {
				sscanf((char[]){(*cmd)[i*2], (*cmd)[i*2+1],0}, "%X", &temp);
				uid[7-i] = temp & 0xff;
			}				
				
			PrintAndLogEx(NORMAL, "Using UID %s", sprintUID(NULL, uid));
			memcpy(&req[reqlen], uid, sizeof(uid));
			reqlen +=  sizeof(uid);
			break;
	}
Ejemplo n.º 24
0
int CmdHF15Restore(const char*Cmd) {
	FILE *file;
	
	uint8_t uid[8]={0x00};
	char filename[FILE_PATH_SIZE] = {0x00};
	char buff[255] = {0x00};
	size_t blocksize=4;
	uint8_t cmdp = 0;
	char newCmdPrefix[255] = {0x00}, tmpCmd[255] = {0x00};
	char param[FILE_PATH_SIZE]="";
	char hex[255]="";
	uint8_t retries = 3, tried = 0;
	int retval=0;
	size_t bytes_read;
	uint8_t i=0;
		while(param_getchar(Cmd, cmdp) != 0x00) {
		switch(tolower(param_getchar(Cmd, cmdp))) {
			case '-':
				param_getstr(Cmd, cmdp, param, sizeof(param));
				switch(param[1])
				{
					case '2':
					case 'o': strncpy(newCmdPrefix, " ",sizeof(newCmdPrefix)-1);
						strncat(newCmdPrefix, param, sizeof(newCmdPrefix)-1);
								break;
					default:
						PrintAndLogEx(WARNING, "Unknown parameter '%s'", param);
						return usage_15_restore();
				}
				break;
			case 'f':
				param_getstr(Cmd, cmdp+1, filename, FILE_PATH_SIZE);
				cmdp++;	
				break;
			case 'r':
				retries=param_get8ex(Cmd, cmdp+1, 3, 10);
				cmdp++;	
				break;
			case 'b':
				blocksize=param_get8ex(Cmd, cmdp+1, 4, 10);
				cmdp++;	
				break;
			case 'u':
				param_getstr(Cmd, cmdp+1, buff, FILE_PATH_SIZE);
				cmdp++;	
				snprintf(filename,sizeof(filename),"hf-15-dump-%s-bin",buff);				
				break;
			case 'h':
				return usage_15_restore();
			default:
				PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
				return usage_15_restore();
				break;
		}
		cmdp++;
	}
	PrintAndLogEx(INFO,"Blocksize: %u",blocksize);
	if(filename[0]=='\0')
	{
		PrintAndLogEx(WARNING,"Please provide a filename");
		return 1;
	}

	if ((file = fopen(filename,"rb")) == NULL) {
		PrintAndLogEx(WARNING, "Could not find file %s", filename);
		return 2;
	}
	
	if (!getUID(uid)) {
		PrintAndLogEx(WARNING, "No tag found");
		return 3;
	}
	while (1) {
		tried=0;
		hex[0]=0x00;
		tmpCmd[0]=0x00;
		
		bytes_read = fread( buff, 1, blocksize, file );
		if ( bytes_read == 0) {
			PrintAndLogEx(SUCCESS, "File reading done (%s).", filename);
			fclose(file);
			return 0;
		}
		else if ( bytes_read != blocksize) {
			PrintAndLogEx(WARNING, "File reading error (%s), %u bytes read instead of %u bytes.", filename, bytes_read, blocksize);
			fclose(file);
			return 2;
		}
		for(int j=0;j<blocksize;j++)
			snprintf(hex+j*2,3,"%02X", (unsigned char)buff[j]);
		for(int j=0;j<sizeof(uid)/sizeof(uid[0]);j++)
			snprintf(buff+j*2,3,"%02X", uid[j]);
		
		//TODO: Addressed mode currently not work
		//snprintf(tmpCmd, sizeof(tmpCmd), "%s %s %d %s", newCmdPrefix, buff, i, hex);
		snprintf(tmpCmd, sizeof(tmpCmd), "%s u %d %s", newCmdPrefix, i, hex);
		PrintAndLogEx(DEBUG, "Command to be sent: %s", tmpCmd);

		for(tried=0;tried<retries;tried++)
			if(!(retval=CmdHF15Write(tmpCmd)))
				break;
		if(tried >= retries)
			return retval;
		i++;
	}
	fclose(file);
}
Ejemplo n.º 25
0
// Reads all memory pages
// need to write to file
int CmdHF15Dump(const char*Cmd) {
	
	uint8_t fileNameLen = 0;
	char filename[FILE_PATH_SIZE] = {0};
	char * fptr = filename;
	bool errors = false;
	uint8_t cmdp = 0;
	uint8_t uid[8] = {0,0,0,0,0,0,0,0};	
	
	while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
		switch(param_getchar(Cmd, cmdp)) {
		case 'h':
		case 'H':
			return usage_15_dump();
		case 'f':
		case 'F':
			fileNameLen = param_getstr(Cmd, cmdp+1, filename, FILE_PATH_SIZE); 
			cmdp += 2;
			break;
		default:
			PrintAndLogEx(WARNING, "Unknown parameter '%c'\n", param_getchar(Cmd, cmdp));
			errors = true;
			break;
		}
	}

	//Validations
	if (errors) return usage_15_dump();
	
	if (fileNameLen < 1) {

		PrintAndLogEx(INFO, "Using UID as filename");

		if (!getUID(uid)) {
			PrintAndLogEx(WARNING, "No tag found.");
			return 1;
		}
		
		fptr += sprintf(fptr, "hf-15-"); 
		FillFileNameByUID(fptr,uid,"-dump",sizeof(uid));

	}	
	// detect blocksize from card :)
	
	PrintAndLogEx(NORMAL, "Reading memory from tag UID %s", sprintUID(NULL, uid));

	int blocknum = 0;
	uint8_t *recv = NULL;

	// memory.
	t15memory mem[256];
	
	uint8_t data[256*4] = {0};
	memset(data, 0, sizeof(data));

	UsbCommand resp;
	UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
	uint8_t *req = c.d.asBytes;
	req[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
	req[1] = ISO15_CMD_READ;

	// copy uid to read command
	memcpy(req+2, uid, sizeof(uid));
	
	for (int retry = 0; retry < 5; retry++) {
	
		req[10] = blocknum;
		AddCrc(req, 11);
		c.arg[0] = 13;
	
		clearCommandBuffer();
		SendCommand(&c);
				
		if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {

			uint8_t len = resp.arg[0];
			if ( len < 2 ) {
				PrintAndLogEx(FAILED, "iso15693 card select failed");
				continue;		
			}
			
			recv = resp.d.asBytes;
			
			if ( !CheckCrc(recv, len) ) {
				PrintAndLogEx(FAILED, "crc fail");
				continue;
			}

			if (recv[0] & ISO15_RES_ERROR) {
				PrintAndLogEx(FAILED, "Tag returned Error %i: %s", recv[1], TagErrorStr(recv[1]) ); 
				break;
			}
								
			mem[blocknum].lock = resp.d.asBytes[0];
			memcpy(mem[blocknum].block, resp.d.asBytes + 1, 4);					
			memcpy(data + (blocknum * 4), resp.d.asBytes + 1, 4);
			
			retry = 0;
			blocknum++;
			
			printf("."); fflush(stdout);
		} 
	}
	PrintAndLogEx(NORMAL, "\n");

	PrintAndLogEx(NORMAL, "block#   | data         |lck| ascii");
	PrintAndLogEx(NORMAL, "---------+--------------+---+----------");	
	for (int i = 0; i < blocknum; i++) {
		PrintAndLogEx(NORMAL, "%3d/0x%02X | %s | %d | %s", i, i, sprint_hex(mem[i].block, 4 ), mem[i].lock, sprint_ascii(mem[i].block, 4) );
	}
	PrintAndLogEx(NORMAL, "\n");

	size_t datalen = blocknum * 4;
	saveFileEML(filename, "eml", data, datalen, 4);	
	saveFile(filename, "bin", data, datalen);
	return 0;
}
Ejemplo n.º 26
0
// --------------------------------------------------------------------------
//
// Function
//      Name:    BBInstance ProcessControl::generateBBInstanceFromPID(int)
//      Purpose: Obtiene todos los parametros y genera una instancia a partir de un PID
//      Created: 25/6/08
//
// ------------------
BBInstance ProcessControl::generateBBInstanceFromPID(int pid)
{
	QString configpath = getConfigPath(pid);
	unsigned int uid = getUID(pid);
	return BBInstance(configpath, userNamefromUID(uid),getBinaryPath(pid));
}
Ejemplo n.º 27
0
bool ProcessControl::checkProcessUser(int pid, int uid)
{
    int processuid=getUID(pid);
    return processuid == uid;
}
Ejemplo n.º 28
0
int
main( int argc, char **argv) {
  int          ckptNum           = NULLINDEX;
  int          makeMiniScaffolds = 1;
  uint64       uidStart          = 1230000;
  UIDserver   *uids              = NULL;

  GlobalData = new Globals_CGW();

  argc = AS_configure(argc, argv);

  int err=0;
  int arg=1;
  while (arg < argc) {
    if        (strcmp(argv[arg], "-p") == 0) {
      ckptNum = GlobalData->setPrefix(argv[++arg]);
    } else if (strcmp(argv[arg], "-c") == 0) {
      strcpy(GlobalData->outputPrefix, argv[++arg]);
    } else if (strcmp(argv[arg], "-g") == 0) {
      strcpy(GlobalData->gkpStoreName, argv[++arg]);
    } else if (strcmp(argv[arg], "-t") == 0) {
      strcpy(GlobalData->tigStoreName, argv[++arg]);
    } else if (strcmp(argv[arg], "-n") == 0) {
      ckptNum = atoi(argv[++arg]);
    } else if (strcmp(argv[arg], "-U") == 0) {
      uidStart = 0;
    } else if (strcmp(argv[arg], "-S") == 0) {
      makeMiniScaffolds = 0;
    } else {
      fprintf(stderr, "unknown option '%s'\n", argv[arg]);
      err = 1;
    }
    arg++;
  }

  if ((GlobalData->outputPrefix[0] == 0) ||
      (GlobalData->gkpStoreName[0] == 0)) {
    fprintf(stderr, "usage: %s [[-p prefix] | [-c name -g gkpstore -n ckptNum]] [-U] [-S]\n", argv[0]);
    fprintf(stderr, "  -p      Attempt to locate the last checkpoint in directory 7-CGW.\n");
    fprintf(stderr, "  -c      Look for checkpoints in 'name'\n");
    fprintf(stderr, "  -g      Path to gkpStore\n");
    fprintf(stderr, "  -n      Checkpoint number to load\n");
    fprintf(stderr, "  -U      Use real UIDs for miniscaffolds, otherwise, UIDs start at 1230000\n");
    fprintf(stderr, "  -S      Do NOT make mini scaffolds.\n");
    exit(1);
  }

  uids = UIDserverInitialize(256, uidStart);

  char *toprint = (char *)safe_malloc(sizeof(char) * (AS_READ_MAX_NORMAL_LEN + 51 + AS_READ_MAX_NORMAL_LEN + 2));

  LoadScaffoldGraphFromCheckpoint(GlobalData->outputPrefix, ckptNum, FALSE);

  int ifrag;
  for (ifrag=0; ifrag < GetNumVA_CIFragT(ScaffoldGraph->CIFrags); ifrag++) {
    CIFragT *frag = GetCIFragT(ScaffoldGraph->CIFrags, ifrag);
    CIFragT *mate = NULL;

    if (frag->flags.bits.isDeleted)
      continue;

    assert(frag->cid != NULLINDEX);
    assert((frag->flags.bits.hasMate == 0) || (frag->mate_iid != 0));

    //  Fix for missing mates -- OBT used to not delete mate links, leaving
    //  dangling mates.  Somebody else seems to be doing this too.
    //
    if (frag->flags.bits.hasMate) {
      mate = GetCIFragT(ScaffoldGraph->CIFrags, frag->mate_iid);
      if (mate == NULL)
        frag->flags.bits.hasMate = 0;
    }

    //  If this fragment is not chaff, we have nothing to do here.
    //
    if (GetGraphNode(ScaffoldGraph->CIGraph,frag->cid)->flags.bits.isChaff == 0)
      continue;

    //  Print a singleton if there is no mate, the mate isn't chaff,
    //  or we were told to not make miniscaffolds.
    //
    if ((mate == NULL) ||
        (mate->flags.bits.isChaff == 0) ||
        (makeMiniScaffolds == 0)) {
      AS_UID  fUID = getFragmentClear(frag->read_iid, 0, toprint);

      AS_UTL_writeFastA(stdout,
                        toprint, strlen(toprint), 0,
                        ">%s /type=singleton\n", AS_UID_toString(fUID));

    } else if ((mate != NULL) &&
               (mate->flags.bits.isChaff == 1) &&
               (makeMiniScaffolds == 1) &&
               (frag->read_iid < mate->read_iid)) {

      //  make sure the following chain of Ns is divisible by three;
      //  the exact length is arbitrary but Doug Rusch points out that
      //  by making it divisible by 3, we can get lucky and maintain
      //  the phase of a protein ...  which helps in the
      //  auto-annotation of environmental samples

      AS_UID  fUID = getFragmentClear(frag->read_iid, 0, toprint);

      strcat(toprint, "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN");

      AS_UID  mUID = getFragmentClear(mate->read_iid, 1, toprint + strlen(toprint));

      AS_UTL_writeFastA(stdout,
                        toprint, strlen(toprint), 0,
                        ">"F_U64" /type=mini_scaffold /frgs=(%s,%s)\n",
                        getUID(uids),
                        AS_UID_toString(fUID),
                        AS_UID_toString(mUID));
    }
  }

  delete GlobalData;

  exit(0);
}
Ejemplo n.º 29
0
uint32 CTSChannel::getHID() {
    uint32 uid = getUID();
    return driver->getHID(uid);

}
Ejemplo n.º 30
0
CTSChannel::~CTSChannel() {
    group.erase(getUID());
}