Fotobot
Get data from your photovoltaic plant
main.cpp
Go to the documentation of this file.
1 
24 #include <QDebug>
25 #include "startup.h"
26 #include "database_tables.h"
27 #include <sys/types.h>
28 #include <unistd.h>
29 #include <pwd.h>
30 
32 #define APPNAME "Nekardas"
33 
35 #define ORGANISATION "Hobrasoft"
36 
38 #define DESCRIPTION "Applications gets data from fronius invertors"
39 
44 int main(int argc, char *argv[]) {
45 
46  char *username = NULL;
47  for (int a=0; a<argc; a++) {
48  if (QString(argv[a]) == "-U") {
49  if (++a >= argc) break;
50  username = argv[a];
51  }
52  }
53 
54  if (username != NULL) {
55  struct passwd *spw;
56  spw = getpwnam(username);
57  if (spw != NULL) {
58  int unused;
59  Q_UNUSED(unused);
60  unused = seteuid(spw->pw_uid);
61  unused = setegid(spw->pw_gid);
62  unused = setgid(spw->pw_gid);
63  } else {
64  qFatal( QString("Cannot change effective user to %1").arg(username).toUtf8() );
65  exit(2);
66  }
67  }
68 
69  qRegisterMetaType<DBT_DATA>("DBT_DATA");
70 
71  // Use a qtservice wrapper to start the application as a Windows service or Unix daemon
72  Startup startup(argc, argv);
73  return startup.exec();
74 
75 }
76 
int main(int argc, char *argv[])
Definition: main.cpp:44