当前位置: 首页>>代码示例>>C++>>正文


C++ safe_strcmp函数代码示例

本文整理汇总了C++中safe_strcmp函数的典型用法代码示例。如果您正苦于以下问题:C++ safe_strcmp函数的具体用法?C++ safe_strcmp怎么用?C++ safe_strcmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了safe_strcmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

int
glsl_type::record_key_compare(const void *a, const void *b)
{
   const glsl_type *const key1 = (glsl_type *) a;
   const glsl_type *const key2 = (glsl_type *) b;

   /* Return zero is the types match (there is zero difference) or non-zero
    * otherwise.
    */
   if (safe_strcmp(key1->name, key2->name) != 0)
      return 1;

   if (key1->length != key2->length)
      return 1;

   for (unsigned i = 0; i < key1->length; i++) {
      if (key1->fields.structure[i].type != key2->fields.structure[i].type)
	 return 1;
      if (safe_strcmp(key1->fields.structure[i].name,
		 key2->fields.structure[i].name) != 0)
	 return 1;
   }

   return 0;
}
开发者ID:1065672644894730302,项目名称:Chromium,代码行数:25,代码来源:glsl_types.cpp

示例2: gncBillTermCompare

int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b)
{
    int ret;

    if (!a && !b) return 0;
    if (!a) return -1;
    if (!b) return 1;

    ret = safe_strcmp (a->name, b->name);
    if (ret) return ret;

    return safe_strcmp (a->desc, b->desc);
}
开发者ID:kleopatra999,项目名称:gnucash-2,代码行数:13,代码来源:gncBillTerm.c

示例3: fatalError

/*
** Print an error message and then quit.
*/
static void fatalError(const char *zFormat, ...){
  va_list ap;
  char *zMsg;
  char zPrefix[30];
  va_start(ap, zFormat);
  zMsg = sqlite3_vmprintf(zFormat, ap);
  va_end(ap);
  sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:FATAL: ", g.zName);
  if( g.pLog ){
    printWithPrefix(g.pLog, zPrefix, zMsg);
    fflush(g.pLog);
    maybeClose(g.pLog);
  }
  if( g.pErrLog && safe_strcmp(g.zErrLog,g.zLog) ){
    printWithPrefix(g.pErrLog, zPrefix, zMsg);
    fflush(g.pErrLog);
    maybeClose(g.pErrLog);
  }
  sqlite3_free(zMsg);
  if( g.db ){
    int nTry = 0;
    g.iTimeout = 0;
    while( trySql("UPDATE client SET wantHalt=1;")==SQLITE_BUSY
           && (nTry++)<100 ){
      sqlite3_sleep(10);
    }
  }
  sqlite3_close(g.db);
  exit(1);  
}
开发者ID:xluoly,项目名称:raw-os_sqlite,代码行数:33,代码来源:mptest.c

示例4: MountVolume

/*
 * Mount the volume identified by drive_guid to mountpoint drive_name
 */
BOOL MountVolume(char* drive_name, char *drive_guid)
{
	char mounted_guid[52];	// You need at least 51 characters on XP

	if (!SetVolumeMountPointA(drive_name, drive_guid)) {
		// If the OS was faster than us at remounting the drive, this operation can fail
		// with ERROR_DIR_NOT_EMPTY. If that's the case, just check that mountpoints match
		if (GetLastError() == ERROR_DIR_NOT_EMPTY) {
			if (!GetVolumeNameForVolumeMountPointA(drive_name, mounted_guid, sizeof(mounted_guid))) {
				uprintf("%s already mounted, but volume GUID could not be checked: %s\n",
					drive_name, WindowsErrorString());
				return FALSE;
			}
			if (safe_strcmp(drive_guid, mounted_guid) != 0) {
				uprintf("%s already mounted, but volume GUID doesn't match:\r\n  expected %s, got %s\n",
					drive_name, drive_guid, mounted_guid);
				return FALSE;
			}
			uprintf("%s was already mounted as %s\n", drive_guid, drive_name);
		} else {
			return FALSE;
		}
	}
	return TRUE;
}
开发者ID:michaelbarnard,项目名称:rufus,代码行数:28,代码来源:drive.c

示例5: getIPv6Addr

int getIPv6Addr(char *intf, char *ipv6addr)
{
	L3Addr_t ips[10] = {0};
	int cnt = 0;
	int i = 0;
	char buf[100] = {0};

	kinfo("Enter");

	if(!safe_strcmp(intf, "br0"))
		cnt = getL3LocalList(ips, 10, NULL);

	kinfo("ipaddr (totally %d)", cnt);
	for(i = 0; i < cnt; i++) {
		kinfo("%s, type(%d)", ips[i].ipAddrStr, ips[i].type);

		changeString(ips[i].ipAddrStr);
		
		sprintf(buf, "%d|%s||", ips[i].type, ips[i].ipAddrStr);

		strcat(ipv6addr, buf);
	}
	
	return 0;		
}
开发者ID:jameshilliard,项目名称:WECB-CC-GPL,代码行数:25,代码来源:act_status.c

示例6: open_loc_file

/*
 * Open a localization file and store its file name, with special case
 * when dealing with the embedded loc file.
 */
FILE* open_loc_file(const char* filename)
{
	FILE* fd = NULL;
	wchar_t *wfilename = NULL;
	const char* tmp_ext = ".tmp";

	if (filename == NULL)
		return NULL;

	if (loc_filename != embedded_loc_filename) {
		safe_free(loc_filename);
	}
	if (safe_strcmp(tmp_ext, &filename[safe_strlen(filename)-4]) == 0) {
		loc_filename = embedded_loc_filename;
	} else {
		loc_filename = safe_strdup(filename);
	}
	wfilename = utf8_to_wchar(filename);
	if (wfilename == NULL) {
		uprintf(conversion_error, filename);
		goto out;
	}
	fd = _wfopen(wfilename, L"rb");
	if (fd == NULL) {
		uprintf("localization: could not open '%s'\n", filename);
	}

out:
	safe_free(wfilename);
	return fd;
}
开发者ID:10se1ucgo,项目名称:rufus,代码行数:35,代码来源:parser.c

示例7: test_load_file

static void
test_load_file(const char *filename)
{
    QofSession *session;
    QofBook *book;
    Account *root;
    gboolean ignore_lock;
    gchar *logdomain = "GConf";
    guint loglevel = G_LOG_LEVEL_WARNING;
    TestErrorStruct check = { loglevel, logdomain, NULL };
    g_log_set_handler (logdomain, loglevel,
		       (GLogFunc)test_checked_handler, &check);

    session = qof_session_new();

    remove_locks(filename);

    ignore_lock = (safe_strcmp(g_getenv("SRCDIR"), ".") != 0);
    qof_session_begin(session, filename, ignore_lock, FALSE, TRUE);

    qof_session_load(session, NULL);
    book = qof_session_get_book (session);

    root = gnc_book_get_root_account(book);
    do_test (gnc_account_get_book (root) == book,
             "book and root account don't match");

    do_test_args(qof_session_get_error(session) == ERR_BACKEND_NO_ERR,
                 "session load xml2", __FILE__, __LINE__,
                 "qof error=%d for file [%s]",
                 qof_session_get_error(session), filename);
    /* Uncomment the line below to generate corrected files */
    qof_session_save( session, NULL );
    qof_session_end(session);
}
开发者ID:nishmu,项目名称:gnucash,代码行数:35,代码来源:test-load-xml2.c

示例8: check_cb

static void
check_cb (QofInstance *ent, gpointer data)
{
    QofInstance *parent, *child;
    QofCollection *coll;
    struct tally *c;
    const QofParam *param;
    mygrand  *testg;
    myparent *testp;
    mychild  *testc;

    c = (struct tally*)data;
    /* check the same number and type of entities
    exist in the copied book */
    testg = (mygrand*)ent;
    /* we always have a grandparent */
    do_test((testg != NULL), "grandparent not found");
    c->total++;
    param = qof_class_get_parameter(GRAND_MODULE_NAME, OBJ_LIST);
    coll = (QofCollection*)param->param_getfcn(ent, param);
    c->collect = qof_collection_count(coll);
    if (c->book)
    {
        qof_book_set_references(c->book);
    }
    param = qof_class_get_parameter(GRAND_MODULE_NAME, OBJ_RELATIVE);
    parent = QOF_INSTANCE(param->param_getfcn(ent, param));
    testp = grand_getChild((mygrand*)ent);
    /* not all grandparents have family so just keep count. */
    if (!parent)
    {
        c->nulls++;
        return;
    }
    do_test((0 == safe_strcmp(parent_getName(testp),
                              parent_getName((myparent*)parent))), "parent copy test");
    param = qof_class_get_parameter(PARENT_MODULE_NAME, OBJ_RELATIVE);
    child = param->param_getfcn(parent, param);
    testc = parent_getChild((myparent*)parent);
    if (!child)
    {
        c->nulls++;
        return;
    }
    do_test((0 == safe_strcmp(child_getName(testc),
                              child_getName((mychild*)child))), "child copy test");
}
开发者ID:nizarklai,项目名称:gnucash-1,代码行数:47,代码来源:test-recursive.c

示例9: find_appropriate_node

static xmlNodePtr
find_appropriate_node(xmlNodePtr node, Split *spl)
{
    xmlNodePtr mark;

    for (mark = node->xmlChildrenNode; mark; mark = mark->next)
    {
        gboolean account_guid_good = FALSE;
        gboolean amount_good = FALSE;
        xmlNodePtr mark2;

        for (mark2 = mark->xmlChildrenNode; mark2; mark2 = mark2->next)
        {
            if (safe_strcmp((char*)mark2->name, "split:value") == 0)
            {
                gnc_numeric *num = dom_tree_to_gnc_numeric(mark2);

                if (gnc_numeric_equal(*num, xaccSplitGetValue(spl)))
                {
                    amount_good = TRUE;
                }

                g_free(num);
            }
            else if (safe_strcmp((char*)mark2->name, "split:account") == 0)
            {
                GncGUID *accid = dom_tree_to_guid(mark2);
                Account *account = xaccSplitGetAccount (spl);

                if (guid_equal(accid, xaccAccountGetGUID(account)))
                {
                    account_guid_good = TRUE;
                }
                g_free(accid);
            }

            if (account_guid_good && amount_good)
            {
                return mark;
            }
        }
    }

    return NULL;
}
开发者ID:kleopatra999,项目名称:gnucash-2,代码行数:45,代码来源:test-xml-transaction.c

