db.h
changeset 14 51eb85ae4de4
parent 13 23a242d7b7fa
child 15 2706fc514dea
--- a/db.h	Mon Oct 31 17:17:07 2011 -0700
+++ b/db.h	Fri Nov 04 20:34:28 2011 -0700
@@ -31,54 +31,15 @@
 #ifndef _DB_H
 #define _DB_H
 
-#include "sqlite3.h"
-
-#define DBSQL_MATCH_REQUEST "                                       \
-	SELECT rewrite_rule, (                                          \
-		CASE WHEN scheme       IS null THEN 1 ELSE 0 END +          \
-		CASE WHEN host         IS null THEN 1 ELSE 0 END +          \
-		CASE WHEN tld          IS null THEN 1 ELSE 0 END +          \
-		CASE WHEN path         IS null THEN 1 ELSE 0 END +          \
-		CASE WHEN port         IS null THEN 1 ELSE 0 END +          \
-		CASE WHEN ip           IS null THEN 1 ELSE 0 END +          \
-		CASE WHEN user         IS null THEN 1 ELSE 0 END +          \
-		CASE WHEN method       IS null THEN 1 ELSE 0 END +          \
-		CASE WHEN rewrite_rule IS null THEN 1 ELSE 0 END ) as nullc \
-	FROM requests                                                   \
-	WHERE                                                           \
-		( scheme IS NULL OR scheme          = lower(?1) ) AND       \
-		( host   IS NULL OR lower( host )   = lower(?2) ) AND       \
-		( tld    IS NULL OR lower( tld )    = lower(?3) ) AND       \
-		( path   IS NULL OR lower( path ) LIKE '?4%'    ) AND       \
-		( port   IS NULL OR port            = ?5        ) AND       \
-		( ip     IS NULL OR ip              = ?6        ) AND       \
-		( user   IS NULL OR lower( user )   = lower(?7) ) AND       \
-		( method IS NULL OR lower( method ) = lower(?8) ) AND       \
-		rewrite_rule IS NOT null                                    \
-	ORDER BY                                                        \
-		length(path) DESC,                                          \
-		nullc ASC                                                   \
-	LIMIT 1"
-
-/* Pull the entire rewrite rule row. */
-#define DBSQL_GET_REWRITE_RULE "\
-	SELECT * \
-	FROM rewrite_rules \
-	WHERE id = ?1"
-
-extern const unsigned short int DB_VERSION;
-
 /*
  * Function prototypes
  *
  */
-int db_attach( void );
-int db_upgrade( unsigned short int );
-unsigned short int prepare_statements( void );
-short int db_version( void );
-rewrite *init_rewrite( void );
-rewrite *prepare_rewrite( request * );
-void finish_rewrite( rewrite * );
+short int db_attach( void );
+unsigned short int db_create_new( char * );
+struct db_input *parse_dbinput( char * );
+char *find_record( char * );
+unsigned int find_records( char *, parsed ** );
 
 #endif