#!/usr/bin/perl use DBD::SQLite; use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=url.db","",""); if (!$dbh) { die "can't connect to database!\n"; } my $sth = $dbh->prepare("select count(*) from links"); $sth->execute; my @row = $sth->fetchrow_array; if (!@row or $#row<0) { die "now links defined!\n"; } print <\n"; my $a = $row[0]-1; print "const int links_len = $a;\n"; $sth->finish; my $sth = $dbh->prepare("select referer,url from links"); $sth->execute; print "#define VHOST \"$ARGV[0]\"\n"; print "struct link_t links [] = {\n"; while ( my @ar =$sth->fetchrow_array) { print "\t{\"$ar[0]\",\"$ar[1]\"},\n" } print "\tNULL\n"; print "};\n#endif\n"; $sth->finish; $dbh->disconnect;