original files of m241
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/* snsCommon.c - Socket Name Service common library */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004-2005 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute, modify or otherwise make use
|
||||
* of this software may be licensed only pursuant to the terms
|
||||
* of an applicable Wind River license agreement.
|
||||
*/
|
||||
#include "copyright_wrs.h"
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01a,31mar05,ebh added new entries for snsShow to display truncated scope text
|
||||
01a,22aug04,ymz created (extracted from snsLib.c). SPR 98183
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
This library contains the Socket Name Service (SNS) common variable
|
||||
and routine used by snsLib.c and snsShow.c. Therefore, both snsLib
|
||||
and snsShow components can use the common data and routine but still
|
||||
decoupled from each other in the project build.
|
||||
|
||||
INCLUDE FILES" snsLibP.h
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
/* includes */
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "dsi/private/snsLibP.h"
|
||||
|
||||
/* defines */
|
||||
|
||||
/* globals */
|
||||
|
||||
/* table used in converting text form of scope to numeric form */
|
||||
|
||||
const struct sns_scope_info snsScopeTbl[SNS_NUM_SCOPES] =
|
||||
{
|
||||
{ SNS_SCOPE_PRIVATE, SNS_SCOPE_PRIVATE_STR, SNS_SCOPE_UPTO_PRIVATE_STR, SNS_SCOPE_SHOW_PRIVATE_STR},
|
||||
{ SNS_SCOPE_NODE, SNS_SCOPE_NODE_STR, SNS_SCOPE_UPTO_NODE_STR, SNS_SCOPE_SHOW_NODE_STR},
|
||||
{ SNS_SCOPE_CLUSTER, SNS_SCOPE_CLUSTER_STR, SNS_SCOPE_UPTO_CLUSTER_STR, SNS_SCOPE_SHOW_CLUSTER_STR},
|
||||
{ SNS_SCOPE_SYSTEM, SNS_SCOPE_SYSTEM_STR, SNS_SCOPE_UPTO_SYSTEM_STR, SNS_SCOPE_SHOW_SYSTEM_STR}
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* snsPatMatch - matching a wildcard pattern with a name string
|
||||
*
|
||||
* This function matches a pattern with a name string, the function only interpret
|
||||
* '*'s and/or '?'s as metacharacter for wildcard matching. This function
|
||||
* does not intepret other classic regular expression such as '.', brackets ,
|
||||
* backslash escape, nested grouping etc.
|
||||
*
|
||||
* Note, '*' denotes any number of characters, including zero,
|
||||
* '?' denote any single character matching.
|
||||
*
|
||||
* RETURNS: 1 if matched, 0 otherwise.
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
|
||||
int snsPatMatch
|
||||
(
|
||||
const char * pat, /* pattern */
|
||||
const char * str /* string to be matched */
|
||||
)
|
||||
|
||||
{
|
||||
/*
|
||||
* The following code should be further optimized to reduce the
|
||||
* number of recursive calls.
|
||||
*/
|
||||
|
||||
switch (*pat)
|
||||
{
|
||||
case '\0': return !*str;
|
||||
case '*' : return (snsPatMatch (pat+1, str)) ||
|
||||
(*str && snsPatMatch (pat, str+1));
|
||||
case '?' : return *str && snsPatMatch (pat+1, str+1);
|
||||
default : return *pat == *str && snsPatMatch (pat+1, str+1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user