本文整理汇总了C++中PWARN函数的典型用法代码示例。如果您正苦于以下问题:C++ PWARN函数的具体用法?C++ PWARN怎么用?C++ PWARN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PWARN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qof_book_get_default_gains_policy
/** Returns pointer to default gain/loss policy for book, if one exists in the
* KVP, or NULL; does not validate contents nor determine if there is a valid
* book-currency, both of which are required, for the 'book-currency'
* currency accounting method to apply. Use instead
* 'gnc_book_get_default_gains_policy' which does these validations. */
const gchar *
qof_book_get_default_gains_policy (QofBook *book)
{
KvpFrame *kvp;
KvpValue *value;
if (!book)
{
PWARN ("No book!!!");
return NULL;
}
/* Get the KVP from the current book */
kvp = qof_instance_get_slots (QOF_INSTANCE (book));
if (!kvp)
{
PWARN ("Book has no KVP_Frame");
return NULL;
}
/* See if there is a default gain/loss policy */
value = kvp->get_slot({KVP_OPTION_PATH, OPTION_SECTION_ACCOUNTS,
OPTION_NAME_DEFAULT_GAINS_POLICY});
if (!value)
/* No default gain/loss policy, therefore not valid book-currency
accounting method */
return nullptr;
return g_strdup(value->get<const char*>());
}
示例2: xaccScrubMergeSubSplits
gboolean
xaccScrubMergeSubSplits (Split *split, gboolean strict)
{
gboolean rc = FALSE;
Transaction *txn;
SplitList *node;
GNCLot *lot;
if (strict && (FALSE == is_subsplit (split))) return FALSE;
txn = split->parent;
// Don't mess with splits from an invoice transaction
// Those are the responsibility of the business code
if (gncInvoiceGetInvoiceFromTxn (txn)) return FALSE;
lot = xaccSplitGetLot (split);
ENTER ("(Lot=%s)", gnc_lot_get_title(lot));
restart:
for (node = txn->splits; node; node = node->next)
{
Split *s = node->data;
if (xaccSplitGetLot (s) != lot) continue;
if (s == split) continue;
if (qof_instance_get_destroying(s)) continue;
// Don't mess with splits from an invoice transaction
// Those are the responsibility of the business code
if (gncInvoiceGetInvoiceFromTxn (s->parent)) return FALSE;
if (strict)
{
/* OK, this split is in the same lot (and thus same account)
* as the indicated split. Make sure it is really a subsplit
* of the split we started with. It's possible to have two
* splits in the same lot and transaction that are not subsplits
* of each other, the test-period test suite does this, for
* example. Only worry about adjacent sub-splits. By
* repeatedly merging adjacent subsplits, we'll get the non-
* adjacent ones too. */
if (!xaccSplitIsPeerSplit (split, s))
continue;
}
merge_splits (split, s);
rc = TRUE;
goto restart;
}
if (rc && gnc_numeric_zero_p (split->amount))
{
time64 pdate = xaccTransGetDate (txn);
gchar *pdatestr = gnc_ctime (&pdate);
PWARN ("Result of merge has zero amt!");
PWARN ("Transaction details - posted date %s - description %s", pdatestr, xaccTransGetDescription(txn));
g_free (pdatestr);
}
LEAVE (" splits merged=%d", rc);
return rc;
}
示例3: gncTaxTableEntryEqual
gboolean gncTaxTableEntryEqual(const GncTaxTableEntry *a, const GncTaxTableEntry *b)
{
if (a == NULL && b == NULL) return TRUE;
if (a == NULL || b == NULL) return FALSE;
if (!xaccAccountEqual(a->account, b->account, TRUE))
{
PWARN("accounts differ");
return FALSE;
}
if (a->type != b->type)
{
PWARN("types differ");
return FALSE;
}
if (!gnc_numeric_equal(a->amount, b->amount))
{
PWARN("amounts differ");
return FALSE;
}
return TRUE;
}
示例4: gnc_timespec_to_iso8601_buff
char *
gnc_timespec_to_iso8601_buff (Timespec ts, char * buff)
{
constexpr size_t max_iso_date_length = 32;
const char* format = "%Y-%m-%d %H:%M:%s %q";
if (! buff) return NULL;
try
{
GncDateTime gncdt(ts.tv_sec);
auto sstr = gncdt.format(format);
memset(buff, 0, sstr.length() + 1);
strncpy(buff, sstr.c_str(), sstr.length());
return buff + sstr.length();
}
catch(std::logic_error& err)
{
PWARN("Error processing time64 %" PRId64 ": %s", ts.tv_sec, err.what());
return buff;
}
catch(std::runtime_error& err)
{
PWARN("Error processing time64 %" PRId64 ": %s", ts.tv_sec, err.what());
return buff;
}
}
示例5: qof_book_get_counter
gint64
qof_book_get_counter (QofBook *book, const char *counter_name)
{
QofBackend *be;
KvpFrame *kvp;
KvpValue *value;
gint64 counter;
if (!book)
{
PWARN ("No book!!!");
return -1;
}
if (!counter_name || *counter_name == '\0')
{
PWARN ("Invalid counter name.");
return -1;
}
/* If we've got a backend with a counter method, call it */
be = book->backend;
if (be && be->counter)
return ((be->counter)(be, counter_name));
/* If not, then use the KVP in the book */
kvp = qof_book_get_slots (book);
if (!kvp)
{
PWARN ("Book has no KVP_Frame");
return -1;
}
value = kvp_frame_get_slot_path (kvp, "counters", counter_name, NULL);
if (value)
{
/* found it */
counter = kvp_value_get_gint64 (value);
}
else
{
/* New counter */
counter = 0;
}
/* Counter is now valid; increment it */
counter++;
/* Save off the new counter */
qof_book_begin_edit(book);
value = kvp_value_new_gint64 (counter);
kvp_frame_set_slot_path (kvp, value, "counters", counter_name, NULL);
kvp_value_delete (value);
qof_book_mark_dirty(book);
qof_book_commit_edit(book);
/* and return the value */
return counter;
}
示例6: qof_book_get_book_currency
/** Returns pointer to book-currency name for book, if one exists in the
* KVP, or NULL; does not validate contents nor determine if there is a valid
* default gain/loss policy, both of which are required, for the
* 'book-currency' currency accounting method to apply. Use instead
* 'gnc_book_get_book_currency' which does these validations. */
const gchar *
qof_book_get_book_currency (QofBook *book)
{
KvpFrame *kvp;
KvpValue *value;
if (!book)
{
PWARN ("No book!!!");
return NULL;
}
/* Get the KVP from the current book */
kvp = qof_instance_get_slots (QOF_INSTANCE (book));
if (!kvp)
{
PWARN ("Book has no KVP_Frame");
return NULL;
}
/* See if there is a book currency. */
value = kvp->get_slot({KVP_OPTION_PATH, OPTION_SECTION_ACCOUNTS,
OPTION_NAME_BOOK_CURRENCY});
if (!value) /* No book-currency */
return nullptr;
return value->get<const char*>();
}
示例7: xaccQueryAddAccountMatch
void
xaccQueryAddAccountMatch(QofQuery *q, AccountList *acct_list,
QofGuidMatch how, QofQueryOp op)
{
GList *list = NULL;
if (!q) return;
for (; acct_list; acct_list = acct_list->next)
{
Account *acc = acct_list->data;
const GncGUID *guid;
if (!acc)
{
PWARN ("acct_list has NULL account");
continue;
}
guid = qof_entity_get_guid (QOF_INSTANCE(acc));
if (!guid)
{
PWARN ("acct returns NULL GncGUID");
continue;
}
list = g_list_prepend (list, (gpointer)guid);
}
xaccQueryAddAccountGUIDMatch (q, list, how, op);
g_list_free (list);
}
示例8: tea5764_i2c_probe
/* I2C probe: check if the device exists and register with v4l if it is */
static int __devinit tea5764_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct tea5764_device *radio;
struct tea5764_regs *r;
int ret;
PDEBUG("probe");
radio = kmalloc(sizeof(struct tea5764_device), GFP_KERNEL);
if (!radio)
return -ENOMEM;
mutex_init(&radio->mutex);
radio->i2c_client = client;
ret = tea5764_i2c_read(radio);
if (ret)
goto errfr;
r = &radio->regs;
PDEBUG("chipid = %04X, manid = %04X", r->chipid, r->manid);
if (r->chipid != TEA5764_CHIPID ||
(r->manid & 0x0fff) != TEA5764_MANID) {
PWARN("This chip is not a TEA5764!");
ret = -EINVAL;
goto errfr;
}
radio->videodev = video_device_alloc();
if (!(radio->videodev)) {
ret = -ENOMEM;
goto errfr;
}
memcpy(radio->videodev, &tea5764_radio_template,
sizeof(tea5764_radio_template));
i2c_set_clientdata(client, radio);
video_set_drvdata(radio->videodev, radio);
ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
if (ret < 0) {
PWARN("Could not register video device!");
goto errrel;
}
/* initialize and power off the chip */
tea5764_i2c_read(radio);
tea5764_set_audout_mode(radio, V4L2_TUNER_MODE_STEREO);
tea5764_mute(radio, 1);
tea5764_power_down(radio);
PINFO("registered.");
return 0;
errrel:
video_device_release(radio->videodev);
errfr:
kfree(radio);
return ret;
}
示例9: gnc_keyring_set_password
void gnc_keyring_set_password (const gchar *access_method,
const gchar *server,
guint32 port,
const gchar *service,
const gchar *user,
const gchar* password)
{
#ifdef HAVE_GNOME_KEYRING
GnomeKeyringResult gkr_result;
guint32 item_id = 0;
gkr_result = gnome_keyring_set_network_password_sync
(NULL, user, NULL, server, service,
access_method, NULL, port, password, &item_id);
if (gkr_result != GNOME_KEYRING_RESULT_OK)
{
PWARN ("Gnome-keyring error: %s",
gnome_keyring_result_to_message(gkr_result));
PWARN ("The user will be prompted for a password again next time.");
}
#endif /* HAVE_GNOME_KEYRING */
#ifdef HAVE_OSX_KEYCHAIN
OSStatus status;
SecKeychainItemRef *itemRef = NULL;
/* mysql and postgres aren't valid protocols on Mac OS X.
* So we use the security domain parameter to allow us to
* distinguish between these two.
*/
// FIXME I'm not sure this works if a password was already in the keychain
// I may have to do a lookup first and if it exists, run some update
// update function instead
status = SecKeychainAddInternetPassword ( NULL, /* keychain */
strlen(server), server, /* servername */
strlen(access_method), access_method, /* securitydomain */
strlen(user), user, /* acountname */
strlen(service), service, /* path */
port, /* port */
kSecProtocolTypeAny, /* protocol */
kSecAuthenticationTypeDefault, /* auth type */
strlen(password), password, /* passworddata */
itemRef );
if ( status != noErr )
{
CFStringRef osx_resultstring = SecCopyErrorMessageString( status, NULL );
const gchar *resultstring = CFStringGetCStringPtr(osx_resultstring,
GetApplicationTextEncoding());
PWARN ( "OS X keychain error: %s", resultstring );
PWARN ( "The user will be prompted for a password again next time." );
CFRelease ( osx_resultstring );
}
#endif /* HAVE_OSX_KEYCHAIN */
}
示例10: qof_book_get_counter_format
const gchar *
qof_book_get_counter_format(const QofBook *book, const char *counter_name)
{
KvpFrame *kvp;
const char *format;
KvpValue *value;
gchar *error;
if (!book)
{
PWARN ("No book!!!");
return NULL;
}
if (!counter_name || *counter_name == '\0')
{
PWARN ("Invalid counter name.");
return NULL;
}
/* Get the KVP from the current book */
kvp = qof_instance_get_slots (QOF_INSTANCE (book));
if (!kvp)
{
PWARN ("Book has no KVP_Frame");
return NULL;
}
format = NULL;
/* Get the format string */
value = kvp->get_slot({"counter_formats", counter_name});
if (value)
{
format = value->get<const char*>();
error = qof_book_validate_counter_format(format);
if (error != NULL)
{
PWARN("Invalid counter format string. Format string: '%s' Counter: '%s' Error: '%s')", format, counter_name, error);
/* Invalid format string */
format = NULL;
g_free(error);
}
}
/* If no (valid) format string was found, use the default format
* string */
if (!format)
{
/* Use the default format */
format = "%.6" G_GINT64_FORMAT;
}
return format;
}
示例11: proc_handle_softreboot
ssize_t proc_handle_softreboot(struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
int len = count, i, start, k, cdev;
u16 devs[4] = { 0 };
char buf[OMAP3_MAX_SEQ];
if (len > OMAP3_MAX_SEQ-1)
{
PWARN("Too long OMAP boot sequence\n");
return -EFAULT;
}
if (copy_from_user(buf, buffer, len))
return -EFAULT;
buf[len++] = 0;
for (i = 0, start = 0, cdev = 0; i < len; i++)
{
if (buf[i] == ',' || !buf[i] || buf[i] == '\n')
{
for (k = 0; k < OMAP3_DEV_COUNT; k++)
{
if (omap3_dev_names[k] &&
!strncmp(buf+start, omap3_dev_names[k], i-start))
{
if (cdev >= 4)
{
PWARN("You can specify only up to 4 OMAP boot devices\n");
return -EFAULT;
}
devs[cdev++] = k;
break;
}
}
if (k >= OMAP3_DEV_COUNT)
{
buf[i] = 0;
PWARN("Incorrect OMAP boot device name \"%s\"\n", buf+start);
return -EFAULT;
}
start = i+1;
if (!buf[i] || buf[i] == '\n')
break;
}
}
// Reboot device with new configuration
PWARN("New config: %x %x %x %x\n", devs[0], devs[1], devs[2], devs[3]);
omap_reset_to(devs);
return count;
}
示例12: gncOwnerOffsetLots
static void gncOwnerOffsetLots (GNCLot *from_lot, GNCLot *to_lot, const GncOwner *owner)
{
gnc_numeric target_offset;
Split *split;
/* from lot should not be a document lot because we're removing a split from there ! */
if (gncInvoiceGetInvoiceFromLot (from_lot))
{
PWARN ("from_lot %p is a document lot. That is not allowed in gncOwnerOffsetLots", from_lot);
return;
}
/* Get best matching split from from_lot to offset to_lot */
target_offset = gnc_lot_get_balance (to_lot);
if (gnc_numeric_zero_p (target_offset))
return; // to_lot is already balanced, nothing more to do
split = gncOwnerFindOffsettingSplit (from_lot, target_offset);
if (!split)
return; // No suitable offsetting split found, nothing more to do
/* If the offsetting split is bigger than the amount needed to balance
* to_lot, reduce the split so its reduced value closes to_lot exactly.
* Note the negation in the reduction function. The split must be of
* opposite sign of to_lot's balance in order to be able to close it.
*/
if (gnc_numeric_compare (gnc_numeric_abs (xaccSplitGetValue (split)),
gnc_numeric_abs (target_offset)) > 0)
gncOwnerReduceSplitTo (split, gnc_numeric_neg (target_offset));
/* Move the reduced split from from_lot to to_lot */
gnc_lot_add_split (to_lot, split);
}
示例13: gncScrubLotIsSingleLotLinkSplit
static gboolean
gncScrubLotIsSingleLotLinkSplit (GNCLot *lot)
{
Split *split = NULL;
Transaction *trans = NULL;
// Lots with a single split which is also a lot link transaction split
// may be sign of a dangling payment. Let's try to fix that
// Only works for single split lots...
if (1 != gnc_lot_count_splits (lot))
return FALSE;
split = gnc_lot_get_earliest_split (lot);
trans = xaccSplitGetParent (split);
if (!trans)
{
// Ooops - the split doesn't belong to any transaction !
// This is not expected so issue a warning and continue with next split
PWARN("Encountered a split in a business lot that's not part of any transaction. "
"This is unexpected! Skipping split %p.", split);
return FALSE;
}
// Only works if single split belongs to a lot link transaction...
if (xaccTransGetTxnType (trans) != TXN_TYPE_LINK)
return FALSE;
return TRUE;
}
示例14: verify_essentials
Transaction* GncPreTrans::create_trans (QofBook* book, gnc_commodity* currency)
{
if (created)
return nullptr;
/* Gently refuse to create the transaction if the basics are not set correctly
* This should have been tested before calling this function though!
*/
auto check = verify_essentials();
if (!check.empty())
{
PWARN ("Refusing to create transaction because essentials not set properly: %s", check.c_str());
return nullptr;
}
auto trans = xaccMallocTransaction (book);
xaccTransBeginEdit (trans);
xaccTransSetCurrency (trans, m_commodity ? *m_commodity : currency);
xaccTransSetDatePostedSecsNormalized (trans,
static_cast<time64>(GncDateTime(*m_date, DayPart::neutral)));
if (m_num)
xaccTransSetNum (trans, m_num->c_str());
if (m_desc)
xaccTransSetDescription (trans, m_desc->c_str());
if (m_notes)
xaccTransSetNotes (trans, m_notes->c_str());
created = true;
return trans;
}
示例15: load_slot
static void
load_slot( slot_info_t *pInfo, GncSqlRow* row )
{
slot_info_t *slot_info;
g_return_if_fail( pInfo != NULL );
g_return_if_fail( pInfo->be != NULL );
g_return_if_fail( row != NULL );
g_return_if_fail( pInfo->pKvpFrame != NULL );
slot_info = slot_info_copy( pInfo, NULL );
g_string_free( slot_info->path, TRUE );
slot_info->path = NULL;
gnc_sql_load_object( pInfo->be, row, TABLE_NAME, slot_info, col_table );
if ( slot_info->path != NULL )
{
(void)g_string_free( slot_info->path, TRUE );
}
if ( slot_info->pList != pInfo->pList )
{
if (pInfo->pList != NULL)
{
PWARN("Load slot returned a different list than the original");
}
else
{
pInfo->pList = slot_info->pList;
}
}
g_slice_free( slot_info_t, slot_info );
}