TEST_F(ImapBayesTest, FindAccountBayes) { auto root = qof_instance_get_slots(QOF_INSTANCE(t_bank_account)); auto acct1_guid = guid_to_string (xaccAccountGetGUID(t_expense_account1)); auto acct2_guid = guid_to_string (xaccAccountGetGUID(t_expense_account2)); auto value = new KvpValue(INT64_C(42)); root->set_path({IMAP_FRAME_BAYES, foo, acct1_guid}, value); root->set_path({IMAP_FRAME_BAYES, bar, acct1_guid}, value); root->set_path({IMAP_FRAME_BAYES, baz, acct2_guid}, value); root->set_path({IMAP_FRAME_BAYES, waldo, acct2_guid}, value); root->set_path({IMAP_FRAME_BAYES, pepper, acct1_guid}, value); root->set_path({IMAP_FRAME_BAYES, salt, acct2_guid}, value); auto account = gnc_account_imap_find_account_bayes(t_imap, t_list1); EXPECT_EQ(t_expense_account1, account); account = gnc_account_imap_find_account_bayes(t_imap, t_list2); EXPECT_EQ(t_expense_account2, account); account = gnc_account_imap_find_account_bayes(t_imap, t_list3); EXPECT_EQ(t_expense_account1, account); account = gnc_account_imap_find_account_bayes(t_imap, t_list4); EXPECT_EQ(t_expense_account2, account); account = gnc_account_imap_find_account_bayes(t_imap, t_list5); EXPECT_EQ(nullptr, account); }
/* for each entry, check the tax tables. If the tax tables are * grandchildren, then fix them to point to the most senior child */ static void taxtable_scrub_entries (QofInstance * entry_p, gpointer ht_p) { GHashTable *ht = ht_p; GncEntry *entry = GNC_ENTRY(entry_p); GncTaxTable *table, *new_tt; gint32 count; table = gncEntryGetInvTaxTable(entry); if (table) { if (taxtable_is_grandchild(table)) { PINFO("Fixing i-taxtable on entry %s\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(entry)))); new_tt = taxtable_find_senior(table); gncEntryBeginEdit(entry); gncEntrySetInvTaxTable(entry, new_tt); gncEntryCommitEdit(entry); table = new_tt; } if (table) { count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table)); count++; g_hash_table_insert(ht, table, GINT_TO_POINTER(count)); } } table = gncEntryGetBillTaxTable(entry); if (table) { if (taxtable_is_grandchild(table)) { PINFO("Fixing b-taxtable on entry %s\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(entry)))); new_tt = taxtable_find_senior(table); gncEntryBeginEdit(entry); gncEntrySetBillTaxTable(entry, new_tt); gncEntryCommitEdit(entry); table = new_tt; } if (table) { count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table)); count++; g_hash_table_insert(ht, table, GINT_TO_POINTER(count)); } } }
static void AddBDANodeDescriptor(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent, const BDANODE_DESCRIPTOR& t) { HRESULT hr; IXMLDOMElementPtr descriptor; std::wstring guid; CreateElement(pDoc,L"descriptor",&descriptor); AddAttribute(pDoc,L"ulBdaNodeType",_variant_t(t.ulBdaNodeType),descriptor); guid_to_string(t.guidFunction,guid); AddAttribute(pDoc,L"guidFunction",guid.c_str(),descriptor); guid_to_string(t.guidName,guid); AddAttribute(pDoc,L"guidName",guid.c_str(),descriptor); return AppendChild(descriptor,pParent); }
static int command_configuration(int argc, char *argv[]) { int i; printf("NumberOfTableEntries=%ld\n", ST->NumberOfTableEntries); for (i = 0; i < ST->NumberOfTableEntries; i++) { EFI_GUID *guid; printf(" "); guid = &ST->ConfigurationTable[i].VendorGuid; if (!memcmp(guid, &mps, sizeof(EFI_GUID))) printf("MPS Table"); else if (!memcmp(guid, &acpi, sizeof(EFI_GUID))) printf("ACPI Table"); else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID))) printf("ACPI 2.0 Table"); else if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) printf("SMBIOS Table"); else if (!memcmp(guid, &sal, sizeof(EFI_GUID))) printf("SAL System Table"); else if (!memcmp(guid, &hcdp, sizeof(EFI_GUID))) printf("DIG64 HCDP Table"); else printf("Unknown Table (%s)", guid_to_string(guid)); printf(" at %p\n", ST->ConfigurationTable[i].VendorTable); } return CMD_OK; }
BOOL CALLBACK DInput_Joystick_EnumCallback( const DIDEVICEINSTANCE* instance, VOID* context ) { if( FAILED( dinput->CreateDevice( instance->guidInstance, &di_joystick[ di_joystick_count ], NULL )) ) return DIENUM_CONTINUE; if( FAILED( di_joystick[ di_joystick_count ]->SetDataFormat( &c_dfDIJoystick2 )) ) return DIENUM_CONTINUE; if( FAILED( di_joystick[ di_joystick_count ]->SetCooperativeLevel( di_enum_hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND )) ) return DIENUM_CONTINUE; /* DIDEVCAPS capabilities; // Determine how many axis the joystick has (so we don't error out setting // properties for unavailable axis) capabilities.dwSize = sizeof(DIDEVCAPS); if (FAILED(hr = joystick->GetCapabilities(&capabilities))) { return hr; } */ if( FAILED( di_joystick[ di_joystick_count ]->EnumObjects( DInput_joystick_enumAxesCallback, NULL, DIDFT_AXIS )) ) return DIENUM_CONTINUE; // save name guid_to_string( &instance->guidInstance, di_joystick_guid[ di_joystick_count ] ); di_joystick_count++; }
TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE *guid) { UINT32 index; UINT32 count; BOOL found = FALSE; char guid_str[GUID_SIZE * 2 + 1]; TSMF_PRESENTATION* presentation; ArrayList_Lock(presentation_list); count = ArrayList_Count(presentation_list); for (index = 0; index < count; index++) { presentation = (TSMF_PRESENTATION*) ArrayList_GetItem(presentation_list, index); if (memcmp(presentation->presentation_id, guid, GUID_SIZE) == 0) { found = TRUE; break; } } ArrayList_Unlock(presentation_list); if (!found) WLog_WARN(TAG, "presentation id %s not found", guid_to_string(guid, guid_str, sizeof(guid_str))); return (found) ? presentation : NULL; }
/* for each invoice, check the bill terms. If the bill terms are * grandchildren, then fix them to point to the most senior child */ static void billterm_scrub_invoices (QofInstance * invoice_p, gpointer ht_p) { GHashTable *ht = ht_p; GncInvoice *invoice = GNC_INVOICE(invoice_p); GncBillTerm *term, *new_bt; gint32 count; term = gncInvoiceGetTerms(invoice); if (term) { if (billterm_is_grandchild(term)) { PWARN("Fixing i-billterm on invoice %s\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(invoice)))); new_bt = billterm_find_senior(term); gncInvoiceBeginEdit(invoice); gncInvoiceSetTerms(invoice, new_bt); gncInvoiceCommitEdit(invoice); term = new_bt; } if (term) { count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term)); count++; g_hash_table_insert(ht, term, GINT_TO_POINTER(count)); } } }
static char * equals_node_val_vs_splits(xmlNodePtr node, const Transaction *trn) { xmlNodePtr spl_node; Split *spl_mark; char *msg; int i; g_return_val_if_fail(node, FALSE); g_return_val_if_fail(node->xmlChildrenNode, FALSE); for (i = 0, spl_mark = xaccTransGetSplit((Transaction*)trn, i); spl_mark; i++, spl_mark = xaccTransGetSplit((Transaction*)trn, i)) { spl_node = find_appropriate_node(node, spl_mark); if (!spl_node) { g_print( "Split GUID %s", guid_to_string(xaccSplitGetGUID(spl_mark)) ); return "no matching split found"; } msg = equals_node_val_vs_split_internal(spl_node, spl_mark); if (msg != NULL) { return msg; } } return NULL; }
static /*@ null @*/ Transaction* load_single_tx( GncSqlBackend* be, GncSqlRow* row ) { const GncGUID* guid; GncGUID tx_guid; Transaction* pTx; g_return_val_if_fail( be != NULL, NULL ); 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). pTx = xaccTransLookup( &tx_guid, be->book ); if ( pTx != NULL ) { return NULL; } pTx = xaccMallocTransaction( be->book ); xaccTransBeginEdit( pTx ); gnc_sql_load_object( be, row, GNC_ID_TRANS, pTx, tx_col_table ); if (pTx != xaccTransLookup( &tx_guid, be->book )) { PERR("A malformed transaction with id %s was found in the dataset.", guid_to_string(qof_instance_get_guid(pTx))); qof_backend_set_error( &be->be, ERR_BACKEND_DATA_CORRUPT); pTx = NULL; } return pTx; }
static void AddKSDATARANGE(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,LPCWSTR name,const KSDATARANGE& v) { HRESULT hr; IXMLDOMElementPtr element; std::wstring guid; CreateElement(pDoc,name,&element); AddAttribute(pDoc,L"FormatSize",_variant_t(v.FormatSize),element); AddAttribute(pDoc,L"Flags",_variant_t(v.Flags),element); AddAttribute(pDoc,L"SampleSize",_variant_t(v.SampleSize),element); AddAttribute(pDoc,L"Reserved",_variant_t(v.Reserved),element); guid_to_string(v.MajorFormat,guid); AddAttribute(pDoc,L"MajorFormat",guid.c_str(),element); guid_to_string(v.SubFormat,guid); AddAttribute(pDoc,L"SubFormat",guid.c_str(),element); guid_to_string(v.Specifier,guid); AddAttribute(pDoc,L"Specifier",guid.c_str(),element); return AppendChild(element,pParent); }
void gncBillTermDestroy (GncBillTerm *term) { if (!term) return; DEBUG("destroying bill term %s (%p)", guid_to_string(qof_instance_get_guid(&term->inst)), term); qof_instance_set_destroying(term, TRUE); qof_instance_set_dirty (&term->inst); gncBillTermCommitEdit (term); }
TEST_F(ImapBayesTest, AddAccountBayes) { // prevent the embedded beginedit/commitedit from doing anything qof_instance_increase_editlevel(QOF_INSTANCE(t_bank_account)); qof_instance_mark_clean(QOF_INSTANCE(t_bank_account)); gnc_account_imap_add_account_bayes(t_imap, t_list1, t_expense_account1); gnc_account_imap_add_account_bayes(t_imap, t_list2, t_expense_account2); gnc_account_imap_add_account_bayes(t_imap, t_list3, t_expense_account1); gnc_account_imap_add_account_bayes(t_imap, t_list4, t_expense_account2); EXPECT_EQ(1, qof_instance_get_editlevel(QOF_INSTANCE(t_bank_account))); EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account))); qof_instance_mark_clean(QOF_INSTANCE(t_bank_account)); gnc_account_imap_add_account_bayes(t_imap, t_list5, NULL); EXPECT_FALSE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account))); qof_instance_reset_editlevel(QOF_INSTANCE(t_bank_account)); auto root = qof_instance_get_slots(QOF_INSTANCE(t_bank_account)); auto acct1_guid = guid_to_string (xaccAccountGetGUID(t_expense_account1)); auto acct2_guid = guid_to_string (xaccAccountGetGUID(t_expense_account2)); auto value = root->get_slot({IMAP_FRAME_BAYES, "foo", "bar"}); auto check_account = [this](KvpValue* v) { return (v->get<const char*>(), this->t_imap->book); }; value = root->get_slot({IMAP_FRAME_BAYES, foo, acct1_guid}); EXPECT_EQ(1, value->get<int64_t>()); value = root->get_slot({IMAP_FRAME_BAYES, bar, acct1_guid}); EXPECT_EQ(1, value->get<int64_t>()); value = root->get_slot({IMAP_FRAME_BAYES, baz, acct2_guid}); EXPECT_EQ(1, value->get<int64_t>()); value = root->get_slot({IMAP_FRAME_BAYES, waldo, acct2_guid}); EXPECT_EQ(1, value->get<int64_t>()); value = root->get_slot({IMAP_FRAME_BAYES, pepper, acct1_guid}); EXPECT_EQ(1, value->get<int64_t>()); value = root->get_slot({IMAP_FRAME_BAYES, salt, acct2_guid}); EXPECT_EQ(1, value->get<int64_t>()); value = root->get_slot({IMAP_FRAME_BAYES, baz, acct1_guid}); EXPECT_EQ(nullptr, value); qof_instance_increase_editlevel(QOF_INSTANCE(t_bank_account)); gnc_account_imap_add_account_bayes(t_imap, t_list2, t_expense_account2); qof_instance_mark_clean(QOF_INSTANCE(t_bank_account)); qof_instance_reset_editlevel(QOF_INSTANCE(t_bank_account)); value = root->get_slot({IMAP_FRAME_BAYES, baz, acct2_guid}); EXPECT_EQ(2, value->get<int64_t>()); }
static void AddGUID(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,const GUID& g) { HRESULT hr; IXMLDOMElementPtr guid; std::wstring guidstr; CreateElement(pDoc,L"guid",&guid); guid_to_string(g,guidstr); AddAttribute(pDoc,L"name",guidstr.c_str(),guid); return AppendChild(guid,pParent); }
static void billterm_scrub_vendor (QofInstance * vendor_p, gpointer ht_p) { GHashTable *ht = ht_p; GncVendor *vendor = GNC_VENDOR(vendor_p); GncBillTerm *term; gint32 count; term = gncVendorGetTerms(vendor); if (term) { count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term)); count++; g_hash_table_insert(ht, term, GINT_TO_POINTER(count)); if (billterm_is_grandchild(term)) PWARN("vendor %s has grandchild billterm %s\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(vendor))), guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term)))); } }
static void billterm_scrub_cust (QofInstance * cust_p, gpointer ht_p) { GHashTable *ht = ht_p; GncCustomer *cust = GNC_CUSTOMER(cust_p); GncBillTerm *term; gint32 count; term = gncCustomerGetTerms(cust); if (term) { count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term)); count++; g_hash_table_insert(ht, term, GINT_TO_POINTER(count)); if (billterm_is_grandchild(term)) PWARN("customer %s has grandchild billterm %s\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(cust))), guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term)))); } }
static void gnc_guid_to_string (const GValue *src, GValue *dest) { const gchar *str; g_return_if_fail (G_VALUE_HOLDS_STRING (dest) && GNC_VALUE_HOLDS_GUID (src)); str = guid_to_string(gnc_value_get_guid (src)); g_value_set_string (dest, str); }
void qof_instance_print_dirty (const QofInstance *inst, gpointer dummy) { QofInstancePrivate *priv; priv = GET_PRIVATE(inst); if (priv->dirty) { printf("%s instance %s is dirty.\n", inst->e_type, guid_to_string(&priv->guid)); } }
static void AddKSIDENTIFIER(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,const KSIDENTIFIER& v) { HRESULT hr; IXMLDOMElementPtr element; std::wstring guid; CreateElement(pDoc,L"ksidentifier",&element); guid_to_string(v.Set,guid); AddAttribute(pDoc,L"Set",guid.c_str(),element); AddAttribute(pDoc,L"Id",_variant_t(v.Id),element); AddAttribute(pDoc,L"Flags",_variant_t(v.Flags),element); return AppendChild(element,pParent); }
static void billterm_reset_refcount (gpointer key, gpointer value, gpointer notused) { GncBillTerm *term = key; gint32 count = GPOINTER_TO_INT(value); if (count != gncBillTermGetRefcount(term) && !gncBillTermGetInvisible(term)) { PWARN("Fixing refcount on billterm %s (%" G_GINT64_FORMAT " -> %d)\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))), gncBillTermGetRefcount(term), count); gncBillTermSetRefcount(term, count); } }
static void print_download_id(gnet_fi_t handle, void *udata) { struct gnutella_shell *sh = udata; gnet_fi_info_t *info; shell_check(sh); info = guc_fi_get_info(handle); g_return_if_fail(info); shell_write(sh, guid_to_string(info->guid)); shell_write(sh, "\n"); /* Terminate line */ }
static void taxtable_reset_refcount (gpointer key, gpointer value, gpointer notused) { GncTaxTable *table = key; gint32 count = GPOINTER_TO_INT(value); if (count != gncTaxTableGetRefcount(table) && !gncTaxTableGetInvisible(table)) { PWARN("Fixing refcount on taxtable %s (%" G_GINT64_FORMAT " -> %d)\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(table))), gncTaxTableGetRefcount(table), count); gncTaxTableSetRefcount(table, count); } }
static int command_configuration(int argc, char *argv[]) { char line[80]; UINTN i; snprintf(line, sizeof(line), "NumberOfTableEntries=%lu\n", (unsigned long)ST->NumberOfTableEntries); pager_open(); if (pager_output(line)) { pager_close(); return (CMD_OK); } for (i = 0; i < ST->NumberOfTableEntries; i++) { EFI_GUID *guid; printf(" "); guid = &ST->ConfigurationTable[i].VendorGuid; if (!memcmp(guid, &mps, sizeof(EFI_GUID))) printf("MPS Table"); else if (!memcmp(guid, &acpi, sizeof(EFI_GUID))) printf("ACPI Table"); else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID))) printf("ACPI 2.0 Table"); else if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) printf("SMBIOS Table %p", ST->ConfigurationTable[i].VendorTable); else if (!memcmp(guid, &dxe, sizeof(EFI_GUID))) printf("DXE Table"); else if (!memcmp(guid, &hoblist, sizeof(EFI_GUID))) printf("HOB List Table"); else if (!memcmp(guid, &memtype, sizeof(EFI_GUID))) printf("Memory Type Information Table"); else if (!memcmp(guid, &debugimg, sizeof(EFI_GUID))) printf("Debug Image Info Table"); else if (!memcmp(guid, &fdtdtb, sizeof(EFI_GUID))) printf("FDT Table"); else printf("Unknown Table (%s)", guid_to_string(guid)); snprintf(line, sizeof(line), " at %p\n", ST->ConfigurationTable[i].VendorTable); if (pager_output(line)) break; } pager_close(); return (CMD_OK); }
static const char * auth_user (const char * name, const char *passwd) { GncGUID *guid; const char *session_auth_string; /* hack alert - XXX - we do no authentication whatsoever, * any user is allowed to login. We only reject null users. */ if (!name || !passwd) return NULL; guid = g_new (GncGUID, 1); guid_new (guid); logged_in_users = g_list_prepend (logged_in_users, guid); session_auth_string = guid_to_string (guid); /* THREAD UNSAFE */ return session_auth_string; }
static void print_download_info(gnet_fi_t handle, void *udata) { struct gnutella_shell *sh = udata; gnet_fi_status_t status; gnet_fi_info_t *info; char buf[1024]; shell_check(sh); info = guc_fi_get_info(handle); g_return_if_fail(info); guc_fi_get_status(handle, &status); str_bprintf(ARYLEN(buf), "ID: %s", guid_to_string(info->guid)); shell_write(sh, buf); shell_write(sh, "\n"); /* Terminate line */ str_bprintf(ARYLEN(buf), "Filename: \"%s\"", info->filename); shell_write(sh, buf); shell_write(sh, "\n"); /* Terminate line */ str_bprintf(ARYLEN(buf), "Hash: %s", info->sha1 ? sha1_to_urn_string(info->sha1) : "<none>"); shell_write(sh, buf); shell_write(sh, "\n"); /* Terminate line */ str_bprintf(ARYLEN(buf), "Status: %s", file_info_status_to_string(&status)); shell_write(sh, buf); shell_write(sh, "\n"); /* Terminate line */ str_bprintf(ARYLEN(buf), "Size: %s", compact_size(status.size, GNET_PROPERTY(display_metric_units))); shell_write(sh, buf); shell_write(sh, "\n"); /* Terminate line */ str_bprintf(ARYLEN(buf), "Done: %u%% (%s)", filesize_per_100(status.size, status.done), compact_size(status.done, GNET_PROPERTY(display_metric_units))); shell_write(sh, buf); shell_write(sh, "\n"); /* Terminate line */ shell_write(sh, "--\n"); guc_fi_free_info(info); }
static /*@ null @*/ Split* load_single_split( GncSqlBackend* be, GncSqlRow* row ) { const GncGUID* guid; GncGUID split_guid; Split* pSplit = NULL; gboolean bad_guid = FALSE; g_return_val_if_fail( be != NULL, NULL ); g_return_val_if_fail( row != NULL, NULL ); guid = gnc_sql_load_guid( be, row ); if ( guid == NULL ) return NULL; if (guid_equal(guid, guid_null())) { PWARN("Bad GUID, creating new"); bad_guid = TRUE; split_guid = guid_new_return(); } else { split_guid = *guid; pSplit = xaccSplitLookup( &split_guid, be->book ); } if ( pSplit == NULL ) { pSplit = xaccMallocSplit( be->book ); } /* If the split is dirty, don't overwrite it */ if ( !qof_instance_is_dirty( QOF_INSTANCE(pSplit) ) ) { gnc_sql_load_object( be, row, GNC_ID_SPLIT, pSplit, split_col_table ); } /*# -ifempty */ if (pSplit != xaccSplitLookup( &split_guid, be->book )) { PERR("A malformed split with id %s was found in the dataset.", guid_to_string(qof_instance_get_guid(pSplit))); qof_backend_set_error( &be->be, ERR_BACKEND_DATA_CORRUPT); pSplit = NULL; } return pSplit; }
// NOTE: XP only sees 'SysMouse' BOOL CALLBACK DInput_Mouse_EnumCallback( const DIDEVICEINSTANCE* instance, VOID* context ) { if( FAILED( dinput->CreateDevice( instance->guidInstance, &di_mouse[ di_mouse_count ], NULL )) ) return DIENUM_CONTINUE; if( FAILED( di_mouse[ di_mouse_count ]->SetDataFormat( &c_dfDIMouse )) ) return DIENUM_CONTINUE; if( FAILED( di_mouse[ di_mouse_count ]->SetCooperativeLevel( di_enum_hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND )) ) return DIENUM_CONTINUE; // save name guid_to_string( &instance->guidInstance, di_mouse_guid[ di_mouse_count ] ); di_mouse_count++; }
static void AddGUIDList(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,std::map<unsigned long,std::vector<GUID> >::const_iterator& l) { HRESULT hr; IXMLDOMElementPtr node; CreateElement(pDoc,L"node",&node); AddAttribute(pDoc,L"id",_variant_t(l->first),node); for(size_t n=0;n<l->second.size();n++) { IXMLDOMElementPtr guid; std::wstring guidstr; CreateElement(pDoc,L"guid",&guid); guid_to_string(l->second[n],guidstr); AddAttribute(pDoc,L"name",guidstr.c_str(),guid); AppendChild(guid,node); } return AppendChild(node,pParent); }
/********************************************************************\ * gnc_split_scm_set_account * * set the account of a scheme representation of a split. * * * * Args: split_scm - the scheme split * * account - the account to set * * Returns: Nothing * \********************************************************************/ void gnc_split_scm_set_account(SCM split_scm, Account *account) { const char *guid_string; SCM arg; initialize_scm_functions(); if (!gnc_is_split_scm(split_scm)) return; if (account == NULL) return; guid_string = guid_to_string(xaccAccountGetGUID(account)); if (guid_string == NULL) return; arg = scm_makfrom0str(guid_string); scm_call_2(setters.split_scm_account_guid, split_scm, arg); }
GncBillTerm * gnc_billterm_xml_find_or_create(QofBook *book, GncGUID *guid) { GncBillTerm *term; g_return_val_if_fail(book, NULL); g_return_val_if_fail(guid, NULL); term = gncBillTermLookup(book, guid); DEBUG("looking for billterm %s, found %p", guid_to_string(guid), term); if (!term) { term = gncBillTermCreate(book); gncBillTermBeginEdit(term); gncBillTermSetGUID(term, guid); gncBillTermCommitEdit(term); DEBUG("Created term: %p", term); } else gncBillTermDecRef(term); return term; }
static void billterm_scrub (QofBook *book) { GList *list = NULL; GList *node; GncBillTerm *parent, *term; GHashTable *ht = g_hash_table_new(g_direct_hash, g_direct_equal); DEBUG("scrubbing billterms..."); qof_object_foreach (GNC_ID_INVOICE, book, billterm_scrub_invoices, ht); qof_object_foreach (GNC_ID_CUSTOMER, book, billterm_scrub_cust, ht); qof_object_foreach (GNC_ID_VENDOR, book, billterm_scrub_vendor, ht); qof_object_foreach (GNC_ID_BILLTERM, book, billterm_scrub_cb, &list); /* destroy the list of "grandchildren" bill terms */ for (node = list; node; node = node->next) { term = node->data; PWARN ("deleting grandchild billterm: %s\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term)))); /* Make sure the parent has no children */ parent = gncBillTermGetParent(term); gncBillTermSetChild(parent, NULL); /* Destroy this bill term */ gncBillTermBeginEdit(term); gncBillTermDestroy(term); } /* reset the refcounts as necessary */ g_hash_table_foreach(ht, billterm_reset_refcount, NULL); g_list_free(list); g_hash_table_destroy(ht); }