yes, we should probably do a parse at the very beginningIf we use getopt_long, I think we should check the argument, --nosplash, in
and probably set some App member variables or globals or
something and then let the splash code and the later code
which processes everything else to just reference them.the reason that we have 2 distinct places which look thru
argv is historical. originally, the only thing we did
with the command line was get the (single, optional)
filename -- and we didn't need it until all the class
registration and the initial window and all its widgets
were created -- this could take some time.if we let the parse code populate a ut_hash or ut_alphahash
of the arguments (and their optional values) of the keywords
and a ut_vector of the filenames to load, then everything
should be fine. these could be stored in XAP_App -- the
absolute base class for the application and then referenced
wherever....and yes, let getopt do all the parsing dirty work in cross-
platform code....thoughts ?? opinions ??
jeff
gzip 1.2.4 (18 Aug 93)
usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
 -c --stdout      write on standard
output, keep original files unchanged
 -d --decompress  decompress
 -f --force       force overwrite
of output file and compress links
 -h --help        give
this help
 -l --list        list
compressed file contents
 -L --license     display software license
 -n --no-name     do not save or restore
the original name and time stamp
 -N --name        save
or restore the original name and time stamp
 -q --quiet       suppress all
warnings
 -r --recursive   operate recursively on directories
 -S .suf  --suffix .suf     use suffix
.suf on compressed files
 -t --test        test
compressed file integrity
 -v --verbose     verbose mode
 -V --version     display version number
 -1 --fast        compress
faster
 -9 --best        compress
better
 file...         
files to (de)compress. If none given, use standard input.
And what option do we need?
-s
-d
-l
-n
????? :)
-- following are a sample of ParseCommandLine() using getopt_long;
#include "getopt.h"
struct option longopts[] =
{
        {"script",     
1, 0, 's'},
        {"dumpstrings", 0, 0,
'd'},
        {"lib",        
1, 0, 'l'},
       
{"nosplash",    0, 0, 'n'},
        {0,            
0, 0,  0 }
};
void AP_UnixApp::ParseCommandLine(void)
{
        // parse the command
line
        // <app> [--script
<scriptname>]* [--dumpstrings]
        //      
[--lib <AbiSuiteLibDirectory>] [<documentname>]*
 
        // TODO when we refactor
the App classes, consider moving
        // TODO this to app-specific,
cross-platform.
        // TODO replace this
with getopt or something similar.
 
        // Unix puts the program
name in argv[0], so [1] is the first argument.
        int k;
        int kWindowsOpened =
0;
       
UT_Bool bShowSplash = UT_TRUE;
        while ((k = getopt_long(m_pArgs->m_argc,
m_pArgs->m_argv, "s:dnl:",
               
longopts, (int *)0)) != EOF) {
               
switch (k) {
               
case 's':
                       
// [--script scriptname]
                       
break;
               
case 'd':
#ifdef DEBUG
                       
{
                       
AP_BuiltinStringSet * pBuiltinStringSet =
                               
new AP_BuiltinStringSet(this,
                               
AP_PREF_DEFAULT_StringSet);
                       
pBuiltinStringSet->dumpBuiltinSet("EnUS.strings");
                       
delete pBuiltinStringSet;
                       
}
#endif
                       
break;
               
case 'n':
                       
bShowSplash = UT_FALSE;
                       
break;
               
case 'l':
                       
// [--lib <AbiSuiteLibDirectory>]
                       
// we've already processed this when we initialized
                       
// the App class
                       
break;
               
default:
                       
UT_DEBUGMSG(("Unknown command line option [%s]\n",
                               
m_pArgs->m_argv[optind]));
                       
// TODO don't know if it has a following argument
                       
//      or not -- assume not
                       
break;
               
}
        }
        AP_UnixFrame *pFirstUnixFrame
= new AP_UnixFrame(this);
        pFirstUnixFrame->initialize();
        while (optind < m_pArgs->m_argc)
{
               
if (pFirstUnixFrame == NULL) {
                       
pFirstUnixFrame = new AP_UnixFrame(this);
                       
pFirstUnixFrame->initialize();
                       
kWindowsOpened++;
               
}
               
if (pFirstUnixFrame->loadDocument(m_pArgs->m_argv[optind],
                       
IEFT_Unknown)) {
                       
pFirstUnixFrame = NULL;
               
} else {
                       
// A simple message box to tell user that we
                       
// can't open a bogus pathname! :)
                       
char message[2048];
                       
g_snprintf(message, 2048,
                       
"Cannot open file %s.", m_pArgs->m_argv[optind]);
                       
messageBoxOK(message);
               
}
               
optind++;
        }
        if (pFirstUnixFrame !=
NULL) {
               
if (kWindowsOpened == 0) {
                       
pFirstUnixFrame->loadDocument(NULL, IEFT_Unknown);
               
} else {
                       
forgetFrame(pFirstUnixFrame);
                       
delete pFirstUnixFrame;
               
}
        }
        if
(bShowSplash) _showSplash(NULL, NULL);
}