Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsPluginsDirOS2.cpp File Reference
#include <os2.h>
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "nsPluginDefs.h"
#include "nsString.h"

Go to the source code of this file.

Defines

#define INCL_DOS
#define INCL_DOSERRORS

Functions

static char * LoadRCDATAString (HMODULE hMod, ULONG resid)
static PRUint32 CalculateVariantCount (char *mimeTypes)
static char ** MakeStringArray (PRUint32 variants, char *data)
static void FreeStringArray (PRUint32 variants, char **array)

Define Documentation

Definition at line 39 of file nsPluginsDirOS2.cpp.

Definition at line 40 of file nsPluginsDirOS2.cpp.


Function Documentation

static PRUint32 CalculateVariantCount ( char *  mimeTypes) [static]

Definition at line 84 of file nsPluginsDirOS2.cpp.

{
  PRUint32 variants = 1;

  if(mimeTypes == nsnull)
    return 0;

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

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

Definition at line 124 of file nsPluginsDirOS2.cpp.

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

  for(PRUint32 i = 0; i < variants; i++)
  {
    if(array[i] != nsnull)
    {
      PL_strfree(array[i]);
      array[i] = nsnull;
    }
  }
  PR_Free(array);
}
static char* LoadRCDATAString ( HMODULE  hMod,
ULONG  resid 
) [static]

Definition at line 53 of file nsPluginsDirOS2.cpp.

{
   APIRET rc;
   ULONG  ulSize = 0;
   char  *string = 0;

   rc = DosQueryResourceSize( hMod, RT_RCDATA, resid, &ulSize);

   if( rc == NO_ERROR)
   {
      char *readOnlyString = 0;
      rc = DosGetResource( hMod, RT_RCDATA, resid, (void**) &readOnlyString);

      /* allow for 0-termination if user hasn't got it right */
      if( readOnlyString[ ulSize - 1] != '\0')
         ulSize++;

      if( rc == NO_ERROR)
      {
         /* copy string & zero-terminate */
         string = (char*) PR_Malloc( ulSize);
         memcpy( string, readOnlyString, ulSize - 1);
         string[ ulSize - 1] = '\0';

         DosFreeResource( readOnlyString);
      }
   }

   return string;
}

Here is the call graph for this function:

static char** MakeStringArray ( PRUint32  variants,
char *  data 
) [static]

Definition at line 102 of file nsPluginsDirOS2.cpp.

{
  if((variants <= 0) || (data == nsnull))
    return nsnull;

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

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

    array[i] = PL_strdup(start);
    start = ++p;
  }
  return array;
}

Here is the call graph for this function: