From 72a17bc35d020a328822e3efa51550094e069b10 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Wed, 2 Jan 2002 02:26:02 +0000 Subject: [PATCH] misc cleanup git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6464 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Period.h | 23 +++++++++++++++-------- src/engine/gnc-session.c | 28 +++++++++++++--------------- src/engine/gnc-session.h | 23 +++++++++++------------ src/engine/gw-engine-spec.scm | 4 ++-- src/engine/test/test-period.c | 4 +++- 5 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/engine/Period.h b/src/engine/Period.h index 7a9feeacde..253e1c3671 100644 --- a/src/engine/Period.h +++ b/src/engine/Period.h @@ -128,17 +128,24 @@ GNCBook * gnc_book_close_period (GNCBook *, Timespec, */ void gnc_book_partition (GNCBook *dest, GNCBook *src, Query *); -/* The gnc_book_insert_trans() routine takes an existing transaction - * that is located in one book, and moves it to another book. - * It moves all of the splits as well. In the course of the - * move, the transaction is literally deleted from the first - * book as its placed into the second. The transaction and - * split GUID's are not changed in the move. This routine - * assumes that twin accounts already exist in both books - * (and can be located with the standard twining proceedure). +/* The gnc_book_insert_trans_clobber() routine takes an existing + * transaction that is located in one book, and moves it to + * another book. It moves all of the splits as well. In the + * course of the move, the transaction is literally deleted + * from the first book as its placed into the second. The + * transaction and split GUID's are not changed in the move. + * This routine assumes that twin accounts already exist in + * both books (and can be located with the standard twining + * proceedure). + * + * The gnc_book_insert_trans() routine does the same as the above, + * except that it doesn't actually clobber the transaction: it + * merely moves the transaction and split GUID's to the new + * books' entity tables, and not much else. */ void gnc_book_insert_trans (GNCBook *book, Transaction *trans); +void gnc_book_insert_trans_clobber (GNCBook *book, Transaction *trans); #endif /* XACC_PERIOD_H */ diff --git a/src/engine/gnc-session.c b/src/engine/gnc-session.c index 42f2d77f6c..e3a24271c9 100644 --- a/src/engine/gnc-session.c +++ b/src/engine/gnc-session.c @@ -243,11 +243,12 @@ gnc_session_load_backend(GNCSession * session, char * backend_name) LEAVE (" "); } -gboolean +void gnc_session_begin (GNCSession *session, const char * book_id, gboolean ignore_lock, gboolean create_if_nonexistent) { - if (!session) return FALSE; + if (!session) return; + ENTER (" sess=%p book=%p ignore_lock=%d, book-id=%s", session, session->book, ignore_lock, book_id ? book_id : "(null)"); @@ -260,7 +261,7 @@ gnc_session_begin (GNCSession *session, const char * book_id, { gnc_session_push_error (session, ERR_BACKEND_LOCKED, NULL); LEAVE("bad book url"); - return FALSE; + return; } /* seriously invalid */ @@ -268,7 +269,7 @@ gnc_session_begin (GNCSession *session, const char * book_id, { gnc_session_push_error (session, ERR_BACKEND_NO_BACKEND, NULL); LEAVE("bad book_id"); - return FALSE; + return; } /* Store the sessionid URL */ session->book_id = g_strdup (book_id); @@ -278,7 +279,7 @@ gnc_session_begin (GNCSession *session, const char * book_id, { gnc_session_push_error (session, ERR_FILEIO_FILE_NOT_FOUND, NULL); LEAVE("bad fullpath"); - return FALSE; /* ouch */ + return; } PINFO ("filepath=%s", session->fullpath ? session->fullpath : "(null)"); @@ -341,25 +342,24 @@ gnc_session_begin (GNCSession *session, const char * book_id, session->book_id = NULL; gnc_session_push_error (session, err, NULL); LEAVE("backend error %d", err); - return FALSE; + return; } } LEAVE (" sess=%p book=%p book-id=%s", session, session->book, book_id ? book_id : "(null)"); - return TRUE; } /* ---------------------------------------------------------------------- */ -gboolean +void gnc_session_load (GNCSession *session) { GNCBook *oldbook; Backend *be; - if (!session) return FALSE; - if (!gnc_session_get_url(session)) return FALSE; + if (!session) return; + if (!gnc_session_get_url(session)) return; ENTER ("sess=%p book_id=%s", session, gnc_session_get_url(session) ? gnc_session_get_url(session) : "(null)"); @@ -419,20 +419,20 @@ gnc_session_load (GNCSession *session) { /* ?? should we restore the oldbook here ?? */ LEAVE("topgroup NULL"); - return FALSE; + return; } if (!gnc_book_get_pricedb (session->book)) { /* ?? should we restore the oldbook here ?? */ LEAVE("pricedb NULL"); - return FALSE; + return; } if (gnc_session_get_error(session) != ERR_BACKEND_NO_ERR) { LEAVE("error from backend %d", gnc_session_get_error(session)); - return FALSE; + return; } xaccLogDisable(); @@ -442,8 +442,6 @@ gnc_session_load (GNCSession *session) LEAVE ("sess = %p, book_id=%s", session, gnc_session_get_url(session) ? gnc_session_get_url(session) : "(null)"); - - return TRUE; } gboolean diff --git a/src/engine/gnc-session.h b/src/engine/gnc-session.h index 8dd9738a6d..225a2d8f59 100644 --- a/src/engine/gnc-session.h +++ b/src/engine/gnc-session.h @@ -105,33 +105,32 @@ void gnc_session_swap_data (GNCSession *session_1, GNCSession *session_2); * If set to FALSE, then file/database-global locks will be tested and * obeyed. * - * If the datastore exists, can be reached (e.g over the net), connected - * to, opened and read, and a lock can be obtained then a lock will be - * obtained and the function returns TRUE. Note that multi-user - * datastores (e.g. the SQL backend) typically will not need to get a - * global lock, and thus, the user will not be locked out. That's the + * If the datastore exists, can be reached (e.g over the net), + * connected to, opened and read, and a lock can be obtained then + * a lock will be obtained. Note that multi-user datastores + * (e.g. the SQL backend) typically will not need to get a global + * lock, and thus, the user will not be locked out. That's the * whole point of 'multi-user'. * * If the file/database doesn't exist, and the create_if_nonexistent * flag is set to TRUE, then the database is created. * - * Otherwise the function returns FALSE. + * If an error occurs, it will be pushed onto the session error + * stack, and that is where it should be examined. */ -gboolean gnc_session_begin (GNCSession *session, const char * book_id, +void gnc_session_begin (GNCSession *session, const char * book_id, gboolean ignore_lock, gboolean create_if_nonexistent); -/* The gnc_session_load() method causes the GNCBook to be made ready to +/* + * The gnc_session_load() method causes the GNCBook to be made ready to * to use with this URL/datastore. When the URL points at a file, * then this routine would load the data from the file. With remote * backends, e.g. network or SQL, this would load only enough data * to make teh book actually usable; it would not cause *all* of the * data to be loaded. - * - * The function returns TRUE on success. - * (Hack alert ... what does failure mean ???) */ -gboolean gnc_session_load (GNCSession *session); +void gnc_session_load (GNCSession *session); /* The gnc_session_get_error() routine can be used to obtain the reason * for any failure. Calling this routine returns the current error. diff --git a/src/engine/gw-engine-spec.scm b/src/engine/gw-engine-spec.scm index b2cf7fdb57..d2f0e84493 100644 --- a/src/engine/gw-engine-spec.scm +++ b/src/engine/gw-engine-spec.scm @@ -1584,7 +1584,7 @@ when no longer needed.") (gw:wrap-function mod 'gnc:session-begin - ' + ' "gnc_session_begin" '(( session) (( gw:const) id) @@ -1595,7 +1595,7 @@ when no longer needed.") (gw:wrap-function mod 'gnc:session-load - ' + ' "gnc_session_load" '(( session)) "Load the data associated with the given session.") diff --git a/src/engine/test/test-period.c b/src/engine/test/test-period.c index c80ae8d700..8c9c388b9c 100644 --- a/src/engine/test/test-period.c +++ b/src/engine/test/test-period.c @@ -1,5 +1,7 @@ -/* test file created by Linas Vepstas +/* Test file created by Linas Vepstas + * Minimal test to see if a book can be split into two periods + * without crashing. * December 2001 * License: GPL */