version 1.43.2.2, 2005/08/02 21:08:32
|
version 1.53.10.1, 2005/12/30 22:01:01
|
|
|
//%2004//////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; | // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// Carol Ann Krug Graves, Hewlett-Packard Company | // Carol Ann Krug Graves, Hewlett-Packard Company |
// (carolann_graves@hp.com) | // (carolann_graves@hp.com) |
// Dave Sudlik, IBM (dsudlik@us.ibm.com) for Bug#1462 |
// Dave Sudlik, IBM (dsudlik@us.ibm.com) |
|
// Vijay Eli, IBM (vijayeli@in.ibm.com), bug#2556. |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <cctype> |
|
#include <cstring> | #include <cstring> |
#include <iostream> | #include <iostream> |
#include "HashTable.h" | #include "HashTable.h" |
#include "CIMObjectPath.h" | #include "CIMObjectPath.h" |
#include "Indentor.h" | #include "Indentor.h" |
#include "CIMName.h" | #include "CIMName.h" |
#include "Destroyer.h" |
|
#include "XmlWriter.h" | #include "XmlWriter.h" |
#include "XmlReader.h" | #include "XmlReader.h" |
#include "ArrayInternal.h" | #include "ArrayInternal.h" |
|
|
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
kbType = REFERENCE; | kbType = REFERENCE; |
break; | break; |
|
// case CIMTYPE_REAL32: |
|
// case CIMTYPE_REAL64: |
|
case CIMTYPE_OBJECT: |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
// From PEP 194: EmbeddedObjects cannot be keys. |
|
throw TypeMismatchException(); |
|
break; |
default: | default: |
kbType = NUMERIC; | kbType = NUMERIC; |
break; | break; |
|
|
kbValue = XmlReader::stringToValue(0, getValue().getCString(), | kbValue = XmlReader::stringToValue(0, getValue().getCString(), |
value.getType()); | value.getType()); |
break; | break; |
|
// case CIMTYPE_REAL32: |
|
// case CIMTYPE_REAL64: |
|
case CIMTYPE_OBJECT: |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
// From PEP 194: EmbeddedObjects cannot be keys. |
|
return false; |
|
break; |
default: // Numerics | default: // Numerics |
if (getType() != NUMERIC) return false; | if (getType() != NUMERIC) return false; |
kbValue = XmlReader::stringToValue(0, getValue().getCString(), | kbValue = XmlReader::stringToValue(0, getValue().getCString(), |
|
|
| |
Boolean isValid = false; | Boolean isValid = false; |
| |
if (isdigit(hostname[0])) |
if (isascii(hostname[0]) && isdigit(hostname[0])) |
{ | { |
//-------------------------------------------------------------- | //-------------------------------------------------------------- |
// Attempt to validate an IP address, but keep in mind that it | // Attempt to validate an IP address, but keep in mind that it |
|
|
// If a non-digit is encountered in the input parameter, | // If a non-digit is encountered in the input parameter, |
// then break from here and attempt to validate as host name. | // then break from here and attempt to validate as host name. |
//---------------------------------------------------------- | //---------------------------------------------------------- |
if (!isdigit(hostname[i])) |
if (!(isascii(hostname[i]) && isdigit(hostname[i]))) |
{ | { |
isValid = false; | isValid = false; |
break; | break; |
} | } |
| |
while (isdigit(hostname[i])) // skip over digits |
// skip over digits |
|
while (isascii(hostname[i]) && isdigit(hostname[i])) |
{ | { |
octetValue = octetValue*10 + (hostname[i] - '0'); | octetValue = octetValue*10 + (hostname[i] - '0'); |
i++; | i++; |
|
|
expectHostSegment = false; | expectHostSegment = false; |
hostSegmentIsNumeric = true; // assume all-numeric host segment | hostSegmentIsNumeric = true; // assume all-numeric host segment |
| |
if (!(isalnum(hostname[i]) || (hostname[i] == '_'))) |
if (!(isascii(hostname[i]) && |
|
(isalnum(hostname[i]) || (hostname[i] == '_')))) |
{ | { |
return false; | return false; |
} | } |
| |
while (isalnum(hostname[i]) || (hostname[i] == '-') || |
while (isascii(hostname[i]) && |
(hostname[i] == '_')) |
(isalnum(hostname[i]) || (hostname[i] == '-') || |
|
(hostname[i] == '_'))) |
{ | { |
// If a non-digit is encountered, set "all-numeric" | // If a non-digit is encountered, set "all-numeric" |
// flag to false | // flag to false |
if (isalpha(hostname[i]) || (hostname[i] == '-') || | if (isalpha(hostname[i]) || (hostname[i] == '-') || |
(hostname[i] == '_')) |
(hostname[i] == '_')) { |
{ |
|
hostSegmentIsNumeric = false; | hostSegmentIsNumeric = false; |
} | } |
i++; | i++; |
|
|
| |
if (hostname[i] == ':') | if (hostname[i] == ':') |
{ | { |
if (!isdigit(hostname[++i])) |
i++; |
|
if (!(isascii(hostname[i]) && isdigit(hostname[i]))) |
{ | { |
return false; | return false; |
} | } |
|
i++; |
| |
while (isdigit(hostname[++i])); |
while (isascii(hostname[i]) && isdigit(hostname[i])) |
|
{ |
|
i++; |
|
} |
} | } |
| |
return (hostname[i] == char(0)); | return (hostname[i] == char(0)); |