(file) Return to OpenSLPWrapper.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Client

Diff for /pegasus/src/Pegasus/Client/OpenSLPWrapper.cpp between version 1.7 and 1.8

version 1.7, 2006/01/30 16:16:42 version 1.8, 2006/11/14 18:34:48
Line 29 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Tony Fiorentino (fiorentino_tony@emc.com)  
 //  
 // Modified By: Keith Petley (keithp@veritas.com)  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "OpenSLPWrapper.h" #include "OpenSLPWrapper.h"
Line 53 
Line 49 
 // [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':
Line 75 
Line 72 
                         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 = ' ';
Line 97 
Line 98 
                                         // 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;
Line 116 
Line 118 
                         }                         }
  
                         // delete any WS before the closing )                         // delete any WS before the closing )
                         if(*ptr == ')' && last == ' ') {              if (*ptr == ')' && last == ' ')
               {
                                 wptr--;                                 wptr--;
                         }                         }
  
Line 138 
Line 141 
 // 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
Line 200 
Line 209 
         *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,
Line 216 
Line 225 
     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)
Line 229 
Line 238 
                 // 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;
                 }                 }
Line 243 
Line 253 
                 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';
Line 301 
Line 322 
 { {
 } }
  
 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;
Line 338 
Line 360 
       // @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,
Line 359 
Line 382 
               // @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,
Line 374 
Line 398 
                                     (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);
Line 401 
Line 426 
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
   


Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2