version 1.7, 2006/01/30 16:16:42
|
version 1.8, 2006/11/14 18:34:48
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Tony Fiorentino (fiorentino_tony@emc.com) |
|
// |
|
// Modified By: Keith Petley (keithp@veritas.com) |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include "OpenSLPWrapper.h" | #include "OpenSLPWrapper.h" |
|
|
// [WS] = WhiteSpace and is deleted | // [WS] = WhiteSpace and is deleted |
// [EWS] = Embedded WhiteSpace and will be folded to a single space. | // [EWS] = Embedded WhiteSpace and will be folded to a single space. |
| |
static void |
static void preprocessAttrList(char* list) |
preprocessAttrList(char *list) |
|
{ | { |
bool eatWhiteSpace = false; | bool eatWhiteSpace = false; |
char *ptr = list; | char *ptr = list; |
char *wptr = list; | char *wptr = list; |
char last; | char last; |
| |
while(*ptr != '\0') { |
while (*ptr != '\0') |
|
{ |
// Outer switch case deals with everything outsde of brackets ( ) | // Outer switch case deals with everything outsde of brackets ( ) |
switch(*ptr) { |
switch(*ptr) |
|
{ |
// We delete all whitespace outside of ( ) | // We delete all whitespace outside of ( ) |
case ' ': | case ' ': |
case '\t': | case '\t': |
|
|
last = '('; | last = '('; |
*wptr++ = *ptr; | *wptr++ = *ptr; |
// Process everything until closing ) | // Process everything until closing ) |
while(*++ptr != '\0' && *ptr != ')') { |
while (*++ptr != '\0' && *ptr != ')') |
switch(*ptr) { |
{ |
|
switch(*ptr) |
|
{ |
case ' ': | case ' ': |
case '\t': | case '\t': |
// if we're deleting WS | // if we're deleting WS |
if(eatWhiteSpace == true){ |
if (eatWhiteSpace == true) |
|
{ |
last = ' '; | last = ' '; |
break; | break; |
} | } |
// if we're folding WS | // if we're folding WS |
if(last == ' ') { |
if (last == ' ') |
|
{ |
break; | break; |
} | } |
last = ' '; | last = ' '; |
|
|
// delete any preceding WS. | // delete any preceding WS. |
// It will have been folded to a | // It will have been folded to a |
// single space | // single space |
if(last == ' '){ |
if (last == ' ') |
|
{ |
wptr--; | wptr--; |
} | } |
*wptr++ = *ptr; | *wptr++ = *ptr; |
|
|
} | } |
| |
// delete any WS before the closing ) | // delete any WS before the closing ) |
if(*ptr == ')' && last == ' ') { |
if (*ptr == ')' && last == ' ') |
|
{ |
wptr--; | wptr--; |
} | } |
| |
|
|
// Assumes a list that has already been whitespace stripped/folded | // Assumes a list that has already been whitespace stripped/folded |
// Overwrites input string with output. | // Overwrites input string with output. |
| |
static void |
static void preprocessAttrValList(char* list) |
preprocessAttrValList(char *list) |
|
{ | { |
char *wptr = list; | char *wptr = list; |
char *ptr = list; | char *ptr = list; |
char last = '\0'; | char last = '\0'; |
bool opaque = false; | bool opaque = false; |
| |
while(*ptr != '\0') { |
while (*ptr != '\0') |
|
{ |
if(opaque == true) { |
if (opaque == true) |
|
{ |
*wptr++ = *ptr++; | *wptr++ = *ptr++; |
continue; | continue; |
} | } |
#ifdef STRIP_QUOTES | #ifdef STRIP_QUOTES |
if(*ptr == '"') { |
if (*ptr == '"') |
|
{ |
ptr++; | ptr++; |
continue; | continue; |
} | } |
#endif | #endif |
| |
// Escape character or opaque sequence | // Escape character or opaque sequence |
if(*ptr == '\\') { |
if (*ptr == '\\') |
if( *(ptr+1) != '\0' && *(ptr+2) != '\0') { |
{ |
if(*(ptr+1) == 'F' && *(ptr+2) == 'F') { |
if (*(ptr+1) != '\0' && *(ptr+2) != '\0') |
|
{ |
|
if (*(ptr+1) == 'F' && *(ptr+2) == 'F') |
|
{ |
opaque = true; | opaque = true; |
*wptr++ = *ptr++; | *wptr++ = *ptr++; |
} else { |
} |
|
else |
|
{ |
// Allow any character to be escaped | // Allow any character to be escaped |
// rfc2608 says to only escape | // rfc2608 says to only escape |
// reserved characters | // reserved characters |
|
|
*wptr = '\0'; | *wptr = '\0'; |
} | } |
| |
static SLPBoolean |
static SLPBoolean wbemSrvUrlCallback( |
wbemSrvUrlCallback(SLPHandle hslp, |
SLPHandle hslp, |
const char* srvurl, | const char* srvurl, |
unsigned short lifetime, | unsigned short lifetime, |
SLPError errcode, | SLPError errcode, |
|
|
return SLP_TRUE; | return SLP_TRUE; |
} | } |
| |
static SLPBoolean |
static SLPBoolean wbemAttrCallback( |
wbemAttrCallback( SLPHandle hslp, |
SLPHandle hslp, |
const char* attrlist, | const char* attrlist, |
SLPError errcode, | SLPError errcode, |
void* cookie) | void* cookie) |
|
|
// Allocate memory to hold working copy of list | // Allocate memory to hold working copy of list |
char *list = new char[strlen(attrlist) + 1]; | char *list = new char[strlen(attrlist) + 1]; |
| |
if(list == (char *)NULL) { |
if (list == (char *)NULL) |
|
{ |
// Ignore out of memory, just go. | // Ignore out of memory, just go. |
return SLP_TRUE; | return SLP_TRUE; |
} | } |
|
|
char *ptr = list; | char *ptr = list; |
char *nptr; | char *nptr; |
| |
while (ptr <= end) { |
while (ptr <= end) |
if(*ptr == '(') { |
{ |
|
if (*ptr == '(') |
|
{ |
ptr++; | ptr++; |
nptr = ptr; | nptr = ptr; |
while(nptr <= end && *nptr != '=') { |
while (nptr <= end && *nptr != '=') |
|
{ |
nptr++; | nptr++; |
} | } |
*nptr = '\0'; | *nptr = '\0'; |
preprocessAttrValList(ptr); | preprocessAttrValList(ptr); |
Attribute newAttr(ptr); | Attribute newAttr(ptr); |
ptr = nptr+1; | ptr = nptr+1; |
while(nptr <= end) { |
while (nptr <= end) |
if(*nptr == ',' || *nptr == ')') { |
{ |
|
if (*nptr == ',' || *nptr == ')') |
|
{ |
bool isBracket = false; | bool isBracket = false; |
if(*nptr == ')'){ |
if (*nptr == ')') |
|
{ |
isBracket = true; | isBracket = true; |
} | } |
*nptr = '\0'; | *nptr = '\0'; |
preprocessAttrValList(ptr); | preprocessAttrValList(ptr); |
newAttr.addValue(ptr); | newAttr.addValue(ptr); |
ptr = nptr + 1; | ptr = nptr + 1; |
if(isBracket){ |
if (isBracket) |
|
{ |
break; | break; |
} | } |
} else { |
} |
|
else |
|
{ |
nptr++; | nptr++; |
} | } |
} | } |
attr_cookie->append(newAttr); | attr_cookie->append(newAttr); |
} | } |
| |
if(*ptr == ',') { |
if (*ptr == ',') |
|
{ |
ptr++; | ptr++; |
continue; | continue; |
} | } |
| |
nptr = ptr; | nptr = ptr; |
while(nptr <= end && *nptr != ',') { |
while (nptr <= end && *nptr != ',') |
|
{ |
nptr++; | nptr++; |
} | } |
*nptr = '\0'; | *nptr = '\0'; |
|
|
{ | { |
} | } |
| |
Array<CIMServerDescription> |
Array<CIMServerDescription> CIMServerDiscoveryRep::lookup( |
CIMServerDiscoveryRep::lookup(const Array<Attribute> & criteria, const SLPClientOptions* options) |
const Array<Attribute>& criteria, |
|
const SLPClientOptions* options) |
{ | { |
SLPError result; | SLPError result; |
SLPHandle hslp; | SLPHandle hslp; |
|
|
// @param4 - filter - NULL is all that match type | // @param4 - filter - NULL is all that match type |
// @param5 - pointer to custom data to use in callback | // @param5 - pointer to custom data to use in callback |
Array<String> urls; | Array<String> urls; |
result = SLPFindSrvs(hslp, |
result = SLPFindSrvs( |
|
hslp, |
(const char *)serviceType.getCString(), | (const char *)serviceType.getCString(), |
NULL, | NULL, |
NULL, | NULL, |
|
|
// @param3 - scope list - NULL is all localhost can query | // @param3 - scope list - NULL is all localhost can query |
// @param4 - attribute list - NULL is all attributes | // @param4 - attribute list - NULL is all attributes |
// @param5 - pointer to custom data to use in callback | // @param5 - pointer to custom data to use in callback |
result = SLPFindAttrs( hslp, |
result = SLPFindAttrs( |
|
hslp, |
(const char *)urls[i].getCString(), | (const char *)urls[i].getCString(), |
NULL, | NULL, |
NULL, | NULL, |
|
|
(char *)((const char *)urls[i].getCString()), | (char *)((const char *)urls[i].getCString()), |
&pSrvUrl)) | &pSrvUrl)) |
{ | { |
// add to the end to protect against existing attributes of the same name. |
// add to the end to protect against existing attributes |
|
// of the same name. |
Attribute tmpAttr(PEG_CUSTOM_ATTR_HOST); | Attribute tmpAttr(PEG_CUSTOM_ATTR_HOST); |
tmpAttr.addValue(pSrvUrl->s_pcHost); | tmpAttr.addValue(pSrvUrl->s_pcHost); |
attributes.append(tmpAttr); | attributes.append(tmpAttr); |
|
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
|
|