Skip to content

Commit

Permalink
Some documentation.
Browse files Browse the repository at this point in the history
git-svn-id: https://subversion.cs.uiuc.edu/svn/bang/eoh2009@44 69d76c3e-0761-0410-948c-9895a8bb34fc
  • Loading branch information
nbysani2 committed Jan 25, 2009
1 parent fbec1d6 commit fbdaa62
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/base/bang-routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
#include<uuid/uuid.h>

#define CREATE_MAPPINGS "CREATE TABLE mappings(route_uuid blob unique primary key, remote integer, peer_id int, module blob, name text, version blob)"
#define CREATE_PEER_LIST "CREATE TABLE peers(id int)"
#define CREATE_ROUTES "CRATE TABLE routes(fst_peer blob, snd_peer blob)"
#define INSERT_STATEMENT "INSERT INTO mappings(route_uuid,remote,module,peer_id,name,text) VALUES (?,?,?,?,?)"
#define SELECT_STATEMENT "SELECT remote,module,peer_id,name,version FROM mappings WHERE ? = route_uuid"

#define CREATE_PEER_LIST "CREATE TABLE peers(id int)"
#define INSERT_PEER "INSERT INTO peers(id) VALUES (?)"
#define INSERT_ROUTE "INSERT INTO routes(fst_peer,snd_peer) VALUES (?,?)"
#define DELETE_PEER "DELETE FROM peers WHERE ? = id"
#define SELECT_STATEMENT "SELECT remote,module,peer_id,name,version FROM mappings WHERE ? = route_uuid"

#define CREATE_ROUTES "CREATE TABLE routes(fst_peer blob, snd_peer blob)"
#define INSERT_ROUTE "INSERT INTO routes(fst_peer,snd_peer) VALUES (?,?)"

#define DB_FILE ":memory:"
#define REMOTE_ROUTE 2
#define LOCAL_ROUTE 1

static sqlite3 *db;

/* TODO: Many elements in the functions are the same, consolidate somehow. DRY, afterall*/
/**
* TODO: START ERROR CHECKING THE SQL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/

static sqlite3_stmt* prepare_select_statement(uuid_t uuid);

Expand All @@ -42,6 +45,8 @@ static void catch_peer_added(int signal, int num_peers, void **p);

static void catch_peer_removed(int signal, int num_peers, void **p);

static sqlite3 *db;

static void mem_append(void *dst, void *src, int length, int *pos) {
memcpy(dst + *pos,src,length);
*pos += length;
Expand Down Expand Up @@ -84,6 +89,8 @@ static sqlite3_stmt* prepare_select_statement(uuid_t uuid) {
return get_peer_route;
}

/* TODO: Many elements in the functions are the same, consolidate somehow. DRY, afterall*/

void BANG_route_job(uuid_t authority, uuid_t peer, BANG_job *job) {
assert(!uuid_is_null(authority));
assert(!uuid_is_null(peer));
Expand Down

0 comments on commit fbdaa62

Please sign in to comment.