Esempio n. 1
0
BOOL
IsNumberInUnicodeList(
   IN DWORD  dwNumber,
   IN LPWSTR lpwszUnicodeList
   )
/*++

Routine Description:

Arguments:

   IN dwNumber
      DWORD number to find in list

   IN lpwszUnicodeList
      NULL terminated, space delimited list of decimal numbers

Return Value:

   TRUE:
      dwNumber found in list

   FALSE:
      dwNumber not found in list

--*/
{
   DWORD	dwThisNumber;
   WCHAR	*pwcThisChar;
   BOOL		bValidNumber;
   BOOL		bNewItem;
   BOOL		bReturnValue;
   WCHAR	wcDelimiter;

   if (lpwszUnicodeList == 0) {
      return FALSE;
   }

   pwcThisChar = lpwszUnicodeList;
   dwThisNumber = 0;
   wcDelimiter = (WCHAR)' ';
   bValidNumber = FALSE;
   bNewItem = TRUE;

   while (TRUE) {
      switch(EvalThisChar (*pwcThisChar, wcDelimiter) ) {
      case DIGIT:
	 //
	 // if this is the first digit after a delimiter, then set
	 // flags to start computing new number;
	 //
	 if (bNewItem) {
	    bNewItem = FALSE;
	    bValidNumber = TRUE;
	 }

	 if (bValidNumber) {
	    dwThisNumber *= 10;
	    dwThisNumber += (*pwcThisChar - (WCHAR)'0');
	 }
	 break;
      case DELIMITER:
	 //
	 // a delimiter is either the delimiter character or the end
	 // of the string, if when the delimiter has been reached, a valid
	 // number was found, then compoare it to the
	 // number from the argument list. if this is the end of the
	 // string and no match was found, then return.
	 //
	 if (bValidNumber) {
	    if (dwThisNumber == dwNumber) {
	       return TRUE;
	    }
	    bValidNumber = FALSE;
	 }

	 if (*pwcThisChar == 0) {
	    return FALSE;
	 } else {
	    bNewItem = TRUE;
	    dwThisNumber = 0;
	 }

	 break;
      case INVALID:
      default:
	 //
	 // if an invalid character was encountered, ignore all characters
	 // upto the next delimiter and then start fresh. The invalid number
	 // is NOT compared.
	 //
	 bValidNumber = FALSE;
	 break;
      }

      pwcThisChar++;

   }

} // End IsNumberInUnicodeList
Esempio n. 2
0
DWORD
IsNumberInUnicodeList (
    IN LPWSTR  lpwszUnicodeList
)
/*++
Routine Description:
    When querying counters, the collect function receives a list of Unicode strings
    representing object indexes.  This function parses the string and returns a bit
    combination representing the needed objects.

Arguments:
     IN lpwszUnicodeList
        Null terminated, space delimited list of decimal numbers

Return Value:
    The returned DWORD is a combination of QUERY_USER and QUERY_CS
--*/
{
    DWORD   dwThisNumber;
    DWORD   dwReturnValue;
    WCHAR   *pwcThisChar;
    WCHAR   wcDelimiter;
    BOOL    bValidNumber;
    BOOL    bNewItem;

    if (lpwszUnicodeList == 0) return 0;    // null pointer, # not found

    pwcThisChar = lpwszUnicodeList;
    dwThisNumber = 0;
    dwReturnValue = 0;
    wcDelimiter = (WCHAR)' ';
    bValidNumber = FALSE;
    bNewItem = TRUE;

    while (TRUE) {
        switch (EvalThisChar (*pwcThisChar, wcDelimiter)) {
            case DIGIT:
                // if this is the first digit after a delimiter, then
                // set flags to start computing the new number
                if (bNewItem) {
                    bNewItem = FALSE;
                    bValidNumber = TRUE;
                }
                if (bValidNumber) {
                    dwThisNumber *= 10;
                    dwThisNumber += (*pwcThisChar - (WCHAR)'0');
                }
                break;
            case ENDOFSTRING:
            case DELIMITER:
                // a delimiter is either the delimiter character or the
                // end of the string ('\0') if when the delimiter has been
                // reached a valid number was found, then compare it to the
                // number from the argument list. if this is the end of the
                // string and no match was found, then return.
                //
                if (bValidNumber) {
                    if (dwThisNumber == UserDataDefinition.UserObjectType.ObjectNameTitleIndex) {
                        dwReturnValue |= QUERY_USER;
                    }
                    else if (dwThisNumber == CSDataDefinition.CSObjectType.ObjectNameTitleIndex) {
                        dwReturnValue |= QUERY_CS;
                    }
                    bValidNumber = FALSE;
                }
                if (*pwcThisChar == 0) {
                    return dwReturnValue;
                }
                else {
                    bNewItem = TRUE;
                    dwThisNumber = 0;
                }
                break;

            case INVALID:
                // if an invalid character was encountered, ignore all
                // characters up to the next delimiter and then start fresh.
                // the invalid number is not compared.
                bValidNumber = FALSE;
                break;

            default:
                break;

        }
    pwcThisChar++;
    }

}   // IsNumberInUnicodeList
Esempio n. 3
0
BOOL
pfIsNumberInUnicodeList (
    IN DWORD   dwNumber,
    IN LPWSTR  lpwszUnicodeList
)
/*++

IsNumberInUnicodeList

Arguments:

    IN dwNumber
        DWORD number to find in list

    IN lpwszUnicodeList
        Null terminated, Space delimited list of decimal numbers

Return Value:

    TRUE:
            dwNumber was found in the list of unicode number strings

    FALSE:
            dwNumber was not found in the list.

--*/
{
    DWORD   dwThisNumber;
    WCHAR   *pwcThisChar;
    BOOL    bValidNumber;
    BOOL    bNewItem;
    WCHAR   wcDelimiter;    /* could be an argument to be more flexible */

    if (lpwszUnicodeList == 0) return FALSE;    /* null pointer, # not found */

    pwcThisChar = lpwszUnicodeList;
    dwThisNumber = 0;
    wcDelimiter = (WCHAR)' ';
    bValidNumber = FALSE;
    bNewItem = TRUE;

    while (TRUE) {
        switch (EvalThisChar (*pwcThisChar, wcDelimiter)) {
        case DIGIT:
            /* if this is the first digit after a delimiter, then  */
            /* set flags to start computing the new number */
            if (bNewItem) {
                bNewItem = FALSE;
                bValidNumber = TRUE;
            }
            if (bValidNumber) {
                dwThisNumber *= 10;
                dwThisNumber += (*pwcThisChar - (WCHAR)'0');
            }
            break;

        case DELIMITER:
            /* a delimiter is either the delimiter character or the
            ** end of the string ('\0') if when the delimiter has been
            ** reached a valid number was found, then compare it to the
            ** number from the argument list. if this is the end of the
            ** string and no match was found, then return.
            */
            if (bValidNumber) {
                if (dwThisNumber == dwNumber) return TRUE;
                bValidNumber = FALSE;
            }
            if (*pwcThisChar == 0) {
                return FALSE;
            } else {
                bNewItem = TRUE;
                dwThisNumber = 0;
            }
            break;

        case INVALID:
            /* if an invalid character was encountered, ignore all
            ** characters up to the next delimiter and then start fresh.
            ** the invalid number is not compared. */
            bValidNumber = FALSE;
            break;

        default:
            break;

        }
        pwcThisChar++;
    }
    return FALSE;
}   /* pfIsNumberInUnicodeList */