Belle II Software  release-08-01-10
nsm_read_argv.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #include <daq/slc/nsm/nsm_read_argv.h>
9 
10 #include <cstring>
11 #include <cstdlib>
12 
13 namespace Belle2 {
19  int nsm_read_argv(int argc, const char** argv,
20  int (*help)(const char** argv), char** argv_in,
21  ConfigFile& config, std::string& name,
22  std::string& username, int nargv)
23  {
24  name = "nsm";
25  int argc_in = 0;
26  username = getenv("USER");
27  for (int i = 0; i < argc; i++) {
28  if (strcmp(argv[i], "-g") == 0) {
29  name = "nsm.global";
30  } else if (strcmp(argv[i], "-h") == 0) {
31  return help(argv);
32  } else if (strcmp(argv[i], "-c") == 0) {
33  if (i + 1 < argc && argv[i + 1][0] != '-') {
34  i++;
35  config.read(argv[i]);
36  }
37  } else if (strcmp(argv[i], "-n") == 0) {
38  if (i + 1 < argc && argv[i + 1][0] != '-') {
39  i++;
40  username = argv[i];
41  }
42  } else {
43  argv_in[argc_in] = new char[100];
44  strcpy(argv_in[argc_in], argv[i]);
45  argc_in++;
46  }
47  }
48  if (argc_in < nargv) {
49  help(argv);
50  exit(1);
51  }
52  return argc_in;
53  }
54 
56 }
Abstract base class for different kinds of events.