diff options
Diffstat (limited to 'src/analysis/db/items')
| -rw-r--r-- | src/analysis/db/items/bookmark.c | 61 | ||||
| -rw-r--r-- | src/analysis/db/items/bookmark.h | 2 | 
2 files changed, 50 insertions, 13 deletions
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c index c28a837..6ff386c 100644 --- a/src/analysis/db/items/bookmark.c +++ b/src/analysis/db/items/bookmark.c @@ -75,6 +75,9 @@ static bool g_db_bookmark_recv_from_fd(GDbBookmark *, int, int);  /* Exporte la définition d'un signet dans un flux réseau. */  static bool g_db_bookmark_send_to_fd(const GDbBookmark *, int, int); +/* Constitue les champs destinés à une insertion / modification. */ +static bool g_db_bookmark_prepare_db_statement(const GDbBookmark *, bool, bound_value **, size_t *); + @@ -97,10 +100,8 @@ bool create_bookmark_db_table(sqlite3 *db)      char *msg;                              /* Message d'erreur            */      sql = "CREATE TABLE Bookmarks ("            \ -             "id INT PRIMARY KEY NOT NULL, "    \ -             "user TEXT NOT NULL, "             \ -             "created INT NOT NULL, "           \ -             "address INT NOT NULL, "           \ +             SQLITE_DB_ITEM_CREATE              \ +             SQLITE_VMPA_CREATE                 \               "comment TEXT"                     \            ");"; @@ -157,6 +158,8 @@ static void g_db_bookmark_class_init(GDbBookmarkClass *klass)      item->recv = (recv_db_item_fc)g_db_bookmark_recv_from_fd;      item->send = (send_db_item_fc)g_db_bookmark_send_to_fd; +    item->prepare_stmt = (prepare_db_statement)g_db_bookmark_prepare_db_statement; +  } @@ -235,13 +238,7 @@ GDbBookmark *g_db_bookmark_new(const vmpa2t *addr, const char *comment)      result = g_object_new(G_TYPE_DB_BOOKMARK, NULL); - - - -    /* TODO */ - -    //dup addr; - +    copy_vmpa(&result->addr, addr);      g_db_bookmark_set_comment(result, comment); @@ -351,6 +348,46 @@ static bool g_db_bookmark_send_to_fd(const GDbBookmark *bookmark, int fd, int fl  } +/****************************************************************************** +*                                                                             * +*  Paramètres  : item   = base d'éléments sur laquelle s'appuyer.             * +*                create = indique si la préparation vise une création ou non. * +*                values = couples de champs et de valeurs à lier. [OUT]       * +*                count  = nombre de ces couples. [OUT]                        * +*                                                                             * +*  Description : Constitue les champs destinés à une insertion / modification.* +*                                                                             * +*  Retour      : Etat du besoin en sauvegarde.                                * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_db_bookmark_prepare_db_statement(const GDbBookmark *bookmark, bool create, bound_value **values, size_t *count) +{ +    bool status;                            /* Bilan d'opération initiale  */ +    bound_value *value;                     /* Valeur à éditer / définir   */ + +    status = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->prepare_stmt(G_DB_ITEM(bookmark), create, values, count); +    if (!status) return false; + +    status = prepare_vmpa_db_statement(&bookmark->addr, create, values, count); +    if (!status) return false; + +    *values = (bound_value *)realloc(*values, ++(*count) * sizeof(bound_value)); +    value = &(*values)[*count - 1]; + +    value->name = "comment"; +    value->type = SQLITE_TEXT; +    value->cstring = g_db_bookmark_get_comment(bookmark); +    value->delete = SQLITE_STATIC; + +    return true; + +} + + + @@ -370,7 +407,7 @@ static bool g_db_bookmark_send_to_fd(const GDbBookmark *bookmark, int fd, int fl  *                                                                             *  ******************************************************************************/ -vmpa2t *g_db_bookmark_get_address(GDbBookmark *bookmark) +const vmpa2t *g_db_bookmark_get_address(GDbBookmark *bookmark)  {      return &bookmark->addr; diff --git a/src/analysis/db/items/bookmark.h b/src/analysis/db/items/bookmark.h index d1b073c..cd5e202 100644 --- a/src/analysis/db/items/bookmark.h +++ b/src/analysis/db/items/bookmark.h @@ -66,7 +66,7 @@ GType g_db_bookmark_get_type(void);  GDbBookmark *g_db_bookmark_new(const vmpa2t *, const char *);  /* Fournit l'adresse associée à un signet. */ -vmpa2t *g_db_bookmark_get_address(GDbBookmark *); +const vmpa2t *g_db_bookmark_get_address(GDbBookmark *);  /* Fournit le commentaire associé à un signet. */  const char *g_db_bookmark_get_comment(const GDbBookmark *);  | 
