Shadowrun: Awakened 29 September 2011 - Build 871
Classes | Functions
getargs.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  argoptions

Functions

int getargs (int argc, char **argv, argoptions *opt)
int useoptions (argoptions *opt, SceneHandle scene)

Function Documentation

int getargs ( int  argc,
char **  argv,
argoptions opt 
)

Definition at line 149 of file getargs.cpp.

References argoptions::filename, argoptions::foundfilename, getparm(), initoptions(), and printusage().

Referenced by main_init_parts().

                                                     {
  int i, rc, unknowncnt;

  if (opt == NULL)
    return -1;

  initoptions(opt);  

  if (argc < 2) {
    printusage(argv);
#ifndef DEFAULT_MODELFILE
    return -1;
#else
    return 0;
#endif//DEFAULT_MODELFILE
  }

  i = 1;
  unknowncnt = 0;
  while (i < argc) {
    if (argv[i][0] == '-' || argv[i][0] == '+') {
      rc = getparm(argc, argv, i, opt);
      if (rc != -1) {
        i += rc;
      }
      else {
        printusage(argv);
        return -1;
      }
    }
    else {
      unknowncnt++;
      if (unknowncnt > 1) {
        fprintf(stderr, "Too many model file names found!\n");
        printusage(argv); 
        return -1;
      } 
      else {
        strcpy(opt->filename, argv[i]);        
        opt->foundfilename = 1;
        i++;
      }
    }
  }

  if (opt->foundfilename == -1) {
    fprintf(stderr, "Missing model file name!\n");
    printusage(argv);
    return -1;
  }

  return 0;
}
int useoptions ( argoptions opt,
SceneHandle  scene 
)

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net