Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsPluginsDirWin.cpp File Reference
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "prprf.h"
#include "windows.h"
#include "winbase.h"
#include "nsString.h"

Go to the source code of this file.

Functions

static char * GetKeyValue (char *verbuf, char *key)
static PRUint32 CalculateVariantCount (char *mimeTypes)
static char ** MakeStringArray (PRUint32 variants, char *data)
static void FreeStringArray (PRUint32 variants, char **array)

Function Documentation

static PRUint32 CalculateVariantCount ( char *  mimeTypes) [static]

Definition at line 85 of file nsPluginsDirWin.cpp.

{
       PRUint32 variants = 1;

  if(mimeTypes == NULL)
    return 0;

       char* index = mimeTypes;
       while (*index)
       {
              if (*index == '|')
                     variants++;

              ++index;
       }
       return variants;
}
static void FreeStringArray ( PRUint32  variants,
char **  array 
) [static]

Definition at line 143 of file nsPluginsDirWin.cpp.

{
  if((variants == 0) || (array == NULL))
    return;

  for(PRUint32 i = 0; i < variants; i++)
  {
    if(array[i] != NULL)
    {
      PL_strfree(array[i]);
      array[i] = NULL;
    }
  }
  PR_Free(array);
}
static char* GetKeyValue ( char *  verbuf,
char *  key 
) [static]

Definition at line 61 of file nsPluginsDirWin.cpp.

{
       char        *buf = NULL;
       UINT        blen;

       ::VerQueryValue(verbuf,
                                   TEXT(key),
                                   (void **)&buf, &blen);

       if(buf != NULL)
       {
#ifdef WINCE
        // On windows CE, the verbuf is wide and the shunt
        // layer can't do much about it.  So, here we
        // convert the wide string.
              return PL_strdup(NS_ConvertUCS2toUTF8((PRUnichar*)buf).get());
#else
              return PL_strdup(buf);      
#endif
       }

       return nsnull;
}
static char** MakeStringArray ( PRUint32  variants,
char *  data 
) [static]

Definition at line 103 of file nsPluginsDirWin.cpp.

{
// The number of variants has been calculated based on the mime
// type array. Plugins are not explicitely required to match
// this number in two other arrays: file extention array and mime
// description array, and some of them actually don't. 
// We should handle such situations gracefully

  if((variants <= 0) || (data == NULL))
    return NULL;

  char ** array = (char **)PR_Calloc(variants, sizeof(char *));
  if(array == NULL)
    return NULL;

  char * start = data;

  for(PRUint32 i = 0; i < variants; i++)
  {
    char * p = PL_strchr(start, '|');
    if(p != NULL)
      *p = 0;

    array[i] = PL_strdup(start);

    if(p == NULL)
    { 
      // nothing more to look for, fill everything left 
      // with empty strings and break
      while(++i < variants)
        array[i] = PL_strdup("");

      break;
    }

    start = ++p;
  }
  return array;
}

Here is the call graph for this function: