Fix lots of splint issues (including memory leaks). This includes some changes

in qof and gnc files adding annotation comments to help splint analyze ownership
of memory and objects.



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17983 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Phil Longstaff
2009-03-09 17:17:57 +00:00
parent 0621803bd6
commit 945e700a37
41 changed files with 1298 additions and 896 deletions

View File

@@ -183,7 +183,7 @@ const gchar * guid_to_string (const GUID * guid);
*
* @return A pointer to the terminating null character of the string.
*/
gchar * guid_to_string_buff (const GUID * guid, gchar *buff);
gchar * guid_to_string_buff (const GUID * guid, /*@ out @*/ gchar *buff);
/** Given a string, decode the id into the guid if guid is non-NULL.
@@ -191,7 +191,7 @@ gchar * guid_to_string_buff (const GUID * guid, gchar *buff);
* hexadecimal number. This function accepts both upper and lower case
* hex digits. If the return value is FALSE, the effect on guid is
* undefined. */
gboolean string_to_guid(const gchar * string, GUID * guid);
gboolean string_to_guid(const gchar * string, /*@ out @*/ GUID * guid);
/** Given two GUIDs, return TRUE if they are non-NULL and equal.

View File

@@ -373,7 +373,7 @@ KvpValue * kvp_frame_get_value(const KvpFrame *frame, const gchar *path);
* @return The KvpFrame at the specified path, or NULL if it doesn't
* exist.
*/
KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
/*@ dependent @*/ KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
/** This routine returns the last frame of the path.
* If the frame path doesn't exist, it is created.
@@ -641,7 +641,7 @@ GList * kvp_value_get_glist(const KvpValue * value);
/** Value accessor. This one is non-copying -- the caller can modify
* the value directly. */
KvpFrame * kvp_value_get_frame(const KvpValue * value);
/*@ dependent @*/ KvpFrame * kvp_value_get_frame(const KvpValue * value);
Timespec kvp_value_get_timespec(const KvpValue * value);
/**

View File

@@ -241,12 +241,12 @@
struct QofBackendProvider_s
{
/** Some arbitrary name given for this particular backend provider */
const char * provider_name;
/*@ observer @*/ const char * provider_name;
/** The access method that this provider provides, for example,
* file:// http:// postgres:// or sqlite://, but without the :// at the end
*/
const char * access_method;
/*@ observer @*/ const char * access_method;
/** \brief Partial QofBook handler
@@ -277,10 +277,10 @@ struct QofBackendProvider_s
types match the incoming data. The backend should not assume that
returning TRUE will mean that the data will naturally follow.
*/
gboolean (*check_data_type) (const char*);
/*@ null @*/ gboolean (*check_data_type) (const char*);
/** Free this structure, unregister this backend handler. */
void (*provider_free) (QofBackendProvider *);
void (*provider_free) (/*@ only @*/ QofBackendProvider *);
};
typedef enum {
@@ -296,9 +296,9 @@ struct QofBackend_s
gboolean ignore_lock,
gboolean create_if_nonexistent);
void (*session_end) (QofBackend *);
void (*destroy_backend) (QofBackend *);
void (*destroy_backend) (/*@ only @*/ QofBackend *);
void (*load) (QofBackend *, QofBook *, QofBackendLoadType);
void (*load) (QofBackend *, /*@ dependent @*/ QofBook *, QofBackendLoadType);
void (*begin) (QofBackend *, QofInstance *);
void (*commit) (QofBackend *, QofInstance *);
@@ -308,9 +308,9 @@ struct QofBackend_s
void (*free_query) (QofBackend *, gpointer);
void (*run_query) (QofBackend *, gpointer);
void (*sync) (QofBackend *, QofBook *);
void (*sync) (QofBackend *, /*@ dependent @*/ QofBook *);
void (*load_config) (QofBackend *, KvpFrame *);
KvpFrame* (*get_config) (QofBackend *);
/*@ observer @*/ KvpFrame* (*get_config) (QofBackend *);
gint64 (*counter) (QofBackend *, const char *counter_name);
gboolean (*events_pending) (QofBackend *);
@@ -370,7 +370,7 @@ struct QofBackend_s
* backend library may register more than one provider, if it is
* capable of handling more than one URL access method.
*/
void qof_backend_register_provider (QofBackendProvider *);
void qof_backend_register_provider (/*@ only @*/ QofBackendProvider *);
/** The qof_backend_set_message() assigns a string to the backend error message.
*/

View File

@@ -158,7 +158,7 @@ typedef struct QofBackendProvider_s QofBackendProvider;
typedef struct QofBackend_s QofBackend;
/** \brief DOCUMENT ME! */
typedef void (*QofBePercentageFunc) (const char *message, double percent);
typedef void (*QofBePercentageFunc) (/*@ null @*/ const char *message, double percent);
/** @name Allow access to the begin routine for this backend. */
//@{

View File

@@ -175,7 +175,7 @@ void qof_book_mark_closed (QofBook *book);
* a non-NULL value. (Unless the system malloc failed (out of
* memory) in which case what happens??).
*/
QofCollection * qof_book_get_collection (const QofBook *, QofIdType);
/*@ dependent @*/ QofCollection * qof_book_get_collection (const QofBook *, QofIdType);
/** Invoke the indicated callback on each collection in the book. */
typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);

View File

@@ -142,14 +142,14 @@ typedef struct _QofParam QofParam;
* also provides a place for the user to hang additional user-defined
* data.
*/
typedef gpointer (*QofAccessFunc)(gpointer object, const QofParam *param);
typedef gpointer (*QofAccessFunc)(gpointer object, /*@ null @*/ const QofParam *param);
/** The QofSetterFunc defines an function pointer for parameter
* setters. Real functions must be of the form:
*
* void setter_func (object_type *self, param_type *param);
*/
typedef void (*QofSetterFunc) (gpointer, gpointer);
typedef void (*QofSetterFunc) (gpointer, /*@ null @*/ gpointer);
/* A callback for how to compare two (same-type) objects based on a
* common getter (parameter member), using the provided comparison

View File

@@ -168,7 +168,7 @@ void qof_collection_destroy (QofCollection *col);
QofIdType qof_collection_get_type (const QofCollection *);
/** Find the entity going only from its guid */
QofInstance * qof_collection_lookup_entity (const QofCollection *, const GUID *);
/*@ dependent @*/ QofInstance * qof_collection_lookup_entity (const QofCollection *, const GUID *);
/** Callback type for qof_collection_foreach */
typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);

View File

@@ -87,7 +87,7 @@ GType qof_instance_get_type(void);
void qof_instance_init_data (QofInstance *, QofIdType, QofBook *);
/** Return the book pointer */
QofBook *qof_instance_get_book (gconstpointer);
/*@ dependent @*/ QofBook *qof_instance_get_book (gconstpointer);
/** Set the book pointer */
void qof_instance_set_book (gconstpointer inst, QofBook *book);
@@ -99,14 +99,14 @@ void qof_instance_copy_book (gpointer ptr1, gconstpointer ptr2);
gboolean qof_instance_books_equal (gconstpointer ptr1, gconstpointer ptr2);
/** Return the GUID of this instance */
const GUID * qof_instance_get_guid (gconstpointer);
/*@ dependent @*/ const GUID * qof_instance_get_guid (gconstpointer);
/** \deprecated Use qof_instance_get_guid instead.
* Works like qof_instance_get_guid, but returns NULL on NULL */
const GUID * qof_entity_get_guid (gconstpointer);
/*@ dependent @*/ const GUID * qof_entity_get_guid (gconstpointer);
/** Return the collection this instance belongs to */
QofCollection* qof_instance_get_collection (gconstpointer inst);
/*@ dependent @*/ QofCollection* qof_instance_get_collection (gconstpointer inst);
/** Set the GUID of this instance */
void qof_instance_set_guid (gpointer inst, const GUID *guid);
@@ -125,7 +125,7 @@ gint qof_instance_guid_compare(const gconstpointer ptr1, const gconstpointer ptr
//void qof_instance_set_e_type (QofInstance *ent, QofIdType e_type);
/** Return the pointer to the kvp_data */
KvpFrame* qof_instance_get_slots (const QofInstance *);
/*@ dependent @*/ KvpFrame* qof_instance_get_slots (const QofInstance *);
/** Return the last time this instance was modified. If QofInstances
* are used with the QofObject storage backends, then the instance

View File

@@ -199,7 +199,7 @@ void qof_log_set_default(QofLogLevel log_level);
/** Print a function entry debugging message */
#define ENTER(format, args...) do { \
if (qof_log_check(log_module, G_LOG_LEVEL_DEBUG)) { \
if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[enter %s:%s()] " format, __FILE__, \
PRETTY_FUNC_NAME , ## args); \
@@ -221,7 +221,7 @@ void qof_log_set_default(QofLogLevel log_level);
/** Print a function exit debugging message. **/
#define LEAVE(format, args...) do { \
if (qof_log_check(log_module, G_LOG_LEVEL_DEBUG)) { \
if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
qof_log_dedent(); \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[leave %s()] " format, \

View File

@@ -167,7 +167,7 @@ gboolean qof_object_register_backend (QofIdTypeConst type_name,
const char *backend_name,
gpointer be_data);
gpointer qof_object_lookup_backend (QofIdTypeConst type_name,
/*@ dependent @*/ gpointer qof_object_lookup_backend (QofIdTypeConst type_name,
const char *backend_name);
void qof_object_foreach_backend (const char *backend_name,

View File

@@ -43,10 +43,10 @@ int qof_query_get_max_results (const QofQuery *q);
* Note that you should NOT modify this list in any way. It belongs
* to the query.
*/
GList * qof_query_get_terms (const QofQuery *q);
/*@ dependent @*/ GList * qof_query_get_terms (const QofQuery *q);
GSList * qof_query_term_get_param_path (const QofQueryTerm *queryterm);
QofQueryPredData *qof_query_term_get_pred_data (const QofQueryTerm *queryterm);
/*@ dependent @*/ GSList * qof_query_term_get_param_path (const QofQueryTerm *queryterm);
/*@ dependent @*/ QofQueryPredData *qof_query_term_get_pred_data (const QofQueryTerm *queryterm);
gboolean qof_query_term_is_inverted (const QofQueryTerm *queryterm);
@@ -58,7 +58,7 @@ gboolean qof_query_term_is_inverted (const QofQueryTerm *queryterm);
void qof_query_get_sorts (QofQuery *q, QofQuerySort **primary,
QofQuerySort **secondary, QofQuerySort **tertiary);
GSList * qof_query_sort_get_param_path (const QofQuerySort *querysort);
/*@ dependent @*/ GSList * qof_query_sort_get_param_path (const QofQuerySort *querysort);
gint qof_query_sort_get_sort_options (const QofQuerySort *querysort);
gboolean qof_query_sort_get_increasing (const QofQuerySort *querysort);

View File

@@ -371,7 +371,7 @@ gboolean qof_query_equal (const QofQuery *q1, const QofQuery *q2);
void qof_query_print (QofQuery *query);
/** Return the type of data we're querying for */
QofIdType qof_query_get_search_for (const QofQuery *q);
/*@ dependent @*/ QofIdType qof_query_get_search_for (const QofQuery *q);
/** Return the list of books we're using */
GList * qof_query_get_books (QofQuery *q);

121
splint-defs.h Normal file
View File

@@ -0,0 +1,121 @@
/********************************************************************
* splint-defs.h: declarations from system include files needed to *
* provide splint with memory usage patterns. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
\********************************************************************/
/* Only need this if running splint. This file contains lines copied from the other
include files, but with the splint annotations added. Yes, this is dangerous if the
definitions change. However, these definitions aren't used during regular compilation,
only when running splint, so the danger is manageable. */
#if !defined( SPLINT_DEFS_H ) && defined( S_SPLINT_S )
#define SPLINT_DEFS_H
/*@ -incondefs @*/
/* Each section is surrounded by the include guard of the appropriate include file */
/* dbi.h */
#ifdef __DBI_H__
void dbi_conn_close( /*@ only @*/ dbi_conn );
int dbi_conn_error( dbi_conn, /*@ out @*/ const char** );
dbi_result dbi_conn_get_table_list( dbi_conn, const char*, /*@ null @*/ const char* );
/*@ dependent @*/ const char* dbi_conn_get_option( dbi_conn, const char* );
int dbi_result_free( /*@ only @*/ dbi_result );
/*@ dependent @*/ const char* dbi_result_get_string_idx( dbi_result, unsigned int );
dbi_driver dbi_driver_list( /*@ null @*/ dbi_driver );
size_t dbi_conn_quote_string_copy( dbi_conn, const char*, /*@ out @*/ char** );
/*@ dependent @*/ dbi_driver_get_name( dbi_driver );
#endif
/* gdate.h */
#ifdef __G_DATE_H__
void g_date_free( /*@ only @*/ GDate* );
#endif
/* gmem.h */
#ifdef __G_MEM_H__
/*@ null @*/ /*@ only @*/ /*@ out @*/ gpointer g_malloc(gsize n_bytes);
/*@ null @*/ /*@ only @*/ /*@ out @*/ gpointer g_malloc0(gsize n_bytes);
void g_free( /*@ only @*/ gpointer );
#endif
/* gvalue.h */
#ifdef __G_VALUE_H__
GValue* g_value_init( /*@ out @*/ GValue*, GType );
/*@ dependent @*/ const gchar* g_value_get_string(const GValue *value);
void g_value_take_string( GValue*, /*@ only @*/ const gchar *);
#endif
/* gstring.h */
#ifdef __G_STRING_H__
gchar* g_string_free( /*@ only @*/ GString*, gboolean );
#endif
/* ghash.h */
#ifdef __G_HASH_H__
GHashTable* g_hash_table_new_full( GHashFunc, GEqualFunc, /*@ null @*/ GDestroyNotify, /*@ null @*/ GDestroyNotify );
void g_hash_table_insert(GHashTable *hash_table, /*@ only @*/ gpointer key, gpointer value);
/*@ dependent @*/ g_hash_table_lookup( GHashTable* hash_table, gpointer key );
#endif
/* glist.h */
#ifdef __G_LIST_H__
GList* g_list_append( /*@ returned @*//*@ null @*/ GList*, /*@ keep @*/ gpointer );
GList* g_list_prepend( /*@ returned @*//*@ null @*/ GList*, /*@ keep @*/ gpointer );
void g_list_free( /*@ only @*/ GList* );
#endif
/* gslist.h */
#ifdef __G_SLIST_H__
GSList* g_slist_append( /*@ returned @*//*@ null @*/ GSList*, /*@ keep @*/ gpointer );
void g_slist_free( /*@ only @*/ GSList* );
#endif
/* gstrfuncs.h */
#ifdef __G_STRFUNCS_H__
gint64 g_ascii_strtoll( const gchar*, /*@ null @*/ gchar**, guint );
#endif
/* gtype.h */
#ifdef __G_TYPE_H__
/*@ dependent @*/ GTypeInstance* g_type_check_instance_cast(GTypeInstance *instance,
GType iface_type);
#endif
/* gtestutils.h */
#ifdef __G_TEST_UTILS_H__
#undef g_assert
#define g_assert assert
#endif
/*@ +incondefs @*/
#endif /* SPLINT_DEFS_H */

31
src/backend/dbi/.splintrc Normal file
View File

@@ -0,0 +1,31 @@
-DHAVE_CONFIG_H
-DG_LOG_DOMAIN="gnc.backend.dbi"
-DLOCALE_DIR="/opt/gnucash2-svn/share/locale"
-DORBIT2=1
-D_FORTIFY_SOURCE=2
-I.
-I..
-I../..
-I../../..
-I../../gnc-module
-I../../../src/backend
-I../../../src/backend/sql
-I../../../src/engine
-I../../../src/core-utils
-I../../../lib/libc
-I../../../lib/libqof/qof
-I../../../lib/libqof/qof
-I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include
-I/usr/include/gconf/2
-I/usr/include/orbit-2.0
-I/usr/include/dbus-1.0
-I/usr/lib/dbus-1.0/include
-I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include
-booltype gboolean
+posixlib
-branchstate
-fcnuse

File diff suppressed because it is too large Load Diff

View File

@@ -20,25 +20,25 @@ int gnc_module_current = 0;
int gnc_module_revision = 0;
int gnc_module_age = 0;
static GNCModule engine;
/*@ dependent @*//*@ null @*/ static GNCModule engine;
gchar *
gnc_module_path(void)
{
return g_strdup("gnucash/backend/dbi");
return g_strdup( "gnucash/backend/dbi" );
}
gchar *
gnc_module_description(void)
{
return g_strdup("The DBI/SQL backend for GnuCash");
return g_strdup( "The DBI/SQL backend for GnuCash" );
}
int
gnc_module_init(int refcount)
{
engine = gnc_module_load("gnucash/engine", 0);
if(!engine) return FALSE;
engine = gnc_module_load( "gnucash/engine", 0 );
if( !engine ) return FALSE;
/* Need to initialize g-type engine for gconf */
if (refcount == 0) {
@@ -53,11 +53,13 @@ gnc_module_end(int refcount)
{
int unload = TRUE;
if (engine)
if( engine != NULL ) {
unload = gnc_module_unload(engine);
}
if (refcount == 0)
if( refcount == 0 ) {
engine = NULL;
}
return unload;
}

39
src/backend/sql/.splintrc Normal file
View File

@@ -0,0 +1,39 @@
-DHAVE_CONFIG_H
-I.
-I../../..
-DG_LOG_DOMAIN="gnc.backend.sql"
-I..
-I../..
-DLOCALE_DIR="/opt/gnucash2-svn/share/locale"
-I../../../src/backend
-I../../../src/engine
-I../../../src/core-utils
-I../../../lib/libc
-I../../../lib/libqof/qof
-I../../../lib/libqof/qof
-I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include
-DORBIT2=1
-I/usr/include/gconf/2
-I/usr/include/orbit-2.0
-I/usr/include/dbus-1.0
-I/usr/lib/dbus-1.0/include
-I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include
-D_FORTIFY_SOURCE=2
+posixlib
# Needed for programs using glib typedefs
-booltype gboolean
# Extra flags about stuff we don't want to worry about right now
-dependenttrans
-branchstate
-fcnuse
-temptrans
-exportlocal
-unqualifiedtrans
-onlytrans
-usedef
-compmempass

View File

@@ -42,14 +42,18 @@
#include "gnc-slots-sql.h"
#include "gnc-transaction-sql.h"
#if defined( S_SPLINT_S )
#include "splint-defs.h"
#endif
static QofLogModule log_module = G_LOG_DOMAIN;
#define TABLE_NAME "accounts"
#define TABLE_VERSION 1
static gpointer get_parent( gpointer pObject, const QofParam* );
static void set_parent( gpointer pObject, gpointer pValue );
static void set_parent_guid( gpointer pObject, gpointer pValue );
static /*@ null @*//*@ dependent @*/ gpointer get_parent( gpointer pObject );
static void set_parent( gpointer pObject, /*@ null @*/ gpointer pValue );
static void set_parent_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
#define ACCOUNT_MAX_NAME_LEN 2048
#define ACCOUNT_MAX_TYPE_LEN 2048
@@ -58,36 +62,37 @@ static void set_parent_guid( gpointer pObject, gpointer pValue );
static const GncSqlColumnTableEntry col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "name", CT_STRING, ACCOUNT_MAX_NAME_LEN, COL_NNUL, "name" },
{ "account_type", CT_STRING, ACCOUNT_MAX_TYPE_LEN, COL_NNUL, NULL, ACCOUNT_TYPE_ },
{ "commodity_guid", CT_COMMODITYREF, 0, COL_NNUL, "commodity" },
{ "commodity_scu", CT_INT, 0, COL_NNUL, "commodity-scu" },
{ "non_std_scu", CT_BOOLEAN, 0, COL_NNUL, "non-std-scu" },
{ "parent_guid", CT_GUID, 0, 0, NULL, NULL, get_parent, set_parent },
{ "parent_guid", CT_GUID, 0, 0, NULL, NULL,
(QofAccessFunc)get_parent, set_parent },
{ "code", CT_STRING, ACCOUNT_MAX_CODE_LEN, 0, "code" },
{ "description", CT_STRING, ACCOUNT_MAX_DESCRIPTION_LEN, 0, "description" },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
static GncSqlColumnTableEntry parent_col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "parent_guid", CT_GUID, 0, 0, NULL, NULL, NULL, set_parent_guid },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
typedef struct {
Account* pAccount;
/*@ dependent @*/ Account* pAccount;
GUID guid;
} account_parent_guid_struct;
/* ================================================================= */
static gpointer
get_parent( gpointer pObject, const QofParam* param )
static /*@ null @*//*@ dependent @*/ gpointer
get_parent( gpointer pObject )
{
const Account* pAccount;
const Account* pParent;
@@ -108,7 +113,7 @@ get_parent( gpointer pObject, const QofParam* param )
}
static void
set_parent( gpointer pObject, gpointer pValue )
set_parent( gpointer pObject, /*@ null @*/ gpointer pValue )
{
Account* pAccount;
QofBook* pBook;
@@ -129,7 +134,7 @@ set_parent( gpointer pObject, gpointer pValue )
}
static void
set_parent_guid( gpointer pObject, gpointer pValue )
set_parent_guid( gpointer pObject, /*@ null @*/ gpointer pValue )
{
account_parent_guid_struct* s = (account_parent_guid_struct*)pObject;
GUID* guid = (GUID*)pValue;
@@ -140,22 +145,21 @@ set_parent_guid( gpointer pObject, gpointer pValue )
s->guid = *guid;
}
static Account*
static /*@ dependent @*//*@ null @*/ Account*
load_single_account( GncSqlBackend* be, GncSqlRow* row,
GList** l_accounts_needing_parents )
{
const GUID* guid;
GUID acc_guid;
Account* pAccount;
Account* pAccount = NULL;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( row != NULL, NULL );
g_return_val_if_fail( l_accounts_needing_parents != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
acc_guid = *guid;
pAccount = xaccAccountLookup( &acc_guid, be->primary_book );
if( guid != NULL ) {
pAccount = xaccAccountLookup( guid, be->primary_book );
}
if( pAccount == NULL ) {
pAccount = xaccMallocAccount( be->primary_book );
}
@@ -167,6 +171,8 @@ load_single_account( GncSqlBackend* be, GncSqlRow* row,
been loaded yet. Remember the account and its parent guid for later. */
if( gnc_account_get_parent( pAccount ) == NULL ) {
account_parent_guid_struct* s = g_malloc( (gsize)sizeof(account_parent_guid_struct) );
g_assert( s != NULL );
s->pAccount = pAccount;
gnc_sql_load_object( be, row, GNC_ID_ACCOUNT, s, parent_col_table );
*l_accounts_needing_parents = g_list_prepend( *l_accounts_needing_parents, s );
@@ -195,6 +201,10 @@ load_all_accounts( GncSqlBackend* be )
pTable = gnc_commodity_table_get_table( pBook );
stmt = gnc_sql_create_select_statement( be, TABLE_NAME );
if( stmt == NULL ) {
LEAVE( "stmt == NULL" );
return;
}
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -212,6 +222,7 @@ load_all_accounts( GncSqlBackend* be )
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
g_list_free( list );
}
/* While there are items on the list of accounts needing parents,
@@ -262,8 +273,10 @@ load_all_accounts( GncSqlBackend* be )
NULL);
}
if( bal_slist != NULL ) {
g_slist_free( bal_slist );
}
}
LEAVE( "" );
}
@@ -290,6 +303,7 @@ gnc_sql_save_account( GncSqlBackend* be, QofInstance* inst )
const GUID* guid;
gboolean is_infant;
gboolean is_ok = FALSE;
gnc_commodity* commodity;
g_return_val_if_fail( be != NULL, FALSE );
g_return_val_if_fail( inst != NULL, FALSE );
@@ -303,7 +317,8 @@ gnc_sql_save_account( GncSqlBackend* be, QofInstance* inst )
// has been entered directly into the register and an account window will
// be opened. The account info is not complete yet, but the name has been
// set, triggering this commit
if( xaccAccountGetCommodity( pAcc ) != NULL ) {
commodity = xaccAccountGetCommodity( pAcc );
if( commodity != NULL ) {
gint op;
is_ok = TRUE;
@@ -317,7 +332,7 @@ gnc_sql_save_account( GncSqlBackend* be, QofInstance* inst )
// If not deleting the account, ensure the commodity is in the db
if( op != OP_DB_DELETE ) {
is_ok = gnc_sql_save_commodity( be, xaccAccountGetCommodity( pAcc ) );
is_ok = gnc_sql_save_commodity( be, commodity );
}
if( is_ok ) {
@@ -343,7 +358,7 @@ gnc_sql_save_account( GncSqlBackend* be, QofInstance* inst )
/* ================================================================= */
static void
load_account_guid( const GncSqlBackend* be, GncSqlRow* row,
QofSetterFunc setter, gpointer pObject,
/*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -360,17 +375,20 @@ load_account_guid( const GncSqlBackend* be, GncSqlRow* row,
if( val == NULL ) {
pGuid = NULL;
} else {
string_to_guid( g_value_get_string( val ), &guid );
(void)string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid;
}
if( pGuid != NULL ) {
account = xaccAccountLookup( pGuid, be->primary_book );
}
if( account != NULL ) {
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, account, NULL );
} else {
g_return_if_fail( setter != NULL );
(*setter)( pObject, (const gpointer)account );
}
}
}
static GncSqlColumnTypeHandler account_guid_handler
@@ -395,7 +413,7 @@ gnc_sql_init_account_handler( void )
NULL /* write */
};
qof_object_register_backend( GNC_ID_ACCOUNT, GNC_SQL_BACKEND, &be_data );
(void)qof_object_register_backend( GNC_ID_ACCOUNT, GNC_SQL_BACKEND, &be_data );
gnc_sql_register_col_type_handler( CT_ACCOUNTREF, &account_guid_handler );
}

File diff suppressed because it is too large Load Diff

View File

@@ -67,7 +67,7 @@ struct GncSqlBackend
{
QofBackend be; /**< QOF backend */
GncSqlConnection* conn; /**< SQL connection */
QofBook *primary_book; /**< The primary, main open book */
/*@ dependent @*/ QofBook *primary_book; /**< The primary, main open book */
gboolean loading; /**< We are performing an initial load */
gboolean in_query; /**< We are processing a query */
gboolean is_pristine_db; /**< Are we saving to a new pristine db? */
@@ -90,7 +90,7 @@ void gnc_sql_init( GncSqlBackend* be );
* @param be SQL backend
* @param book Book to be loaded
*/
void gnc_sql_load( GncSqlBackend* be, QofBook *book, QofBackendLoadType loadType );
void gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoadType loadType );
/**
* Save the contents of a book to an SQL database.
@@ -98,7 +98,7 @@ void gnc_sql_load( GncSqlBackend* be, QofBook *book, QofBackendLoadType loadType
* @param be SQL backend
* @param book Book to be saved
*/
void gnc_sql_sync_all( GncSqlBackend* be, QofBook *book );
void gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book );
/**
* An object is about to be edited.
@@ -139,8 +139,8 @@ typedef struct GncSqlRow GncSqlRow;
*/
struct GncSqlStatement
{
void (*dispose)( GncSqlStatement* );
gchar* (*toSql)( GncSqlStatement* );
void (*dispose)( /*@ only @*/ GncSqlStatement* );
/*@ dependent @*/ gchar* (*toSql)( GncSqlStatement* );
void (*addWhereCond)( GncSqlStatement*, QofIdTypeConst, gpointer, const GncSqlColumnTableEntry*, GValue* );
};
#define gnc_sql_statement_dispose(STMT) \
@@ -158,10 +158,10 @@ struct GncSqlStatement
*/
struct GncSqlConnection
{
void (*dispose)( GncSqlConnection* );
void (*dispose)( /*@ only @*/ GncSqlConnection* );
GncSqlResult* (*executeSelectStatement)( GncSqlConnection*, GncSqlStatement* ); /**< Returns NULL if error */
gint (*executeNonSelectStatement)( GncSqlConnection*, GncSqlStatement* ); /**< Returns -1 if error */
GncSqlStatement* (*createStatementFromSql)( GncSqlConnection*, gchar* );
GncSqlStatement* (*createStatementFromSql)( /*@ observer @*/ GncSqlConnection*, const gchar* );
gboolean (*doesTableExist)( GncSqlConnection*, const gchar* );
gboolean (*beginTransaction)( GncSqlConnection* ); /**< Returns TRUE if successful, FALSE if error */
gboolean (*rollbackTransaction)( GncSqlConnection* ); /**< Returns TRUE if successful, FALSE if error */
@@ -204,7 +204,7 @@ struct GncSqlConnection
struct GncSqlRow
{
const GValue* (*getValueAtColName)( GncSqlRow*, const gchar* );
void (*dispose)( GncSqlRow* );
void (*dispose)( /*@ only @*/ GncSqlRow* );
};
#define gnc_sql_row_get_value_at_col_name(ROW,N) \
(ROW)->getValueAtColName(ROW,N)
@@ -219,10 +219,10 @@ struct GncSqlRow
*/
struct GncSqlResult
{
gint (*getNumRows)( GncSqlResult* );
guint (*getNumRows)( GncSqlResult* );
GncSqlRow* (*getFirstRow)( GncSqlResult* );
GncSqlRow* (*getNextRow)( GncSqlResult* );
void (*dispose)( GncSqlResult* );
void (*dispose)( /*@ only @*/ GncSqlResult* );
};
#define gnc_sql_result_get_num_rows(RESULT) \
(RESULT)->getNumRows(RESULT)
@@ -254,21 +254,21 @@ typedef struct
/** Commit an instance of this object to the database
* @return TRUE if successful, FALSE if error
*/
gboolean (*commit)( GncSqlBackend* be, QofInstance* inst );
/*@ null @*/ gboolean (*commit)( GncSqlBackend* be, QofInstance* inst );
/** Load all objects of this type from the database */
void (*initial_load)( GncSqlBackend* be );
/*@ null @*/ void (*initial_load)( GncSqlBackend* be );
/** Create database tables for this object */
void (*create_tables)( GncSqlBackend* be );
/*@ null @*/ void (*create_tables)( GncSqlBackend* be );
/** Compile a query on these objects */
gpointer (*compile_query)( GncSqlBackend* be, QofQuery* pQuery );
/*@ null @*/ gpointer (*compile_query)( GncSqlBackend* be, QofQuery* pQuery );
/** Run a query on these objects */
void (*run_query)( GncSqlBackend* be, gpointer pQuery );
/*@ null @*/ void (*run_query)( GncSqlBackend* be, gpointer pQuery );
/** Free a query on these objects */
void (*free_query)( GncSqlBackend* be, gpointer pQuery );
/*@ null @*/ void (*free_query)( GncSqlBackend* be, gpointer pQuery );
/** Write all objects of this type to the database
* @return TRUE if successful, FALSE if error
*/
gboolean (*write)( GncSqlBackend* be );
/*@ null @*/ gboolean (*write)( GncSqlBackend* be );
} GncSqlObjectBackend;
#define GNC_SQL_BACKEND "gnc:sql:1"
#define GNC_SQL_BACKEND_VERSION 1
@@ -280,7 +280,7 @@ typedef struct
* a column in a table.
*/
typedef struct {
const gchar* name; /**< Column name */
/*@ only @*/ const gchar* name; /**< Column name */
GType type; /**< Column basic type */
gint size; /**< Column size (string types) */
gboolean is_unicode; /**< Column is unicode (string types) */
@@ -322,7 +322,7 @@ typedef struct {
* GncSqlColumnTableEntry objects, with a final member having col_name == NULL.
*/
struct GncSqlColumnTableEntry {
const gchar* col_name; /**< Column name */
/*@ dependent @*/ const gchar* col_name; /**< Column name */
const gchar* col_type; /**< Column type */
gint size; /**< Column size in bytes, for string columns */
#define COL_PKEY 0x01 /**< The column is a primary key */
@@ -330,10 +330,10 @@ struct GncSqlColumnTableEntry {
#define COL_UNIQUE 0x04 /**< The column must contain unique values */
#define COL_AUTOINC 0x08 /**< The column is an auto-incrementing int */
gint flags; /**< Column flags */
const gchar* gobj_param_name; /**< If non-null, g_object param name */
const gchar* qof_param_name; /**< If non-null, qof parameter name */
QofAccessFunc getter; /**< General access function */
QofSetterFunc setter; /**< General setter function */
/*@ null @*/ const gchar* gobj_param_name; /**< If non-null, g_object param name */
/*@ null @*/ const gchar* qof_param_name; /**< If non-null, qof parameter name */
/*@ null @*/ QofAccessFunc getter; /**< General access function */
/*@ null @*/ QofSetterFunc setter; /**< General setter function */
};
typedef enum {
@@ -344,7 +344,7 @@ typedef enum {
typedef void (*GNC_SQL_LOAD_FN)( const GncSqlBackend* be,
GncSqlRow* row,
QofSetterFunc setter, gpointer pObject,
/*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table );
typedef void (*GNC_SQL_ADD_COL_INFO_TO_LIST_FN)( const GncSqlBackend* be,
const GncSqlColumnTableEntry* table_row,
@@ -392,7 +392,7 @@ typedef struct {
* @param table_row DB table column
* @return Access function
*/
QofAccessFunc gnc_sql_get_getter( QofIdTypeConst obj_name, const GncSqlColumnTableEntry* table_row );
/*@ null @*/ QofAccessFunc gnc_sql_get_getter( QofIdTypeConst obj_name, const GncSqlColumnTableEntry* table_row );
/**
* Adds a column name to a list. If the column type spans multiple columns,
@@ -430,7 +430,7 @@ gboolean gnc_sql_do_db_operation( GncSqlBackend* be,
* @param statement Statement
* @return Results, or NULL if an error has occured
*/
GncSqlResult* gnc_sql_execute_select_statement( GncSqlBackend* be, GncSqlStatement* statement );
/*@ null @*/ GncSqlResult* gnc_sql_execute_select_statement( GncSqlBackend* be, GncSqlStatement* statement );
/**
* Executes an SQL SELECT statement from an SQL char string and returns the
@@ -441,7 +441,7 @@ GncSqlResult* gnc_sql_execute_select_statement( GncSqlBackend* be, GncSqlStateme
* @param sql SQL SELECT string
* @return Results, or NULL if an error has occured
*/
GncSqlResult* gnc_sql_execute_select_sql( GncSqlBackend* be, gchar* sql );
/*@ null @*/ GncSqlResult* gnc_sql_execute_select_sql( GncSqlBackend* be, const gchar* sql );
/**
* Executes an SQL non-SELECT statement from an SQL char string.
@@ -450,7 +450,7 @@ GncSqlResult* gnc_sql_execute_select_sql( GncSqlBackend* be, gchar* sql );
* @param sql SQL non-SELECT string
* @returns Number of rows affected, or -1 if an error has occured
*/
gint gnc_sql_execute_nonselect_sql( GncSqlBackend* be, gchar* sql );
gint gnc_sql_execute_nonselect_sql( GncSqlBackend* be, const gchar* sql );
/**
* Creates a statement from an SQL char string.
@@ -459,7 +459,7 @@ gint gnc_sql_execute_nonselect_sql( GncSqlBackend* be, gchar* sql );
* @param sql SQL char string
* @return Statement
*/
GncSqlStatement* gnc_sql_create_statement_from_sql( GncSqlBackend* be, gchar* sql );
/*@ null @*/ GncSqlStatement* gnc_sql_create_statement_from_sql( GncSqlBackend* be, const gchar* sql );
/**
* Loads a Gnucash object from the database.
@@ -471,7 +471,7 @@ GncSqlStatement* gnc_sql_create_statement_from_sql( GncSqlBackend* be, gchar* sq
* @param table DB table description
*/
void gnc_sql_load_object( const GncSqlBackend* be, GncSqlRow* row,
QofIdTypeConst obj_name, gpointer pObject,
/*@ null @*/ QofIdTypeConst obj_name, gpointer pObject,
const GncSqlColumnTableEntry* table );
/**
@@ -557,7 +557,7 @@ gboolean gnc_sql_create_index( const GncSqlBackend* be, const gchar* index_name,
* @param row Database row
* @return GUID
*/
const GUID* gnc_sql_load_guid( const GncSqlBackend* be, GncSqlRow* row );
/*@ dependent @*//*@ null @*/ const GUID* gnc_sql_load_guid( const GncSqlBackend* be, GncSqlRow* row );
/**
* Loads the transaction guid from a database row. The table must have a column
@@ -567,7 +567,7 @@ const GUID* gnc_sql_load_guid( const GncSqlBackend* be, GncSqlRow* row );
* @param row Database row
* @return GUID
*/
const GUID* gnc_sql_load_tx_guid( const GncSqlBackend* be, GncSqlRow* row );
/*@ dependent @*//*@ null @*/ const GUID* gnc_sql_load_tx_guid( const GncSqlBackend* be, GncSqlRow* row );
/**
* Creates a basic SELECT statement for a table.
@@ -576,7 +576,7 @@ const GUID* gnc_sql_load_tx_guid( const GncSqlBackend* be, GncSqlRow* row );
* @param table_name Table name
* @return Statement
*/
GncSqlStatement* gnc_sql_create_select_statement( GncSqlBackend* be,
/*@ null @*/ GncSqlStatement* gnc_sql_create_select_statement( GncSqlBackend* be,
const gchar* table_name );
/**
@@ -691,14 +691,14 @@ gint64 gnc_sql_get_integer_value( const GValue* value );
void gnc_sql_upgrade_table( GncSqlBackend* be, const gchar* table_name,
const GncSqlColumnTableEntry* col_table );
void _retrieve_guid_( gpointer pObject, gpointer pValue );
void _retrieve_guid_( gpointer pObject, /*@ null @*/ gpointer pValue );
gpointer gnc_sql_compile_query( QofBackend* pBEnd, QofQuery* pQuery );
/*@ null @*/ gpointer gnc_sql_compile_query( QofBackend* pBEnd, QofQuery* pQuery );
void gnc_sql_free_query( QofBackend* pBEnd, gpointer pQuery );
void gnc_sql_run_query( QofBackend* pBEnd, gpointer pQuery );
typedef struct {
GncSqlBackend* be;
/*@ dependent @*/ GncSqlBackend* be;
gboolean is_ok;
} write_objects_t;

View File

@@ -42,29 +42,35 @@
#include "SX-book.h"
#include "SX-book-p.h"
#if defined( S_SPLINT_S )
#include "splint-defs.h"
#endif
#define BOOK_TABLE "books"
#define TABLE_VERSION 1
static QofLogModule log_module = G_LOG_DOMAIN;
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
static gpointer get_root_account_guid( gpointer pObject, const QofParam* );
static void set_root_account_guid( gpointer pObject, gpointer pValue );
static gpointer get_root_template_guid( gpointer pObject, const QofParam* );
static void set_root_template_guid( gpointer pObject, gpointer pValue );
static /*@ dependent @*//*@ null @*/ gpointer get_root_account_guid( gpointer pObject );
static void set_root_account_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
static /*@ dependent @*//*@ null @*/ gpointer get_root_template_guid( gpointer pObject );
static void set_root_template_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
static const GncSqlColumnTableEntry col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "root_account_guid", CT_GUID, 0, COL_NNUL, NULL, NULL, get_root_account_guid, set_root_account_guid },
{ "root_template_guid", CT_GUID, 0, COL_NNUL, NULL, NULL, get_root_template_guid, set_root_template_guid },
{ "root_account_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)get_root_account_guid, set_root_account_guid },
{ "root_template_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)get_root_template_guid, set_root_template_guid },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* ================================================================= */
static gpointer
get_root_account_guid( gpointer pObject, const QofParam* param )
static /*@ dependent @*//*@ null @*/ gpointer
get_root_account_guid( gpointer pObject )
{
GNCBook* book = QOF_BOOK(pObject);
const Account* root;
@@ -77,7 +83,7 @@ get_root_account_guid( gpointer pObject, const QofParam* param )
}
static void
set_root_account_guid( gpointer pObject, gpointer pValue )
set_root_account_guid( gpointer pObject, /*@ null @*/ gpointer pValue )
{
GNCBook* book = QOF_BOOK(pObject);
const Account* root;
@@ -91,8 +97,8 @@ set_root_account_guid( gpointer pObject, gpointer pValue )
qof_instance_set_guid( QOF_INSTANCE(root), guid );
}
static gpointer
get_root_template_guid( gpointer pObject, const QofParam* param )
static /*@ dependent @*//*@ null @*/ gpointer
get_root_template_guid( gpointer pObject )
{
const GNCBook* book = QOF_BOOK(pObject);
const Account* root;
@@ -105,7 +111,7 @@ get_root_template_guid( gpointer pObject, const QofParam* param )
}
static void
set_root_template_guid( gpointer pObject, gpointer pValue )
set_root_template_guid( gpointer pObject, /*@ null @*/ gpointer pValue )
{
GNCBook* book = QOF_BOOK(pObject);
GUID* guid = (GUID*)pValue;
@@ -131,14 +137,12 @@ static void
load_single_book( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
GUID book_guid;
GNCBook* pBook;
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
guid = gnc_sql_load_guid( be, row );
book_guid = *guid;
pBook = be->primary_book;
if( pBook == NULL ) {
@@ -160,6 +164,7 @@ load_all_books( GncSqlBackend* be )
g_return_if_fail( be != NULL );
stmt = gnc_sql_create_select_statement( be, BOOK_TABLE );
if( stmt != NULL ) {
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -167,7 +172,7 @@ load_all_books( GncSqlBackend* be )
// If there are no rows, try committing the book
if( row == NULL ) {
gnc_sql_save_book( be, QOF_INSTANCE(be->primary_book) );
(void)gnc_sql_save_book( be, QOF_INSTANCE(be->primary_book) );
} else {
// Otherwise, load the 1st book.
load_single_book( be, row );
@@ -175,6 +180,7 @@ load_all_books( GncSqlBackend* be )
gnc_sql_result_dispose( result );
}
}
}
/* ================================================================= */
@@ -187,7 +193,7 @@ create_book_tables( GncSqlBackend* be )
version = gnc_sql_get_table_version( be, BOOK_TABLE );
if( version == 0 ) {
gnc_sql_create_table( be, BOOK_TABLE, TABLE_VERSION, col_table );
(void)gnc_sql_create_table( be, BOOK_TABLE, TABLE_VERSION, col_table );
}
}

View File

@@ -42,51 +42,55 @@
#include "gnc-budget.h"
#if defined( S_SPLINT_S )
#include "splint-defs.h"
#endif
#define BUDGET_TABLE "budgets"
#define TABLE_VERSION 1
static QofLogModule log_module = G_LOG_DOMAIN;
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define BUDGET_MAX_NAME_LEN 2048
#define BUDGET_MAX_DESCRIPTION_LEN 2048
static const GncSqlColumnTableEntry col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "name", CT_STRING, BUDGET_MAX_NAME_LEN, COL_NNUL, "name" },
{ "description", CT_STRING, BUDGET_MAX_DESCRIPTION_LEN, 0, "description" },
{ "num_periods", CT_INT, 0, COL_NNUL, "num_periods" },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* ================================================================= */
static GncBudget*
static /*@ dependent @*//*@ null @*/ GncBudget*
load_single_budget( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
GUID budget_guid;
GncBudget* pBudget;
GncBudget* pBudget = NULL;
Recurrence* r;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
budget_guid = *guid;
pBudget = gnc_budget_lookup( &budget_guid, be->primary_book );
if( guid != NULL ) {
pBudget = gnc_budget_lookup( guid, be->primary_book );
}
if( pBudget == NULL ) {
pBudget = gnc_budget_new( be->primary_book );
}
gnc_budget_begin_edit( pBudget );
gnc_sql_load_object( be, row, GNC_ID_BUDGET, pBudget, col_table );
r = g_new0( Recurrence, 1 );
gnc_sql_recurrence_load( be, gnc_budget_get_guid( pBudget ), r );
r = gnc_sql_recurrence_load( be, gnc_budget_get_guid( pBudget ) );
if( r != NULL ) {
gnc_budget_set_recurrence( pBudget, r );
g_free( r );
}
gnc_budget_commit_edit( pBudget );
return pBudget;
@@ -102,6 +106,7 @@ load_all_budgets( GncSqlBackend* be )
g_return_if_fail( be != NULL );
stmt = gnc_sql_create_select_statement( be, BUDGET_TABLE );
if( stmt != NULL ) {
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -119,6 +124,8 @@ load_all_budgets( GncSqlBackend* be )
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
g_list_free( list );
}
}
}
}
@@ -133,7 +140,7 @@ create_budget_tables( GncSqlBackend* be )
version = gnc_sql_get_table_version( be, BUDGET_TABLE );
if( version == 0 ) {
gnc_sql_create_table( be, BUDGET_TABLE, TABLE_VERSION, col_table );
(void)gnc_sql_create_table( be, BUDGET_TABLE, TABLE_VERSION, col_table );
}
}
@@ -172,7 +179,7 @@ save_budget( GncSqlBackend* be, QofInstance* inst )
} else {
is_ok = gnc_sql_recurrence_delete( be, guid );
if( is_ok ) {
gnc_sql_slots_delete( be, guid );
(void)gnc_sql_slots_delete( be, guid );
}
}
}
@@ -222,6 +229,6 @@ gnc_sql_init_budget_handler( void )
write_budgets /* write */
};
qof_object_register_backend( GNC_ID_BUDGET, GNC_SQL_BACKEND, &be_data );
(void)qof_object_register_backend( GNC_ID_BUDGET, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */

View File

@@ -38,10 +38,14 @@
#include "gnc-commodity-sql.h"
#include "gnc-slots-sql.h"
static QofLogModule log_module = G_LOG_DOMAIN;
#if defined( S_SPLINT_S )
#include "splint-defs.h"
#endif
static gpointer get_quote_source_name( gpointer pObject, const QofParam* );
static void set_quote_source_name( gpointer pObject, gpointer pValue );
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
static /*@ dependent @*//*@ null @*/ gpointer get_quote_source_name( gpointer pObject );
static void set_quote_source_name( gpointer pObject, /*@ null @*/ gpointer pValue );
#define COMMODITIES_TABLE "commodities"
#define TABLE_VERSION 1
@@ -54,7 +58,7 @@ static void set_quote_source_name( gpointer pObject, gpointer pValue );
#define COMMODITY_MAX_QUOTE_TZ_LEN 2048
static const GncSqlColumnTableEntry col_table[] = {
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "namespace", CT_STRING, COMMODITY_MAX_NAMESPACE_LEN, COL_NNUL, NULL, NULL,
(QofAccessFunc)gnc_commodity_get_namespace,
@@ -65,22 +69,23 @@ static const GncSqlColumnTableEntry col_table[] = {
{ "fraction", CT_INT, 0, COL_NNUL, "fraction" },
{ "quote_flag", CT_BOOLEAN, 0, COL_NNUL, "quote_flag" },
{ "quote_source", CT_STRING, COMMODITY_MAX_QUOTESOURCE_LEN, 0, NULL, NULL,
get_quote_source_name, set_quote_source_name },
(QofAccessFunc)get_quote_source_name, set_quote_source_name },
{ "quote_tz", CT_STRING, COMMODITY_MAX_QUOTE_TZ_LEN, 0, "quote-tz" },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* ================================================================= */
static gpointer
get_quote_source_name( gpointer pObject, const QofParam* param )
static /*@ dependent @*//*@ null @*/ gpointer
get_quote_source_name( gpointer pObject )
{
const gnc_commodity* pCommodity = GNC_COMMODITY(pObject);
const gnc_commodity* pCommodity;
g_return_val_if_fail( pObject != NULL, NULL );
g_return_val_if_fail( GNC_IS_COMMODITY(pObject), NULL );
pCommodity = GNC_COMMODITY(pObject);
return (gpointer)gnc_quote_source_get_internal_name(
gnc_commodity_get_quote_source(pCommodity));
}
@@ -88,7 +93,7 @@ get_quote_source_name( gpointer pObject, const QofParam* param )
static void
set_quote_source_name( gpointer pObject, gpointer pValue )
{
gnc_commodity* pCommodity = GNC_COMMODITY(pObject);
gnc_commodity* pCommodity;
const gchar* quote_source_name = (const gchar*)pValue;
gnc_quote_source* quote_source;
@@ -97,11 +102,12 @@ set_quote_source_name( gpointer pObject, gpointer pValue )
if( pValue == NULL ) return;
pCommodity = GNC_COMMODITY(pObject);
quote_source = gnc_quote_source_lookup_by_internal( quote_source_name );
gnc_commodity_set_quote_source( pCommodity, quote_source );
}
static gnc_commodity*
static /*@ dependent @*/ gnc_commodity*
load_single_commodity( GncSqlBackend* be, GncSqlRow* row )
{
QofBook* pBook = be->primary_book;
@@ -124,6 +130,7 @@ load_all_commodities( GncSqlBackend* be )
pTable = gnc_commodity_table_get_table( be->primary_book );
stmt = gnc_sql_create_select_statement( be, COMMODITIES_TABLE );
if( stmt == NULL ) return;
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -148,6 +155,7 @@ load_all_commodities( GncSqlBackend* be )
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
g_list_free( list );
}
}
}
@@ -161,7 +169,7 @@ create_commodities_tables( GncSqlBackend* be )
version = gnc_sql_get_table_version( be, COMMODITIES_TABLE );
if( version == 0 ) {
gnc_sql_create_table( be, COMMODITIES_TABLE, TABLE_VERSION, col_table );
(void)gnc_sql_create_table( be, COMMODITIES_TABLE, TABLE_VERSION, col_table );
}
}
@@ -205,12 +213,11 @@ gnc_sql_save_commodity( GncSqlBackend* be, gnc_commodity* pCommodity )
static void
load_commodity_guid( const GncSqlBackend* be, GncSqlRow* row,
QofSetterFunc setter, gpointer pObject,
/*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
GUID guid;
const GUID* pGuid;
gnc_commodity* commodity = NULL;
g_return_if_fail( be != NULL );
@@ -219,18 +226,12 @@ load_commodity_guid( const GncSqlBackend* be, GncSqlRow* row,
g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
if( val == NULL ) {
pGuid = NULL;
} else {
string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid;
}
if( pGuid != NULL ) {
commodity = gnc_commodity_find_commodity_by_guid( pGuid, be->primary_book );
}
g_assert( val != NULL );
(void)string_to_guid( g_value_get_string( val ), &guid );
commodity = gnc_commodity_find_commodity_by_guid( &guid, be->primary_book );
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, commodity, NULL );
} else {
} else if( setter != NULL ) {
(*setter)( pObject, (const gpointer)commodity );
}
}
@@ -257,7 +258,7 @@ gnc_sql_init_commodity_handler( void )
NULL /* write */
};
qof_object_register_backend( GNC_ID_COMMODITY, GNC_SQL_BACKEND, &be_data );
(void)qof_object_register_backend( GNC_ID_COMMODITY, GNC_SQL_BACKEND, &be_data );
gnc_sql_register_col_type_handler( CT_COMMODITYREF, &commodity_guid_handler );
}

View File

@@ -38,44 +38,50 @@
#include "gnc-lots-sql.h"
static QofLogModule log_module = G_LOG_DOMAIN;
#if defined( S_SPLINT_S )
#include "splint-defs.h"
#endif
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define TABLE_NAME "lots"
#define TABLE_VERSION 2
static gpointer get_lot_account( gpointer pObject, const QofParam* param );
static void set_lot_account( gpointer pObject, gpointer pValue );
static /*@ dependent @*//*@ null @*/ gpointer get_lot_account( gpointer pObject );
static void set_lot_account( gpointer pObject, /*@ null @*/ gpointer pValue );
static void set_lot_is_closed( gpointer pObject, gboolean value );
static const GncSqlColumnTableEntry col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "account_guid", CT_GUID, 0, 0, NULL, NULL, get_lot_account, set_lot_account },
{ "account_guid", CT_GUID, 0, 0, NULL, NULL,
(QofAccessFunc)get_lot_account, set_lot_account },
{ "is_closed", CT_BOOLEAN, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)gnc_lot_is_closed, (QofSetterFunc)set_lot_is_closed },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* ================================================================= */
static gpointer
get_lot_account( gpointer pObject, const QofParam* param )
static /*@ dependent @*//*@ null @*/ gpointer
get_lot_account( gpointer pObject )
{
const GNCLot* lot = GNC_LOT(pObject);
const GNCLot* lot;
const Account* pAccount;
g_return_val_if_fail( pObject != NULL, NULL );
g_return_val_if_fail( GNC_IS_LOT(pObject), NULL );
lot = GNC_LOT(pObject);
pAccount = gnc_lot_get_account( lot );
return (gpointer)qof_instance_get_guid( QOF_INSTANCE(pAccount) );
}
static void
set_lot_account( gpointer pObject, gpointer pValue )
set_lot_account( gpointer pObject, /*@ null @*/ gpointer pValue )
{
GNCLot* lot = GNC_LOT(pObject);
GNCLot* lot;
QofBook* pBook;
GUID* guid = (GUID*)pValue;
Account* pAccount;
@@ -84,6 +90,7 @@ set_lot_account( gpointer pObject, gpointer pValue )
g_return_if_fail( GNC_IS_LOT(pObject) );
g_return_if_fail( pValue != NULL );
lot = GNC_LOT(pObject);
pBook = qof_instance_get_book( QOF_INSTANCE(lot) );
pAccount = xaccAccountLookup( guid, pBook );
if( pAccount != NULL ) {
@@ -94,15 +101,16 @@ set_lot_account( gpointer pObject, gpointer pValue )
static void
set_lot_is_closed( gpointer pObject, gboolean closed )
{
GNCLot* lot = GNC_LOT(pObject);
GNCLot* lot;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_LOT(pObject) );
lot->is_closed = closed;
lot = GNC_LOT(pObject);
lot->is_closed = (char)closed;
}
static GNCLot*
static /*@ dependent @*//*@ null @*/ GNCLot*
load_single_lot( GncSqlBackend* be, GncSqlRow* row )
{
GNCLot* lot;
@@ -128,6 +136,7 @@ load_all_lots( GncSqlBackend* be )
g_return_if_fail( be != NULL );
stmt = gnc_sql_create_select_statement( be, TABLE_NAME );
if( stmt != NULL ) {
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -146,6 +155,8 @@ load_all_lots( GncSqlBackend* be )
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
g_list_free( list );
}
}
}
}
@@ -161,7 +172,7 @@ create_lots_tables( GncSqlBackend* be )
version = gnc_sql_get_table_version( be, TABLE_NAME );
if( version == 0 ) {
/* The table doesn't exist, so create it */
gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
(void)gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
} else if( version == 1 ) {
/* Version 1 -> 2 removes the 'NOT NULL' constraint on the account_guid
field.
@@ -170,7 +181,7 @@ create_lots_tables( GncSqlBackend* be )
old table, then rename the new one. */
gnc_sql_upgrade_table( be, TABLE_NAME, col_table );
gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
(void)gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
}
}
@@ -213,13 +224,12 @@ write_lots( GncSqlBackend* be )
/* ================================================================= */
static void
load_lot_guid( const GncSqlBackend* be, GncSqlRow* row,
QofSetterFunc setter, gpointer pObject,
/*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
GUID guid;
const GUID* pGuid;
GNCLot* lot = NULL;
GNCLot* lot;
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
@@ -227,18 +237,15 @@ load_lot_guid( const GncSqlBackend* be, GncSqlRow* row,
g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
if( val == NULL ) {
pGuid = NULL;
} else {
string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid;
}
if( pGuid != NULL ) {
lot = gnc_lot_lookup( pGuid, be->primary_book );
}
g_return_if_fail( val != NULL );
(void)string_to_guid( g_value_get_string( val ), &guid );
lot = gnc_lot_lookup( &guid, be->primary_book );
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, lot, NULL );
} else {
g_return_if_fail( setter != NULL );
(*setter)( pObject, (const gpointer)lot );
}
}
@@ -263,7 +270,7 @@ gnc_sql_init_lot_handler( void )
write_lots /* save all */
};
qof_object_register_backend( GNC_ID_LOT, GNC_SQL_BACKEND, &be_data );
(void)qof_object_register_backend( GNC_ID_LOT, GNC_SQL_BACKEND, &be_data );
gnc_sql_register_col_type_handler( CT_LOTREF, &lot_guid_handler );
}

View File

@@ -39,7 +39,11 @@
#include "gnc-price-sql.h"
#include "gnc-slots-sql.h"
static QofLogModule log_module = G_LOG_DOMAIN;
#if defined( S_SPLINT_S )
#include "splint-defs.h"
#endif
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define TABLE_NAME "prices"
#define TABLE_VERSION 2
@@ -49,7 +53,7 @@ static QofLogModule log_module = G_LOG_DOMAIN;
static const GncSqlColumnTableEntry col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "commodity_guid", CT_COMMODITYREF, 0, COL_NNUL, NULL, PRICE_COMMODITY },
{ "currency_guid", CT_COMMODITYREF, 0, COL_NNUL, NULL, PRICE_CURRENCY },
@@ -58,12 +62,12 @@ static const GncSqlColumnTableEntry col_table[] =
{ "type", CT_STRING, PRICE_MAX_TYPE_LEN, 0, NULL, PRICE_TYPE },
{ "value", CT_NUMERIC, 0, COL_NNUL, NULL, PRICE_VALUE },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* ================================================================= */
static GNCPrice*
static /*@ null @*//*@ dependent @*/ GNCPrice*
load_single_price( GncSqlBackend* be, GncSqlRow* row )
{
GNCPrice* pPrice;
@@ -93,6 +97,7 @@ load_all_prices( GncSqlBackend* be )
pBook = be->primary_book;
pPriceDB = gnc_book_get_pricedb( pBook );
stmt = gnc_sql_create_select_statement( be, TABLE_NAME );
if( stmt != NULL ) {
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -105,7 +110,7 @@ load_all_prices( GncSqlBackend* be )
if( pPrice != NULL ) {
list = g_list_append( list, pPrice );
gnc_pricedb_add_price( pPriceDB, pPrice );
(void)gnc_pricedb_add_price( pPriceDB, pPrice );
}
row = gnc_sql_result_get_next_row( result );
}
@@ -113,6 +118,8 @@ load_all_prices( GncSqlBackend* be )
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
g_list_free( list );
}
}
}
}
@@ -127,11 +134,11 @@ create_prices_tables( GncSqlBackend* be )
version = gnc_sql_get_table_version( be, TABLE_NAME );
if( version == 0 ) {
gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
(void)gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
} else if( version == 1 ) {
/* Upgrade 64 bit int handling */
gnc_sql_upgrade_table( be, TABLE_NAME, col_table );
gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
(void)gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
}
}
@@ -160,7 +167,7 @@ save_price( GncSqlBackend* be, QofInstance* inst )
if( op != OP_DB_DELETE ) {
/* Ensure commodity and currency are in the db */
gnc_sql_save_commodity( be, gnc_price_get_commodity( pPrice ) );
(void)gnc_sql_save_commodity( be, gnc_price_get_commodity( pPrice ) );
is_ok = gnc_sql_save_commodity( be, gnc_price_get_currency( pPrice ) );
}
@@ -216,7 +223,7 @@ gnc_sql_init_price_handler( void )
write_prices /* write */
};
qof_object_register_backend( GNC_ID_PRICE, GNC_SQL_BACKEND, &be_data );
(void)qof_object_register_backend( GNC_ID_PRICE, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */

View File

@@ -38,7 +38,11 @@
#include "gnc-recurrence-sql.h"
static QofLogModule log_module = G_LOG_DOMAIN;
#if defined( S_SPLINT_S )
#include "splint-defs.h"
#endif
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define TABLE_NAME "recurrences"
#define TABLE_VERSION 1
@@ -46,49 +50,50 @@ static QofLogModule log_module = G_LOG_DOMAIN;
#define BUDGET_MAX_RECURRENCE_PERIOD_TYPE_LEN 2048
typedef struct {
GncSqlBackend* be;
const GUID* guid;
Recurrence* pRecurrence;
/*@ dependent @*/ GncSqlBackend* be;
/*@ dependent @*/ const GUID* guid;
/*@ dependent @*/ Recurrence* pRecurrence;
} recurrence_info_t;
static gpointer get_obj_guid( gpointer pObject, const QofParam* param );
static void set_obj_guid( gpointer pObject, gpointer pValue );
static /*@ null @*/ gpointer get_obj_guid( gpointer pObject );
static void set_obj_guid( void );
static gint get_recurrence_mult( gpointer pObject );
static void set_recurrence_mult( gpointer pObject, gint value );
static gpointer get_recurrence_period_type( gpointer pObject, const QofParam* );
static void set_recurrence_period_type( gpointer pObject, gpointer pValue );
static gpointer get_recurrence_period_start( gpointer pObject, const QofParam* );
static void set_recurrence_period_start( gpointer pObject, gpointer pValue );
static /*@ null @*/ gpointer get_recurrence_period_type( gpointer pObject );
static void set_recurrence_period_type( gpointer pObject, /*@ null @*/ gpointer pValue );
static /*@ dependent @*//*@ null @*/ gpointer get_recurrence_period_start( gpointer pObject );
static void set_recurrence_period_start( gpointer pObject, /*@ null @*/ gpointer pValue );
static const GncSqlColumnTableEntry col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "obj_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
get_obj_guid, set_obj_guid },
(QofAccessFunc)get_obj_guid, (QofSetterFunc)set_obj_guid },
{ "recurrence_mult", CT_INT, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)get_recurrence_mult, (QofSetterFunc)set_recurrence_mult },
{ "recurrence_period_type", CT_STRING, BUDGET_MAX_RECURRENCE_PERIOD_TYPE_LEN, COL_NNUL, NULL, NULL,
get_recurrence_period_type, set_recurrence_period_type },
(QofAccessFunc)get_recurrence_period_type, set_recurrence_period_type },
{ "recurrence_period_start", CT_GDATE, 0, COL_NNUL, NULL, NULL,
get_recurrence_period_start, set_recurrence_period_start },
(QofAccessFunc)get_recurrence_period_start, set_recurrence_period_start },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* Special column table because we need to be able to access the table by
a column other than the primary key */
static const GncSqlColumnTableEntry guid_col_table[] =
{
/*# -fullinitblock */
{ "obj_guid", CT_GUID, 0, 0, NULL, NULL, get_obj_guid, set_obj_guid },
/*@ -full_init_block @*/
{ "obj_guid", CT_GUID, 0, 0, NULL, NULL,
(QofAccessFunc)get_obj_guid, (QofSetterFunc)set_obj_guid },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* ================================================================= */
static gpointer
get_obj_guid( gpointer pObject, const QofParam* param )
static /*@ null @*/ gpointer
get_obj_guid( gpointer pObject )
{
recurrence_info_t* pInfo = (recurrence_info_t*)pObject;
@@ -98,7 +103,7 @@ get_obj_guid( gpointer pObject, const QofParam* param )
}
static void
set_obj_guid( gpointer pObject, gpointer pValue )
set_obj_guid( void )
{
// Nowhere to put the GUID
}
@@ -125,8 +130,8 @@ set_recurrence_mult( gpointer pObject, gint value )
pInfo->pRecurrence->mult = (guint16)value;
}
static gpointer
get_recurrence_period_type( gpointer pObject, const QofParam* param )
static /*@ null @*/ gpointer
get_recurrence_period_type( gpointer pObject )
{
recurrence_info_t* pInfo = (recurrence_info_t*)pObject;
@@ -149,8 +154,8 @@ set_recurrence_period_type( gpointer pObject, gpointer pValue )
pInfo->pRecurrence->ptype = recurrencePeriodTypeFromString( (gchar*)pValue );
}
static gpointer
get_recurrence_period_start( gpointer pObject, const QofParam* param )
static /*@ dependent @*//*@ null @*/ gpointer
get_recurrence_period_start( gpointer pObject )
{
recurrence_info_t* pInfo = (recurrence_info_t*)pObject;
static GDate date;
@@ -186,7 +191,7 @@ gnc_sql_recurrence_save( GncSqlBackend* be, const GUID* guid, const Recurrence*
g_return_val_if_fail( guid != NULL, FALSE );
g_return_val_if_fail( r != NULL, FALSE );
gnc_sql_recurrence_delete( be, guid );
(void)gnc_sql_recurrence_delete( be, guid );
recurrence_info.be = be;
recurrence_info.guid = guid;
@@ -204,7 +209,7 @@ gnc_sql_recurrence_save_list( GncSqlBackend* be, const GUID* guid, GList* schedu
g_return_if_fail( be != NULL );
g_return_if_fail( guid != NULL );
gnc_sql_recurrence_delete( be, guid );
(void)gnc_sql_recurrence_delete( be, guid );
recurrence_info.be = be;
recurrence_info.guid = guid;
@@ -230,7 +235,7 @@ gnc_sql_recurrence_delete( GncSqlBackend* be, const GUID* guid )
}
static void
load_recurrence( GncSqlBackend* be, GncSqlRow* row, Recurrence* r )
load_recurrence( GncSqlBackend* be, GncSqlRow* row, /*@ out @*/ Recurrence* r )
{
recurrence_info_t recurrence_info;
@@ -244,7 +249,7 @@ load_recurrence( GncSqlBackend* be, GncSqlRow* row, Recurrence* r )
gnc_sql_load_object( be, row, TABLE_NAME, &recurrence_info, col_table );
}
static GncSqlResult*
static /*@ null @*/ GncSqlResult*
gnc_sql_set_recurrences_from_db( GncSqlBackend* be, const GUID* guid )
{
gchar* buf;
@@ -258,45 +263,49 @@ gnc_sql_set_recurrences_from_db( GncSqlBackend* be, const GUID* guid )
(void)guid_to_string_buff( guid, guid_buf );
buf = g_strdup_printf( "SELECT * FROM %s WHERE obj_guid='%s'", TABLE_NAME, guid_buf );
stmt = gnc_sql_connection_create_statement_from_sql( be->conn, buf );
g_free( buf );
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
return result;
}
void
gnc_sql_recurrence_load( GncSqlBackend* be, const GUID* guid, Recurrence* pRecurrence )
/*@ null @*/ Recurrence*
gnc_sql_recurrence_load( GncSqlBackend* be, const GUID* guid )
{
GncSqlResult* result;
Recurrence* r = NULL;
g_return_if_fail( be != NULL );
g_return_if_fail( guid != NULL );
g_return_if_fail( pRecurrence != NULL );
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( guid != NULL, NULL );
result = gnc_sql_set_recurrences_from_db( be, guid );
if( result != NULL ) {
int numRows = gnc_sql_result_get_num_rows( result );
guint numRows = gnc_sql_result_get_num_rows( result );
if( numRows > 0 ) {
if( numRows > 1 ) {
g_warning( "More than 1 recurrence found: first one used" );
}
load_recurrence( be, gnc_sql_result_get_first_row( result ),
pRecurrence );
r = g_new0( Recurrence, 1 );
g_assert( r != NULL );
load_recurrence( be, gnc_sql_result_get_first_row( result ), r );
} else {
g_warning( "No recurrences found" );
}
gnc_sql_result_dispose( result );
}
return r;
}
void
gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid, GList** pSchedule )
/*@ null @*/ GList*
gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid )
{
GncSqlResult* result;
GList* list = NULL;
g_return_if_fail( be != NULL );
g_return_if_fail( guid != NULL );
g_return_if_fail( pSchedule != NULL );
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( guid != NULL, NULL );
result = gnc_sql_set_recurrences_from_db( be, guid );
if( result != NULL ) {
@@ -304,12 +313,15 @@ gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid, GList** pSche
while( row != NULL ) {
Recurrence* pRecurrence = g_new0( Recurrence, 1 );
g_assert( pRecurrence != NULL );
load_recurrence( be, row, pRecurrence );
*pSchedule = g_list_append( *pSchedule, pRecurrence );
list = g_list_append( list, pRecurrence );
row = gnc_sql_result_get_next_row( result );
}
gnc_sql_result_dispose( result );
}
return list;
}
/* ================================================================= */
@@ -322,7 +334,7 @@ create_recurrence_tables( GncSqlBackend* be )
version = gnc_sql_get_table_version( be, TABLE_NAME );
if( version == 0 ) {
gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
(void)gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
}
}
@@ -343,6 +355,6 @@ gnc_sql_init_recurrence_handler( void )
NULL /* write */
};
qof_object_register_backend( TABLE_NAME, GNC_SQL_BACKEND, &be_data );
(void)qof_object_register_backend( TABLE_NAME, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */

View File

@@ -35,8 +35,8 @@
gboolean gnc_sql_recurrence_save( GncSqlBackend* be, const GUID* guid, const Recurrence* pRecurrence );
void gnc_sql_recurrence_save_list( GncSqlBackend* be, const GUID* guid, GList* schedule );
gboolean gnc_sql_recurrence_delete( GncSqlBackend* be, const GUID* guid );
void gnc_sql_recurrence_load( GncSqlBackend* be, const GUID* guid, Recurrence* pRecurrence );
void gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid, GList** pSchedule );
/*@ null @*/ Recurrence* gnc_sql_recurrence_load( GncSqlBackend* be, const GUID* guid );
/*@ null @*/ GList* gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid );
void gnc_sql_init_recurrence_handler( void );

View File

@@ -44,10 +44,14 @@
#include "gnc-recurrence-sql.h"
#include "gnc-transaction-sql.h"
#ifdef S_SPLINT_S
#include "splint-defs.h"
#endif
#define SCHEDXACTION_TABLE "schedxactions"
#define TABLE_VERSION 1
static QofLogModule log_module = G_LOG_DOMAIN;
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define SX_MAX_NAME_LEN 2048
@@ -56,12 +60,12 @@ static void set_autocreate( gpointer pObject, gboolean value );
static gboolean get_autonotify( gpointer pObject );
static void set_autonotify( gpointer pObject, gboolean value );
static gint get_instance_count( gpointer pObject );
static gpointer get_template_act_guid( gpointer pObject, const QofParam* param );
static void set_template_act_guid( gpointer pObject, gpointer pValue );
static /*@ null @*/ gpointer get_template_act_guid( gpointer pObject );
static void set_template_act_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
static const GncSqlColumnTableEntry col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "name", CT_STRING, SX_MAX_NAME_LEN, 0, NULL, GNC_SX_NAME },
{ "enabled", CT_BOOLEAN, 0, COL_NNUL, NULL, NULL,
@@ -83,9 +87,9 @@ static const GncSqlColumnTableEntry col_table[] =
{ "instance_count", CT_INT, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)get_instance_count, (QofSetterFunc)gnc_sx_set_instance_count },
{ "template_act_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
get_template_act_guid, set_template_act_guid },
(QofAccessFunc)get_template_act_guid, set_template_act_guid },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* ================================================================= */
@@ -93,13 +97,14 @@ static const GncSqlColumnTableEntry col_table[] =
static gboolean
get_autocreate( gpointer pObject )
{
const SchedXaction* pSx = GNC_SX(pObject);
const SchedXaction* pSx;
gboolean autoCreate;
gboolean autoNotify;
g_return_val_if_fail( pObject != NULL, FALSE );
g_return_val_if_fail( GNC_IS_SX(pObject), FALSE );
pSx = GNC_SX(pObject);
xaccSchedXactionGetAutoCreate( pSx, &autoCreate, &autoNotify );
return autoCreate;
}
@@ -107,13 +112,14 @@ get_autocreate( gpointer pObject )
static void
set_autocreate( gpointer pObject, gboolean value )
{
SchedXaction* pSx = GNC_SX(pObject);
SchedXaction* pSx;
gboolean autoNotify;
gboolean dummy;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_SX(pObject) );
pSx = GNC_SX(pObject);
xaccSchedXactionGetAutoCreate( pSx, &dummy, &autoNotify );
xaccSchedXactionSetAutoCreate( pSx, value, autoNotify );
}
@@ -121,13 +127,14 @@ set_autocreate( gpointer pObject, gboolean value )
static gboolean
get_autonotify( gpointer pObject )
{
const SchedXaction* pSx = GNC_SX(pObject);
const SchedXaction* pSx;
gboolean autoCreate;
gboolean autoNotify;
g_return_val_if_fail( pObject != NULL, FALSE );
g_return_val_if_fail( GNC_IS_SX(pObject), FALSE );
pSx = GNC_SX(pObject);
xaccSchedXactionGetAutoCreate( pSx, &autoCreate, &autoNotify );
return autoNotify;
}
@@ -135,13 +142,14 @@ get_autonotify( gpointer pObject )
static void
set_autonotify( gpointer pObject, gboolean value )
{
SchedXaction* pSx = GNC_SX(pObject);
SchedXaction* pSx;
gboolean autoCreate;
gboolean dummy;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_SX(pObject) );
pSx = GNC_SX(pObject);
xaccSchedXactionGetAutoCreate( pSx, &autoCreate, &dummy );
xaccSchedXactionSetAutoCreate( pSx, autoCreate, value );
}
@@ -149,29 +157,28 @@ set_autonotify( gpointer pObject, gboolean value )
static gint
get_instance_count( gpointer pObject )
{
const SchedXaction* pSx = GNC_SX(pObject);
g_return_val_if_fail( pObject != NULL, FALSE );
g_return_val_if_fail( GNC_IS_SX(pObject), FALSE );
return gnc_sx_get_instance_count( pSx, NULL );
return gnc_sx_get_instance_count( GNC_SX(pObject), NULL );
}
static gpointer
get_template_act_guid( gpointer pObject, const QofParam* param )
get_template_act_guid( gpointer pObject )
{
const SchedXaction* pSx = GNC_SX(pObject);
const SchedXaction* pSx;
g_return_val_if_fail( pObject != NULL, NULL );
g_return_val_if_fail( GNC_IS_SX(pObject), NULL );
pSx = GNC_SX(pObject);
return (gpointer)xaccAccountGetGUID( pSx->template_acct );
}
static void
set_template_act_guid( gpointer pObject, gpointer pValue )
{
SchedXaction* pSx = GNC_SX(pObject);
SchedXaction* pSx;
QofBook* pBook;
GUID* guid = (GUID*)pValue;
Account* pAcct;
@@ -180,31 +187,30 @@ set_template_act_guid( gpointer pObject, gpointer pValue )
g_return_if_fail( GNC_IS_SX(pObject) );
g_return_if_fail( pValue != NULL );
pSx = GNC_SX(pObject);
pBook = qof_instance_get_book( QOF_INSTANCE(pSx) );
pAcct = xaccAccountLookup( guid, pBook );
sx_set_template_account( pSx, pAcct );
}
/* ================================================================= */
static SchedXaction*
static /*@ null @*/ SchedXaction*
load_single_sx( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
GUID sx_guid;
SchedXaction* pSx;
GList* schedule = NULL;
GList* schedule;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
sx_guid = *guid;
g_assert( guid != NULL );
pSx = xaccSchedXactionMalloc( be->primary_book );
gnc_sx_begin_edit( pSx );
gnc_sql_load_object( be, row, GNC_SX_ID, pSx, col_table );
gnc_sql_recurrence_load_list( be, guid, &schedule );
schedule = gnc_sql_recurrence_load_list( be, guid );
gnc_sx_set_schedule( pSx, schedule );
gnc_sx_commit_edit( pSx );
gnc_sql_transaction_load_tx_for_account( be, pSx->template_acct );
@@ -221,6 +227,7 @@ load_all_sxes( GncSqlBackend* be )
g_return_if_fail( be != NULL );
stmt = gnc_sql_create_select_statement( be, SCHEDXACTION_TABLE );
if( stmt == NULL ) return;
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -244,6 +251,7 @@ load_all_sxes( GncSqlBackend* be )
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
g_list_free( list );
}
}
}
@@ -258,7 +266,7 @@ create_sx_tables( GncSqlBackend* be )
version = gnc_sql_get_table_version( be, SCHEDXACTION_TABLE );
if( version == 0 ) {
gnc_sql_create_table( be, SCHEDXACTION_TABLE, TABLE_VERSION, col_table );
(void)gnc_sql_create_table( be, SCHEDXACTION_TABLE, TABLE_VERSION, col_table );
}
}
@@ -319,6 +327,6 @@ gnc_sql_init_schedxaction_handler( void )
NULL /* write */
};
qof_object_register_backend( GNC_ID_SCHEDXACTION, GNC_SQL_BACKEND, &be_data );
(void)qof_object_register_backend( GNC_ID_SCHEDXACTION, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */

View File

@@ -37,38 +37,42 @@
#include "gnc-slots-sql.h"
static QofLogModule log_module = G_LOG_DOMAIN;
#ifdef S_SPLINT_S
#include "splint-defs.h"
#endif
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define TABLE_NAME "slots"
#define TABLE_VERSION 2
typedef struct {
GncSqlBackend* be;
const GUID* guid;
/*@ dependent @*/ GncSqlBackend* be;
/*@ dependent @*/ const GUID* guid;
gboolean is_ok;
KvpFrame* pKvpFrame;
/*@ dependent @*/ KvpFrame* pKvpFrame;
KvpValueType value_type;
KvpValue* pKvpValue;
/*@ dependent @*/ KvpValue* pKvpValue;
GString* path;
} slot_info_t;
static gpointer get_obj_guid( gpointer pObject, const QofParam* param );
static void set_obj_guid( gpointer pObject, gpointer pValue );
static gpointer get_path( gpointer pObject, const QofParam* param );
static void set_path( gpointer pObject, gpointer pValue );
static gpointer get_slot_type( gpointer pObject, const QofParam* param );
static void set_slot_type( gpointer pObject, gpointer pValue );
static gint64 get_int64_val( gpointer pObject, const QofParam* param );
static /*@ null @*/ gpointer get_obj_guid( gpointer pObject );
static void set_obj_guid( void );
static /*@ null @*/ gpointer get_path( gpointer pObject );
static void set_path( gpointer pObject, /*@ null @*/ gpointer pValue );
static /*@ null @*/ gpointer get_slot_type( gpointer pObject );
static void set_slot_type( gpointer pObject, /*@ null @*/ gpointer pValue );
static gint64 get_int64_val( gpointer pObject );
static void set_int64_val( gpointer pObject, gint64 pValue );
static gpointer get_string_val( gpointer pObject, const QofParam* param );
static void set_string_val( gpointer pObject, gpointer pValue );
static gpointer get_double_val( gpointer pObject, const QofParam* param );
static void set_double_val( gpointer pObject, gpointer pValue );
static Timespec get_timespec_val( gpointer pObject, const QofParam* param );
static /*@ null @*/ gpointer get_string_val( gpointer pObject );
static void set_string_val( gpointer pObject, /*@ null @*/ gpointer pValue );
static /*@ dependent @*//*@ null @*/ gpointer get_double_val( gpointer pObject );
static void set_double_val( gpointer pObject, /*@ null @*/ gpointer pValue );
static Timespec get_timespec_val( gpointer pObject );
static void set_timespec_val( gpointer pObject, Timespec ts );
static gpointer get_guid_val( gpointer pObject, const QofParam* param );
static void set_guid_val( gpointer pObject, gpointer pValue );
static gnc_numeric get_numeric_val( gpointer pObject, const QofParam* param );
static /*@ null @*/ gpointer get_guid_val( gpointer pObject );
static void set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue );
static gnc_numeric get_numeric_val( gpointer pObject );
static void set_numeric_val( gpointer pObject, gnc_numeric value );
#define SLOT_MAX_PATHNAME_LEN 4096
@@ -76,43 +80,43 @@ static void set_numeric_val( gpointer pObject, gnc_numeric value );
static const GncSqlColumnTableEntry col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "obj_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
get_obj_guid, set_obj_guid },
(QofAccessFunc)get_obj_guid, (QofSetterFunc)set_obj_guid },
{ "name", CT_STRING, SLOT_MAX_PATHNAME_LEN, COL_NNUL, NULL, NULL,
get_path, set_path },
(QofAccessFunc)get_path, set_path },
{ "slot_type", CT_INT, 0, COL_NNUL, NULL, NULL,
get_slot_type, set_slot_type, },
(QofAccessFunc)get_slot_type, set_slot_type, },
{ "int64_val", CT_INT64, 0, 0, NULL, NULL,
(QofAccessFunc)get_int64_val, (QofSetterFunc)set_int64_val },
{ "string_val", CT_STRING, SLOT_MAX_PATHNAME_LEN, 0, NULL, NULL,
get_string_val, set_string_val },
(QofAccessFunc)get_string_val, set_string_val },
{ "double_val", CT_DOUBLE, 0, 0, NULL, NULL,
get_double_val, set_double_val },
(QofAccessFunc)get_double_val, set_double_val },
{ "timespec_val", CT_TIMESPEC, 0, 0, NULL, NULL,
(QofAccessFunc)get_timespec_val, (QofSetterFunc)set_timespec_val },
{ "guid_val", CT_GUID, 0, 0, NULL, NULL,
get_guid_val, set_guid_val },
(QofAccessFunc)get_guid_val, set_guid_val },
{ "numeric_val", CT_NUMERIC, 0, 0, NULL, NULL,
(QofAccessFunc)get_numeric_val, (QofSetterFunc)set_numeric_val },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* Special column table because we need to be able to access the table by
a column other than the primary key */
static const GncSqlColumnTableEntry obj_guid_col_table[] =
{
/*# -fullinitblock */
{ "obj_guid", CT_GUID, 0, 0, NULL, NULL, get_obj_guid, _retrieve_guid_ },
/*@ -full_init_block @*/
{ "obj_guid", CT_GUID, 0, 0, NULL, NULL, (QofAccessFunc)get_obj_guid, _retrieve_guid_ },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
/* ================================================================= */
static gpointer
get_obj_guid( gpointer pObject, const QofParam* param )
static /*@ null @*/ gpointer
get_obj_guid( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -122,13 +126,13 @@ get_obj_guid( gpointer pObject, const QofParam* param )
}
static void
set_obj_guid( gpointer pObject, gpointer pValue )
set_obj_guid( void )
{
// Nowhere to put the GUID
}
static gpointer
get_path( gpointer pObject, const QofParam* param )
static /*@ null @*/ gpointer
get_path( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -138,18 +142,21 @@ get_path( gpointer pObject, const QofParam* param )
}
static void
set_path( gpointer pObject, gpointer pValue )
set_path( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
g_return_if_fail( pObject != NULL );
g_return_if_fail( pValue != NULL );
if( pInfo->path != NULL ) {
(void)g_string_free( pInfo->path, TRUE );
}
pInfo->path = g_string_new( (gchar*)pValue );
}
static gpointer
get_slot_type( gpointer pObject, const QofParam* param )
static /*@ null @*/ gpointer
get_slot_type( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -159,7 +166,7 @@ get_slot_type( gpointer pObject, const QofParam* param )
}
static void
set_slot_type( gpointer pObject, gpointer pValue )
set_slot_type( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -170,7 +177,7 @@ set_slot_type( gpointer pObject, gpointer pValue )
}
static gint64
get_int64_val( gpointer pObject, const QofParam* param )
get_int64_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -195,8 +202,8 @@ set_int64_val( gpointer pObject, gint64 value )
}
}
static gpointer
get_string_val( gpointer pObject, const QofParam* param )
static /*@ null @*/ gpointer
get_string_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -210,7 +217,7 @@ get_string_val( gpointer pObject, const QofParam* param )
}
static void
set_string_val( gpointer pObject, gpointer pValue )
set_string_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -221,8 +228,8 @@ set_string_val( gpointer pObject, gpointer pValue )
}
}
static gpointer
get_double_val( gpointer pObject, const QofParam* param )
static /*@ dependent @*//*@ null @*/ gpointer
get_double_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
static double d_val;
@@ -238,7 +245,7 @@ get_double_val( gpointer pObject, const QofParam* param )
}
static void
set_double_val( gpointer pObject, gpointer pValue )
set_double_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -250,7 +257,7 @@ set_double_val( gpointer pObject, gpointer pValue )
}
static Timespec
get_timespec_val( gpointer pObject, const QofParam* param )
get_timespec_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -272,8 +279,8 @@ set_timespec_val( gpointer pObject, Timespec ts )
}
}
static gpointer
get_guid_val( gpointer pObject, const QofParam* param )
static /*@ null @*/ gpointer
get_guid_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -287,7 +294,7 @@ get_guid_val( gpointer pObject, const QofParam* param )
}
static void
set_guid_val( gpointer pObject, gpointer pValue )
set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -299,7 +306,7 @@ set_guid_val( gpointer pObject, gpointer pValue )
}
static gnc_numeric
get_numeric_val( gpointer pObject, const QofParam* param )
get_numeric_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -370,7 +377,7 @@ gnc_sql_slots_save( GncSqlBackend* be, const GUID* guid, gboolean is_infant, Kvp
// If this is not saving into a new db, clear out the old saved slots first
if( !be->is_pristine_db && !is_infant ) {
gnc_sql_slots_delete( be, guid );
(void)gnc_sql_slots_delete( be, guid );
}
slot_info.be = be;
@@ -443,6 +450,8 @@ gnc_sql_slots_load( GncSqlBackend* be, QofInstance* inst )
buf = g_strdup_printf( "SELECT * FROM %s WHERE obj_guid='%s'", TABLE_NAME, guid_buf );
stmt = gnc_sql_create_statement_from_sql( be, buf );
g_free( buf );
if( stmt != NULL ) {
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -454,9 +463,10 @@ gnc_sql_slots_load( GncSqlBackend* be, QofInstance* inst )
}
gnc_sql_result_dispose( result );
}
}
}
static const GUID*
static /*@ dependent @*//*@ null @*/ const GUID*
load_obj_guid( const GncSqlBackend* be, GncSqlRow* row )
{
static GUID guid;
@@ -481,6 +491,7 @@ load_slot_for_list_item( GncSqlBackend* be, GncSqlRow* row, QofCollection* coll
g_return_if_fail( coll != NULL );
guid = load_obj_guid( be, row );
g_assert( guid != NULL );
inst = qof_collection_lookup_entity( coll, guid );
slot_info.be = be;
@@ -527,6 +538,7 @@ gnc_sql_slots_load_for_list( GncSqlBackend* be, GList* list )
// Execute the query and load the slots
stmt = gnc_sql_create_statement_from_sql( be, sql->str );
g_assert( stmt != NULL );
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -545,14 +557,13 @@ gnc_sql_slots_load_for_list( GncSqlBackend* be, GList* list )
static void
create_slots_tables( GncSqlBackend* be )
{
gboolean ok;
gint version;
g_return_if_fail( be != NULL );
version = gnc_sql_get_table_version( be, TABLE_NAME );
if( version == 0 ) {
gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
(void)gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
#if 0
// FIXME: Create index
ok = gnc_sql_create_index( be, "slots_guid_index", TABLE_NAME, obj_guid_col_table, &error );
@@ -563,7 +574,7 @@ create_slots_tables( GncSqlBackend* be )
} else if( version == 1 ) {
/* Upgrade 64-bit int values to proper definition */
gnc_sql_upgrade_table( be, TABLE_NAME, col_table );
gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
(void)gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
}
}
@@ -584,6 +595,6 @@ gnc_sql_init_slots_handler( void )
NULL /* write */
};
qof_object_register_backend( TABLE_NAME, GNC_SQL_BACKEND, &be_data );
(void)qof_object_register_backend( TABLE_NAME, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */

View File

@@ -47,7 +47,11 @@
#include "gnc-engine.h"
static QofLogModule log_module = G_LOG_DOMAIN;
#ifdef S_SPLINT_S
#include "splint-defs.h"
#endif
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define TRANSACTION_TABLE "transactions"
#define TX_TABLE_VERSION 2
@@ -55,8 +59,8 @@ static QofLogModule log_module = G_LOG_DOMAIN;
#define SPLIT_TABLE_VERSION 2
typedef struct {
GncSqlBackend* be;
const GUID* guid;
/*@ dependent @*/ GncSqlBackend* be;
/*@ dependent @*/ const GUID* guid;
gboolean is_ok;
} split_info_t;
@@ -65,7 +69,7 @@ typedef struct {
static const GncSqlColumnTableEntry tx_col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "currency_guid", CT_COMMODITYREF, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)xaccTransGetCurrency, (QofSetterFunc)xaccTransSetCurrency },
@@ -78,27 +82,27 @@ static const GncSqlColumnTableEntry tx_col_table[] =
{ "description", CT_STRING, TX_MAX_DESCRIPTION_LEN, 0, NULL, NULL,
(QofAccessFunc)xaccTransGetDescription, (QofSetterFunc)xaccTransSetDescription },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
static gpointer get_split_reconcile_state( gpointer pObject, const QofParam* param );
static void set_split_reconcile_state( gpointer pObject, gpointer pValue );
static /*@ dependent @*//*@ null @*/ gpointer get_split_reconcile_state( gpointer pObject );
static void set_split_reconcile_state( gpointer pObject, /*@ null @*/ gpointer pValue );
static void set_split_reconcile_date( gpointer pObject, Timespec ts );
static void set_split_lot( gpointer pObject, gpointer pLot );
static void set_split_lot( gpointer pObject, /*@ null @*/ gpointer pLot );
#define SPLIT_MAX_MEMO_LEN 2048
#define SPLIT_MAX_ACTION_LEN 2048
static const GncSqlColumnTableEntry split_col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "tx_guid", CT_TXREF, 0, COL_NNUL, NULL, SPLIT_TRANS },
{ "account_guid", CT_ACCOUNTREF, 0, COL_NNUL, NULL, SPLIT_ACCOUNT },
{ "memo", CT_STRING, SPLIT_MAX_MEMO_LEN, COL_NNUL, NULL, SPLIT_MEMO },
{ "action", CT_STRING, SPLIT_MAX_ACTION_LEN, COL_NNUL, NULL, SPLIT_ACTION },
{ "reconcile_state", CT_STRING, 1, COL_NNUL, NULL, NULL,
get_split_reconcile_state, set_split_reconcile_state },
(QofAccessFunc)get_split_reconcile_state, set_split_reconcile_state },
{ "reconcile_date", CT_TIMESPEC, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)xaccSplitRetDateReconciledTS, (QofSetterFunc)set_split_reconcile_date },
{ "value", CT_NUMERIC, 0, COL_NNUL, NULL, SPLIT_VALUE },
@@ -106,46 +110,42 @@ static const GncSqlColumnTableEntry split_col_table[] =
{ "lot_guid", CT_LOTREF, 0, 0, NULL, NULL,
(QofAccessFunc)xaccSplitGetLot, set_split_lot },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
static const GncSqlColumnTableEntry guid_col_table[] =
{
/*# -fullinitblock */
/*@ -full_init_block @*/
{ "tx_guid", CT_GUID, 0, 0, "guid" },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
static void retrieve_numeric_value( gpointer pObject, gnc_numeric value );
/* ================================================================= */
static gpointer
get_split_reconcile_state( gpointer pObject, const QofParam* param )
static /*@ dependent @*//*@ null @*/ gpointer
get_split_reconcile_state( gpointer pObject )
{
const Split* pSplit = GNC_SPLIT(pObject);
static gchar c[2];
g_return_val_if_fail( pObject != NULL, NULL );
g_return_val_if_fail( GNC_IS_SPLIT(pObject), NULL );
c[0] = xaccSplitGetReconcile( pSplit );
c[0] = xaccSplitGetReconcile( GNC_SPLIT(pObject) );
c[1] = '\0';
return (gpointer)c;
}
static void
set_split_reconcile_state( gpointer pObject, gpointer pValue )
set_split_reconcile_state( gpointer pObject, /*@ null @*/ gpointer pValue )
{
Split* pSplit = GNC_SPLIT(pObject);
const gchar* s = (const gchar*)pValue;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_SPLIT(pObject) );
g_return_if_fail( pValue != NULL );
xaccSplitSetReconcile( pSplit, s[0] );
xaccSplitSetReconcile( GNC_SPLIT(pObject), s[0] );
}
static void
@@ -158,17 +158,7 @@ set_split_reconcile_date( gpointer pObject, Timespec ts )
}
static void
retrieve_numeric_value( gpointer pObject, gnc_numeric value )
{
gnc_numeric* pResult = (gnc_numeric*)pObject;
g_return_if_fail( pObject != NULL );
*pResult = value;
}
static void
set_split_lot( gpointer pObject, gpointer pLot )
set_split_lot( gpointer pObject, /*@ null @*/ gpointer pLot )
{
GNCLot* lot;
Split* split;
@@ -185,18 +175,7 @@ set_split_lot( gpointer pObject, gpointer pLot )
gnc_lot_add_split( lot, split );
}
#if 0
// Table to retrieve just the quantity
static GncSqlColumnTableEntry quantity_table[] =
{
/*# -fullinitblock */
{ "quantity", CT_NUMERIC, 0, COL_NNUL, NULL, NULL, NULL, (QofSetterFunc)retrieve_numeric_value },
{ NULL }
/*# +fullinitblock */
};
#endif
static Split*
static /*@ null @*/ Split*
load_single_split( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
@@ -207,6 +186,7 @@ load_single_split( GncSqlBackend* be, GncSqlRow* row )
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
if( guid == NULL ) return NULL;
split_guid = *guid;
pSplit = xaccSplitLookup( &split_guid, be->primary_book );
@@ -242,7 +222,7 @@ load_splits_for_tx_list( GncSqlBackend* be, GList* list )
// Execute the query and load the splits
result = gnc_sql_execute_select_sql( be, sql->str );
if( result != NULL ) {
GList* list = NULL;
GList* split_list = NULL;
GncSqlRow* row;
row = gnc_sql_result_get_first_row( result );
@@ -250,13 +230,14 @@ load_splits_for_tx_list( GncSqlBackend* be, GList* list )
Split* s;
s = load_single_split( be, row );
if( s != NULL ) {
list = g_list_append( list, s );
split_list = g_list_append( split_list, s );
}
row = gnc_sql_result_get_next_row( result );
}
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
if( split_list != NULL ) {
gnc_sql_slots_load_for_list( be, split_list );
g_list_free( split_list );
}
gnc_sql_result_dispose( result );
@@ -264,7 +245,7 @@ load_splits_for_tx_list( GncSqlBackend* be, GList* list )
(void)g_string_free( sql, FALSE );
}
static Transaction*
static /*@ null @*/ Transaction*
load_single_tx( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
@@ -275,6 +256,7 @@ load_single_tx( GncSqlBackend* be, GncSqlRow* row )
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
if( guid == NULL ) return NULL;
tx_guid = *guid;
// Don't overwrite the transaction if it's already been loaded (and possibly modified).
@@ -299,7 +281,7 @@ load_single_tx( GncSqlBackend* be, GncSqlRow* row )
* are unchanged.
*/
typedef struct {
Account* acc;
/*@ dependent @*/ Account* acc;
gnc_numeric start_bal;
gnc_numeric end_bal;
gnc_numeric start_cleared_bal;
@@ -324,6 +306,8 @@ save_account_balances( Account* acc, gpointer pData )
gnc_numeric* pend_r;
newbal = g_malloc( (gsize)sizeof( full_acct_balances_t ) );
g_assert( newbal != NULL );
newbal->acc = acc;
g_object_get( acc,
"start-balance", &pstart,
@@ -436,7 +420,9 @@ query_transactions( GncSqlBackend* be, GncSqlStatement* stmt )
}
xaccAccountRecomputeBalance( balns->acc );
}
if( bal_list != NULL ) {
g_slist_free( bal_list );
}
xaccAccountCommitEdit( root );
qof_event_resume();
@@ -453,20 +439,20 @@ create_transaction_tables( GncSqlBackend* be )
version = gnc_sql_get_table_version( be, TRANSACTION_TABLE );
if( version == 0 ) {
gnc_sql_create_table( be, TRANSACTION_TABLE, TX_TABLE_VERSION, tx_col_table );
(void)gnc_sql_create_table( be, TRANSACTION_TABLE, TX_TABLE_VERSION, tx_col_table );
} else if( version == 1 ) {
/* Upgrade 64 bit int handling */
gnc_sql_upgrade_table( be, TRANSACTION_TABLE, tx_col_table );
gnc_sql_set_table_version( be, TRANSACTION_TABLE, TX_TABLE_VERSION );
(void)gnc_sql_set_table_version( be, TRANSACTION_TABLE, TX_TABLE_VERSION );
}
version = gnc_sql_get_table_version( be, SPLIT_TABLE );
if( version == 0 ) {
gnc_sql_create_table( be, SPLIT_TABLE, SPLIT_TABLE_VERSION, split_col_table );
(void)gnc_sql_create_table( be, SPLIT_TABLE, SPLIT_TABLE_VERSION, split_col_table );
} else if( version == 1 ) {
/* Upgrade 64 bit int handling */
gnc_sql_upgrade_table( be, SPLIT_TABLE, split_col_table );
gnc_sql_set_table_version( be, SPLIT_TABLE, SPLIT_TABLE_VERSION );
(void)gnc_sql_set_table_version( be, SPLIT_TABLE, SPLIT_TABLE_VERSION );
}
}
/* ================================================================= */
@@ -638,7 +624,7 @@ commit_transaction( GncSqlBackend* be, QofInstance* inst )
}
/* ================================================================= */
static const GUID*
static /*@ dependent @*//*@ null @*/ const GUID*
get_guid_from_query( QofQuery* pQuery )
{
GList* pOrTerms;
@@ -689,8 +675,11 @@ void gnc_sql_transaction_load_tx_for_account( GncSqlBackend* be, Account* accoun
query_sql = g_strdup_printf( "SELECT * FROM %s WHERE guid IN (%s)", TRANSACTION_TABLE, subquery_sql );
g_free( subquery_sql );
stmt = gnc_sql_create_statement_from_sql( be, query_sql );
g_free( query_sql );
if( stmt != NULL ) {
query_transactions( be, stmt );
gnc_sql_statement_dispose( stmt );
}
}
/**
@@ -708,8 +697,11 @@ void gnc_sql_transaction_load_all_tx( GncSqlBackend* be )
query_sql = g_strdup_printf( "SELECT * FROM %s", TRANSACTION_TABLE );
stmt = gnc_sql_create_statement_from_sql( be, query_sql );
g_free( query_sql );
if( stmt != NULL ) {
query_transactions( be, stmt );
gnc_sql_statement_dispose( stmt );
}
}
typedef struct {
@@ -718,12 +710,12 @@ typedef struct {
gboolean has_been_run;
} split_query_info_t;
static gpointer
static /*@ null @*/ gpointer
compile_split_query( GncSqlBackend* be, QofQuery* pQuery )
{
const GUID* acct_guid;
gchar guid_buf[GUID_ENCODING_LENGTH+1];
split_query_info_t* query_info;
split_query_info_t* query_info = NULL;
gchar* subquery_sql;
gchar* query_sql;
@@ -731,16 +723,21 @@ compile_split_query( GncSqlBackend* be, QofQuery* pQuery )
g_return_val_if_fail( pQuery != NULL, NULL );
acct_guid = get_guid_from_query( pQuery );
if( acct_guid != NULL ) {
(void)guid_to_string_buff( acct_guid, guid_buf );
subquery_sql = g_strdup_printf( "SELECT DISTINCT tx_guid FROM %s WHERE account_guid='%s'", SPLIT_TABLE, guid_buf );
query_sql = g_strdup_printf( "SELECT * FROM %s WHERE guid IN (%s)", TRANSACTION_TABLE, subquery_sql );
query_info = g_malloc( (gsize)sizeof(split_query_info_t) );
g_assert( query_info != NULL );
query_info->stmt = gnc_sql_create_statement_from_sql( be, query_sql );
g_free( query_sql );
query_info->has_been_run = FALSE;
query_info->acct = xaccAccountLookup( acct_guid, be->primary_book );
g_free( subquery_sql );
}
return query_info;
}
@@ -775,8 +772,8 @@ free_split_query( GncSqlBackend* be, gpointer pQuery )
/* ----------------------------------------------------------------- */
typedef struct {
const GncSqlBackend* be;
Account* acct;
/*@ dependent @*/ const GncSqlBackend* be;
/*@ dependent @*/ Account* acct;
char reconcile_state;
gnc_numeric balance;
} single_acct_balance_t;
@@ -817,15 +814,15 @@ set_acct_bal_balance( gpointer pObject, gnc_numeric value )
static const GncSqlColumnTableEntry acct_balances_col_table[] =
{
/*# -fullinitblock */
{ "account_guid", CT_GUID, 0, 0, NULL, NULL, NULL, set_acct_bal_account_from_guid },
{ "reconcile_state", CT_STRING, 1, 0, NULL, NULL, NULL, set_acct_bal_reconcile_state },
/*@ -full_init_block @*/
{ "account_guid", CT_GUID, 0, 0, NULL, NULL, NULL, (QofSetterFunc)set_acct_bal_account_from_guid },
{ "reconcile_state", CT_STRING, 1, 0, NULL, NULL, NULL, (QofSetterFunc)set_acct_bal_reconcile_state },
{ "quantity", CT_NUMERIC, 0, 0, NULL, NULL, NULL, (QofSetterFunc)set_acct_bal_balance },
{ NULL }
/*# +fullinitblock */
/*@ +full_init_block @*/
};
static single_acct_balance_t*
static /*@ null @*/ single_acct_balance_t*
load_single_acct_balances( const GncSqlBackend* be, GncSqlRow* row )
{
single_acct_balance_t* bal = NULL;
@@ -834,13 +831,15 @@ load_single_acct_balances( const GncSqlBackend* be, GncSqlRow* row )
g_return_val_if_fail( row != NULL, NULL );
bal = g_malloc( (gsize)sizeof(single_acct_balance_t) );
g_assert( bal != NULL );
bal->be = be;
gnc_sql_load_object( be, row, NULL, bal, acct_balances_col_table );
return bal;
}
GSList*
/*@ null @*/ GSList*
gnc_sql_get_account_balances_slist( GncSqlBackend* be )
{
GncSqlResult* result;
@@ -853,7 +852,8 @@ gnc_sql_get_account_balances_slist( GncSqlBackend* be )
buf = g_strdup_printf( "SELECT account_guid, reconcile_state, sum(quantity_num) as quantity_num, quantity_denom FROM %s GROUP BY account_guid, reconcile_state, quantity_denom",
SPLIT_TABLE );
stmt = gnc_sql_create_statement_from_sql( be, buf );
g_assert( stmt != NULL );
g_free( buf );
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -877,6 +877,8 @@ gnc_sql_get_account_balances_slist( GncSqlBackend* be )
}
if( bal == NULL ) {
bal = g_malloc( (gsize)sizeof(acct_balances_t) );
g_assert( bal != NULL );
bal->acct = single_bal->acct;
bal->balance = gnc_numeric_zero();
bal->cleared_balance = gnc_numeric_zero();
@@ -892,6 +894,7 @@ gnc_sql_get_account_balances_slist( GncSqlBackend* be )
bal->reconciled_balance = gnc_numeric_add( bal->reconciled_balance, single_bal->balance,
GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD );
}
g_free( single_bal );
}
row = gnc_sql_result_get_next_row( result );
}
@@ -913,13 +916,12 @@ gnc_sql_get_account_balances_slist( GncSqlBackend* be )
/* ----------------------------------------------------------------- */
static void
load_tx_guid( const GncSqlBackend* be, GncSqlRow* row,
QofSetterFunc setter, gpointer pObject,
/*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
GUID guid;
const GUID* pGuid;
Transaction* tx = NULL;
Transaction* tx;
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
@@ -927,18 +929,13 @@ load_tx_guid( const GncSqlBackend* be, GncSqlRow* row,
g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
if( val == NULL ) {
pGuid = NULL;
} else {
string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid;
}
if( pGuid != NULL ) {
tx = xaccTransLookup( pGuid, be->primary_book );
}
g_assert( val != NULL );
(void)string_to_guid( g_value_get_string( val ), &guid );
tx = xaccTransLookup( &guid, be->primary_book );
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, tx, NULL );
} else {
g_return_if_fail( setter != NULL );
(*setter)( pObject, (const gpointer)tx );
}
}
@@ -977,8 +974,8 @@ gnc_sql_init_transaction_handler( void )
NULL /* write */
};
qof_object_register_backend( GNC_ID_TRANS, GNC_SQL_BACKEND, &be_data_tx );
qof_object_register_backend( GNC_ID_SPLIT, GNC_SQL_BACKEND, &be_data_split );
(void)qof_object_register_backend( GNC_ID_TRANS, GNC_SQL_BACKEND, &be_data_tx );
(void)qof_object_register_backend( GNC_ID_SPLIT, GNC_SQL_BACKEND, &be_data_split );
gnc_sql_register_col_type_handler( CT_TXREF, &tx_guid_handler );
}

View File

@@ -80,6 +80,6 @@ typedef struct {
* @param be SQL backend
* @return GSList of acct_balances_t structures
*/
GSList* gnc_sql_get_account_balances_slist( GncSqlBackend* be );
/*@ null @*/ GSList* gnc_sql_get_account_balances_slist( GncSqlBackend* be );
#endif /* GNC_TRANSACTION_SQL_H_ */

View File

@@ -274,8 +274,8 @@ void gnc_gconf_general_remove_any_cb (GncGconfGeneralAnyCb func,
* returned by GConf.
*/
gboolean gnc_gconf_get_bool (const gchar *section,
const gchar *name,
GError **error);
/*@ null @*/ const gchar *name,
/*@ null @*/ GError **error);
/** Get a boolean value from GConf with no error argument.
*

View File

@@ -228,7 +228,7 @@ const gchar *gnc_get_account_separator_string (void);
gunichar gnc_get_account_separator (void);
void gnc_set_account_separator (const gchar *separator);
Account *gnc_book_get_root_account(QofBook *book);
/*@ dependent @*/ Account *gnc_book_get_root_account(QofBook *book);
void gnc_book_set_root_account(QofBook *book, Account *root);
/** @deprecated */
@@ -238,7 +238,7 @@ void gnc_book_set_root_account(QofBook *book, Account *root);
/** The xaccAccountLookup() subroutine will return the
* account associated with the given id, or NULL
* if there is no such account. */
Account * xaccAccountLookup (const GUID *guid, QofBook *book);
/*@ dependent @*/ Account * xaccAccountLookup (const GUID *guid, QofBook *book);
#define xaccAccountLookupDirect(g,b) xaccAccountLookup(&(g),b)
/** @} */
@@ -475,7 +475,7 @@ void xaccAccountSetCommodity (Account *account, gnc_commodity *comm);
#define DxaccAccountSetSecurity xaccAccountSetCommodity
/** Get the account's commodity */
gnc_commodity * xaccAccountGetCommodity (const Account *account);
/*@ dependent @*/ gnc_commodity * xaccAccountGetCommodity (const Account *account);
/** @deprecated do not use */
#define DxaccAccountGetSecurity xaccAccountGetCommodity
@@ -627,7 +627,7 @@ void gnc_account_remove_child (Account *parent, Account *child);
*
* @return A pointer to the parent account node, or NULL if there is
* no parent account. */
Account * gnc_account_get_parent (const Account *account);
/*@ dependent @*/ Account * gnc_account_get_parent (const Account *account);
/** This routine returns the root account of the account tree that the
* specified account belongs to. It is the equivalent of repeatedly
@@ -773,7 +773,7 @@ gint gnc_account_get_tree_depth (const Account *account);
*
* @param user_data This data will be passed to each call of func. */
void gnc_account_foreach_child (const Account *account,
AccountCb func, gpointer user_data);
AccountCb func, /*@ null @*/ gpointer user_data);
/** This method will traverse the immediate children of this accounts,
* calling 'func' on each account. Traversal will stop when func
@@ -791,7 +791,7 @@ void gnc_account_foreach_child (const Account *account,
*
* @param user_data This data will be passed to each call of func. */
gpointer gnc_account_foreach_child_until (const Account *account,
AccountCb2 func, gpointer user_data);
AccountCb2 func, /*@ null @*/ gpointer user_data);
/** This method will traverse all children of this accounts and their
@@ -808,7 +808,7 @@ gpointer gnc_account_foreach_child_until (const Account *account,
*
* @param user_data This data will be passed to each call of func. */
void gnc_account_foreach_descendant (const Account *account,
AccountCb func, gpointer user_data);
AccountCb func, /*@ null @*/ gpointer user_data);
/** This method will traverse all children of this accounts and their
* descendants, calling 'func' on each account. Traversal will stop
@@ -826,7 +826,7 @@ void gnc_account_foreach_descendant (const Account *account,
*
* @param user_data This data will be passed to each call of func. */
gpointer gnc_account_foreach_descendant_until (const Account *account,
AccountCb2 func, gpointer user_data);
AccountCb2 func, /*@ null @*/ gpointer user_data);
/** @} */
@@ -1056,7 +1056,7 @@ LotList* xaccAccountGetLotList (const Account *account);
*/
gpointer xaccAccountForEachLot(
const Account *acc,
gpointer (*proc)(GNCLot *lot, gpointer user_data), gpointer user_data);
gpointer (*proc)(GNCLot *lot, gpointer user_data), /*@ null @*/ gpointer user_data);
/** Find a list of open lots that match the match_func. Sort according
@@ -1067,7 +1067,7 @@ gpointer xaccAccountForEachLot(
LotList * xaccAccountFindOpenLots (const Account *acc,
gboolean (*match_func)(GNCLot *lot,
gpointer user_data),
gpointer user_data, GCompareFunc sort_func);
/*@ null @*/ gpointer user_data, GCompareFunc sort_func);
/** @} */
/* ------------------ */

View File

@@ -74,13 +74,13 @@ GType gnc_schedxactions_get_type(void);
#define GNC_IS_SXES(obj) GNC_IS_SCHEDXACTIONS(obj)
#define GNC_SXES(obj) GNC_SCHEDXACTIONS(obj)
SchedXactions* gnc_book_get_schedxactions(QofBook* book);
/*@ dependent @*/ SchedXactions* gnc_book_get_schedxactions(QofBook* book);
void gnc_sxes_add_sx(SchedXactions* sxes, SchedXaction* sx);
void gnc_sxes_del_sx(SchedXactions* sxes, SchedXaction* sx);
/** Returns the template group from the book. **/
Account *gnc_book_get_template_root(const QofBook *book);
/*@ dependent @*/ Account *gnc_book_get_template_root(const QofBook *book);
/** @return The list of SXes which reference the given Account. Caller should free this list. **/
GList* gnc_sx_get_sxes_referencing_account(QofBook *book, Account *acct);

View File

@@ -148,9 +148,9 @@ void gnc_sx_begin_edit (SchedXaction *sx);
void gnc_sx_commit_edit (SchedXaction *sx);
/** @return GList<Recurrence*> **/
GList* gnc_sx_get_schedule(const SchedXaction *sx);
/*@ dependent @*/ GList* gnc_sx_get_schedule(const SchedXaction *sx);
/** @param[in] schedule A GList<Recurrence*> **/
void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule);
void gnc_sx_set_schedule(SchedXaction *sx, /*@ null @*//*@ only @*/ GList *schedule);
gchar *xaccSchedXactionGetName( const SchedXaction *sx );
/**
@@ -196,7 +196,7 @@ void xaccSchedXactionSetRemOccur( SchedXaction *sx, gint numRemain );
* @param sx The instance whose state should be retrieved.
* @param stateData may be NULL.
*/
gint gnc_sx_get_instance_count( const SchedXaction *sx, void *stateData );
gint gnc_sx_get_instance_count( const SchedXaction *sx, /*@ null @*/ void *stateData );
/**
* Sets the instance count to something other than the default. As the
* default is the incorrect value '0', callers should DTRT here.
@@ -210,8 +210,8 @@ gboolean xaccSchedXactionGetEnabled( const SchedXaction *sx );
void xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled );
void xaccSchedXactionGetAutoCreate( const SchedXaction *sx,
gboolean *outAutoCreate,
gboolean *outNotify );
/*@ out @*/ gboolean *outAutoCreate,
/*@ out @*/ gboolean *outNotify );
void xaccSchedXactionSetAutoCreate( SchedXaction *sx,
gboolean newAutoCreate,
gboolean newNotify );

View File

@@ -215,7 +215,7 @@ gboolean xaccTransIsOpen (const Transaction *trans);
/** The xaccTransLookup() subroutine will return the
transaction associated with the given id, or NULL
if there is no such transaction. */
Transaction * xaccTransLookup (const GUID *guid, QofBook *book);
/*@ dependent @*//*@ null @*/ Transaction * xaccTransLookup (const GUID *guid, QofBook *book);
#define xaccTransLookupDirect(g,b) xaccTransLookup(&(g),b)
Split * xaccTransFindSplitByAccount(const Transaction *trans,
@@ -303,7 +303,7 @@ int xaccTransGetSplitIndex(const Transaction *trans, const Split *split);
in a transaction.
@return The list of splits. This list must NOT be modified. Do *NOT* free
this list when you are done with it. */
SplitList * xaccTransGetSplitList (const Transaction *trans);
/*@ dependent @*/ SplitList * xaccTransGetSplitList (const Transaction *trans);
gboolean xaccTransStillHasSplit(const Transaction *trans, const Split *s);
@@ -337,7 +337,7 @@ gboolean xaccTransHasSplitsInStateByAccount (const Transaction *trans,
* The total value of the transaction must be zero when all splits
* are valued in this currency.
* @note What happens if the Currency isn't set? Ans: bad things. */
gnc_commodity * xaccTransGetCurrency (const Transaction *trans);
/*@ dependent @*/ gnc_commodity * xaccTransGetCurrency (const Transaction *trans);
/** Set the commodity of this transaction. */
void xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr);

View File

@@ -95,7 +95,7 @@ gboolean gnc_budget_register(void);
/**
* Creates and initializes a Budget.
**/
GncBudget *gnc_budget_new(QofBook *book);
/*@ dependent @*/ GncBudget *gnc_budget_new(QofBook *book);
/** Deletes the given budget object.*/
void gnc_budget_destroy(GncBudget* budget);
@@ -103,24 +103,24 @@ void gnc_budget_destroy(GncBudget* budget);
void gnc_budget_begin_edit(GncBudget *bgt);
void gnc_budget_commit_edit(GncBudget *bgt);
const GUID* gnc_budget_get_guid(GncBudget* budget);
/*@ dependent @*/ const GUID* gnc_budget_get_guid(GncBudget* budget);
#define gnc_budget_return_guid(X) \
(X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
/** Set/Get the name of the Budget */
void gnc_budget_set_name(GncBudget* budget, const gchar* name);
const gchar* gnc_budget_get_name(GncBudget* budget);
/*@ dependent @*/ const gchar* gnc_budget_get_name(GncBudget* budget);
/** Set/Get the description of the Budget */
void gnc_budget_set_description(GncBudget* budget, const gchar* description);
const gchar* gnc_budget_get_description(GncBudget* budget);
/*@ dependent @*/ const gchar* gnc_budget_get_description(GncBudget* budget);
/** Set/Get the number of periods in the Budget */
void gnc_budget_set_num_periods(GncBudget* budget, guint num_periods);
guint gnc_budget_get_num_periods(GncBudget* budget);
void gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r);
const Recurrence * gnc_budget_get_recurrence(GncBudget *budget);
/*@ dependent @*/ const Recurrence * gnc_budget_get_recurrence(GncBudget *budget);
/** Set/Get the starting date of the Budget */
Timespec gnc_budget_get_period_start_date(GncBudget* budget, guint period_num);
@@ -146,7 +146,7 @@ QofBook* gnc_budget_get_book(GncBudget* budget);
GncBudget* gnc_budget_get_default(QofBook *book);
/* Get the budget associated with the given GUID from the given book. */
GncBudget* gnc_budget_lookup (const GUID *guid, QofBook *book);
/*@ dependent @*/ GncBudget* gnc_budget_lookup (const GUID *guid, QofBook *book);
#define gnc_budget_lookup_direct(g,b) gnc_budget_lookup(&(g),(b))
#endif // __BUDGET_H__

View File

@@ -180,7 +180,7 @@ gnc_quote_source *gnc_quote_source_add_new(const char * name, gboolean supported
* @return A pointer to the price quote source that has the specified
* internal name.
*/
gnc_quote_source *gnc_quote_source_lookup_by_internal(const char * internal_name);
/*@ dependent @*/ gnc_quote_source *gnc_quote_source_lookup_by_internal(const char * internal_name);
/** Given the type/index of a quote source, find the data structure
* identified by this pair.
@@ -230,7 +230,7 @@ gint gnc_quote_source_get_index (const gnc_quote_source *source);
*
* @return The user friendly name.
*/
const char *gnc_quote_source_get_user_name (const gnc_quote_source *source);
/*@ dependent @*/ const char *gnc_quote_source_get_user_name (const gnc_quote_source *source);
/** Given a gnc_quote_source data structure, return the internal name
* of this quote source. This is the name used by both gnucash and
@@ -240,7 +240,7 @@ const char *gnc_quote_source_get_user_name (const gnc_quote_source *source);
*
* @return The internal name.
*/
const char *gnc_quote_source_get_internal_name (const gnc_quote_source *source);
/*@ dependent @*/ const char *gnc_quote_source_get_internal_name (const gnc_quote_source *source);
/** Given a gnc_quote_source data structure, return the internal name
* of this quote source. This is the name used by both gnucash and
@@ -294,11 +294,11 @@ const char *gnc_quote_source_get_old_internal_name (const gnc_quote_source *sour
*
* @return A pointer to the new commodity.
*/
gnc_commodity * gnc_commodity_new(QofBook *book,
const char * fullname,
const char * namespace,
const char * mnemonic,
const char * cusip,
/*@ dependent @*/ gnc_commodity * gnc_commodity_new(QofBook *book,
/*@ null @*/ const char * fullname,
/*@ null @*/ const char * namespace,
/*@ null @*/ const char * mnemonic,
/*@ null @*/ const char * cusip,
int fraction);
/** Destroy a commodity. Release all memory attached to this data structure.
@@ -461,8 +461,8 @@ gboolean gnc_commodity_get_quote_flag(const gnc_commodity *cm);
*
* @return A pointer to the price quote source for this commodity.
*/
gnc_quote_source* gnc_commodity_get_quote_source(const gnc_commodity *cm);
gnc_quote_source* gnc_commodity_get_default_quote_source(const gnc_commodity *cm);
/*@ dependent @*/ gnc_quote_source* gnc_commodity_get_quote_source(const gnc_commodity *cm);
/*@ dependent @*/ gnc_quote_source* gnc_commodity_get_default_quote_source(const gnc_commodity *cm);
/** Retrieve the automatic price quote timezone for the specified
* commodity. This will be a pointer to a null terminated string of
@@ -697,7 +697,7 @@ gboolean gnc_commodity_is_currency(const gnc_commodity *cm);
/** Returns the commodity table assoicated with a book.
*/
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book);
/*@ dependent @*/ gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book);
/* XXX backwards compat function; remove me someday */
#define gnc_book_get_commodity_table gnc_commodity_table_get_table
@@ -725,7 +725,7 @@ gnc_commodity * gnc_commodity_table_find_full(const gnc_commodity_table * t,
const char * namespace,
const char * fullname);
gnc_commodity * gnc_commodity_find_commodity_by_guid(const GUID *guid, QofBook *book);
/*@ dependent @*/ gnc_commodity * gnc_commodity_find_commodity_by_guid(const GUID *guid, QofBook *book);
gnc_commodity_namespace * gnc_commodity_find_namespace_by_guid(const GUID *guid, QofBook *book);
/** @} */
@@ -749,7 +749,7 @@ gnc_commodity_namespace * gnc_commodity_find_namespace_by_guid(const GUID *guid,
* @note The commodity pointer passed to this function should not be
* used after its return, as it may have been destroyed. Use the
* return value which is guaranteed to be valid. */
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table,
/*@ dependent @*/ gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table,
gnc_commodity * comm);
/** Remove a commodity from the commodity table. If the commodity to

View File

@@ -79,10 +79,10 @@ typedef struct _GncLotClass GNCLotClass;
GType gnc_lot_get_type(void);
GNCLot * gnc_lot_new (QofBook *);
/*@ dependent @*/ GNCLot * gnc_lot_new (QofBook *);
void gnc_lot_destroy (GNCLot *);
GNCLot * gnc_lot_lookup (const GUID *guid, QofBook *book);
/*@ dependent @*/ GNCLot * gnc_lot_lookup (const GUID *guid, QofBook *book);
QofBook * gnc_lot_get_book (GNCLot *);
void gnc_lot_begin_edit (GNCLot *lot);
@@ -110,7 +110,7 @@ gint gnc_lot_count_splits (const GNCLot *);
/** The gnc_lot_get_account() routine returns the account with which
* this lot is associated. */
Account * gnc_lot_get_account (const GNCLot *);
/*@ dependent @*/ Account * gnc_lot_get_account (const GNCLot *);
/** The gnc_lot_get_balance() routine returns the balance of the lot.
* The commodity in which this balance is expressed is the commodity

View File

@@ -166,7 +166,7 @@ typedef GList PriceList;
/** gnc_price_create - returns a newly allocated and initialized price
with a reference count of 1. */
GNCPrice *gnc_price_create(QofBook *book);
/*@ dependent @*/ GNCPrice *gnc_price_create(QofBook *book);
/** gnc_price_clone - returns a newly allocated price that's a
content-wise duplicate of the given price, p. The returned clone
@@ -219,8 +219,8 @@ void gnc_price_set_value(GNCPrice *p, gnc_numeric value);
/** As mentioned above all of the getters return data that's internal
to the GNCPrice, not copies, so don't free these values. */
GNCPrice * gnc_price_lookup (const GUID *guid, QofBook *book);
gnc_commodity * gnc_price_get_commodity(const GNCPrice *p);
gnc_commodity * gnc_price_get_currency(const GNCPrice *p);
/*@ dependent @*/ gnc_commodity * gnc_price_get_commodity(const GNCPrice *p);
/*@ dependent @*/ gnc_commodity * gnc_price_get_currency(const GNCPrice *p);
Timespec gnc_price_get_time(const GNCPrice *p);
const char * gnc_price_get_source(const GNCPrice *p);
const char * gnc_price_get_typestr(const GNCPrice *p);
@@ -281,7 +281,7 @@ typedef struct gnc_price_db_s GNCPriceDB;
#define gnc_book_get_pricedb gnc_pricedb_get_db
/** return the pricedb associated with the book */
GNCPriceDB * gnc_pricedb_get_db(QofBook *book);
/*@ dependent @*/ GNCPriceDB * gnc_pricedb_get_db(QofBook *book);
GNCPriceDB * gnc_collection_get_pricedb(QofCollection *col);
/** gnc_pricedb_destroy - destroy the given pricedb and unref all of

View File

@@ -25,7 +25,7 @@ GList * gnc_module_system_modinfo(void);
* module_name is not a const gchar?! It certainly should be const
* (because of passing string literals), and from a quick glance it is
* also only used in a const way. */
GNCModule gnc_module_load(gchar * module_name, gint iface);
/*@ dependent @*/ GNCModule gnc_module_load(gchar * module_name, gint iface);
GNCModule gnc_module_load_optional(gchar * module_name, gint iface);
int gnc_module_unload(GNCModule mod);