
// mpgui.cpp
//
// Copyright (c) 1995 by Toshiaki Tsuji, all rights reserved.

#include "stdgfx.h"
#include "mpgui.h"

void ProcessArgs ( int argc, char **argv )
  {
    INT i;
    INT Pos=0;
    NumArgs = argc-1;
         for (i=1;i<argc;i++)
      {
        INT j=0;
        while (argv[i][j]!=NULL)
          {
            CmdLine[Pos] = argv[i][j];
            Pos++;
            j++;
          } // End while
        CmdLine[Pos] = ' ';
        Pos++;
      } // End for
  } // End of ProcessArgs

void InitApp ()
  {
    InitWinHashTable ();
    #if defined (__FOROS2__)
      hAB = WinInitialize ( 0 );
      hMQ = WinCreateMsgQueue ( hAB, 0 );
    #elif defined (__FORUNIX__)
    #endif
  } // End of InitApp

VOID PrepareArg ( STRING args )
  {
    INT i,Pos;

    i = 0;
    Pos = 0;
    NumArgs = 0;
    while (args[i]!=NULL)
      {
        while ((args[i]==' '))
          i++;
        if (args[i]==NULL)
          break;
          
        while ((args[i]!=' ')&&(args[i]!=NULL))
          {
            CmdLine[Pos++] = args[i++];  
          } // End while
        NumArgs++;  
        CmdLine[Pos++] = ' ';  
      } // End while
    if (Pos>0)  
      CmdLine[Pos-1] = NULL;
    else
      CmdLine[Pos] = NULL;  
  } // End of PrepareArg

LONG GetNumArgs ()
  {
    return NumArgs;    
  } // End of GetNumArgs 

VOID GetArg ( LONG Index, STRING Str )
  {
    if (Str==NULL)
      return;
      
    if ((Index>=NumArgs)||(Index<0))
      {
        Str[0] = NULL;  
      } // End if

    INT i,Count;

    i = 0;
    Count = 0;
    while (Count!=Index)
      {
        if (CmdLine[i]==' ')
          Count++;
        i++;  
      } // End if

    INT j;
    j = 0;
    while ((CmdLine[i]!=' ')&&(CmdLine[i]!=NULL))
      Str[j++] = CmdLine[i++];
    Str[j] = NULL;  
  } // End of GetArg

  








