本文整理汇总了C++中STR_EQ函数的典型用法代码示例。如果您正苦于以下问题:C++ STR_EQ函数的具体用法?C++ STR_EQ怎么用?C++ STR_EQ使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STR_EQ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: S_run_basic_tests
static void
S_run_basic_tests(CFCTest *test) {
CFCParcel *neato_parcel = CFCParcel_new("Neato", NULL, NULL, NULL);
CFCParcel_register(neato_parcel);
CFCType *type = CFCType_new(0, neato_parcel, "mytype_t", 0);
OK(test, CFCType_get_parcel(type) == neato_parcel, "get_parcel");
STR_EQ(test, CFCType_to_c(type), "mytype_t", "to_c");
STR_EQ(test, CFCType_get_specifier(type), "mytype_t", "get_specifier");
#define TEST_BOOL_ACCESSOR(type, name) \
OK(test, !CFCType_ ## name(type), #name " false by default");
TEST_BOOL_ACCESSOR(type, const);
TEST_BOOL_ACCESSOR(type, nullable);
TEST_BOOL_ACCESSOR(type, incremented);
TEST_BOOL_ACCESSOR(type, decremented);
TEST_BOOL_ACCESSOR(type, is_void);
TEST_BOOL_ACCESSOR(type, is_object);
TEST_BOOL_ACCESSOR(type, is_primitive);
TEST_BOOL_ACCESSOR(type, is_integer);
TEST_BOOL_ACCESSOR(type, is_floating);
TEST_BOOL_ACCESSOR(type, is_string_type);
TEST_BOOL_ACCESSOR(type, is_va_list);
TEST_BOOL_ACCESSOR(type, is_arbitrary);
TEST_BOOL_ACCESSOR(type, is_composite);
CFCBase_decref((CFCBase*)neato_parcel);
CFCBase_decref((CFCBase*)type);
CFCParcel_reap_singletons();
}
示例2: S_run_void_tests
static void
S_run_void_tests(CFCTest *test) {
CFCParser *parser = CFCParser_new();
{
CFCType *type = CFCType_new_void(false);
STR_EQ(test, CFCType_get_specifier(type), "void", "get_specifier");
STR_EQ(test, CFCType_to_c(type), "void", "to_c");
OK(test, CFCType_is_void(type), "is_void");
CFCBase_decref((CFCBase*)type);
}
{
CFCType *type = CFCType_new_void(true);
STR_EQ(test, CFCType_to_c(type), "const void",
"'const' in C representation");
CFCBase_decref((CFCBase*)type);
}
{
CFCType *type = CFCTest_parse_type(test, parser, "void");
OK(test, CFCType_is_void(type), "void is_void");
CFCBase_decref((CFCBase*)type);
}
{
CFCType *type = CFCTest_parse_type(test, parser, "const void");
OK(test, CFCType_is_void(type), "const void is_void");
OK(test, CFCType_const(type), "const void is const");
CFCBase_decref((CFCBase*)type);
}
CFCBase_decref((CFCBase*)parser);
}
示例3: render_html
static void
render_html(test_batch_runner *runner)
{
char *html;
static const char markdown[] =
"foo *bar*\n"
"\n"
"paragraph 2\n";
cmark_node *doc = cmark_parse_document(markdown, sizeof(markdown) - 1,
CMARK_OPT_DEFAULT);
cmark_node *paragraph = cmark_node_first_child(doc);
html = cmark_render_html(paragraph, CMARK_OPT_DEFAULT);
STR_EQ(runner, html, "<p>foo <em>bar</em></p>\n",
"render single paragraph");
free(html);
cmark_node *string = cmark_node_first_child(paragraph);
html = cmark_render_html(string, CMARK_OPT_DEFAULT);
STR_EQ(runner, html, "foo ", "render single inline");
free(html);
cmark_node *emph = cmark_node_next(string);
html = cmark_render_html(emph, CMARK_OPT_DEFAULT);
STR_EQ(runner, html, "<em>bar</em>", "render inline with children");
free(html);
cmark_node_free(doc);
}
示例4: set_dmq_node_params
/**
* @brief set the parameters for the node
*/
int set_dmq_node_params(dmq_node_t *node, param_t *params)
{
str *status;
if(!params) {
LM_DBG("no parameters given\n");
return 0;
}
status = get_param_value(params, &dmq_node_status_str);
if(status) {
if(STR_EQ(*status, dmq_node_active_str)) {
node->status = DMQ_NODE_ACTIVE;
} else if(STR_EQ(*status, dmq_node_timeout_str)) {
node->status = DMQ_NODE_TIMEOUT;
} else if(STR_EQ(*status, dmq_node_disabled_str)) {
node->status = DMQ_NODE_DISABLED;
} else if(STR_EQ(*status, dmq_node_pending_str)) {
node->status = DMQ_NODE_PENDING;
} else {
LM_ERR("invalid status parameter: %.*s\n", STR_FMT(status));
goto error;
}
}
return 0;
error:
return -1;
}
示例5: S_run_tests
static void
S_run_tests(CFCTest *test) {
CFCParser *parser = CFCParser_new();
{
CFCCBlock *block = CFCCBlock_new("int foo;");
STR_EQ(test, CFCCBlock_get_contents(block), "int foo;",
"get_contents");
CFCBase_decref((CFCBase*)block);
}
{
const char *cblock_string =
" __C__\n"
"#define FOO_BAR 1\n"
"__END_C__ ";
CFCBase *result = CFCParser_parse(parser, cblock_string);
OK(test, result != NULL, "parse cblock");
STR_EQ(test, CFCBase_get_cfc_class(result),
"Clownfish::CFC::Model::CBlock", "result class of cblock");
CFCCBlock *block = (CFCCBlock*)result;
STR_EQ(test, CFCCBlock_get_contents(block), "#define FOO_BAR 1\n",
"parse embed_c");
CFCBase_decref((CFCBase*)block);
}
CFCBase_decref((CFCBase*)parser);
}
示例6: cmp_dmq_node
/**
* @brief compare dmq node addresses
*/
int cmp_dmq_node(dmq_node_t *node, dmq_node_t *cmpnode)
{
if(!node || !cmpnode) {
LM_ERR("cmp_dmq_node - null node received\n");
return -1;
}
return STR_EQ(node->uri.host, cmpnode->uri.host)
&& STR_EQ(node->uri.port, cmpnode->uri.port);
}
示例7: malloc
char *test_parse_store()
{
char *resp, buf[BUFSIZE];
parsed_text *parsed = malloc(sizeof(parsed_text));
prime_buf(buf, "set");
resp = parse_store(buf, parsed);
mu_assert("set != key_error", STR_EQ(resp, "CLIENT_ERROR: no key received\r\n"));
prime_buf(buf, "set ");
resp = parse_store(buf, parsed);
mu_assert("set[space] != key_error", STR_EQ(resp, "CLIENT_ERROR: no key received\r\n"));
prime_buf(buf, "set foo");
resp = parse_store(buf, parsed);
mu_assert("set foo != flags error", STR_EQ(resp, "CLIENT_ERROR: no flags received\r\n"));
prime_buf(buf, "set foo 14hi");
resp = parse_store(buf, parsed);
mu_assert("set foo 14hi != flag convert error", STR_EQ(resp, "CLIENT_ERROR: flags not number\r\n"));
prime_buf(buf, "set foo bar");
resp = parse_store(buf, parsed);
mu_assert("set foo 14hi != flag convert error", STR_EQ(resp, "CLIENT_ERROR: flags not number\r\n"));
prime_buf(buf, "set foo 17");
resp = parse_store(buf, parsed);
mu_assert("set foo 17 != no exptime error", STR_EQ(resp, "CLIENT_ERROR: no exptime received\r\n"));
prime_buf(buf, "set foo 17 bar");
resp = parse_store(buf, parsed);
mu_assert("set foo 17 bar != exptime convert error", STR_EQ(resp, "CLIENT_ERROR: exptime not number\r\n"));
prime_buf(buf, "set foo 17 12");
resp = parse_store(buf, parsed);
mu_assert("set foo 17 12 != bytes error", STR_EQ(resp, "CLIENT_ERROR: no bytes (length) received\r\n"));
prime_buf(buf, "set foo 17 12 14ar");
resp = parse_store(buf, parsed);
mu_assert("set foo 17 12 14ar != bytes error", STR_EQ(resp, "CLIENT_ERROR: bytes not number\r\n"));
prime_buf(buf, "set foo 17 12 14");
resp = parse_store(buf, parsed);
mu_assert("set foo 17 12 14 != NULL", (resp == NULL) && (!parsed->no_reply));
prime_buf(buf, "set foo 17 12 14 noreply");
resp = parse_store(buf, parsed);
mu_assert("set foo 17 12 14 noreply != NULL", ((resp == NULL) && parsed->no_reply));
prime_buf(buf, "set foo 17 12 14 foo");
resp = parse_store(buf, parsed);
mu_assert("set foo 17 12 14 foo != tokens error", STR_EQ(resp, "CLIENT_ERROR: too many tokens sent\r\n"));
return 0;
}
示例8: xbuff_match_type_re
int xbuff_match_type_re(str *s, xbuff_type_t *type, sr_xavp_t **addr)
{
size_t nmatch = 3;
regmatch_t matches[3];
int e;
size_t bfsz = 128;
char errbuff[128];
str tname;
str a;
xbuff_type_t t;
matches[0].rm_so = 0;
matches[0].rm_eo = s->len;
e = regexec(&xbuff_type_re,s->s,nmatch,matches,REG_STARTEND);
if (e == 0) {
tname.s = s->s + matches[1].rm_so;
tname.len = matches[1].rm_eo - matches[1].rm_so;
a.s = s->s + matches[2].rm_so;
a.len = matches[2].rm_eo - matches[1].rm_so;
if (STR_EQ(tname,xbuff_types[XBUFF_TYPE_ATOM])) {
t = XBUFF_TYPE_ATOM;
} else if (STR_EQ(tname,xbuff_types[XBUFF_TYPE_LIST])) {
t = XBUFF_TYPE_LIST;
} else if (STR_EQ(tname,xbuff_types[XBUFF_TYPE_TUPLE])) {
t = XBUFF_TYPE_TUPLE;
} else if (STR_EQ(tname,xbuff_types[XBUFF_TYPE_PID])) {
t = XBUFF_TYPE_PID;
} else if (STR_EQ(tname,xbuff_types[XBUFF_TYPE_REF])) {
t = XBUFF_TYPE_REF;
} else {
LM_ERR("BUG: unknown xbuff type");
return -1;
}
if(type) *type = t;
if (addr)
sscanf(a.s,"%lx>>",(long unsigned int *)addr);
return 0;
} else if (e != REG_NOMATCH) {
regerror(e,&xbuff_type_re,errbuff,bfsz);
LM_ERR("regexec error: %s\n",errbuff);
}
return -1;
}
示例9: S_run_integer_tests
static void
S_run_integer_tests(CFCTest *test) {
{
CFCType *type = CFCType_new_integer(CFCTYPE_CONST, "int32_t");
OK(test, CFCType_const(type), "const");
STR_EQ(test, CFCType_get_specifier(type), "int32_t", "get_specifier");
STR_EQ(test, CFCType_to_c(type), "const int32_t",
"'const' in C representation");
CFCBase_decref((CFCBase*)type);
}
{
CFCParser *parser = CFCParser_new();
static const char *specifiers[14] = {
"bool",
"char",
"short",
"int",
"long",
"size_t",
"int8_t",
"int16_t",
"int32_t",
"int64_t",
"uint8_t",
"uint16_t",
"uint32_t",
"uint64_t"
};
for (int i = 0; i < 14; ++i) {
const char *specifier = specifiers[i];
CFCType *type;
type = CFCTest_parse_type(test, parser, specifier);
OK(test, CFCType_is_integer(type), "%s is_integer", specifier);
CFCBase_decref((CFCBase*)type);
char *const_specifier = CFCUtil_sprintf("const %s", specifier);
type = CFCTest_parse_type(test, parser, const_specifier);
OK(test, CFCType_is_integer(type), "%s is_integer",
const_specifier);
OK(test, CFCType_const(type), "%s is const", const_specifier);
FREEMEM(const_specifier);
CFCBase_decref((CFCBase*)type);
}
CFCBase_decref((CFCBase*)parser);
}
}
示例10: notification_resp_callback_f
/**
* @brief notification response callback
*/
int notification_resp_callback_f(struct sip_msg* msg, int code,
dmq_node_t* node, void* param)
{
int ret;
int nodes_recv;
LM_DBG("notification_callback_f triggered [%p %d %p]\n", msg, code, param);
if(code == 200) {
nodes_recv = extract_node_list(node_list, msg);
LM_DBG("received %d new or changed nodes\n", nodes_recv);
if (dmq_init_callback_done && !*dmq_init_callback_done) {
*dmq_init_callback_done = 1;
run_init_callbacks();
}
} else if(code == 408) {
/* deleting node - the server did not respond */
LM_ERR("deleting server %.*s because of failed request\n", STR_FMT(&node->orig_uri));
if (STR_EQ(node->orig_uri, dmq_notification_address)) {
LM_ERR("not deleting notification_peer\n");
return 0;
}
ret = del_dmq_node(node_list, node);
LM_DBG("del_dmq_node returned %d\n", ret);
}
return 0;
}
示例11: lua_sr_push_xavp_name_table
/**
* creates and push a table for the key name in xavp
* if simple_flag is != 0 it will return only the first value
*/
static void lua_sr_push_xavp_name_table(lua_State *L, sr_xavp_t *xavp,
str name, const int simple_flag)
{
lua_Number i = 1;
lua_Number elem = 1;
sr_xavp_t *avp = xavp;
while(avp!=NULL&&!STR_EQ(avp->name,name))
{
avp = avp->next;
}
if(simple_flag==0) lua_newtable(L);
while(avp!=NULL){
if(simple_flag==0) lua_pushnumber(L, elem);
switch(avp->val.type) {
case SR_XTYPE_NULL:
lua_pushnil(L);
break;
case SR_XTYPE_INT:
i = avp->val.v.i;
lua_pushnumber(L, i);
break;
case SR_XTYPE_STR:
lua_pushlstring(L, avp->val.v.s.s, avp->val.v.s.len);
break;
case SR_XTYPE_TIME:
case SR_XTYPE_LONG:
case SR_XTYPE_LLONG:
case SR_XTYPE_DATA:
lua_pushnil(L);
LM_WARN("XAVP type:%d value not supported\n", avp->val.type);
break;
case SR_XTYPE_XAVP:
if(!lua_sr_push_xavp_table(L,avp->val.v.xavp, simple_flag)){
LM_ERR("xavp:%.*s subtable error. Nil value added\n",
avp->name.len, avp->name.s);
lua_pushnil(L);
}
break;
default:
LM_ERR("xavp:%.*s unknown type: %d. Nil value added\n",
avp->name.len, avp->name.s, avp->val.type);
lua_pushnil(L);
break;
}
if(simple_flag==0)
{
lua_rawset(L, -3);
elem = elem + 1;
avp = xavp_get_next(avp);
}
else {
lua_setfield(L, -2, name.s);
avp = NULL;
}
}
if(simple_flag==0) lua_setfield(L, -2, name.s);
}
示例12: PluginLoadGenericMultiple
static DWORD PluginLoadGenericMultiple(
_Inout_ LPTSTR names,
_Inout_ PBYTE pluginsArray,
_In_ DWORD max,
_In_ PLUGIN_TYPE const * const type
) {
DWORD count = 0;
DWORD i = 0;
LPTSTR pluginName = NULL;
LPTSTR ctx = NULL;
PPLUGIN_HEAD plugin = NULL;
while (StrNextToken(names, _T(","), &ctx, &pluginName)) {
LOG(Info, SUB_LOG(_T("Loading %s <%s>")), type->name, pluginName);
if (count >= max) {
FATAL(_T("Cannot load more than <%u> %ss"), max, type->name);
}
for (i = 0; i < count; i++) {
if (STR_EQ(pluginName, PLUGIN_GET_NAME((PPLUGIN_HEAD)(pluginsArray + (i * type->size))))) {
FATAL(_T("%s <%s> is already loaded"), type->name, pluginName);
}
}
plugin = (PPLUGIN_HEAD)(pluginsArray + (count * type->size));
PLUGIN_SET_NAME(plugin, pluginName);
PLUGIN_SET_TYPE(plugin, type);
PluginLoadGenericSingle(plugin);
count++;
}
return count;
}
示例13: internal_rpc_profile_print_dlgs
/*!
* \brief Helper function that outputs the dialogs belonging to a given profile via the RPC interface
* \see rpc_profile_print_dlgs
* \see rpc_profile_w_value_print_dlgs
* \param rpc RPC node that should be filled
* \param c RPC void pointer
* \param profile_name the given profile
* \param value the given profile value
* \param with_context if 1 then the dialog context will be also printed
*/
static void internal_rpc_profile_print_dlgs(rpc_t *rpc, void *c, str *profile_name,
str *value) {
dlg_profile_table_t *profile;
dlg_profile_hash_t *ph;
unsigned int i;
profile = search_dlg_profile( profile_name );
if (!profile) {
rpc->fault(c, 404, "Profile not found: %.*s",
profile_name->len, profile_name->s);
return;
}
/* go through the hash and print the dialogs */
if (profile->has_value==0)
value=NULL;
lock_get( &profile->lock );
for ( i=0 ; i< profile->size ; i++ ) {
ph = profile->entries[i].first;
if(ph) {
do {
if ((!value || (STR_EQ(*value, ph->value))) && ph->dlg) {
/* print dialog */
internal_rpc_print_dlg(rpc, c, ph->dlg, 0);
}
/* next */
ph=ph->next;
}while(ph!=profile->entries[i].first);
}
lock_release(&profile->lock);
}
}
示例14: version
static void
version(test_batch_runner *runner)
{
INT_EQ(runner, cmark_version, CMARK_VERSION, "cmark_version");
STR_EQ(runner, cmark_version_string, CMARK_VERSION_STRING,
"cmark_version_string");
}
示例15: _cfgt_get_obj_avp_vals
int _cfgt_get_obj_avp_vals(str name, sr_xavp_t *xavp, srjson_doc_t *jdoc, srjson_t **jobj)
{
sr_xavp_t *avp = NULL;
srjson_t *jobjt = NULL;
*jobj = srjson_CreateArray(jdoc);
if(*jobj==NULL)
{
LM_ERR("cannot create json object\n");
return -1;
}
avp = xavp;
while(avp!=NULL&&!STR_EQ(avp->name,name))
{
avp = avp->next;
}
while(avp!=NULL)
{
_cfgt_get_obj_xavp_val(avp, jdoc, &jobjt);
srjson_AddItemToArray(jdoc, *jobj, jobjt);
jobjt = NULL;
avp = xavp_get_next(avp);
}
return 0;
}