Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
nsCmdLineService Class Reference

#include <nsCommandLineService.h>

Inheritance diagram for nsCmdLineService:
Inheritance graph
[legend]
Collaboration diagram for nsCmdLineService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsCmdLineService (void)
void initialize (in long argc, out string argv)
 initialize Used to pass the original argv/argc from main() Warning: This will hold a reference to the original argv passed into Initialze();
string getCmdLineValue (in string argv)
 getCmdLineValue returns the 2nd parameter, if any, to the parameter passed in For example, getCmdLineValue "-edit" will return any url that came after the -edit parameter
nsICmdLineHandler getHandlerForParam (in string param)
 Get the command line handler for the given parameter.

Public Attributes

readonly attribute string URLToLoad
 URLToLoad The URL to load as passed to the command line.
readonly attribute string programName
 programName
readonly attribute long argc
 argc The number of parameters passed in on the command line
readonly attribute charArray argv
 argv returns a direct reference to the parameter array passed in to initialize() - do NOT dereference this array!

Protected Member Functions

virtual ~nsCmdLineService ()
PRBool ArgsMatch (const char *lookingFor, const char *userGave)

Protected Attributes

nsVoidArray mArgList
nsVoidArray mArgValueList
PRInt32 mArgCount
PRInt32 mArgc
char ** mArgv

Detailed Description

Definition at line 44 of file nsCommandLineService.h.


Constructor & Destructor Documentation

Definition at line 51 of file nsCommandLineService.cpp.

       :  mArgCount(0), mArgc(0), mArgv(0)
{
}
nsCmdLineService::~nsCmdLineService ( ) [protected, virtual]

Definition at line 307 of file nsCommandLineService.cpp.

{
  PRInt32 curr = mArgList.Count();
  while ( curr ) {
    char* str = NS_REINTERPRET_CAST(char*, mArgList[curr-1]);
    if ( str )
      nsMemory::Free(str);
    --curr;
  }
  
  curr = mArgValueList.Count();
  while ( curr ) {
    char* str = NS_REINTERPRET_CAST(char*, mArgValueList[curr-1]);
    if ( str )
      nsMemory::Free(str);
    --curr;
  }

  curr = mArgc;
  while ( curr ) {
    char *str = mArgv ? mArgv[curr-1] : 0;
    if ( str )
      nsMemory::Free( mArgv[curr-1] );
    --curr;
  }
  delete [] mArgv;
}

Member Function Documentation

PRBool nsCmdLineService::ArgsMatch ( const char *  lookingFor,
const char *  userGave 
) [protected]

Definition at line 234 of file nsCommandLineService.cpp.

{
    if (!lookingFor || !userGave) return PR_FALSE;

    if (!PL_strcasecmp(lookingFor,userGave)) return PR_TRUE;

#if defined(XP_UNIX) || defined(XP_BEOS)
    /* on unix and beos, we'll allow --mail for -mail */
    if (lookingFor && userGave && (lookingFor[0] != '\0') && (userGave[0] != '\0') && (userGave[1] != '\0')) {
        if (!PL_strcasecmp(lookingFor+1,userGave+2) && (lookingFor[0] == '-') && (userGave[0] == '-') && (userGave[1] == '-')) return PR_TRUE;
    }
#endif
#if defined(XP_WIN) || defined(XP_OS2)
    /* on windows /mail is the same as -mail */
    if (lookingFor && userGave && (lookingFor[0] != '\0') && (userGave[0] != '\0')) {
        if (!PL_strcasecmp(lookingFor+1,userGave+1) && (lookingFor[0] == '-') && (userGave[0] == '/')) return PR_TRUE;
    }
#endif 
    return PR_FALSE;
}

Here is the call graph for this function:

getCmdLineValue returns the 2nd parameter, if any, to the parameter passed in For example, getCmdLineValue "-edit" will return any url that came after the -edit parameter

Get the command line handler for the given parameter.

Parameters:
param- can be any parameter, with or without leading "-" such as "-mail" or "edit" - Pass in a null string if you want the "default" handler
void nsICmdLineService::initialize ( in long  argc,
out string  argv 
) [inherited]

initialize Used to pass the original argv/argc from main() Warning: This will hold a reference to the original argv passed into Initialze();


Member Data Documentation

readonly attribute long nsICmdLineService::argc [inherited]

argc The number of parameters passed in on the command line

Definition at line 78 of file nsICmdLineService.idl.

argv returns a direct reference to the parameter array passed in to initialize() - do NOT dereference this array!

Definition at line 85 of file nsICmdLineService.idl.

Definition at line 60 of file nsCommandLineService.h.

Definition at line 57 of file nsCommandLineService.h.

Definition at line 55 of file nsCommandLineService.h.

char** nsCmdLineService::mArgv [protected]

Definition at line 61 of file nsCommandLineService.h.

Definition at line 56 of file nsCommandLineService.h.

programName

  

Definition at line 72 of file nsICmdLineService.idl.

URLToLoad The URL to load as passed to the command line.

Definition at line 66 of file nsICmdLineService.idl.


The documentation for this class was generated from the following files: