RDK Documentation (Open Sourced RDK Components)
main.cpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 /**
23 * @defgroup trm
24 * @{
25 * @defgroup qtapp
26 * @{
27 **/
28 
29 
30 #include <iostream>
31 #include <cstdio>
32 
33 #include <QFile>
34 #include <QCoreApplication>
35 
36 #include "trm/TRM.h"
37 #include "Server.h"
38 #include "rdk_debug.h"
39 
40 using namespace TRM;
41 
42 Server *serverInstance = 0;
43 
44 int main(int argc, char *argv[])
45 {
46  QCoreApplication app(argc, argv);
47  QStringList args = app.arguments();
48  char *debugConfigFile = NULL;
49 
50  int portNumber= -1;
51  QString hostAddressStr;
52 
53  /*Delia 5860 - Line Buffering*/
54  setvbuf(stdout, NULL, _IOLBF, 0);
55 
56  QRegExp optionPort("-port");
57  QRegExp optionIP("-ip");
58  QRegExp optionDebugFile("-debugconfig");
59 
60  for (int i = 1; i < args.size(); ++i) {
61  if (optionPort.indexIn(args.at(i)) != -1 ) {
62  portNumber= args.at(i+1).toInt();
63  ++i;
64  qDebug() << "port is " << portNumber;
65  }
66  else if (optionIP.indexIn(args.at(i)) != -1 ) {
67  hostAddressStr = args.at(i+1);
68  ++i;
69  qDebug() << "ip is " << hostAddressStr;
70  }
71  else if (optionDebugFile.indexIn(args.at(i)) != -1 ) {
72  debugConfigFile = argv[i+1];
73  ++i;
74  qDebug() << "rdklogger debug file is " << debugConfigFile;
75 
76  }
77  }
78 
79  rdk_logger_init(debugConfigFile);
80 
81  RDK_LOG(RDK_LOG_DEBUG, "LOG.RDK.TRM", "This is a test line");
82 
83  if (portNumber < 0 || portNumber > 65535 || hostAddressStr.isEmpty()) {
84  printf("\r\n%s: <ip address> <port number> \r\n", args.at(0).toUtf8().data());
85  exit(0);
86  }
87 
88  QHostAddress hostAddress(hostAddressStr);
89  Server server(hostAddress, portNumber);
90  serverInstance = &server;
91 
92  return app.exec();
93 }
94 
95 
96 /** @} */
97 /** @} */
rdk_debug.h
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
TRM::Server
Definition: Server.h:42
rdk_logger_init
rdk_Error rdk_logger_init(const char *debugConfigFile)
Initialize the logger. Sets up the environment variable storage by parsing debug configuration file t...
Definition: rdk_logger_init.c:57