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


C++ STRNCMP函数代码示例

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


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

示例1: test2

void test2()
{
    const char* src = "100 120\n"
                      "0 process0 2 10 1 1 2 2\n"
                      "0 process1 2 10 1 1 2 2\n"
                      "0 process2 2 10 1 1 2 2\n"
                      "0 process3 2 10 1 1 2 2\n";

    mm_simulator_t* simulator = mm_simulator_parse(src);

    ASSERT(simulator->physical && simulator->virtual,
           "Must have created physical and virtual memories");
    ASSERT(simulator->physical->size == 100, "");
    ASSERT(simulator->virtual->size == 120, "");
    ASSERT(simulator->process_count == 4, "");

    ASSERT(simulator->processes[0]->t0 == 0, "");
    STRNCMP(simulator->processes[0]->pname, "process0");
    ASSERT(simulator->processes[0]->access_count == 2, "");
    ASSERT(simulator->processes[0]->access[0].position == 1, "");
    ASSERT(simulator->processes[0]->access[0].time == 1, "");

    STRNCMP(simulator->processes[1]->pname, "process1");
    STRNCMP(simulator->processes[2]->pname, "process2");
    STRNCMP(simulator->processes[3]->pname, "process3");

    while (simulator->process_count-- > 0)
        mm_process_destroy(simulator->processes[simulator->process_count]);
    mm_simulator_destroy(simulator);
}
开发者ID:cirocosta,项目名称:memman,代码行数:30,代码来源:test-simulator.c

示例2: MemChecker_ParseLineCB

void MemChecker_ParseLineCB(void *pUser, const char *pszKey, int nKeyLen, const char *pszValue, int nValueLen)
{
    MemChecker *pMe = (MemChecker *)pUser;
    char *pszValueCopy = NULL;

    pszValueCopy = MALLOC(nValueLen + 1);
    if (NULL == pszValueCopy) {
        return;
    }
    MEMCPY(pszValueCopy, pszValue, nValueLen);

    if (0 == STRNCMP("ClassID", pszKey, nKeyLen))
    {
        if (STRBEGINS("0x", pszValueCopy)) {
            pMe->m_clsCheckedApp = STRTOUL(pszValueCopy, NULL, 16);
        } else {
            pMe->m_clsCheckedApp = ATOI(pszValueCopy);
        }
    }
    else if (0 == STRNCMP("OutputTo", pszKey, nKeyLen))
    {
        pMe->m_eOutputMode = ATOI(pszValueCopy);
    }

    FREEIF(pszValueCopy);
}
开发者ID:virqin,项目名称:brew_code,代码行数:26,代码来源:MemChecker.c

示例3: test3

void test3()
{
  const char* msg =
      ":levin.mozilla.org NOTICE Auth :*** Looking up your hostname...\r\n";

  yi_buffer_t* buf = yi_buffer_create(msg, strlen(msg));

  // prefix = levin.mozilla.org
  ASSERT(yi_lex_prefix(buf), "");
  ASSERT(buf->token->type == YI_T_PREFIX_HOSTNAME, "");
  STRNCMP(buf->token->buf, "levin.mozilla.org");

  // textual command
  ASSERT(yi_lex_command(buf), "");
  ASSERT(buf->token->type == YI_T_COMMAND, "");
  STRNCMP(buf->token->buf, "NOTICE");

  // parameter
  ASSERT(yi_lex_param_middle(buf), "");
  ASSERT(buf->token->type == YI_T_PARAM, "");
  STRNCMP(buf->token->buf, "Auth");

  // parameter
  ASSERT(yi_lex_param_trailing(buf), "");
  ASSERT(buf->token->type == YI_T_PARAM, "");
  STRNCMP(buf->token->buf, "*** Looking up your hostname...");

  // crlf
  ASSERT(yi_lex_terminal(buf, "\r\n", 2), "tokenize crlf");
  ASSERT(buf->token->type == YI_T_TERMINAL, "it's a terminal!");

  yi_buffer_destroy(buf);
}
开发者ID:cirocosta,项目名称:yairc,代码行数:33,代码来源:test-lexer.c

示例4: test2

void test2()
{
  const char* msg =
      ":levin.mozilla.org 376 guest :End of message of the day.\r\n";

  yi_buffer_t* buf = yi_buffer_create(msg, strlen(msg));

  // prefix = levin.mozilla.org
  ASSERT(yi_lex_prefix(buf), "");
  ASSERT(buf->token->type == YI_T_PREFIX_HOSTNAME, "");
  STRNCMP(buf->token->buf, "levin.mozilla.org");

  // numeric command
  ASSERT(yi_lex_command(buf), "");
  ASSERT(buf->token->type == YI_T_COMMAND, "");
  STRNCMP(buf->token->buf, "376");

  // parameter
  ASSERT(yi_lex_param_middle(buf), "");
  ASSERT(buf->token->type == YI_T_PARAM, "");
  STRNCMP(buf->token->buf, "guest");

  // parameter
  ASSERT(yi_lex_param_trailing(buf), "");
  ASSERT(buf->token->type == YI_T_PARAM, "");
  STRNCMP(buf->token->buf, "End of message of the day.");

  yi_buffer_destroy(buf);
}
开发者ID:cirocosta,项目名称:yairc,代码行数:29,代码来源:test-lexer.c

示例5: test5

void test5()
{
  const char* msg = ":[email protected] NOTICE guest "
                    ":please choose a different nick.\r\n";

  yi_buffer_t* buf = yi_buffer_create(msg, strlen(msg));

  // nicknamed prefix
  ASSERT(yi_lex_prefix(buf), "");
  ASSERT(buf->token->type == YI_T_PREFIX_NICKNAME, "");
  STRNCMP(buf->token->buf, "[email protected]");

  // textual command
  ASSERT(yi_lex_command(buf), "");
  ASSERT(buf->token->type == YI_T_COMMAND, "");
  STRNCMP(buf->token->buf, "NOTICE");

  // parameter
  ASSERT(yi_lex_param_middle(buf), "");
  ASSERT(buf->token->type == YI_T_PARAM, "");
  STRNCMP(buf->token->buf, "guest");

  // parameter
  ASSERT(yi_lex_param_trailing(buf), "");
  ASSERT(buf->token->type == YI_T_PARAM, "");
  STRNCMP(buf->token->buf, "please choose a different nick.");

  // crlf
  ASSERT(yi_lex_terminal(buf, "\r\n", 2), "tokenize crlf");
  ASSERT(buf->token->type == YI_T_TERMINAL, "it's a terminal!");

  yi_buffer_destroy(buf);
}
开发者ID:cirocosta,项目名称:yairc,代码行数:33,代码来源:test-lexer.c

示例6: if

/// Like hash_find(), but caller computes "hash".
///
/// @param[in]  key  The key of the looked-for item. Must not be NULL.
/// @param[in]  key_len  Key length.
/// @param[in]  hash  The precomputed hash for the key.
///
/// @return Pointer to the hashitem corresponding to the given key.
///         If not found, then return pointer to the empty item that would be
///         used for that key.
///         WARNING: Returned pointer becomes invalid as soon as the hash table
///                  is changed in any way.
hashitem_T *hash_lookup(hashtab_T *const ht,
                        const char *const key, const size_t key_len,
                        const hash_T hash)
{
#ifdef HT_DEBUG
  hash_count_lookup++;
#endif  // ifdef HT_DEBUG

  // Quickly handle the most common situations:
  // - return if there is no item at all
  // - skip over a removed item
  // - return if the item matches
  hash_T idx = hash & ht->ht_mask;
  hashitem_T *hi = &ht->ht_array[idx];

  if (hi->hi_key == NULL) {
    return hi;
  }

  hashitem_T *freeitem = NULL;
  if (hi->hi_key == HI_KEY_REMOVED) {
    freeitem = hi;
  } else if ((hi->hi_hash == hash)
             && (STRNCMP(hi->hi_key, key, key_len) == 0)
             && hi->hi_key[key_len] == NUL) {
    return hi;
  }

  // Need to search through the table to find the key. The algorithm
  // to step through the table starts with large steps, gradually becoming
  // smaller down to (1/4 table size + 1). This means it goes through all
  // table entries in the end.
  // When we run into a NULL key it's clear that the key isn't there.
  // Return the first available slot found (can be a slot of a removed
  // item).
  for (hash_T perturb = hash;; perturb >>= PERTURB_SHIFT) {
#ifdef HT_DEBUG
    // count a "miss" for hashtab lookup
    hash_count_perturb++;
#endif  // ifdef HT_DEBUG
    idx = 5 * idx + perturb + 1;
    hi = &ht->ht_array[idx & ht->ht_mask];

    if (hi->hi_key == NULL) {
      return freeitem == NULL ? hi : freeitem;
    }

    if ((hi->hi_hash == hash)
        && (hi->hi_key != HI_KEY_REMOVED)
        && (STRNCMP(hi->hi_key, key, key_len) == 0)
        && hi->hi_key[key_len] == NUL) {
      return hi;
    }

    if ((hi->hi_key == HI_KEY_REMOVED) && (freeitem == NULL)) {
      freeitem = hi;
    }
  }
}
开发者ID:chengyi818,项目名称:neovim,代码行数:70,代码来源:hashtab.c

