Skip to content

Commit 925c18b

Browse files
Merge branch 'master' of github.com:treefrogframework/treefrog-framework
2 parents 3ea3a49 + 2e3114c commit 925c18b

16 files changed

+131
-120
lines changed

configure.bat

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,21 @@ if not ERRORLEVEL 1 (
102102
set CMAKEOPT=Visual Studio 16 2019
103103
)
104104
) else (
105-
set VSVER=2017
106-
if /i "%Platform%" == "x64" (
107-
set CMAKEOPT=Visual Studio 15 2017 Win64
105+
echo %QT_INSTALL_PREFIX% | find "msvc2017" >NUL
106+
if not ERRORLEVEL 1 (
107+
set VSVER=2017
108+
if /i "%Platform%" == "x64" (
109+
set CMAKEOPT=Visual Studio 15 2017 Win64
110+
) else (
111+
set CMAKEOPT=Visual Studio 15 2017
112+
)
108113
) else (
109-
set CMAKEOPT=Visual Studio 15 2017
114+
set VSVER=2015
115+
if /i "%Platform%" == "x64" (
116+
set CMAKEOPT=Visual Studio 14 2015 Win64
117+
) else (
118+
set CMAKEOPT=Visual Studio 14 2015
119+
)
110120
)
111121
)
112122

tools/tfmanager/main.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ bool checkArguments()
160160
{
161161
for (const auto &arg : QCoreApplication::arguments()) {
162162
if (arg.startsWith('-') && options()->value(arg, Invalid) == Invalid) {
163-
fprintf(stderr, "invalid argument\n");
163+
std::fprintf(stderr, "invalid argument\n");
164164
return false;
165165
}
166166
}
@@ -347,10 +347,10 @@ void showRunningAppList()
347347
{
348348
QStringList approots = runningApplicationPathList();
349349
if (approots.isEmpty()) {
350-
printf("no running application\n");
350+
std::printf("no running application\n");
351351
} else {
352352
int cnt = approots.count();
353-
printf(" %d application%s running:\n", cnt, (cnt > 1 ? "s" : ""));
353+
std::printf(" %d application%s running:\n", cnt, (cnt > 1 ? "s" : ""));
354354

355355
for (const QString &path : approots) {
356356
QString url;
@@ -362,7 +362,7 @@ void showRunningAppList()
362362
url += readJsonOfApplication(path)[JSON_UNIX_KEY].toString();
363363
}
364364

365-
printf(" * %s\n %s\n\n", qPrintable(path), qPrintable(url));
365+
std::printf(" * %s\n %s\n\n", qPrintable(path), qPrintable(url));
366366
}
367367
}
368368
}
@@ -379,7 +379,7 @@ void showRoutes(const QString &path)
379379
if (process->waitForStarted(1000)) {
380380
process->waitForFinished(1000);
381381
auto str = process->readAll();
382-
printf("%s", str.data());
382+
std::printf("%s", str.data());
383383
}
384384
delete process;
385385
}
@@ -391,15 +391,15 @@ int killTreeFrogProcess(const QString &cmd)
391391

392392
if (cmd == "status") { // status command
393393
if (pid > 0) {
394-
printf("TreeFrog server is running. ( %s )\n", qPrintable(Tf::app()->webRootPath()));
394+
std::printf("TreeFrog server is running. ( %s )\n", qPrintable(Tf::app()->webRootPath()));
395395
} else {
396-
printf("TreeFrog server is stopped. ( %s )\n", qPrintable(Tf::app()->webRootPath()));
396+
std::printf("TreeFrog server is stopped. ( %s )\n", qPrintable(Tf::app()->webRootPath()));
397397
}
398398
return (pid > 0) ? 0 : 1;
399399
}
400400

401401
if (pid < 0) {
402-
printf("TreeFrog server not running\n");
402+
std::printf("TreeFrog server not running\n");
403403
return 1;
404404
}
405405

@@ -408,10 +408,10 @@ int killTreeFrogProcess(const QString &cmd)
408408
if (cmd == "stop") { // stop command
409409
pi.terminate();
410410
if (pi.waitForTerminated()) {
411-
printf("TreeFrog application servers shutdown completed\n");
411+
std::printf("TreeFrog application servers shutdown completed\n");
412412
tf_unlink(oldPidFilePath().toLatin1().data());
413413
} else {
414-
fprintf(stderr, "TreeFrog application servers shutdown failed\n");
414+
std::fprintf(stderr, "TreeFrog application servers shutdown failed\n");
415415
}
416416

417417
} else if (cmd == "abort") { // abort command
@@ -425,11 +425,11 @@ int killTreeFrogProcess(const QString &cmd)
425425

426426
TProcessInfo::kill(pids); // kills the server process
427427
tSystemInfo("Killed TreeFrog application server processes");
428-
printf("Killed TreeFrog application server processes\n");
428+
std::printf("Killed TreeFrog application server processes\n");
429429

430430
} else if (cmd == "restart") { // restart command
431431
pi.restart();
432-
printf("Sent a restart request\n");
432+
std::printf("Sent a restart request\n");
433433

434434
} else {
435435
usage();
@@ -443,7 +443,7 @@ void showProcessId()
443443
{
444444
qint64 pid = readPidOfApplication();
445445
if (pid > 0) {
446-
printf("%lld\n", pid);
446+
std::printf("%lld\n", pid);
447447
}
448448
}
449449

@@ -473,7 +473,7 @@ int managerMain(int argc, char *argv[])
473473
int cmd = options()->value(arg, Invalid);
474474
switch (cmd) {
475475
case PrintVersion:
476-
printf("%s version %s (r%d) built on %s / Qt %s\n", qPrintable(QFileInfo(argv[0]).baseName()), TF_VERSION_STR, TF_SRC_REVISION, __DATE__, qVersion());
476+
std::printf("%s version %s (r%d) built on %s / Qt %s\n", qPrintable(QFileInfo(argv[0]).baseName()), TF_VERSION_STR, TF_SRC_REVISION, __DATE__, qVersion());
477477
return 0;
478478
break;
479479

@@ -497,7 +497,7 @@ int managerMain(int argc, char *argv[])
497497

498498
case SendSignal:
499499
if (!i.hasNext()) {
500-
fprintf(stderr, "Missing signal name\n");
500+
std::fprintf(stderr, "Missing signal name\n");
501501
return 1;
502502
}
503503
signalCmd = i.next(); // assign a command
@@ -509,7 +509,7 @@ int managerMain(int argc, char *argv[])
509509

510510
case Port:
511511
if (!i.hasNext()) {
512-
fprintf(stderr, "Missing port number\n");
512+
std::fprintf(stderr, "Missing port number\n");
513513
return 1;
514514
}
515515
listenPort = i.next().toInt();
@@ -534,7 +534,7 @@ int managerMain(int argc, char *argv[])
534534
}
535535

536536
if (!app.appSettingsFileExists()) {
537-
fprintf(stderr, "INI file not found [%s]\n\n", qPrintable(app.appSettingsFilePath()));
537+
std::fprintf(stderr, "INI file not found [%s]\n\n", qPrintable(app.appSettingsFilePath()));
538538
return 1;
539539
}
540540

@@ -558,7 +558,7 @@ int managerMain(int argc, char *argv[])
558558
// Check TreeFrog processes are running
559559
qint64 pid = runningApplicationPid();
560560
if (pid > 0) {
561-
fprintf(stderr, "Already running pid:%ld\n", (long)pid);
561+
std::fprintf(stderr, "Already running pid:%ld\n", (long)pid);
562562
return 1;
563563
}
564564

@@ -589,7 +589,7 @@ int managerMain(int argc, char *argv[])
589589
// start daemon process
590590
if (daemonMode) {
591591
if (!startDaemon()) {
592-
fprintf(stderr, "Failed to create process\n\n");
592+
std::fprintf(stderr, "Failed to create process\n\n");
593593
return 1;
594594
}
595595
return 0;
@@ -634,7 +634,7 @@ int managerMain(int argc, char *argv[])
634634

635635
if (!started) {
636636
tSystemError("TreeFrog application server startup failed");
637-
fprintf(stderr, "TreeFrog application server startup failed\n\n");
637+
std::fprintf(stderr, "TreeFrog application server startup failed\n\n");
638638
return 1;
639639
}
640640

tools/tfmanager/servermanager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ bool ServerManager::start(const QHostAddress &address, quint16 port)
7070
int sd = TApplicationServerBase::nativeListen(address, port, TApplicationServerBase::NonCloseOnExec);
7171
if (sd <= 0) {
7272
tSystemError("Failed to create listening socket");
73-
fprintf(stderr, "Failed to create listening socket\n");
73+
std::fprintf(stderr, "Failed to create listening socket\n");
7474
return false;
7575
}
7676
listeningSocket = sd;
@@ -98,7 +98,7 @@ bool ServerManager::start(const QString &fileDomain)
9898
int sd = TApplicationServerBase::nativeListen(fileDomain, TApplicationServerBase::NonCloseOnExec);
9999
if (sd <= 0) {
100100
tSystemError("listening socket create failed [%s:%d]", __FILE__, __LINE__);
101-
fprintf(stderr, "Failed to create listening socket of UNIX domain\n");
101+
std::fprintf(stderr, "Failed to create listening socket of UNIX domain\n");
102102
return false;
103103
}
104104

@@ -291,7 +291,7 @@ void ServerManager::readStandardError() const
291291
if (server) {
292292
QByteArray buf = server->readAllStandardError();
293293
tSystemWarn("treefrog stderr: %s", buf.constData());
294-
fprintf(stderr, "treefrog stderr: %s", buf.constData());
294+
std::fprintf(stderr, "treefrog stderr: %s", buf.constData());
295295
}
296296
}
297297

tools/tfserver/main.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <TUrlRoute>
2222
#include <TWebApplication>
2323
#include <cstdlib>
24+
#include <cstdio>
2425
using namespace TreeFrog;
2526

2627
constexpr auto DEBUG_MODE_OPTION = "--debug";
@@ -127,7 +128,7 @@ void showRoutes()
127128

128129
auto routes = TUrlRoute::instance().allRoutes();
129130
if (!routes.isEmpty()) {
130-
printf("Available routes:\n");
131+
std::printf("Available routes:\n");
131132

132133
for (auto &route : routes) {
133134
QByteArray action;
@@ -145,12 +146,12 @@ void showRoutes()
145146
} else {
146147
action = QByteArrayLiteral("(not found)");
147148
}
148-
printf(" %s%s -> %s\n", methodDef()->value(route.method).data(), qPrintable(path), qPrintable(action));
149+
std::printf(" %s%s -> %s\n", methodDef()->value(route.method).data(), qPrintable(path), qPrintable(action));
149150
}
150-
printf("\n");
151+
std::printf("\n");
151152
}
152153

