/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/NPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is Mozilla Communicator client code. * * The Initial Developer of the Original Code is Netscape Communications * Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): */ #include "nsICmdLineService.h" #include "nsCommandLineService.h" #include "nsIComponentManager.h" #include "nsString.h" #include "plstr.h" nsCmdLineService::nsCmdLineService() : mArgCount(0), mArgc(0), mArgv(0) { NS_INIT_REFCNT(); } /* * Implement the nsISupports methods... */ NS_IMPL_ISUPPORTS1(nsCmdLineService, nsICmdLineService); NS_IMETHODIMP nsCmdLineService::Initialize(int aArgc, char ** aArgv) { PRInt32 i=0; nsresult rv = nsnull; // Save aArgc and argv mArgc = aArgc; mArgv = aArgv; //Insert the program name if (aArgv[0]) { mArgList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("-progname"))); mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup(aArgv[0]))); mArgCount++; i++; } for(i=1; i 0) && (PL_strlen(userGave) > 1)) { if (!PL_strcasecmp(lookingFor+1,userGave+2) && (lookingFor[0] == '-') && (userGave[0] == '-') && (userGave[1] == '-')) return PR_TRUE; } #endif #ifdef XP_PC /* on windows /mail is the same as -mail */ if ((PL_strlen(lookingFor) > 0) && (PL_strlen(userGave) > 0)) { if (!PL_strcasecmp(lookingFor+1,userGave+1) && (lookingFor[0] == '-') && (userGave[0] == '/')) return PR_TRUE; } #endif return PR_FALSE; } NS_IMETHODIMP nsCmdLineService::GetCmdLineValue(const char * aArg, char ** aResult) { nsresult rv = NS_OK; if (nsnull == aArg || nsnull == aResult ) { return NS_ERROR_NULL_POINTER; } for (int i = 0; i