示例10: gnc_query_list_set_query_sort

/********************************************************************\
 * gnc_query_list_set_query_sort                                    *
 *   sets the sorting order of entries in the list                  *
 *                                                                  *
 * Args: list       - list to change the sort order for             *
 *	 new_column - is this a new column (so should we set the    *
 *                    query sort order or just set the 'increasing' *
 * Returns: nothing                                                 *
\********************************************************************/
static void
gnc_query_list_set_query_sort (GNCQueryList *list, gboolean new_column)
{
    gboolean sort_order = list->increasing;
    GList *node;
    GNCSearchParam *param;

    /* Find the column parameter definition */
    node = g_list_nth(list->column_params, list->sort_column);
    param = node->data;

    /* If we're asked to invert numerics, and if this is a numeric or
     * debred column, then invert the sort order.
     */
    if (list->numeric_inv_sort)
    {
        const char *type = gnc_search_param_get_param_type (param);
        if (!safe_strcmp(type, QOF_TYPE_NUMERIC) ||
                !safe_strcmp(type, QOF_TYPE_DEBCRED))
            sort_order = !sort_order;
    }

    /* Set the sort order for the engine, if the key changed */
    if (new_column)
    {
        GSList *p1, *p2;

        p1 = gnc_search_param_get_param_path(param);
        p2 = g_slist_prepend(NULL, QUERY_DEFAULT_SORT);
        qof_query_set_sort_order (list->query, p1, p2, NULL);
    }

    qof_query_set_sort_increasing (list->query,
                                   sort_order,
                                   sort_order,
                                   sort_order);

    /*
     * Recompute the list. Is this really necessary? Why not just sort
     * the rows already in the clist?  Answer: it would be an n-squared
     * algorithm to get the clist to match the resulting list.
     */
    gnc_query_list_refresh(list);
}
开发者ID:nishmu,项目名称:gnucash,代码行数:53,代码来源:gnc-query-list.c

示例11: set_value_combo_cell

static void set_value_combo_cell(BasicCell *cell, const char *new_value)
{
    if (!cell || !new_value)
        return;
    if (safe_strcmp (new_value, gnc_basic_cell_get_value (cell)) == 0)
        return;

    gnc_combo_cell_set_value ((ComboCell *) cell, new_value);
    gnc_basic_cell_set_changed (cell, TRUE);
}
开发者ID:nishmu,项目名称:gnucash,代码行数:10,代码来源:gncEntryLedgerControl.c

示例12: recurrenceWeekendAdjustFromString

WeekendAdjust
recurrenceWeekendAdjustFromString(const gchar *str)
{
    int i;

    for (i = 0; i < NUM_WEEKEND_ADJS; i++)
        if (safe_strcmp(weekend_adj_strings[i], str) == 0)
            return i;
    return -1;
}
开发者ID:nizarklai,项目名称:gnucash-1,代码行数:10,代码来源:Recurrence.c

示例13: g_vfs_icon_equal

static gboolean
g_vfs_icon_equal (GIcon *icon1,
                  GIcon *icon2)
{
  GVfsIcon *vfs1 = G_VFS_ICON (icon1);
  GVfsIcon *vfs2 = G_VFS_ICON (icon2);

  return g_mount_spec_equal (vfs1->mount_spec, vfs2->mount_spec) &&
    (safe_strcmp (vfs1->icon_id, vfs2->icon_id) == 0);
}
开发者ID:Alustriel,项目名称:gvfs,代码行数:10,代码来源:gvfsicon.c

示例14: seatcmp

static int seatcmp(GGZSeat seat1, GGZSeat seat2)
{
	if (seat1.num == seat2.num 
	    && seat1.type == seat2.type
	    && seat1.fd == seat2.fd
	    && safe_strcmp(seat1.name, seat2.name) == 0)
		return 0;
	else
		return -1;
}
开发者ID:ralight,项目名称:ggz,代码行数:10,代码来源:basic.c

示例15: sizeof

ir_expression_operation
ir_expression::get_operator(const char *str)
{
   const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]);
   for (int op = 0; op < operator_count; op++) {
      if (safe_strcmp(str, operator_strs[op]) == 0)
	 return (ir_expression_operation) op;
   }
   return (ir_expression_operation) -1;
}
开发者ID:1065672644894730302,项目名称:Chromium,代码行数:10,代码来源:ir.cpp


注:本文中的safe_strcmp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。