Why doesn't the db grow?

new topic     » topic index » view thread      » older message » newer message

So i pulled this out of mothballs. I'm not even sure why I wrote it but as I'm in the process of putting almost everything up on github ...

When I run this the edb file never grows beyond 442 bytes. What was I doing wrong?

include std/net/dns.e 
include std/rand.e 
include std/math.e 
include std/eds.e 
include std/filesys.e 
 
--with trace 
--trace(2) 
 
object eds 
eds = dir("bofls.edb") 
if atom( eds ) then 
	if db_create("bofls.edb", DB_LOCK_NO) != DB_OK then 
		puts(2, "Couldn't create the database!\n") 
		abort(1) 
	end if 
else 
	if db_open("bofls.edb") != DB_OK then 
		puts(2, "Couldn't create the database!\n") 
		abort(1) 
	end if 
end if 
 
if db_create_table("ip") != DB_OK then 
    puts(2, "ip table already exists!\n") 
end if 
 
check_free_list() 
 
sequence errs = db_get_errors() 
if length(errs) != 0 then 
    --display_errors(errs) 
    abort(1) 
end if 
 
if db_compress() != DB_OK then 
    puts(2, "compress failed!\n") 
end if 
 
set_rand("") 
 
integer c = 0 
while 1 label "one" do 
	integer i = rand_range(1,254) 
	integer j = rand_range(1,254) 
	integer k = rand_range(1,254) 
	integer l = rand_range(1,254) 
	if i = 1 or i = 10 or i = 192 then 
		continue "one" 
	end if 
	sequence addr = sprintf("%d.%d.%d.%d", {i, j, k, l}) 
	if db_find_key( addr ) < 0 then 
		object hba = host_by_addr(addr) 
		puts( 1, addr ) 
		if not atom(hba) then 
			puts(1, " " & hba[1] & "\n") 
			if db_insert( addr, hba[1] ) != DB_OK then 
				puts( 1, "Cannot insert!\n") 
			end if 
		else 
			puts(1, "\n") 
		end if 
	else  
	    -- puts(1, "Found " & addr & "\n") 
	end if 
	c = c + 1 
	printf(1, "%d\r", c ) 
	integer key = get_key() 
	if key != -1 then 
		--puts(1, sprintf("%d\r", {key})) 
		if key = 27 then 
			exit "one"  
		end if 
	end if 
end while 
 
db_close() 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu