library/src/blockclass/BP-BlockClass.cc
// stack new insert result (fast ad-hoc stacking using hex embedding, should be audited)
stack new insert result (fast ad-hoc stacking using hex embedding, should be audited)
stack new insert result ( fast ad - hoc stacking using hex embedding should be audited )
BP_ERROR_T Block::stackInsertRequest(size_t type, char *href, size_t status_code, size_t parent_id)
{
	if(!this->result_stack_builder)
	{
		this->result_stack_builder = new BP_StringUtils(NULL);
		this->result_stack_builder->duplicate_unique_strings = true;
	}
	if(this->result_stack_builder->AddUniqueString(href) != true)
		return ERR_FAILURE;
	this->result_stack_n++;
	if(!this->result_stack_builder->build_str)
		this->result_stack_builder->BuildString("INSERT INTO `results`( `type`, `href`, `sha1`, `base`, `path`,  `status`, `commit_timestamp`, `audit_start_timestamp`, `audit_completed_timestamp`, `spider_parent_result_id`) VALUES ");
	char *href_buff        = BP_BufferToHexString(href, bpstrlen(href));
	char *type_buff        = BP_SizeTToBuffer(type);
	char *status_code_buff = BP_SizeTToBuffer(status_code);
	char *parent_id_buff   = BP_SizeTToBuffer(parent_id);
	this->result_stack_builder->BuildString("( ");
	this->result_stack_builder->BuildString(type_buff);
	this->result_stack_builder->BuildString(",0x");
	this->result_stack_builder->BuildString(href_buff);
	this->result_stack_builder->BuildString(",SHA1(0x");
	this->result_stack_builder->BuildString(href_buff);
	this->result_stack_builder->BuildString("),");
	this->result_stack_builder->BuildString("0,0,");
	this->result_stack_builder->BuildString(status_code_buff);
	this->result_stack_builder->BuildString(",NOW(),0,0,");
	this->result_stack_builder->BuildString(parent_id_buff);
	this->result_stack_builder->BuildString("),");
	bpfree(href_buff);
	bpfree(type_buff);
	bpfree(status_code_buff);
	bpfree(parent_id_buff);
	if(this->result_stack_n == this->result_stacking_flush_rate)
	{
		this->flushInsertRequests();
	}
	return ERR_SUCCESS;
}
BP_ERROR_T Block :: stackInsertRequest ( size_t type , char * href , size_t status_code , size_t parent_id ) { if ( ! this -> result_stack_builder ) { this -> result_stack_builder = new BP_StringUtils ( NULL ) ; this -> result_stack_builder -> duplicate_unique_strings = true ; } if ( this -> result_stack_builder -> AddUniqueString ( href ) != true ) return ERR_FAILURE ; this -> result_stack_n ++ ; if ( ! this -> result_stack_builder -> build_str ) this -> result_stack_builder -> BuildString ( " " ) ; char * href_buff = BP_BufferToHexString ( href , bpstrlen ( href ) ) ; char * type_buff = BP_SizeTToBuffer ( type ) ; char * status_code_buff = BP_SizeTToBuffer ( status_code ) ; char * parent_id_buff = BP_SizeTToBuffer ( parent_id ) ; this -> result_stack_builder -> BuildString ( " " ) ; this -> result_stack_builder -> BuildString ( type_buff ) ; this -> result_stack_builder -> BuildString ( " " ) ; this -> result_stack_builder -> BuildString ( href_buff ) ; this -> result_stack_builder -> BuildString ( " " ) ; this -> result_stack_builder -> BuildString ( href_buff ) ; this -> result_stack_builder -> BuildString ( " " ) ; this -> result_stack_builder -> BuildString ( " " ) ; this -> result_stack_builder -> BuildString ( status_code_buff ) ; this -> result_stack_builder -> BuildString ( " " ) ; this -> result_stack_builder -> BuildString ( parent_id_buff ) ; this -> result_stack_builder -> BuildString ( " " ) ; bpfree ( href_buff ) ; bpfree ( type_buff ) ; bpfree ( status_code_buff ) ; bpfree ( parent_id_buff ) ; if ( this -> result_stack_n == this -> result_stacking_flush_rate ) { this -> flushInsertRequests ( ) ; } return ERR_SUCCESS ; }
stack new insert result (fast ad-hoc stacking using hex embedding, should be audited)
stack new insert result ( fast ad - hoc stacking using hex embedding should be audited )
// create new stack builder if necessary // create new string builder // set default behavior to duplicate the provided input string and // store the allocation as a pointer. // only add unique strings to the current stack (reduces insert overhead // further) // add result stack // display stacking message // printf("\n [+] Stacking unique element %zu", this->result_stack_n); // if the stack is empty, build on the front part // set buffers from quick conversions // destroy builder variables // check to see how many requests we have stacked // flush the requests if we've hit threshold // (this destroys all stacking related data and null resets variables) // return indicating success