153-
printf("Available controllers:\n");
154+
std::printf("Available controllers:\n");
154155
auto keys = Tf::objectFactories()->keys();
155156
std::sort(keys.begin(), keys.end());
156157

@@ -171,7 +172,7 @@ void showRoutes()
171172
}
172173

173174
QByteArray action = createMethodString(ctlrDispatcher.typeName(), metaMethod);
174-
printf(" %s -> %s\n", api.data(), action.data());
175+
std::printf(" %s -> %s\n", api.data(), action.data());
175176
}
176177
}
177178
}
@@ -185,6 +186,9 @@ int main(int argc, char *argv[])
185186
TApplicationServerBase *server = nullptr;
186187
int ret = -1;
187188

189+
// No stdout buffering
190+
std::setvbuf(stdout, nullptr, _IONBF, 0);
191+
188192
// Setup loggers
189193
Tf::setupSystemLogger();
190194
Tf::setupAccessLogger();
@@ -232,14 +236,14 @@ int main(int argc, char *argv[])
232236

233237
if (!webapp.webRootExists()) {
234238
tSystemError("No such directory");
235-
fprintf(stderr, "No such directory\n");
239+
std::fprintf(stderr, "No such directory\n");
236240
goto finish;
237241
}
238242
tSystemDebug("Web Root: %s", qPrintable(webapp.webRootPath()));
239243

