You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
898 B

#define MICHLIB_NOSOURCE
#include "ParseArgs.h"
CLArgs ParseArgs(int argc, char** argv)
{
CLArgs out;
out["_nargs"] = MString(argc);
out["_cmdline"] = out["_name"] = out["_arg0"] = argv[0];
for(int i = 1; i < argc; i++)
{
MString carg = argv[i];
out["_arg" + MString(i)] = carg;
bool namevalue = false;
out["_cmdline"] += " " + carg;
for(size_t c = 0; c < carg.Len(); c++)
if(carg[c] == '=')
{
MString name = carg.SubStr(1, c);
MString val = carg.SubStr(c + 2, carg.Len() - c - 1);
out[name] = val;
namevalue = true;
break;
}
if(!namevalue) out[carg] = "";
}
SList sl;
michlib_internal::ParseParameterFile("/etc/odm.conf", sl, 0);
return out;
}
MString GetExt(const MString& fname)
{
for(size_t i = fname.Len(); i != 0; i--)
if(fname[i - 1] == '.') return fname.SubStr(i + 1, fname.Len() - i);
return "";
}