Replace wahjamsrv build with qmake project file

The Qt framework provides a cross-platform build tool called qmake.
qmake simplifies the build process and has support for easily linking
against Qt libraries.

This is the first step to using Qt in wahjamsrv.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Add wahjamsrv/Makefile to .gitignore

The wahjamsrv makefile is auto-generated by qmake, do not show it in
git-status(1) output.  Also remove the cursesclient gitignore line since
cursesclient no longer exists.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Use const char* for ninjamsrv logText() fmt string

Using const char* for strings avoids compiler warnings with string
literals.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Declare logText() in ninjamsrv.h

Several files use logText() and it's time to declare the function in a
header file.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Capture server configuration in a struct

The server uses a number of globals to query the configuration
variables.  This patch introduces the ServerConfig struct and moves
configuration variables into this new struct.

This will make it possible to clean up server state changes.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Unify config loading in wahjamsrv

The configuration file is loaded when wahjamsrv starts.  It can also be
reloaded while the server is running by sending SIGHUP or using the
Windows server console.  This patch introduces the reloadConfig()
function which handles both instances of configuration file loading.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Drop wahjamsrv Windows prompt

On Windows there is a administrator prompt which can be used to reload
the config, list users, and kick users.  Drop this feature for now to
make it easier to convert wahjamsrv to Qt.  This sort of feature can be
reintroduced in a cross-platform way again later.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Introduce a Server class

Extract the server code into its own class and leave ninjamsrv.cpp with
the main loop, configuration code, and user lookup.

This change is necessary so that an event-driven main loop can be used
instead of the existing polling behavior.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Add QCoreApplication event loop to wahjamsrv

Use QCoreApplication::processEvents() instead of sleeping in the main
loop.  This allows us to begin using Qt events in the server and it will
eventually be possible to block while waiting for events instead of
spinning.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Convert listener to QTcpServer

Use the Qt QTcpServer class to listen for connections instead of
JNL_Listen.  The advantage of QTcpServer is that it is event-driven and
does not need polling.

Since Net_Connection has not been converted to QTcpSocket yet we dup(2)
the socket file descriptor and then close the QTcpSocket.  The server
still uses JNL_Connection for client connections.  Future patches will
make it possible to use QTcpSocket instead of JNL_Connection.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Convert wsprintf() back to sprintf()

The jnetlib library #defined wsprintf to sprintf.  Once we switch to
QTcpSocket and drop jnetlib we will no longer have this macro.  Switch
back to sprintf() for now.

The long term plan for strings is to use QString so that encoding is
handled and the const char* vs char* warnings can be fixed.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Replace JNL_Connection with QTcpSocket

Convert the client connections from JNL_Connection to QTcpSocket.  This
is just the first step and still relies on polling.

The next step is to use signals/slots for event-driven I/O and
disconnect handling.

Note: after disconnect the remote address is no longer available and the
server will print an empty IP address in its log.  This will be fixed
once signals/slots are used for disconnect handling.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Use QString for strcasecmp() in wahjamsrv

The strcasecmp() (POSIX) and stricmp() (Windows) functions are not
portable.  WDL jnetlib defines macros to make them available on both
platforms.

Since we intend to get rid of WDL jnetlib switch to QString for
case-insensitive string comparison.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Remove WDL jnetlib dependency

Since network I/O now uses Qt's network classes the WDL jnetlib library
is no longer used.  Remove the last dependencies and drop it from the
makefiles.

Note that jnetlib includes system headers so we need to explicitly
include <time.h> now.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Purge WDL jnetlib from the source tree

The WDL jnetlib networking library is no longer used.  This patch
removes it from the source tree.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>