library/src/databases/bpdb/BP-DBSQLSyntaxGenerators.cc
// attempt to check tablenames against schema
attempt to check tablenames against schema
attempt to check tablenames against schema
BP_ERROR_T BP_DBCheckTableNamesAgainstSchema(P_BPDB_SQLGEN syngen, P_BP_LINKL table_name_list)
{
	if(!syngen)
		return ERR_FAILURE;
	if(!syngen->bpdb)
		return ERR_FAILURE;
	if(!table_name_list)
		return ERR_FAILURE;
	P_BP_LINKL_DATA table_name_iter = TAILQ_FIRST(&table_name_list->head);
	if(!table_name_iter)
		return ERR_FAILURE;
	TAILQ_FOREACH(table_name_iter, &table_name_list->head, linkl_data)
	{
		if
		(
			table_name_iter->data_type != BP_MEMPROF_ALLOC_TYPE_STRDUP   &&
			table_name_iter->data_type != BP_MEMPROF_ALLOC_TYPE_STRNDUP
		)
		{
			return ERR_FAILURE;
		}
		if(!BP_DBLookupTableByName(syngen->bpdb, (char *) table_name_iter->data))
			return ERR_FAILURE;
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DBCheckTableNamesAgainstSchema ( P_BPDB_SQLGEN syngen , P_BP_LINKL table_name_list ) { if ( ! syngen ) return ERR_FAILURE ; if ( ! syngen -> bpdb ) return ERR_FAILURE ; if ( ! table_name_list ) return ERR_FAILURE ; P_BP_LINKL_DATA table_name_iter = TAILQ_FIRST ( & table_name_list -> head ) ; if ( ! table_name_iter ) return ERR_FAILURE ; TAILQ_FOREACH ( table_name_iter , & table_name_list -> head , linkl_data ) { if ( table_name_iter -> data_type != BP_MEMPROF_ALLOC_TYPE_STRDUP && table_name_iter -> data_type != BP_MEMPROF_ALLOC_TYPE_STRNDUP ) { return ERR_FAILURE ; } if ( ! BP_DBLookupTableByName ( syngen -> bpdb , ( char * ) table_name_iter -> data ) ) return ERR_FAILURE ; } return ERR_SUCCESS ; }
attempt to check tablenames against schema
attempt to check tablenames against schema
// basic null checks // attempt to get the first item // ensure we have a first item // looks for a pointer in the item // only work with strndup/strdup types // return indicating failure // lookup the table and make sure it exists // return indicating success