示例7: sign_define_cmd

/*
 * ":sign define {name} ..." command
 */
    static void
sign_define_cmd(char_u *sign_name, char_u *cmdline)
{
    char_u	*arg;
    char_u	*p = cmdline;
    char_u	*icon = NULL;
    char_u	*text = NULL;
    char_u	*linehl = NULL;
    char_u	*texthl = NULL;
    int failed = FALSE;

    // set values for a defined sign.
    for (;;)
    {
	arg = skipwhite(p);
	if (*arg == NUL)
	    break;
	p = skiptowhite_esc(arg);
	if (STRNCMP(arg, "icon=", 5) == 0)
	{
	    arg += 5;
	    icon = vim_strnsave(arg, (int)(p - arg));
	}
	else if (STRNCMP(arg, "text=", 5) == 0)
	{
	    arg += 5;
	    text = vim_strnsave(arg, (int)(p - arg));
	}
	else if (STRNCMP(arg, "linehl=", 7) == 0)
	{
	    arg += 7;
	    linehl = vim_strnsave(arg, (int)(p - arg));
	}
	else if (STRNCMP(arg, "texthl=", 7) == 0)
	{
	    arg += 7;
	    texthl = vim_strnsave(arg, (int)(p - arg));
	}
	else
	{
	    semsg(_(e_invarg2), arg);
	    failed = TRUE;
	    break;
	}
    }

    if (!failed)
	sign_define_by_name(sign_name, icon, linehl, text, texthl);

    vim_free(icon);
    vim_free(text);
    vim_free(linehl);
    vim_free(texthl);
}
开发者ID:Snaptags,项目名称:vim,代码行数:57,代码来源:sign.c

示例8: acpi_db_unload_acpi_table

void
acpi_db_unload_acpi_table (
	NATIVE_CHAR             *table_arg,
	NATIVE_CHAR             *instance_arg)
{
	u32                     i;
	acpi_status             status;


	/* Search all tables for the target type */

	for (i = 0; i < NUM_ACPI_TABLES; i++) {
		if (!STRNCMP (table_arg, acpi_gbl_acpi_table_data[i].signature,
				acpi_gbl_acpi_table_data[i].sig_length)) {
			/* Found the table, unload it */

			status = acpi_unload_table (i);
			if (ACPI_SUCCESS (status)) {
				acpi_os_printf ("[%s] unloaded and uninstalled\n", table_arg);
			}
			else {
				acpi_os_printf ("%s, while unloading [%s]\n",
					acpi_format_exception (status), table_arg);
			}

			return;
		}
	}

	acpi_os_printf ("Unknown table type [%s]\n", table_arg);
}
开发者ID:GunioRobot,项目名称:MI424WR_GEN2_Rev_E-F,代码行数:31,代码来源:dbcmds.c

示例9:

/* get an item from a list with the given name */
static generic_item *GetItemFromList(generic_item * list, const char *name)
{
	generic_item *curr;

	for (curr = list; curr != NULL; curr = curr->next) {
		if ((curr->type == TYPE_BLOCK)
		    && !STRNCMP(curr->item.block.block_name, name, MAXSTRLEN))
			return curr;
		if ((curr->type == TYPE_AFFECT)
		    && !STRNCMP(curr->item.affect.varname, name, MAXSTRLEN))
			return curr;
	}
	/* not found */
	return NULL;

}
开发者ID:asias,项目名称:nfs-ganesha,代码行数:17,代码来源:config_parsing.c

示例10: os_nodetype