240244
if (!webapp.appSettingsFileExists()) {
241245
tSystemError("Settings file not found");
242-
fprintf(stderr, "Settings file not found\n");
246+
std::fprintf(stderr, "Settings file not found\n");
243247
goto finish;
244248
} else {
245249
// Sets search paths for JavaScript
@@ -262,7 +266,7 @@ int main(int argc, char *argv[])
262266
int port = (portNumber > 0) ? portNumber : Tf::appSettings()->value(Tf::ListenPort).toInt();
263267
if (port <= 0 || port > USHRT_MAX) {
264268
tSystemError("Invalid port number: %d", port);
265-
fprintf(stderr, "Invalid port number: %d\n", port);
269+
std::fprintf(stderr, "Invalid port number: %d\n", port);
266270
goto finish;
267271
}
268272
// Listen address
@@ -277,7 +281,7 @@ int main(int argc, char *argv[])
277281

278282
if (sock <= 0) {
279283
tSystemError("Invalid socket descriptor: %d", sock);
280-
fprintf(stderr, "Invalid option\n");
284+
std::fprintf(stderr, "Invalid option\n");
281285
goto finish;
282286
}
283287

@@ -304,7 +308,7 @@ int main(int argc, char *argv[])
304308
server->setAutoReloadingEnabled(reload);
305309
if (!server->start(debug)) {
306310
tSystemError("Server open failed");
307-
fprintf(stderr, "Server open failed\n");
311+
std::fprintf(stderr, "Server open failed\n");
308312
goto finish;
309313
}
310314

@@ -331,8 +335,6 @@ int main(int argc, char *argv[])
331335
Tf::releaseSystemLogger();
332336

333337
end:
334-
fflush(stderr);
335-
fflush(stdout);
336338
_exit(ret);
337339
return ret;
338340
}

tools/tfserver/stacktrace_powerpc-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
// Linux has similar code: http://patchwork.ozlabs.org/linuxppc/patch?id=8882
3737

3838
#include "stacktrace.h"
39-
#include <stdint.h> // for uintptr_t
40-
#include <stdio.h>
39+
#include <cstdint> // for uintptr_t
40+
#include <cstdio>
4141

4242
_START_GOOGLE_NAMESPACE_
4343

tools/tfserver/stacktrace_x86-inl.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// Produce stack trace
3333

3434
#include <QtGlobal>
35-
#include <stdint.h> // for uintptr_t
35+
#include <cstdint> // for uintptr_t
3636

3737
#if !defined(Q_OS_WIN32)
3838
#include <sys/mman.h>
@@ -41,12 +41,11 @@
4141

4242
#include "gconfig.h"
4343
#include "stacktrace.h"
44-
#include <stdio.h> // for NULL
4544

4645
_START_GOOGLE_NAMESPACE_
4746

4847
// Given a pointer to a stack frame, locate and return the calling
49-
// stackframe, or return NULL if no stackframe can be found. Perform sanity
48+
// stackframe, or return nullptr if no stackframe can be found. Perform sanity
5049
// checks (the strictness of which is controlled by the boolean parameter
5150
// "STRICT_UNWINDING") to reduce the chance that a bad pointer is returned.
5251
template <bool STRICT_UNWINDING>
@@ -60,28 +59,28 @@ static void **NextStackFrame(void **old_sp)
6059
// With the stack growing downwards, older stack frame must be
6160
// at a greater address that the current one.
6261
if (new_sp <= old_sp)
63-
return NULL;
62+
return nullptr;
6463
// Assume stack frames larger than 100,000 bytes are bogus.
6564
if ((uintptr_t)new_sp - (uintptr_t)old_sp > 100000)
66-
return NULL;
65+
return nullptr;
6766
} else {
6867
// In the non-strict mode, allow discontiguous stack frames.
6968
// (alternate-signal-stacks for example).
7069
if (new_sp == old_sp)
71-
return NULL;
70+
return nullptr;
7271
// And allow frames upto about 1MB.
7372
if ((new_sp > old_sp)
7473
&& ((uintptr_t)new_sp - (uintptr_t)old_sp > 1000000))
75-
return NULL;
74+
return nullptr;
7675
}
7776
if ((uintptr_t)new_sp & (sizeof(void *) - 1))
78-
return NULL;
77+
return nullptr;
7978
#ifdef __i386__
8079
// On 64-bit machines, the stack pointer can be very close to
8180
// 0xffffffff, so we explicitly check for a pointer into the
8281
// last two pages in the address space
8382
if ((uintptr_t)new_sp >= 0xffffe000)
84-
return NULL;
83+
return nullptr;
8584
#endif
8685
#if !defined(Q_OS_WIN32)
8786
if (!STRICT_UNWINDING) {
@@ -93,7 +92,7 @@ static void **NextStackFrame(void **old_sp)
9392
static int page_size = getpagesize();
9493
void *new_sp_aligned = (void *)((uintptr_t)new_sp & ~(page_size - 1));
9594
if (msync(new_sp_aligned, page_size, MS_ASYNC) == -1)
96-
return NULL;
95+
return nullptr;
9796
}
9897
#endif
9998
return new_sp;

0 commit comments

Comments
 (0)