Fotobot
Get data from your photovoltaic plant
Macros | Functions
main.cpp File Reference
#include <QDebug>
#include "startup.h"
#include "database_tables.h"
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>

Go to the source code of this file.

Macros

#define APPNAME   "Nekardas"
 
#define ORGANISATION   "Hobrasoft"
 
#define DESCRIPTION   "Applications gets data from fronius invertors"
 

Functions

int main (int argc, char *argv[])
 

Detailed Description

Author
Petr Bravenec

Definition in file main.cpp.

Macro Definition Documentation

#define APPNAME   "Nekardas"

Name of this application

Definition at line 32 of file main.cpp.

#define DESCRIPTION   "Applications gets data from fronius invertors"

Short description of this application

Definition at line 38 of file main.cpp.

#define ORGANISATION   "Hobrasoft"

Publisher of this application

Definition at line 35 of file main.cpp.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Entry point of the program. Passes control to the service helper.

Definition at line 44 of file main.cpp.

44  {
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 }