CMDPROC2.CPP

// cmdproc.cpp : replacement for mfc CCommandLineInfo 
// 
// 
// This is a part of the Microsoft Foundation Classes C++ library. 
// Copyright (C) 1997 Microsoft Corporation 
// All rights reserved. 
// 
// This source code is only intended as a supplement to the 
// Broadcast Architecture Programmer's Reference. 
// See the reference for detailed information regarding 
// Broadcast Architecture. 
 
#include "stdafx.h" 
#include "cmdproc.h" 
 
BOOLEAN 
CCommandLineProc::ProcessCommandLine(int iSC, int &argc, _TCHAR **argv) 
{ 
    CString csSwitchChars; 
    csSwitchChars.LoadString(iSC); 
    CString csParam; 
 
    if(acapArgs[0].m_Cmd == NULL) 
{ 
        return TRUE; 
    } 
  int i = 1; 
    while(i < argc) 
{ 
        csParam = argv[i]; 
if(!_tcscspn(csParam, csSwitchChars)) 
{ 
            // its a switch 
// remove flag specifier 
csParam = csParam.Right(csParam.GetLength() - 1); 
            // find the function for this switch 
            CString csSwitch, csArg; 
             
            for(int j = 0; acapArgs[j].m_Cmd != NULL; j++) 
{ 
                csSwitch.LoadString(acapArgs[j].m_iIDS); 
                if(!_tcsnccmp(csParam, csSwitch, csSwitch.GetLength())) 
{                     
                    break; 
                }             
            } 
            if(acapArgs[j].m_Cmd != NULL) 
{ 
                csArg = csParam.Right(csParam.GetLength() - csSwitch.GetLength()); 
                (this->*(acapArgs[j].m_Cmd))(csArg); 
                DeleteArg(i, argc, argv); 
            } 
else 
{ 
                i++;  // skip this one 
            } 
} 
else 
{ 
            // its positional so skip it. 
            i++;             
        } 
 
} 
    return GetPositionalArgs(argc, argv); 
} 
 
BOOLEAN 
CCommandLineProc::GetPositionalArgs(int &argc, _TCHAR **argv) 
{ 
    // default implementation provides no positional args 
    return TRUE; 
}