mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove ancient if-0'd code from backends
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23206 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
2e4c3e5f2f
commit
413aa58c40
@ -1559,49 +1559,6 @@ conn_table_operation( GncSqlConnection *sql_conn, GSList *table_name_list,
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 0 /* Not Used */
|
||||
/**
|
||||
* Really a bit of an understatement. More like "delete everything in
|
||||
* storage and replace with what's in memory".
|
||||
*
|
||||
* THIS ROUTINE IS EXTREMELY DANGEROUS AND CAN LEAD TO SEVERE DATA
|
||||
* LOSS It should be used *only* by gnc_dbi_safe_sync_all!
|
||||
*
|
||||
* @param qbe: QofBackend for the session.
|
||||
* @param book: QofBook to be saved in the database.
|
||||
*/
|
||||
static void
|
||||
gnc_dbi_sync_all( QofBackend* qbe, /*@ dependent @*/ QofBook *book )
|
||||
{
|
||||
GncDbiBackend* be = (GncDbiBackend*)qbe;
|
||||
GncDbiSqlConnection *conn = (GncDbiSqlConnection*)(((GncSqlBackend*)be)->conn);
|
||||
GSList* table_name_list;
|
||||
const gchar* dbname;
|
||||
|
||||
g_return_if_fail( be != NULL );
|
||||
g_return_if_fail( book != NULL );
|
||||
|
||||
ENTER( "book=%p, primary=%p", book, be->primary_book );
|
||||
|
||||
/* Destroy the current contents of the database */
|
||||
dbname = dbi_conn_get_option( be->conn, "dbname" );
|
||||
table_name_list = conn->provider->get_table_list( conn->conn, dbname );
|
||||
if ( !conn_table_operation( (GncSqlConnection*)conn, table_name_list,
|
||||
drop ) )
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
return;
|
||||
}
|
||||
gnc_table_slist_free( table_name_list );
|
||||
/* Save all contents */
|
||||
be->is_pristine_db = TRUE;
|
||||
be->primary_book = book;
|
||||
gnc_sql_sync_all( &be->sql_be, book );
|
||||
|
||||
LEAVE( "book=%p", book );
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Safely resave a database by renaming all of its tables, recreating
|
||||
* everything, and then dropping the backup tables only if there were
|
||||
@ -2343,22 +2300,6 @@ conn_create_statement_from_sql( /*@ observer @*/ GncSqlConnection* conn, const g
|
||||
return create_dbi_statement( conn, sql );
|
||||
}
|
||||
|
||||
#if 0 /* Not Used */
|
||||
static GValue*
|
||||
create_gvalue_from_string( /*@ only @*/ gchar* s )
|
||||
{
|
||||
GValue* s_gval;
|
||||
|
||||
s_gval = g_new0( GValue, 1 );
|
||||
g_assert( s_gval != NULL );
|
||||
|
||||
(void)g_value_init( s_gval, G_TYPE_STRING );
|
||||
g_value_take_string( s_gval, s );
|
||||
|
||||
return s_gval;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
conn_does_table_exist( GncSqlConnection* conn, const gchar* table_name )
|
||||
{
|
||||
|
@ -78,9 +78,6 @@
|
||||
#include "splint-defs.h"
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static const gchar* convert_search_obj( QofIdType objType );
|
||||
#endif
|
||||
static void gnc_sql_init_object_handlers( void );
|
||||
static void update_progress( GncSqlBackend* be );
|
||||
static void finish_progress( GncSqlBackend* be );
|
||||
@ -279,59 +276,6 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
|
||||
|
||||
/* ================================================================= */
|
||||
|
||||
#if 0
|
||||
static gint
|
||||
compare_namespaces(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const gchar *sa = (const gchar *) a;
|
||||
const gchar *sb = (const gchar *) b;
|
||||
|
||||
return( g_strcmp0( sa, sb ) );
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_commodity_ids(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const gnc_commodity *ca = (const gnc_commodity *) a;
|
||||
const gnc_commodity *cb = (const gnc_commodity *) b;
|
||||
|
||||
return( g_strcmp0( gnc_commodity_get_mnemonic( ca ),
|
||||
gnc_commodity_get_mnemonic( cb ) ) );
|
||||
}
|
||||
|
||||
static void
|
||||
write_commodities( GncSqlBackend* be, QofBook* book )
|
||||
{
|
||||
gnc_commodity_table* tbl;
|
||||
GList* namespaces;
|
||||
GList* lp;
|
||||
|
||||
g_return_if_fail( be != NULL );
|
||||
g_return_if_fail( book != NULL );
|
||||
|
||||
tbl = gnc_commodity_table_get_table( book );
|
||||
namespaces = gnc_commodity_table_get_namespaces( tbl );
|
||||
if ( namespaces != NULL )
|
||||
{
|
||||
namespaces = g_list_sort( namespaces, compare_namespaces );
|
||||
}
|
||||
for ( lp = namespaces; lp != NULL; lp = lp->next )
|
||||
{
|
||||
GList* comms;
|
||||
GList* lp2;
|
||||
|
||||
comms = gnc_commodity_table_get_commodities( tbl, lp->data );
|
||||
comms = g_list_sort( comms, compare_commodity_ids );
|
||||
|
||||
for ( lp2 = comms; lp2 != NULL; lp2 = lp2->next )
|
||||
{
|
||||
gnc_sql_save_commodity( be, GNC_COMMODITY(lp2->data) );
|
||||
}
|
||||
}
|
||||
update_progress( be );
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
write_account_tree( GncSqlBackend* be, Account* root )
|
||||
{
|
||||
|
@ -75,12 +75,6 @@ static GncSqlColumnTableEntry col_table[] =
|
||||
"parent", CT_GUID, 0, 0, NULL, NULL,
|
||||
(QofAccessFunc)bt_get_parent, (QofSetterFunc)bt_set_parent
|
||||
},
|
||||
#if 0
|
||||
{
|
||||
"child", CT_BILLTERMREF, 0, 0, NULL, NULL,
|
||||
(QofAccessFunc)gncBillTermReturnChild, (QofSetterFunc)gncBillTermSetChild
|
||||
},
|
||||
#endif
|
||||
{ "type", CT_STRING, MAX_TYPE_LEN, COL_NNUL, NULL, GNC_BILLTERM_TYPE },
|
||||
{ "duedays", CT_INT, 0, 0, 0, GNC_BILLTERM_DUEDAYS },
|
||||
{ "discountdays", CT_INT, 0, 0, 0, GNC_BILLTERM_DISCDAYS },
|
||||
|
@ -139,18 +139,6 @@ set_obj_guid( gpointer pObject, gpointer pValue )
|
||||
{
|
||||
// Nowhere to put the GncGUID
|
||||
}
|
||||
#if 0 /* Not Used */
|
||||
static gpointer
|
||||
get_child( gpointer pObject, const QofParam* param )
|
||||
{
|
||||
GncTaxTable* tt = GNC_TAXTABLE(pObject);
|
||||
|
||||
g_return_val_if_fail( pObject != NULL, NULL );
|
||||
g_return_val_if_fail( GNC_IS_TAXTABLE(pObject), NULL );
|
||||
|
||||
return gncTaxTableGetChild( tt );
|
||||
}
|
||||
#endif
|
||||
|
||||
static /*@ null @*//*@ dependent @*/ gpointer
|
||||
bt_get_parent( gpointer pObject )
|
||||
|
@ -167,16 +167,6 @@ set_split_reconcile_state( gpointer pObject, /*@ null @*/ gpointer pValue )
|
||||
|
||||
xaccSplitSetReconcile( GNC_SPLIT(pObject), s[0] );
|
||||
}
|
||||
#if 0 /* Not Used */
|
||||
static void
|
||||
set_split_reconcile_date( gpointer pObject, Timespec ts )
|
||||
{
|
||||
g_return_if_fail( pObject != NULL );
|
||||
g_return_if_fail( GNC_IS_SPLIT(pObject) );
|
||||
|
||||
xaccSplitSetDateReconciledTS( GNC_SPLIT(pObject), &ts );
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
set_split_lot( gpointer pObject, /*@ null @*/ gpointer pLot )
|
||||
@ -319,53 +309,6 @@ typedef struct
|
||||
gnc_numeric end_reconciled_bal;
|
||||
} full_acct_balances_t;
|
||||
|
||||
#if 0 /* Not Used */
|
||||
/**
|
||||
* Saves the start/end balances for an account.
|
||||
*
|
||||
* @param acc Account
|
||||
* @param pData Pointer to balances info list
|
||||
*/
|
||||
static void
|
||||
save_account_balances( Account* acc, gpointer pData )
|
||||
{
|
||||
GSList** pBal_list = (GSList**)pData;
|
||||
full_acct_balances_t* newbal;
|
||||
gnc_numeric* pstart;
|
||||
gnc_numeric* pend;
|
||||
gnc_numeric* pstart_c;
|
||||
gnc_numeric* pend_c;
|
||||
gnc_numeric* pstart_r;
|
||||
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,
|
||||
"end-balance", &pend,
|
||||
"start-cleared-balance", &pstart_c,
|
||||
"end-cleared-balance", &pend_c,
|
||||
"start-reconciled-balance", &pstart_r,
|
||||
"end-reconciled-balance", &pend_r,
|
||||
NULL );
|
||||
newbal->start_bal = *pstart;
|
||||
newbal->end_bal = *pend;
|
||||
newbal->start_cleared_bal = *pstart_c;
|
||||
newbal->end_cleared_bal = *pend_c;
|
||||
newbal->start_reconciled_bal = *pstart_r;
|
||||
newbal->end_reconciled_bal = *pend_r;
|
||||
*pBal_list = g_slist_append( *pBal_list, newbal );
|
||||
|
||||
g_free( pstart );
|
||||
g_free( pend );
|
||||
g_free( pstart_c );
|
||||
g_free( pend_c );
|
||||
g_free( pstart_r );
|
||||
g_free( pend_r );
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Executes a transaction query statement and loads the transactions and all
|
||||
* of the splits.
|
||||
@ -820,38 +763,6 @@ commit_transaction( GncSqlBackend* be, QofInstance* inst )
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
#if 0 /* Not Used */
|
||||
static /*@ dependent @*//*@ null @*/ const GncGUID*
|
||||
get_guid_from_query( QofQuery* pQuery )
|
||||
{
|
||||
GList* pOrTerms;
|
||||
GList* pAndTerms;
|
||||
GList* andTerm;
|
||||
QofQueryTerm* pTerm;
|
||||
QofQueryPredData* pPredData;
|
||||
GSList* pParamPath;
|
||||
|
||||
g_return_val_if_fail( pQuery != NULL, NULL );
|
||||
|
||||
pOrTerms = qof_query_get_terms( pQuery );
|
||||
pAndTerms = (GList*)pOrTerms->data;
|
||||
andTerm = pAndTerms->next;
|
||||
pTerm = (QofQueryTerm*)andTerm->data;
|
||||
|
||||
pPredData = qof_query_term_get_pred_data( pTerm );
|
||||
pParamPath = qof_query_term_get_param_path( pTerm );
|
||||
|
||||
if ( strcmp( pPredData->type_name, "guid" ) == 0 )
|
||||
{
|
||||
query_guid_t pData = (query_guid_t)pPredData;
|
||||
return pData->guids->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Loads all transactions for an account.
|
||||
*
|
||||
|
@ -1205,22 +1205,6 @@ gnc_xml_be_write_accounts_to_file(QofBackend *be, QofBook *book)
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
#if 0 //def GNUCASH_MAJOR_VERSION
|
||||
QofBackend *
|
||||
libgncmod_backend_file_LTX_gnc_backend_new(void)
|
||||
{
|
||||
|
||||
fbe->dirname = NULL;
|
||||
fbe->fullpath = NULL;
|
||||
fbe->lockfile = NULL;
|
||||
fbe->linkfile = NULL;
|
||||
fbe->lockfd = -1;
|
||||
|
||||
fbe->primary_book = NULL;
|
||||
|
||||
return be;
|
||||
}
|
||||
#endif
|
||||
|
||||
static QofBackend*
|
||||
gnc_backend_new(void)
|
||||
|
@ -166,15 +166,6 @@ gnc_parser_configure_for_input_version(GNCParseStatus *status, gint64 version)
|
||||
sixtp_add_sub_parser(status->gnc_parser, "ledger-data", ledger_data_pr);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* add <query-server> */
|
||||
{
|
||||
sixtp *query_server_pr = query_server_parser_new();
|
||||
g_return_val_if_fail(query_server_pr, FALSE);
|
||||
sixtp_add_sub_parser(status->gnc_parser, "query-server", query_server_pr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -259,12 +250,6 @@ gnc_parser_before_child_handler(gpointer data_for_children,
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (strcmp(child_tag, "query-server") == 0)
|
||||
{
|
||||
if (pstatus->query) return(FALSE);
|
||||
}
|
||||
#endif
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -290,15 +275,6 @@ gnc_parser_after_child_handler(gpointer data_for_children,
|
||||
child_result->should_cleanup = FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (strcmp(child_tag, "query-server") == 0)
|
||||
{
|
||||
g_return_val_if_fail(child_result, FALSE);
|
||||
g_return_val_if_fail(child_result->data, FALSE);
|
||||
pstatus->query = (Query *) child_result->data;
|
||||
child_result->should_cleanup = FALSE;
|
||||
}
|
||||
#endif
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -2205,530 +2181,6 @@ generic_gnc_commodity_lookup_parser_new(void)
|
||||
return(top_level);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/***********************************************************************/
|
||||
/* <query-server> (parent <gnc-data>)
|
||||
|
||||
On failure or on normal cleanup, the query will be killed,
|
||||
so if you want it, you better set should_cleanup to false
|
||||
|
||||
input: NA
|
||||
to-children-via-*result: new Query*
|
||||
returns: a Query*
|
||||
start: creates the query and puts it into *result
|
||||
characters: NA
|
||||
end: finishes up the query and leaves it in result.
|
||||
cleanup-result: deletes the query (use should_cleanup to avoid).
|
||||
cleanup-chars: NA
|
||||
fail: deletes the query in *result.
|
||||
result-fail: same as cleanup-result.
|
||||
chars-fail: NA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
static gboolean
|
||||
query_server_start_handler(GSList* sibling_data,
|
||||
gpointer parent_data,
|
||||
gpointer global_data,
|
||||
gpointer *data_for_children,
|
||||
gpointer *result,
|
||||
const gchar *tag,
|
||||
gchar **attrs)
|
||||
{
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
query_server_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
Query *q;
|
||||
sixtp_child_result *cr;
|
||||
|
||||
g_return_val_if_fail(data_from_children, FALSE);
|
||||
|
||||
cr = (sixtp_child_result *) data_from_children->data;
|
||||
g_return_val_if_fail(cr, FALSE);
|
||||
|
||||
q = (Query *) (cr->data);
|
||||
g_return_val_if_fail(q, FALSE);
|
||||
|
||||
*result = q;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================= */
|
||||
/* <query> (parent <query-server>)
|
||||
|
||||
This block does nothing.
|
||||
It generates no data of its own, so it doesn't need any cleanup.
|
||||
|
||||
input: NA
|
||||
to-children-via-*result: NA
|
||||
returns: NA
|
||||
start: NA.
|
||||
characters: NA
|
||||
end: NA
|
||||
cleanup-result: NA
|
||||
cleanup-chars: NA
|
||||
fail: NA
|
||||
result-fail: NA
|
||||
chars-fail: NA
|
||||
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
query_start_handler(GSList* sibling_data, gpointer parent_data,
|
||||
gpointer global_data, gpointer *data_for_children,
|
||||
gpointer *result, const gchar *tag, gchar **attrs)
|
||||
{
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
query_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
Query *q;
|
||||
sixtp_child_result *cr;
|
||||
|
||||
g_return_val_if_fail(data_from_children, FALSE);
|
||||
|
||||
cr = (sixtp_child_result *) data_from_children->data;
|
||||
g_return_val_if_fail(cr, FALSE);
|
||||
|
||||
q = (Query *) (cr->data);
|
||||
g_return_val_if_fail(q, FALSE);
|
||||
|
||||
*result = q;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
/* <restore> (lineage <query> <query-server>)
|
||||
|
||||
restores a given query. We allocate the new query in the
|
||||
start block, the children modify it, and in the end block, we see
|
||||
if the resultant query is OK, and if so, we're done.
|
||||
|
||||
input: Query*
|
||||
to-children-via-*result: new Query*
|
||||
returns: NA
|
||||
start: create new Query*, and leave in for children.
|
||||
characters: NA
|
||||
end: clear *result
|
||||
cleanup-result: NA
|
||||
cleanup-chars: NA
|
||||
fail: delete Query*
|
||||
result-fail: NA
|
||||
chars-fail: NA
|
||||
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
query_restore_start_handler(GSList* sibling_data, gpointer parent_data,
|
||||
gpointer global_data, gpointer *data_for_children,
|
||||
gpointer *result, const gchar *tag, gchar **attrs)
|
||||
{
|
||||
Query *q;
|
||||
q = qof_query_create_for(GNC_ID_SPLIT);
|
||||
g_return_val_if_fail(q, FALSE);
|
||||
*data_for_children = q;
|
||||
*result = q;
|
||||
return(q != NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
query_restore_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
sixtp_child_result *cr;
|
||||
Query *qand, *qret;
|
||||
Query *q = (Query *) data_for_children;
|
||||
g_return_val_if_fail(q, FALSE);
|
||||
|
||||
g_return_val_if_fail(data_from_children, FALSE);
|
||||
cr = (sixtp_child_result *) data_from_children->data;
|
||||
g_return_val_if_fail(cr, FALSE);
|
||||
|
||||
qand = (Query *) (cr->data);
|
||||
g_return_val_if_fail(qand, FALSE);
|
||||
|
||||
/* append the and terms by or'ing them in ... */
|
||||
qret = qof_query_merge (q, qand, QOF_QUERY_OR);
|
||||
if (!qret)
|
||||
{
|
||||
qof_query_destroy(qand);
|
||||
*result = q;
|
||||
g_return_val_if_fail(qret, FALSE);
|
||||
}
|
||||
|
||||
qof_query_destroy(q);
|
||||
qof_query_destroy(qand);
|
||||
|
||||
*result = qret;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
query_restore_after_child_handler(gpointer data_for_children,
|
||||
GSList* data_from_children,
|
||||
GSList* sibling_data,
|
||||
gpointer parent_data,
|
||||
gpointer global_data,
|
||||
gpointer *result,
|
||||
const gchar *tag,
|
||||
const gchar *child_tag,
|
||||
sixtp_child_result *child_result)
|
||||
{
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
query_restore_fail_handler(gpointer data_for_children,
|
||||
GSList* data_from_children,
|
||||
GSList* sibling_data,
|
||||
gpointer parent_data,
|
||||
gpointer global_data,
|
||||
gpointer *result,
|
||||
const gchar *tag)
|
||||
{
|
||||
Query *q = (Query *) data_for_children;
|
||||
if (q) qof_query_destroy(q);
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
/* <and-terms> (lineage <restore> <query> <query-server>)
|
||||
|
||||
restores a given query. We allocate the new query in the
|
||||
start block, the children modify it, and in the end block, we see
|
||||
if the resultant query is OK, and if so, we're done.
|
||||
|
||||
input: Query*
|
||||
to-children-via-*result: new Query*
|
||||
returns: NA
|
||||
start: create new Query*, and leave in for children.
|
||||
characters: NA
|
||||
end: clear *result
|
||||
cleanup-result: NA
|
||||
cleanup-chars: NA
|
||||
fail: delete Query*
|
||||
result-fail: NA
|
||||
chars-fail: NA
|
||||
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
query_and_start_handler(GSList* sibling_data, gpointer parent_data,
|
||||
gpointer global_data, gpointer *data_for_children,
|
||||
gpointer *result, const gchar *tag, gchar **attrs)
|
||||
{
|
||||
Query *q;
|
||||
|
||||
/* note this malloc freed in the node higher up (query_restore_end_handler) */
|
||||
q = qof_query_create_for(GNC_ID_SPLIT);
|
||||
g_return_val_if_fail(q, FALSE);
|
||||
*data_for_children = q;
|
||||
*result = q;
|
||||
return(q != NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
query_and_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
Query *q = (Query *) data_for_children;
|
||||
g_return_val_if_fail(q, FALSE);
|
||||
*result = q;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
query_and_fail_handler(gpointer data_for_children,
|
||||
GSList* data_from_children,
|
||||
GSList* sibling_data,
|
||||
gpointer parent_data,
|
||||
gpointer global_data,
|
||||
gpointer *result,
|
||||
const gchar *tag)
|
||||
{
|
||||
Query *q = (Query *) data_for_children;
|
||||
if (q) qof_query_destroy(q);
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
|
||||
#define CVT_INT(to) { \
|
||||
gint32 val; \
|
||||
gboolean ok; \
|
||||
gchar *txt = NULL; \
|
||||
\
|
||||
txt = concatenate_child_result_chars(data_from_children); \
|
||||
g_return_val_if_fail(txt, FALSE); \
|
||||
\
|
||||
ok = (gboolean) string_to_gint32(txt, &val); \
|
||||
g_free(txt); \
|
||||
g_return_val_if_fail(ok, FALSE); \
|
||||
(to) = val; \
|
||||
}
|
||||
|
||||
#define CVT_DATE(to) { \
|
||||
TimespecParseInfo *info = (TimespecParseInfo *) data_for_children; \
|
||||
\
|
||||
g_return_val_if_fail(info, FALSE); \
|
||||
if(!timespec_parse_ok(info)) { \
|
||||
g_free(info); \
|
||||
return(FALSE); \
|
||||
} \
|
||||
\
|
||||
to = info->ts; \
|
||||
g_free(info); \
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
|
||||
static gboolean
|
||||
qrestore_genericpred_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
Query *q = (Query *) parent_data;
|
||||
PredicateData *dp = (PredicateData *) data_for_children;
|
||||
|
||||
g_return_val_if_fail(q, FALSE);
|
||||
g_return_val_if_fail(dp, FALSE);
|
||||
|
||||
xaccQueryAddPredicate (q, dp, QOF_QUERY_AND);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
/* <datepred> (lineage <and-terms> <restore> <query> <query-server>)
|
||||
Restores a given date predicate.
|
||||
|
||||
from parent: Query*
|
||||
for children: NA
|
||||
result: NA
|
||||
-----------
|
||||
start: malloc a date predicate
|
||||
chars: allow and ignore only whitespace.
|
||||
end: AddDateMatch to Query
|
||||
cleanup-result: NA
|
||||
cleanup-chars: NA
|
||||
fail: ??
|
||||
result-fail: NA
|
||||
chars-fail: NA
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
qrestore_datepred_start_handler(GSList* sibling_data, gpointer parent_data,
|
||||
gpointer global_data,
|
||||
gpointer *data_for_children,
|
||||
gpointer *result, const gchar *tag,
|
||||
gchar **attrs)
|
||||
{
|
||||
DatePredicateData *dp = g_new0 (DatePredicateData, 1);
|
||||
g_return_val_if_fail(dp, FALSE);
|
||||
dp->type = PD_DATE;
|
||||
dp->term_type = PR_DATE;
|
||||
*data_for_children = dp;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
qrestore_datepred_fail_handler(gpointer data_for_children,
|
||||
GSList* data_from_children,
|
||||
GSList* sibling_data,
|
||||
gpointer parent_data,
|
||||
gpointer global_data,
|
||||
gpointer *result,
|
||||
const gchar *tag)
|
||||
{
|
||||
// g_free (data_for_children);
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
/* <end-date> (lineage <date-pred> <and-terms> <restore> <query>)
|
||||
restores a given query's end-date.
|
||||
Just uses a generic_timespec parser, but with our own end handler.
|
||||
end: set end-date.
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
datepred_use_start_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
DatePredicateData *dp = (DatePredicateData *) parent_data;
|
||||
CVT_INT(dp->use_start);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
datepred_use_end_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
DatePredicateData *dp = (DatePredicateData *) parent_data;
|
||||
CVT_INT(dp->use_end);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
datepred_start_date_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
DatePredicateData *dp = (DatePredicateData *) parent_data;
|
||||
CVT_DATE (dp->start);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
datepred_end_date_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
DatePredicateData *dp = (DatePredicateData *) parent_data;
|
||||
CVT_DATE (dp->end);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
generic_pred_sense_end_handler(gpointer data_for_children,
|
||||
GSList *data_from_children, GSList *sibling_data,
|
||||
gpointer parent_data, gpointer global_data,
|
||||
gpointer *result, const gchar *tag)
|
||||
{
|
||||
PredicateData *dp = (PredicateData *) parent_data;
|
||||
CVT_INT(dp->base.sense);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static sixtp*
|
||||
pred_parser_new(sixtp_end_handler ender)
|
||||
{
|
||||
return sixtp_set_any(simple_chars_only_parser_new(NULL), FALSE,
|
||||
SIXTP_END_HANDLER_ID, ender,
|
||||
SIXTP_NO_MORE_HANDLERS);
|
||||
}
|
||||
|
||||
/* ================================================================= */
|
||||
|
||||
static sixtp*
|
||||
qrestore_datepred_parser_new(void)
|
||||
{
|
||||
return sixtp_add_some_sub_parsers(
|
||||
sixtp_new(), TRUE,
|
||||
"sense", pred_parser_new(generic_pred_sense_end_handler),
|
||||
"use-start", pred_parser_new(datepred_use_start_end_handler),
|
||||
"use-end", pred_parser_new(datepred_use_end_end_handler),
|
||||
"start-date",
|
||||
generic_timespec_parser_new(datepred_start_date_end_handler),
|
||||
"end-date",
|
||||
generic_timespec_parser_new(datepred_end_date_end_handler),
|
||||
0);
|
||||
}
|
||||
|
||||
static sixtp*
|
||||
query_server_parser_new (void)
|
||||
{
|
||||
sixtp *top_level;
|
||||
sixtp *query_pr;
|
||||
sixtp *restore_pr;
|
||||
sixtp *and_pr;
|
||||
sixtp *date_pred_pr;
|
||||
|
||||
/* <query_server> */
|
||||
if (!(top_level =
|
||||
sixtp_set_any(sixtp_new(), FALSE,
|
||||
SIXTP_START_HANDLER_ID, query_server_start_handler,
|
||||
SIXTP_CHARACTERS_HANDLER_ID,
|
||||
allow_and_ignore_only_whitespace,
|
||||
SIXTP_END_HANDLER_ID, query_server_end_handler,
|
||||
SIXTP_NO_MORE_HANDLERS)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* <query_server> <query> */
|
||||
if (!(query_pr =
|
||||
sixtp_set_any(sixtp_new(), FALSE,
|
||||
SIXTP_START_HANDLER_ID, query_start_handler,
|
||||
SIXTP_CHARACTERS_HANDLER_ID,
|
||||
allow_and_ignore_only_whitespace,
|
||||
SIXTP_END_HANDLER_ID, query_end_handler,
|
||||
SIXTP_NO_MORE_HANDLERS)))
|
||||
{
|
||||
sixtp_destroy(top_level);
|
||||
return (NULL);
|
||||
}
|
||||
sixtp_add_sub_parser(top_level, "query", query_pr);
|
||||
|
||||
/* <query> <restore> */
|
||||
if (!(restore_pr = sixtp_set_any(
|
||||
sixtp_new(), FALSE,
|
||||
SIXTP_START_HANDLER_ID, query_restore_start_handler,
|
||||
SIXTP_END_HANDLER_ID, query_restore_end_handler,
|
||||
SIXTP_FAIL_HANDLER_ID, query_restore_fail_handler,
|
||||
SIXTP_AFTER_CHILD_HANDLER_ID, query_restore_after_child_handler,
|
||||
SIXTP_NO_MORE_HANDLERS)))
|
||||
{
|
||||
sixtp_destroy(top_level);
|
||||
return(NULL);
|
||||
}
|
||||
sixtp_add_sub_parser(query_pr, "restore", restore_pr);
|
||||
|
||||
/* <query> <restore> <and-terms> */
|
||||
if (!(and_pr =
|
||||
sixtp_set_any(sixtp_new(), FALSE,
|
||||
SIXTP_START_HANDLER_ID, query_and_start_handler,
|
||||
SIXTP_CHARACTERS_HANDLER_ID,
|
||||
allow_and_ignore_only_whitespace,
|
||||
SIXTP_END_HANDLER_ID, query_and_end_handler,
|
||||
SIXTP_FAIL_HANDLER_ID, query_and_fail_handler,
|
||||
SIXTP_NO_MORE_HANDLERS)))
|
||||
{
|
||||
sixtp_destroy(top_level);
|
||||
return (NULL);
|
||||
}
|
||||
sixtp_add_sub_parser(restore_pr, "and-terms", and_pr);
|
||||
|
||||
if (!(date_pred_pr =
|
||||
sixtp_set_any(qrestore_datepred_parser_new(), FALSE,
|
||||
SIXTP_START_HANDLER_ID, qrestore_datepred_start_handler,
|
||||
SIXTP_CHARACTERS_HANDLER_ID,
|
||||
allow_and_ignore_only_whitespace,
|
||||
SIXTP_END_HANDLER_ID, qrestore_genericpred_end_handler,
|
||||
SIXTP_FAIL_HANDLER_ID, qrestore_datepred_fail_handler,
|
||||
SIXTP_NO_MORE_HANDLERS)))
|
||||
{
|
||||
sixtp_destroy(top_level);
|
||||
return NULL;
|
||||
}
|
||||
sixtp_add_sub_parser(and_pr, "date-pred", date_pred_pr);
|
||||
|
||||
return(top_level);
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/***********************************************************************/
|
||||
/****************************************************************************/
|
||||
/* <transaction> (parent <ledger-data>)
|
||||
|
||||
|
@ -41,6 +41,9 @@
|
||||
#include "io-gncxml-gen.h"
|
||||
#include "sixtp-utils.h"
|
||||
|
||||
/*
|
||||
#define __DEBUG 1
|
||||
*/
|
||||
/***********************************************************************/
|
||||
|
||||
static int
|
||||
@ -388,7 +391,7 @@ test_files_in_dir(int argc, char **argv, gxpf_callback cb,
|
||||
{
|
||||
if (!S_ISDIR(file_info.st_mode))
|
||||
{
|
||||
#if 0
|
||||
#ifdef __DEBUG
|
||||
printf( "testing load of file \"%s\":\n", argv[count] );
|
||||
#endif
|
||||
test_load_file(to_open, cb, top_parser, book);
|
||||
|
Loading…
Reference in New Issue
Block a user