library/src/blockclass/BP-BlockClass.cc
// Insert an email into the discovered emails list.
Insert an email into the discovered emails list.
Insert an email into the discovered emails list .
size_t Block::insertDiscoveredEmail(char *email_address)
{
	if(!this->mysqlSession)
		return ERR_FAILURE;
	BP_BLOCK_MARIADB_ENTER_CRITICAL_SECTION;
	if(!email_address)
		BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);
	if(!this->mysqlSession)
		BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);
	char * query = (char *) "INSERT INTO `discovered_emails`(`result_id`, `sha1`, `email`) VALUES (?,  SHA1(?), ? )";
	if (this->mysqlPrepareQuery((char *) query ) == ERR_FAILURE)
	{
		this->AddErrorToStack((char*) "\n Cannot prepare query");
		BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);
	}
	this->mysqlPrepareQuery(query);
	this->mysqlAddParameter(MYSQL_TYPE_LONG, (char *) &this->web_result_id, sizeof(this->web_result_id));
	this->mysqlAddParameter(MYSQL_TYPE_STRING, (char *) email_address, bpstrlen(email_address));
	this->mysqlAddParameter(MYSQL_TYPE_STRING, (char *) email_address, bpstrlen(email_address));
	this->mysqlBindParameters();
	this->mysqlExecuteStatement();
	BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_SUCCESS);
}
size_t Block :: insertDiscoveredEmail ( char * email_address ) { if ( ! this -> mysqlSession ) return ERR_FAILURE ; BP_BLOCK_MARIADB_ENTER_CRITICAL_SECTION ; if ( ! email_address ) BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_FAILURE ) ; if ( ! this -> mysqlSession ) BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_FAILURE ) ; char * query = ( char * ) " " ; if ( this -> mysqlPrepareQuery ( ( char * ) query ) == ERR_FAILURE ) { this -> AddErrorToStack ( ( char * ) " \n " ) ; BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_FAILURE ) ; } this -> mysqlPrepareQuery ( query ) ; this -> mysqlAddParameter ( MYSQL_TYPE_LONG , ( char * ) & this -> web_result_id , sizeof ( this -> web_result_id ) ) ; this -> mysqlAddParameter ( MYSQL_TYPE_STRING , ( char * ) email_address , bpstrlen ( email_address ) ) ; this -> mysqlAddParameter ( MYSQL_TYPE_STRING , ( char * ) email_address , bpstrlen ( email_address ) ) ; this -> mysqlBindParameters ( ) ; this -> mysqlExecuteStatement ( ) ; BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_SUCCESS ) ; }
Insert an email into the discovered emails list.
Insert an email into the discovered emails list .
// ensure we have a mysql session // enter critical section // check if we have an email address // update query // prepare query // add result type // add href // add sha1 // bind parameters // execute query // return indicating success