diff options
Diffstat (limited to 'hybring.cr')
-rw-r--r-- | hybring.cr | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/hybring.cr b/hybring.cr index 4b37469..f4a2f07 100644 --- a/hybring.cr +++ b/hybring.cr @@ -19,6 +19,7 @@ require "http/server" require "uri" +require "./sqlite" require "./xhtml" MAX_CONTENT_LENGTH = 4096 @@ -26,38 +27,11 @@ OPENNIC_TLD = Set{".bbs", ".chan", ".cyb", ".dyn", ".epic", ".geek", ".gopher", ".indy", ".libre", ".neo", ".null", ".o", ".oss", ".oz", ".parody", ".pirate"} -@[Link("sqlite3")] -lib SQLite - type Database = Void* - type Statement = Void* - fun open = sqlite3_open(filename : LibC::Char*, db : Database*) : LibC::Int - fun prepare = sqlite3_prepare(db : Database, query : LibC::Char*, - length : LibC::Int, stmt : Statement*, - query_tail : LibC::Char*) : LibC::Int - fun step = sqlite3_step(stmt : Statement) : Int32 - fun column_text = sqlite3_column_text(stmt : Statement, - col : LibC::Int) : LibC::Char* - fun finalize = sqlite3_finalize(stmt : Statement) : LibC::Int - fun close = sqlite3_close(db : Database) : LibC::Int -end - -DB_INIT = "CREATE TABLE member ( - id INTEGER PRIMARY KEY, - nick TEXT NOT NULL UNIQUE, - opennic TEXT NOT NULL UNIQUE, - icann TEXT NOT NULL UNIQUE, -);"; - -SQLite.open "foo.db", out db -begin -ensure - SQLite.close db -end - def http_error(context, status, message = nil) context.response.respond_with_status status, message end +db = Database.new "hybring.db" File.write "index.xhtml", page server = HTTP::Server.new do |context| # Manually crafted request |