/// Check what `name` is:
/// @return NODE_NORMAL: file or directory (or doesn't exist)
///         NODE_WRITABLE: writable device, socket, fifo, etc.
///         NODE_OTHER: non-writable things
int os_nodetype(const char *name)
{
#ifdef WIN32
  // Edge case from Vim os_win32.c:
  // We can't open a file with a name "\\.\con" or "\\.\prn", trying to read
  // from it later will cause Vim to hang. Thus return NODE_WRITABLE here.
  if (STRNCMP(name, "\\\\.\\", 4) == 0) {
    return NODE_WRITABLE;
  }
#endif

  uv_stat_t statbuf;
  if (0 != os_stat(name, &statbuf)) {
    return NODE_NORMAL;  // File doesn't exist.
  }

#ifndef WIN32
  // libuv does not handle BLK and DIR in uv_handle_type.
  //    Related: https://github.com/joyent/libuv/pull/1421
  if (S_ISREG(statbuf.st_mode) || S_ISDIR(statbuf.st_mode)) {
    return NODE_NORMAL;
  }
  if (S_ISBLK(statbuf.st_mode)) {  // block device isn't writable
    return NODE_OTHER;
  }
#endif

  // Vim os_win32.c:mch_nodetype does this (since patch 7.4.015):
  //    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) {
  //      wn = enc_to_utf16(name, NULL);
  //      hFile = CreatFile(wn, ...)
  // to get a HANDLE. But libuv just calls win32's _get_osfhandle() on the fd we
  // give it. uv_fs_open calls fs__capture_path which does a similar dance and
  // saves us the hassle.

  int nodetype = NODE_WRITABLE;
  int fd = os_open(name, O_RDONLY, 0);
  switch(uv_guess_handle(fd)) {
    case UV_TTY:         // FILE_TYPE_CHAR
      nodetype = NODE_WRITABLE;
      break;
    case UV_FILE:        // FILE_TYPE_DISK
      nodetype = NODE_NORMAL;
      break;
    case UV_NAMED_PIPE:  // not handled explicitly in Vim os_win32.c
    case UV_UDP:         // unix only
    case UV_TCP:         // unix only
    case UV_UNKNOWN_HANDLE:
    default:
#ifdef WIN32
      nodetype = NODE_NORMAL;
#else
      nodetype = NODE_WRITABLE;  // Everything else is writable?
#endif
      break;
  }

  close(fd);
  return nodetype;
}
开发者ID:DINKIN,项目名称:neovim,代码行数:64,代码来源:fs.c

示例11: free

/*
 * Lookup part of a menu name in the translations.
 * Return a pointer to the translation or NULL if not found.
 */
static char_u *menutrans_lookup(char_u *name, int len)
{
  menutrans_T         *tp = (menutrans_T *)menutrans_ga.ga_data;
  char_u              *dname;

  for (int i = 0; i < menutrans_ga.ga_len; ++i) {
    if (STRNCMP(name, tp[i].from, len) == 0 && tp[i].from[len] == NUL) {
      return tp[i].to;
    }
  }

  /* Now try again while ignoring '&' characters. */
  char c = name[len];
  name[len] = NUL;
  dname = menu_text(name, NULL, NULL);
  name[len] = c;
  if (dname != NULL) {
    for (int i = 0; i < menutrans_ga.ga_len; ++i) {
      if (STRCMP(dname, tp[i].from_noamp) == 0) {
        free(dname);
        return tp[i].to;
      }
    }
    free(dname);
  }

  return NULL;
}
开发者ID:Happy-Dude,项目名称:neovim,代码行数:32,代码来源:menu.c

示例12: default_parameters

void factor_vm::init_parameters_from_args(vm_parameters *p, int argc, vm_char **argv)
{
	default_parameters(p);
	p->executable_path = argv[0];

	int i = 0;

	for(i = 1; i < argc; i++)
	{
		vm_char *arg = argv[i];
		if(STRCMP(arg,STRING_LITERAL("--")) == 0) break;
		else if(factor_arg(arg,STRING_LITERAL("-datastack=%d"),&p->datastack_size));
		else if(factor_arg(arg,STRING_LITERAL("-retainstack=%d"),&p->retainstack_size));
		else if(factor_arg(arg,STRING_LITERAL("-callstack=%d"),&p->callstack_size));
		else if(factor_arg(arg,STRING_LITERAL("-young=%d"),&p->young_size));
		else if(factor_arg(arg,STRING_LITERAL("-aging=%d"),&p->aging_size));
		else if(factor_arg(arg,STRING_LITERAL("-tenured=%d"),&p->tenured_size));
		else if(factor_arg(arg,STRING_LITERAL("-codeheap=%d"),&p->code_size));
		else if(factor_arg(arg,STRING_LITERAL("-pic=%d"),&p->max_pic_size));
		else if(factor_arg(arg,STRING_LITERAL("-callbacks=%d"),&p->callback_size));
		else if(STRCMP(arg,STRING_LITERAL("-fep")) == 0) p->fep = true;
		else if(STRCMP(arg,STRING_LITERAL("-nosignals")) == 0) p->signals = false;
		else if(STRNCMP(arg,STRING_LITERAL("-i="),3) == 0) p->image_path = arg + 3;
		else if(STRCMP(arg,STRING_LITERAL("-console")) == 0) p->console = true;
	}
}
开发者ID:bogiebro,项目名称:factor,代码行数:26,代码来源:factor.cpp

示例13: hrt_acpi_scan_memory_for_rsdp

/*******************************************************************************
 *
 * FUNCTION:    hrt_acpi_scan_memory_for_rsdp
 *
 * PARAMETERS:  Start_address       - Starting pointer for search
 *              Length              - Maximum length to search
 *
 * RETURN:      Pointer to the RSDP if found, otherwise NULL.
 *
 * DESCRIPTION: Search a block of memory for the RSDP signature
 *
 ******************************************************************************/
static __init u8 *
hrt_acpi_scan_memory_for_rsdp(u8 * start_address, u32 length)
{
	u32 offset;
	u8 *mem_rover;

	/* Search from given start addr for the requested length  */

	for (offset = 0, mem_rover = start_address;
	     offset < length;
	     offset += ACPI_RSDP_SCAN_STEP, mem_rover += ACPI_RSDP_SCAN_STEP) {

		/* The signature and checksum must both be correct */

		if (STRNCMP((NATIVE_CHAR *) mem_rover,
			    RSDP_SIG, sizeof (RSDP_SIG) - 1) == 0 &&
		    hrt_acpi_checksum(mem_rover, RSDP_CHECKSUM_LENGTH) == 0) {
			/* If so, we have found the RSDP */

			;
			return (mem_rover);
		}
	}

	/* Searched entire block, no RSDP was found */

	return (NULL);
}
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:40,代码来源:high-res-tbxfroot.c

示例14: flash_device_listup

void flash_device_listup(struct flash_listup *t)
{
	const wgChar *str;
	HSQUIRRELVM v = qr_open(NULL);
	SQInteger top = sq_gettop(v);

	if(SQ_FAILED(sqstd_dofile(v, _SC("flashdevice.nut"), SQFalse, SQTrue))){
//		puts("flash device script error");
		qr_close(v);
		return;
	}

	int i;
	const int device_num = flash_device_number_get(v);
	sq_settop(v, top);

	for(i = 0; i < device_num; i++){
		flash_device_name_get(v, i, &str);
		if(STRNCMP(str, _SC("dummy"), 6) != 0){
			t->append(t->obj_cpu, str);
			t->append(t->obj_ppu, str);
		}
		sq_settop(v, top);
	}

	qr_close(v);
	v = NULL;
}
开发者ID:ericandre615,项目名称:unagi_client,代码行数:28,代码来源:flash_device.c

示例15: CheckDuplicateEntry

/**
 * \retval 0 if the entry is unique in the list
 * \retval != if there are several items with this name in the list
 */
static int CheckDuplicateEntry(generic_item * list, const char *name)
{
	generic_item *curr;
	unsigned int found = 0;

	for (curr = list; curr != NULL; curr = curr->next) {
		if ((curr->type == TYPE_BLOCK)
		    && !STRNCMP(curr->item.block.block_name, name, MAXSTRLEN))
			found++;
		if ((curr->type == TYPE_AFFECT)
		    && !STRNCMP(curr->item.affect.varname, name, MAXSTRLEN))
			found++;
		if (found > 1)
			break;
	}
	return (found > 1);
}
开发者ID:asias,项目名称:nfs-ganesha,代码行数:21,代码来源:config_parsing.c


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