本文整理汇总了C++中IsItemIn函数的典型用法代码示例。如果您正苦于以下问题:C++ IsItemIn函数的具体用法?C++ IsItemIn怎么用?C++ IsItemIn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsItemIn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_purge_old_connections_purge_middle
static void test_purge_old_connections_purge_middle(void)
{
const time_t time_now = 100000;
Item *connections = NULL;
char time_str[64];
snprintf(time_str, sizeof(time_str), "%ld", time_now - CONNECTION_MAX_AGE_SECONDS);
PrependItem(&connections, "123.123.123.3", time_str);
snprintf(time_str, sizeof(time_str), "%ld", time_now - CONNECTION_MAX_AGE_SECONDS - 1);
PrependItem(&connections, "123.123.123.2", time_str);
snprintf(time_str, sizeof(time_str), "%ld", time_now - CONNECTION_MAX_AGE_SECONDS + 100);
PrependItem(&connections, "123.123.123.1", time_str);
assert_int_equal(ListLen(connections), 3);
PurgeOldConnections(&connections, time_now);
assert_int_equal(ListLen(connections), 2);
assert_true(IsItemIn(connections, "123.123.123.1"));
assert_false(IsItemIn(connections, "123.123.123.2"));
assert_true(IsItemIn(connections, "123.123.123.3"));
DeleteItemList(connections);
}
示例2: EvalContextHeapAddAbort
void EvalContextHeapAddAbort(EvalContext *ctx, const char *context, const char *activated_on_context)
{
if (!IsItemIn(ctx->heap_abort, context))
{
AppendItem(&ctx->heap_abort, context, activated_on_context);
}
}
示例3: CheckParseOpts
static SyntaxTypeMatch CheckParseOpts(const char *lval, const char *s, const char *range)
{
Item *split;
/* List/menu types are separated by comma str "a,b,c,..." */
CfDebug("\nCheckParseOpts(%s => %s/%s)\n", lval, s, range);
if (IsNakedVar(s, '@') || IsNakedVar(s, '$'))
{
return SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED;
}
split = SplitString(range, ',');
if (!IsItemIn(split, s))
{
DeleteItemList(split);
return SYNTAX_TYPE_MATCH_ERROR_OPTS_OUT_OF_RANGE;
}
DeleteItemList(split);
return SYNTAX_TYPE_MATCH_OK;
}
示例4: EvalContextHeapAddAbortCurrentBundle
void EvalContextHeapAddAbortCurrentBundle(EvalContext *ctx, const char *context, const char *activated_on_context)
{
if (!IsItemIn(ctx->heap_abort_current_bundle, context))
{
AppendItem(&ctx->heap_abort_current_bundle, context, activated_on_context);
}
}
示例5: RelevantBundle
int RelevantBundle(char *agent,char *blocktype)
{ struct Item *ip;
if (strcmp(agent,CF_AGENTTYPES[cf_common]) == 0 || strcmp(CF_COMMONC,P.blocktype) == 0)
{
return true;
}
/* Here are some additional bundle types handled by cfAgent */
ip = SplitString("edit_line,edit_xml",',');
if (strcmp(agent,CF_AGENTTYPES[cf_agent]) == 0)
{
if (IsItemIn(ip,blocktype))
{
DeleteItemList(ip);
return true;
}
}
DeleteItemList(ip);
return false;
}
示例6: AddInstallable
void AddInstallable(char *classlist)
{ char *sp, currentitem[CF_MAXVARSIZE];
if (classlist == NULL)
{
return;
}
Debug("AddInstallable(%s)\n",classlist);
for (sp = classlist; *sp != '\0'; sp++)
{
currentitem[0] = '\0';
sscanf(sp,"%[^,:.]",currentitem);
sp += strlen(currentitem);
if (! IsItemIn(VALLADDCLASSES,currentitem))
{
AppendItem(&VALLADDCLASSES,currentitem,NULL);
}
if (*sp == '\0')
{
break;
}
}
}
示例7: ArchiveToRepository
int ArchiveToRepository(const char *file, Attributes attr, Promise *pp, const ReportContext *report_context)
/* Returns true if the file was backup up and false if not */
{
char destination[CF_BUFSIZE];
struct stat sb, dsb;
if (!GetRepositoryPath(file, attr, destination))
{
return false;
}
if (attr.copy.backup == cfa_nobackup)
{
return true;
}
if (IsItemIn(VREPOSLIST, file))
{
CfOut(OUTPUT_LEVEL_INFORM, "",
"The file %s has already been moved to the repository once. Multiple update will cause loss of backup.",
file);
return true;
}
ThreadLock(cft_getaddr);
PrependItemList(&VREPOSLIST, file);
ThreadUnlock(cft_getaddr);
CfDebug("Repository(%s)\n", file);
JoinPath(destination, CanonifyName(file));
if (!MakeParentDirectory(destination, attr.move_obstructions, report_context))
{
}
if (cfstat(file, &sb) == -1)
{
CfDebug("File %s promised to archive to the repository but it disappeared!\n", file);
return true;
}
cfstat(destination, &dsb);
CheckForFileHoles(&sb, pp);
if (pp && CopyRegularFileDisk(file, destination, pp->makeholes))
{
CfOut(OUTPUT_LEVEL_INFORM, "", "Moved %s to repository location %s\n", file, destination);
return true;
}
else
{
CfOut(OUTPUT_LEVEL_INFORM, "", "Failed to move %s to repository location %s\n", file, destination);
return false;
}
}
示例8: IncrementCounter
static void IncrementCounter(Item **list, char *name)
{
if (!IsItemIn(*list, name))
{
AppendItem(list, name, "");
}
IncrementItemListCounter(*list, name);
}
示例9: AllowedUser
int AllowedUser(char *user)
{
if (IsItemIn(SV.allowuserlist, user))
{
Log(LOG_LEVEL_VERBOSE, "User %s granted connection privileges", user);
return true;
}
Log(LOG_LEVEL_VERBOSE, "User %s is not allowed on this server", user);
return false;
}
示例10: ArchiveToRepository
int ArchiveToRepository(const char *file, Attributes attr)
/* Returns true if the file was backup up and false if not */
{
char destination[CF_BUFSIZE];
struct stat sb, dsb;
if (!GetRepositoryPath(file, attr, destination))
{
return false;
}
if (attr.copy.backup == BACKUP_OPTION_NO_BACKUP)
{
return true;
}
if (IsItemIn(VREPOSLIST, file))
{
Log(LOG_LEVEL_INFO,
"The file '%s' has already been moved to the repository once. Multiple update will cause loss of backup.",
file);
return true;
}
ThreadLock(cft_getaddr);
PrependItemList(&VREPOSLIST, file);
ThreadUnlock(cft_getaddr);
JoinPath(destination, CanonifyName(file));
if (!MakeParentDirectory(destination, attr.move_obstructions))
{
}
if (stat(file, &sb) == -1)
{
Log(LOG_LEVEL_DEBUG, "File '%s' promised to archive to the repository but it disappeared!", file);
return true;
}
stat(destination, &dsb);
if (CopyRegularFileDisk(file, destination))
{
Log(LOG_LEVEL_INFO, "Moved '%s' to repository location '%s'", file, destination);
return true;
}
else
{
Log(LOG_LEVEL_INFO, "Failed to move '%s' to repository location '%s'", file, destination);
return false;
}
}
示例11: GetSysUsers
static bool GetSysUsers( int *userListSz, int *numRootProcs, int *numOtherProcs)
{
FILE *fp;
char user[CF_BUFSIZE];
char vbuff[CF_BUFSIZE];
char cbuff[CF_BUFSIZE];
#if defined(__sun)
xsnprintf(cbuff, CF_BUFSIZE, "/bin/ps -eo user > %s/users.txt", CFWORKDIR);
#elif defined(_AIX)
xsnprintf(cbuff, CF_BUFSIZE, "/bin/ps -N -eo user > %s/users.txt", CFWORKDIR);
#elif defined(__linux__)
xsnprintf(cbuff, CF_BUFSIZE, "/bin/ps -eo user > %s/users.txt", CFWORKDIR);
#else
assert_true(1);
return false;
#endif
Item *userList = NULL;
system(cbuff);
xsnprintf(cbuff, CF_BUFSIZE, "%s/users.txt", CFWORKDIR);
if ((fp = fopen(cbuff, "r")) == NULL)
{
return false;
}
while (fgets(vbuff, CF_BUFSIZE, fp) != NULL)
{
sscanf(vbuff, "%s", user);
if (strcmp(user, "USER") == 0)
{
continue;
}
if (!IsItemIn(userList, user))
{
PrependItem(&userList, user, NULL);
(*userListSz)++;
}
if (strcmp(user, "root") == 0)
{
(*numRootProcs)++;
}
else
{
(*numOtherProcs)++;
}
}
fclose(fp);
return true;
}
示例12: SetNetworkEntropyClasses
static void SetNetworkEntropyClasses(const char *service, const char *direction, const Item *list)
{
const Item *ip;
Item *addresses = NULL;
double entropy;
for (ip = list; ip != NULL; ip = ip->next)
{
if (strlen(ip->name) > 0)
{
char local[CF_BUFSIZE];
char remote[CF_BUFSIZE];
char vbuff[CF_BUFSIZE];
char *sp;
if (strncmp(ip->name, "tcp", 3) == 0)
{
sscanf(ip->name, "%*s %*s %*s %s %s", local, remote); /* linux-like */
}
else
{
sscanf(ip->name, "%s %s", local, remote); /* solaris-like */
}
strncpy(vbuff, remote, CF_BUFSIZE - 1);
vbuff[CF_BUFSIZE-1] = '\0';
for (sp = vbuff + strlen(vbuff) - 1; isdigit((int) *sp) && (sp > vbuff); sp--)
{
}
*sp = '\0';
if (!IsItemIn(addresses, vbuff))
{
AppendItem(&addresses, vbuff, "");
}
IncrementItemListCounter(addresses, vbuff);
}
}
entropy = MonEntropyCalculate(addresses);
MonEntropyClassesSet(service, direction, entropy);
DeleteItemList(addresses);
}
示例13: ListsCompare
bool ListsCompare(const Item *list1, const Item *list2)
{
if (ListLen(list1) != ListLen(list2))
{
return false;
}
for (const Item *ptr = list1; ptr != NULL; ptr = ptr->next)
{
if (IsItemIn(list2, ptr->name) == false)
{
return false;
}
}
return true;
}
示例14: Unix_GatherProcessUsers
static int Unix_GatherProcessUsers(struct Item **userList, int *userListSz, int *numRootProcs, int *numOtherProcs)
{
FILE *pp;
char pscomm[CF_BUFSIZE];
char user[CF_MAXVARSIZE];
char vbuff[CF_BUFSIZE];
snprintf(pscomm,CF_BUFSIZE,"%s %s",VPSCOMM[VSYSTEMHARDCLASS],VPSOPTS[VSYSTEMHARDCLASS]);
if ((pp = cf_popen(pscomm,"r")) == NULL)
{
return false;
}
CfReadLine(vbuff,CF_BUFSIZE,pp);
while (!feof(pp))
{
CfReadLine(vbuff,CF_BUFSIZE,pp);
sscanf(vbuff,"%s",user);
if (strcmp(user,"USER") == 0)
{
continue;
}
if (!IsItemIn(*userList,user))
{
PrependItem(userList,user,NULL);
(*userListSz)++;
}
if (strcmp(user,"root") == 0)
{
(*numRootProcs)++;
}
else
{
(*numOtherProcs)++;
}
}
cf_pclose(pp);
return true;
}
示例15: ListSubsetOfList
/**
* Checks whether list1 is a subset of list2, i.e. every entry in list1 must
* be found in list2.
*/
bool ListSubsetOfList(const Item *list1, const Item *list2)
{
const Item *list1_ptr = list1;
CYCLE_DECLARE(list1_ptr, slow, toggle);
while (list1_ptr != NULL)
{
if (!IsItemIn(list2, list1_ptr->name))
{
return false;
}
list1_ptr = list1_ptr->next;
CYCLE_CHECK(list1_ptr, slow, toggle);
}
return true; /* all elements of list1 were found in list2 */
}